Merge pull request #45 from hlopko:fix_cc_configure

PiperOrigin-RevId: 278612577
Change-Id: I70ed5cfba7bc5c5ee5cb0db45e0f072a36a49cff
This commit is contained in:
Copybara-Service 2019-11-05 06:40:31 -08:00
commit e7c97c3af7
4 changed files with 18 additions and 8 deletions

View File

@ -54,3 +54,6 @@ load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_
rules_proto_dependencies() rules_proto_dependencies()
rules_proto_toolchains() rules_proto_toolchains()
load("//cc:repositories.bzl", "rules_cc_toolchains")
rules_cc_toolchains()

View File

@ -24,7 +24,6 @@ load(
load( load(
":unix_cc_configure.bzl", ":unix_cc_configure.bzl",
"configure_unix_toolchain", "configure_unix_toolchain",
"find_cc",
"get_env", "get_env",
"get_escaped_cxx_inc_directories", "get_escaped_cxx_inc_directories",
) )
@ -64,7 +63,6 @@ def configure_osx_toolchain(repository_ctx, overriden_tools):
"@bazel_tools//tools/objc:xcrunwrapper.sh", "@bazel_tools//tools/objc:xcrunwrapper.sh",
"@bazel_tools//tools/osx/crosstool:BUILD.tpl", "@bazel_tools//tools/osx/crosstool:BUILD.tpl",
"@bazel_tools//tools/osx/crosstool:cc_toolchain_config.bzl", "@bazel_tools//tools/osx/crosstool:cc_toolchain_config.bzl",
"@bazel_tools//tools/osx/crosstool:wrapped_ar.tpl",
"@bazel_tools//tools/osx/crosstool:wrapped_clang.cc", "@bazel_tools//tools/osx/crosstool:wrapped_clang.cc",
"@bazel_tools//tools/osx:xcode_locator.m", "@bazel_tools//tools/osx:xcode_locator.m",
]) ])
@ -82,7 +80,13 @@ def configure_osx_toolchain(repository_ctx, overriden_tools):
fail("BAZEL_USE_XCODE_TOOLCHAIN is set to 1 but Bazel couldn't find Xcode installed on the " + fail("BAZEL_USE_XCODE_TOOLCHAIN is set to 1 but Bazel couldn't find Xcode installed on the " +
"system. Verify that 'xcode-select -p' is correct.") "system. Verify that 'xcode-select -p' is correct.")
if xcode_toolchains: if xcode_toolchains:
cc = find_cc(repository_ctx, overriden_tools = {}) # For Xcode toolchains, there's no reason to use anything other than
# wrapped_clang, so that we still get the Bazel Xcode placeholder
# substitution and other behavior for actions that invoke this
# 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")
repository_ctx.template( repository_ctx.template(
"cc_wrapper.sh", "cc_wrapper.sh",
paths["@rules_cc//cc/private/toolchain:osx_cc_wrapper.sh.tpl"], paths["@rules_cc//cc/private/toolchain:osx_cc_wrapper.sh.tpl"],
@ -103,10 +107,6 @@ def configure_osx_toolchain(repository_ctx, overriden_tools):
paths["@bazel_tools//tools/objc:make_hashed_objlist.py"], paths["@bazel_tools//tools/objc:make_hashed_objlist.py"],
"make_hashed_objlist.py", "make_hashed_objlist.py",
) )
repository_ctx.symlink(
paths["@bazel_tools//tools/osx/crosstool:wrapped_ar.tpl"],
"wrapped_ar",
)
repository_ctx.symlink( repository_ctx.symlink(
paths["@bazel_tools//tools/osx/crosstool:cc_toolchain_config.bzl"], paths["@bazel_tools//tools/osx/crosstool:cc_toolchain_config.bzl"],
"cc_toolchain_config.bzl", "cc_toolchain_config.bzl",
@ -118,7 +118,10 @@ def configure_osx_toolchain(repository_ctx, overriden_tools):
"env", "env",
"-i", "-i",
"xcrun", "xcrun",
"--sdk",
"macosx",
"clang", "clang",
"-mmacosx-version-min=10.9",
"-std=c++11", "-std=c++11",
"-lc++", "-lc++",
"-o", "-o",

View File

@ -256,7 +256,7 @@ def _get_no_canonical_prefixes_opt(repository_ctx, cc):
) )
return opt return opt
def _get_env(repository_ctx): def get_env(repository_ctx):
"""Convert the environment in a list of export if in Homebrew. Doesn't %-escape the result! """Convert the environment in a list of export if in Homebrew. Doesn't %-escape the result!
Args: Args:

View File

@ -9,6 +9,7 @@
# Ideally we'd delete this entire file. # Ideally we'd delete this entire file.
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//cc/private/toolchain:cc_configure.bzl", "cc_configure")
def rules_cc_dependencies(): def rules_cc_dependencies():
_maybe( _maybe(
@ -22,6 +23,9 @@ def rules_cc_dependencies():
], ],
) )
def rules_cc_toolchains(*args):
cc_configure(*args)
def _maybe(repo_rule, name, **kwargs): def _maybe(repo_rule, name, **kwargs):
if not native.existing_rule(name): if not native.existing_rule(name):
repo_rule(name = name, **kwargs) repo_rule(name = name, **kwargs)