Skip to content

Commit 6e54230

Browse files
authored
add foreign_cc deps to cmake prefix path (#1311)
1 parent e67c45c commit 6e54230

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

examples/third_party/curl/BUILD.curl.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ _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",
1615
"CMAKE_USE_OPENSSL": "on",
1716
# TODO: ldap should likely be enabled
1817
"CURL_DISABLE_LDAP": "on",
19-
"OPENSSL_ROOT_DIR": "$$EXT_BUILD_DEPS/openssl",
2018
}
2119

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

examples/third_party/libgit2/BUILD.libgit2.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ _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:-}",
1716
#"EMBED_SSH_PATH": "$(location @libssh2//:libssh2)",
1817
"USE_HTTPS": "on",
1918
}

examples/third_party/libssh2/BUILD.libssh2.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ _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",
1716
}
1817

1918
_LINUX_CACHE_ENTRIES = dict(_CACHE_ENTRIES.items() + {

foreign_cc/cmake.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ def _create_configure_script(configureParameters):
271271
cmake_prefix = prefix,
272272
include_dirs = inputs.include_dirs,
273273
is_debug_mode = is_debug_mode(ctx),
274+
ext_build_dirs = inputs.ext_build_dirs,
274275
)
275276
return configure_script
276277

foreign_cc/private/cmake_script.bzl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def create_cmake_script(
5858
cmake_commands,
5959
include_dirs = [],
6060
cmake_prefix = None,
61-
is_debug_mode = True):
61+
is_debug_mode = True,
62+
ext_build_dirs = []):
6263
"""Constructs CMake script to be passed to cc_external_rule_impl.
6364
6465
Args:
@@ -81,12 +82,13 @@ def create_cmake_script(
8182
include_dirs: Optional additional include directories. Defaults to [].
8283
cmake_prefix: Optional prefix before the cmake command (without the trailing space).
8384
is_debug_mode: If the compilation mode is `debug`. Defaults to True.
85+
ext_build_dirs: A list of gen_dirs for each foreign_cc dep.
8486
8587
Returns:
8688
list: Lines of bash which make up the build script
8789
"""
8890

89-
merged_prefix_path = _merge_prefix_path(user_cache, include_dirs)
91+
merged_prefix_path = _merge_prefix_path(user_cache, include_dirs, ext_build_dirs)
9092

9193
toolchain_dict = _fill_crossfile_from_toolchain(workspace_name, tools, flags)
9294
params = None
@@ -171,9 +173,12 @@ def _wipe_empty_values(cache, keys_with_empty_values_in_user_cache):
171173
cache.pop(key)
172174

173175
# From CMake documentation: ;-list of directories specifying installation prefixes to be searched...
174-
def _merge_prefix_path(user_cache, include_dirs):
176+
def _merge_prefix_path(user_cache, include_dirs, ext_build_dirs):
175177
user_prefix = user_cache.get("CMAKE_PREFIX_PATH")
176178
values = ["$$EXT_BUILD_DEPS$$"] + include_dirs
179+
for ext_dir in ext_build_dirs:
180+
values.append("$$EXT_BUILD_DEPS$$/{}".format(ext_dir.basename))
181+
177182
if user_prefix != None:
178183
# remove it, it is gonna be merged specifically
179184
user_cache.pop("CMAKE_PREFIX_PATH")

0 commit comments

Comments
 (0)