Support location expansion and make variable substitution in CMake cache entries (#1272)
This commit is contained in:
parent
780f59568b
commit
b25485b26d
|
@ -21,8 +21,8 @@ cmake(
|
||||||
cmake(
|
cmake(
|
||||||
name = "lib_with_duplicate_transitive_bazel_deps",
|
name = "lib_with_duplicate_transitive_bazel_deps",
|
||||||
cache_entries = {
|
cache_entries = {
|
||||||
"LIBA_DIR": "$$EXT_BUILD_DEPS$$",
|
"LIBA_DIR": "$$EXT_BUILD_DEPS",
|
||||||
"LIBB_DIR": "$$EXT_BUILD_DEPS$$",
|
"LIBB_DIR": "$$EXT_BUILD_DEPS",
|
||||||
},
|
},
|
||||||
generate_args = ["-GNinja"],
|
generate_args = ["-GNinja"],
|
||||||
lib_name = "libc",
|
lib_name = "libc",
|
||||||
|
|
|
@ -10,7 +10,7 @@ cmake(
|
||||||
"CMAKE_DISABLE_FIND_PACKAGE_LIBA": "True",
|
"CMAKE_DISABLE_FIND_PACKAGE_LIBA": "True",
|
||||||
# as currently we copy all libraries, built with Bazel, into $EXT_BUILD_DEPS/lib
|
# as currently we copy all libraries, built with Bazel, into $EXT_BUILD_DEPS/lib
|
||||||
# and the headers into $EXT_BUILD_DEPS/include
|
# and the headers into $EXT_BUILD_DEPS/include
|
||||||
"LIBA_DIR": "$EXT_BUILD_DEPS",
|
"LIBA_DIR": "$$EXT_BUILD_DEPS",
|
||||||
},
|
},
|
||||||
generate_args = ["-GNinja"],
|
generate_args = ["-GNinja"],
|
||||||
lib_source = "//cmake_with_bazel_transitive/libb:b_srcs",
|
lib_source = "//cmake_with_bazel_transitive/libb:b_srcs",
|
||||||
|
|
|
@ -12,11 +12,11 @@ _CACHE_ENTRIES = {
|
||||||
"BUILD_CURL_EXE": "off",
|
"BUILD_CURL_EXE": "off",
|
||||||
"BUILD_SHARED_LIBS": "off",
|
"BUILD_SHARED_LIBS": "off",
|
||||||
"CMAKE_BUILD_TYPE": "RELEASE",
|
"CMAKE_BUILD_TYPE": "RELEASE",
|
||||||
"CMAKE_PREFIX_PATH": "$$EXT_BUILD_DEPS$$/openssl",
|
"CMAKE_PREFIX_PATH": "$$EXT_BUILD_DEPS/openssl",
|
||||||
"CMAKE_USE_OPENSSL": "on",
|
"CMAKE_USE_OPENSSL": "on",
|
||||||
# TODO: ldap should likely be enabled
|
# TODO: ldap should likely be enabled
|
||||||
"CURL_DISABLE_LDAP": "on",
|
"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() + {
|
_MACOS_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {
|
||||||
|
|
|
@ -13,13 +13,13 @@ _CACHE_ENTRIES = {
|
||||||
"BUILD_EXAMPLES": "off",
|
"BUILD_EXAMPLES": "off",
|
||||||
"BUILD_FUZZERS": "off",
|
"BUILD_FUZZERS": "off",
|
||||||
"BUILD_SHARED_LIBS": "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:-}",
|
"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)",
|
#"EMBED_SSH_PATH": "$(location @libssh2//:libssh2)",
|
||||||
"USE_HTTPS": "on",
|
"USE_HTTPS": "on",
|
||||||
}
|
}
|
||||||
|
|
||||||
_LINUX_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {
|
_LINUX_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {
|
||||||
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
|
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
|
||||||
"REGEX_BACKEND": "pcre2",
|
"REGEX_BACKEND": "pcre2",
|
||||||
}.items())
|
}.items())
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ cmake(
|
||||||
cache_entries = {
|
cache_entries = {
|
||||||
"CMAKE_BUILD_TYPE": "RELEASE",
|
"CMAKE_BUILD_TYPE": "RELEASE",
|
||||||
"CMAKE_POLICY_DEFAULT_CMP0074": "NEW",
|
"CMAKE_POLICY_DEFAULT_CMP0074": "NEW",
|
||||||
"ZLIB_ROOT": "$EXT_BUILD_DEPS/zlib",
|
"ZLIB_ROOT": "$$EXT_BUILD_DEPS/zlib",
|
||||||
},
|
},
|
||||||
lib_source = "//:all_srcs",
|
lib_source = "//:all_srcs",
|
||||||
out_include_dir = "include/libpng16",
|
out_include_dir = "include/libpng16",
|
||||||
|
|
|
@ -13,11 +13,11 @@ _CACHE_ENTRIES = {
|
||||||
"BUILD_SHARED_LIBS": "off",
|
"BUILD_SHARED_LIBS": "off",
|
||||||
"BUILD_TESTING": "off",
|
"BUILD_TESTING": "off",
|
||||||
"CMAKE_FIND_DEBUG_MODE": "on",
|
"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() + {
|
_LINUX_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {
|
||||||
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
|
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
|
||||||
}.items())
|
}.items())
|
||||||
|
|
||||||
cmake(
|
cmake(
|
||||||
|
|
|
@ -15,7 +15,7 @@ filegroup(
|
||||||
cmake(
|
cmake(
|
||||||
name = "pcre",
|
name = "pcre",
|
||||||
cache_entries = {
|
cache_entries = {
|
||||||
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
|
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
|
||||||
},
|
},
|
||||||
lib_source = ":all_srcs",
|
lib_source = ":all_srcs",
|
||||||
out_static_libs = select({
|
out_static_libs = select({
|
||||||
|
|
|
@ -15,7 +15,7 @@ cmake(
|
||||||
name = "zlib",
|
name = "zlib",
|
||||||
cache_entries = select({
|
cache_entries = select({
|
||||||
"@platforms//os:linux": {
|
"@platforms//os:linux": {
|
||||||
"CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC",
|
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
|
||||||
},
|
},
|
||||||
"//conditions:default": {},
|
"//conditions:default": {},
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -264,7 +264,7 @@ def _create_configure_script(configureParameters):
|
||||||
install_prefix = "$$INSTALLDIR$$",
|
install_prefix = "$$INSTALLDIR$$",
|
||||||
root = root,
|
root = root,
|
||||||
no_toolchain_file = no_toolchain_file,
|
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),
|
user_env = expand_locations_and_make_variables(ctx, ctx.attr.env, "env", data),
|
||||||
options = attrs.generate_args,
|
options = attrs.generate_args,
|
||||||
cmake_commands = cmake_commands,
|
cmake_commands = cmake_commands,
|
||||||
|
|
Loading…
Reference in New Issue