Support location expansion and make variable substitution in CMake cache entries (#1272)

This commit is contained in:
Michael Allwright 2024-09-05 15:58:37 +02:00 committed by GitHub
parent 780f59568b
commit b25485b26d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 14 additions and 14 deletions

View File

@ -21,8 +21,8 @@ cmake(
cmake(
name = "lib_with_duplicate_transitive_bazel_deps",
cache_entries = {
"LIBA_DIR": "$$EXT_BUILD_DEPS$$",
"LIBB_DIR": "$$EXT_BUILD_DEPS$$",
"LIBA_DIR": "$$EXT_BUILD_DEPS",
"LIBB_DIR": "$$EXT_BUILD_DEPS",
},
generate_args = ["-GNinja"],
lib_name = "libc",

View File

@ -10,7 +10,7 @@ cmake(
"CMAKE_DISABLE_FIND_PACKAGE_LIBA": "True",
# as currently we copy all libraries, built with Bazel, into $EXT_BUILD_DEPS/lib
# and the headers into $EXT_BUILD_DEPS/include
"LIBA_DIR": "$EXT_BUILD_DEPS",
"LIBA_DIR": "$$EXT_BUILD_DEPS",
},
generate_args = ["-GNinja"],
lib_source = "//cmake_with_bazel_transitive/libb:b_srcs",

View File

@ -12,11 +12,11 @@ _CACHE_ENTRIES = {
"BUILD_CURL_EXE": "off",
"BUILD_SHARED_LIBS": "off",
"CMAKE_BUILD_TYPE": "RELEASE",
"CMAKE_PREFIX_PATH": "$$EXT_BUILD_DEPS$$/openssl",
"CMAKE_PREFIX_PATH": "$$EXT_BUILD_DEPS/openssl",
"CMAKE_USE_OPENSSL": "on",
# TODO: ldap should likely be enabled
"CURL_DISABLE_LDAP": "on",
"OPENSSL_ROOT_DIR": "$$EXT_BUILD_DEPS$$/openssl",
"OPENSSL_ROOT_DIR": "$$EXT_BUILD_DEPS/openssl",
}
_MACOS_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {

View File

@ -13,13 +13,13 @@ _CACHE_ENTRIES = {
"BUILD_EXAMPLES": "off",
"BUILD_FUZZERS": "off",
"BUILD_SHARED_LIBS": "off",
"CMAKE_PREFIX_PATH": "$EXT_BUILD_DEPS/pcre;$EXT_BUILD_DEPS/openssl;$EXT_BUILD_DEPS/libssh2;$EXT_BUILD_DEPS/zlib;${CMAKE_PREFIX_PATH:-}",
"EMBED_SSH_PATH": "$(location @libssh2//:libssh2)",
"CMAKE_PREFIX_PATH": "$$EXT_BUILD_DEPS/pcre;$$EXT_BUILD_DEPS/openssl;$$EXT_BUILD_DEPS/libssh2;$$EXT_BUILD_DEPS/zlib;$${CMAKE_PREFIX_PATH:-}",
#"EMBED_SSH_PATH": "$(location @libssh2//:libssh2)",
"USE_HTTPS": "on",
}
_LINUX_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
"REGEX_BACKEND": "pcre2",
}.items())

View File

@ -15,7 +15,7 @@ cmake(
cache_entries = {
"CMAKE_BUILD_TYPE": "RELEASE",
"CMAKE_POLICY_DEFAULT_CMP0074": "NEW",
"ZLIB_ROOT": "$EXT_BUILD_DEPS/zlib",
"ZLIB_ROOT": "$$EXT_BUILD_DEPS/zlib",
},
lib_source = "//:all_srcs",
out_include_dir = "include/libpng16",

View File

@ -13,11 +13,11 @@ _CACHE_ENTRIES = {
"BUILD_SHARED_LIBS": "off",
"BUILD_TESTING": "off",
"CMAKE_FIND_DEBUG_MODE": "on",
"CMAKE_PREFIX_PATH": "${CMAKE_PREFIX_PATH:-};$EXT_BUILD_DEPS/openssl",
"CMAKE_PREFIX_PATH": "$${CMAKE_PREFIX_PATH:-};$$EXT_BUILD_DEPS/openssl",
}
_LINUX_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
}.items())
cmake(

View File

@ -15,7 +15,7 @@ filegroup(
cmake(
name = "pcre",
cache_entries = {
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
},
lib_source = ":all_srcs",
out_static_libs = select({

View File

@ -15,7 +15,7 @@ cmake(
name = "zlib",
cache_entries = select({
"@platforms//os:linux": {
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
},
"//conditions:default": {},
}),

View File

@ -264,7 +264,7 @@ def _create_configure_script(configureParameters):
install_prefix = "$$INSTALLDIR$$",
root = root,
no_toolchain_file = no_toolchain_file,
user_cache = dict(ctx.attr.cache_entries),
user_cache = expand_locations_and_make_variables(ctx, ctx.attr.cache_entries, "cache_entries", data),
user_env = expand_locations_and_make_variables(ctx, ctx.attr.env, "env", data),
options = attrs.generate_args,
cmake_commands = cmake_commands,