Skip to content

Commit

Permalink
Fix buildifier
Browse files Browse the repository at this point in the history
  • Loading branch information
keith committed Nov 2, 2022
1 parent 85f4edf commit 65e700a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 51 deletions.
50 changes: 4 additions & 46 deletions crosstool/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def _compare_versions(dv1, v2):
return dv1.compare_to(apple_common.dotted_version(v2))

def _can_use_deterministic_libtool(ctx):
"""Returns `True` if the current version of `libtool` has support for
deterministic mode, and `False` otherwise."""
"""Returns `True` if the current version of `libtool` has support for deterministic mode, and `False` otherwise."""
xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig]
xcode_version = xcode_config.xcode_version()
if _compare_versions(xcode_version, _SUPPORTS_DETERMINISTIC_MODE) >= 0:
Expand All @@ -49,8 +48,7 @@ def _can_use_deterministic_libtool(ctx):
return False

def _deterministic_libtool_flags(ctx):
"""Returns additional `libtool` flags to enable deterministic mode, if they
are available."""
"""Returns additional `libtool` flags to enable deterministic mode, if they are available."""
if _can_use_deterministic_libtool(ctx):
return ["-D"]
return []
Expand Down Expand Up @@ -117,48 +115,6 @@ def _impl(ctx):
if ctx.attr.cpu in ["ios_sim_arm64", "tvos_sim_arm64", "watchos_arm64"]:
arch = "arm64"

all_compile_actions = [
ACTION_NAMES.c_compile,
ACTION_NAMES.cpp_compile,
ACTION_NAMES.linkstamp_compile,
ACTION_NAMES.assemble,
ACTION_NAMES.preprocess_assemble,
ACTION_NAMES.cpp_header_parsing,
ACTION_NAMES.cpp_module_compile,
ACTION_NAMES.cpp_module_codegen,
ACTION_NAMES.clif_match,
ACTION_NAMES.lto_backend,
]

all_cpp_compile_actions = [
ACTION_NAMES.cpp_compile,
ACTION_NAMES.linkstamp_compile,
ACTION_NAMES.cpp_header_parsing,
ACTION_NAMES.cpp_module_compile,
ACTION_NAMES.cpp_module_codegen,
ACTION_NAMES.clif_match,
]

preprocessor_compile_actions = [
ACTION_NAMES.c_compile,
ACTION_NAMES.cpp_compile,
ACTION_NAMES.linkstamp_compile,
ACTION_NAMES.preprocess_assemble,
ACTION_NAMES.cpp_header_parsing,
ACTION_NAMES.cpp_module_compile,
ACTION_NAMES.clif_match,
]

codegen_compile_actions = [
ACTION_NAMES.c_compile,
ACTION_NAMES.cpp_compile,
ACTION_NAMES.linkstamp_compile,
ACTION_NAMES.assemble,
ACTION_NAMES.preprocess_assemble,
ACTION_NAMES.cpp_module_codegen,
ACTION_NAMES.lto_backend,
]

all_link_actions = [
ACTION_NAMES.cpp_link_executable,
ACTION_NAMES.cpp_link_dynamic_library,
Expand Down Expand Up @@ -2765,6 +2721,7 @@ def _impl(ctx):
ubsan_feature,
default_sanitizer_flags_feature,
archive_param_file_feature,
supports_pic_feature,
]
elif (ctx.attr.cpu == "darwin_x86_64" or
ctx.attr.cpu == "darwin_arm64" or
Expand Down Expand Up @@ -2847,6 +2804,7 @@ def _impl(ctx):
ubsan_feature,
default_sanitizer_flags_feature,
archive_param_file_feature,
supports_pic_feature,
]
else:
fail("Unreachable")
Expand Down
10 changes: 5 additions & 5 deletions crosstool/osx_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ load(
"get_env",
)

def _get_escaped_xcode_cxx_inc_directories(repository_ctx, cc, xcode_toolchains):
def _get_escaped_xcode_cxx_inc_directories(repository_ctx, xcode_toolchains):
"""Compute the list of default C++ include paths on Xcode-enabled darwin.
Args:
repository_ctx: The repository context.
cc: The default C++ compiler on the local system.
xcode_toolchains: A list containing the xcode toolchains available
Returns:
include_paths: A list of builtin include paths.
Expand Down Expand Up @@ -139,6 +138,9 @@ def configure_osx_toolchain(repository_ctx):
Args:
repository_ctx: The repository context.
Returns:
Whether or not configuration was successful
"""
paths = resolve_labels(repository_ctx, [
"@bazel_tools//tools/cpp:armeabi_cc_toolchain_config.bzl",
Expand Down Expand Up @@ -172,8 +174,6 @@ def configure_osx_toolchain(repository_ctx):
# cc_wrapper.sh script. The wrapped_clang binary is already hardcoded
# into the Objective-C crosstool actions, anyway, so this ensures that
# the C++ actions behave consistently.
cc = repository_ctx.path("wrapped_clang")

cc_path = '"$(/usr/bin/dirname "$0")"/wrapped_clang'
repository_ctx.template(
"cc_wrapper.sh",
Expand Down Expand Up @@ -220,7 +220,7 @@ def configure_osx_toolchain(repository_ctx):
gcov_path = repository_ctx.which(gcov_path)
tool_paths["gcov"] = gcov_path

escaped_include_paths = _get_escaped_xcode_cxx_inc_directories(repository_ctx, cc, xcode_toolchains)
escaped_include_paths = _get_escaped_xcode_cxx_inc_directories(repository_ctx, xcode_toolchains)
escaped_cxx_include_directories = []
for path in escaped_include_paths:
escaped_cxx_include_directories.append((" \"%s\"," % path))
Expand Down

0 comments on commit 65e700a

Please sign in to comment.