Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions foreign_cc/private/cmake_script.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ _TARGET_OS_PARAMS = {
"linux": {
"CMAKE_SYSTEM_NAME": "Linux",
},
"macos": {
"CMAKE_SYSTEM_NAME": "Darwin",
},
}

_TARGET_ARCH_PARAMS = {
Expand Down Expand Up @@ -124,8 +127,19 @@ def create_cmake_script(
# buildifier: disable=print
print("target_arch is unknown, please update foreign_cc/private/framework/platform.bzl and foreign_cc/private/cmake_script.bzl; triggered by", current_label)
elif target_os != host_os or target_arch != host_arch:
toolchain_dict.update(_TARGET_OS_PARAMS.get(target_os, {}))
toolchain_dict.update(_TARGET_ARCH_PARAMS.get(target_arch, {}))
# if we don't have a value here, it will end up attempting a native
# compile, even if that's not right, so emit a warning
if target_os in _TARGET_OS_PARAMS:
toolchain_dict.update(_TARGET_OS_PARAMS[target_os])
else:
# buildifier: disable=print
print("target_os", target_os, "is not in _TARGET_OS_PARAMS, please update foreign_cc/private/cmake_script.bzl; triggered by", current_label)
Comment on lines +135 to +136
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason not to actually fail() here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, I just did it this way for parity with the checks above, but I can make it fail if you'd prefer that


if target_arch in _TARGET_ARCH_PARAMS:
toolchain_dict.update(_TARGET_ARCH_PARAMS[target_arch])
else:
# buildifier: disable=print
print("target_arch", target_arch, "is not in _TARGET_ARCH_PARAMS, please update foreign_cc/private/cmake_script.bzl; triggered by", current_label)

keys_with_empty_values_in_user_cache = [key for key in user_cache if user_cache.get(key) == ""]

Expand Down