Skip to content

Commit b25485b

Browse files
authored
Support location expansion and make variable substitution in CMake cache entries (#1272)
1 parent 780f595 commit b25485b

File tree

9 files changed

+14
-14
lines changed

9 files changed

+14
-14
lines changed

examples/cmake_synthetic/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ cmake(
2121
cmake(
2222
name = "lib_with_duplicate_transitive_bazel_deps",
2323
cache_entries = {
24-
"LIBA_DIR": "$$EXT_BUILD_DEPS$$",
25-
"LIBB_DIR": "$$EXT_BUILD_DEPS$$",
24+
"LIBA_DIR": "$$EXT_BUILD_DEPS",
25+
"LIBB_DIR": "$$EXT_BUILD_DEPS",
2626
},
2727
generate_args = ["-GNinja"],
2828
lib_name = "libc",

examples/cmake_with_bazel_transitive/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cmake(
1010
"CMAKE_DISABLE_FIND_PACKAGE_LIBA": "True",
1111
# as currently we copy all libraries, built with Bazel, into $EXT_BUILD_DEPS/lib
1212
# and the headers into $EXT_BUILD_DEPS/include
13-
"LIBA_DIR": "$EXT_BUILD_DEPS",
13+
"LIBA_DIR": "$$EXT_BUILD_DEPS",
1414
},
1515
generate_args = ["-GNinja"],
1616
lib_source = "//cmake_with_bazel_transitive/libb:b_srcs",

examples/third_party/curl/BUILD.curl.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ _CACHE_ENTRIES = {
1212
"BUILD_CURL_EXE": "off",
1313
"BUILD_SHARED_LIBS": "off",
1414
"CMAKE_BUILD_TYPE": "RELEASE",
15-
"CMAKE_PREFIX_PATH": "$$EXT_BUILD_DEPS$$/openssl",
15+
"CMAKE_PREFIX_PATH": "$$EXT_BUILD_DEPS/openssl",
1616
"CMAKE_USE_OPENSSL": "on",
1717
# TODO: ldap should likely be enabled
1818
"CURL_DISABLE_LDAP": "on",
19-
"OPENSSL_ROOT_DIR": "$$EXT_BUILD_DEPS$$/openssl",
19+
"OPENSSL_ROOT_DIR": "$$EXT_BUILD_DEPS/openssl",
2020
}
2121

2222
_MACOS_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {

examples/third_party/libgit2/BUILD.libgit2.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ _CACHE_ENTRIES = {
1313
"BUILD_EXAMPLES": "off",
1414
"BUILD_FUZZERS": "off",
1515
"BUILD_SHARED_LIBS": "off",
16-
"CMAKE_PREFIX_PATH": "$EXT_BUILD_DEPS/pcre;$EXT_BUILD_DEPS/openssl;$EXT_BUILD_DEPS/libssh2;$EXT_BUILD_DEPS/zlib;${CMAKE_PREFIX_PATH:-}",
17-
"EMBED_SSH_PATH": "$(location @libssh2//:libssh2)",
16+
"CMAKE_PREFIX_PATH": "$$EXT_BUILD_DEPS/pcre;$$EXT_BUILD_DEPS/openssl;$$EXT_BUILD_DEPS/libssh2;$$EXT_BUILD_DEPS/zlib;$${CMAKE_PREFIX_PATH:-}",
17+
#"EMBED_SSH_PATH": "$(location @libssh2//:libssh2)",
1818
"USE_HTTPS": "on",
1919
}
2020

2121
_LINUX_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {
22-
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
22+
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
2323
"REGEX_BACKEND": "pcre2",
2424
}.items())
2525

examples/third_party/libpng/BUILD.libpng.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cmake(
1515
cache_entries = {
1616
"CMAKE_BUILD_TYPE": "RELEASE",
1717
"CMAKE_POLICY_DEFAULT_CMP0074": "NEW",
18-
"ZLIB_ROOT": "$EXT_BUILD_DEPS/zlib",
18+
"ZLIB_ROOT": "$$EXT_BUILD_DEPS/zlib",
1919
},
2020
lib_source = "//:all_srcs",
2121
out_include_dir = "include/libpng16",

examples/third_party/libssh2/BUILD.libssh2.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ _CACHE_ENTRIES = {
1313
"BUILD_SHARED_LIBS": "off",
1414
"BUILD_TESTING": "off",
1515
"CMAKE_FIND_DEBUG_MODE": "on",
16-
"CMAKE_PREFIX_PATH": "${CMAKE_PREFIX_PATH:-};$EXT_BUILD_DEPS/openssl",
16+
"CMAKE_PREFIX_PATH": "$${CMAKE_PREFIX_PATH:-};$$EXT_BUILD_DEPS/openssl",
1717
}
1818

1919
_LINUX_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {
20-
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
20+
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
2121
}.items())
2222

2323
cmake(

examples/third_party/pcre/BUILD.pcre.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ filegroup(
1515
cmake(
1616
name = "pcre",
1717
cache_entries = {
18-
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
18+
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
1919
},
2020
lib_source = ":all_srcs",
2121
out_static_libs = select({

examples/third_party/zlib/BUILD.zlib.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cmake(
1515
name = "zlib",
1616
cache_entries = select({
1717
"@platforms//os:linux": {
18-
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
18+
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
1919
},
2020
"//conditions:default": {},
2121
}),

foreign_cc/cmake.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def _create_configure_script(configureParameters):
264264
install_prefix = "$$INSTALLDIR$$",
265265
root = root,
266266
no_toolchain_file = no_toolchain_file,
267-
user_cache = dict(ctx.attr.cache_entries),
267+
user_cache = expand_locations_and_make_variables(ctx, ctx.attr.cache_entries, "cache_entries", data),
268268
user_env = expand_locations_and_make_variables(ctx, ctx.attr.env, "env", data),
269269
options = attrs.generate_args,
270270
cmake_commands = cmake_commands,

0 commit comments

Comments
 (0)