Skip to content

Commit

Permalink
Remove pre Xcode 12 logic (#204)
Browse files Browse the repository at this point in the history
We require Xcode 13+ (matching the App Store) at this point, so we don't
need to support versions that can't build for Apple Silicon
  • Loading branch information
keith authored Feb 16, 2023
1 parent ffecf73 commit 3cc7250
Showing 1 changed file with 27 additions and 49 deletions.
76 changes: 27 additions & 49 deletions crosstool/osx_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ def _get_escaped_xcode_cxx_inc_directories(repository_ctx, xcode_toolchains):

return include_dirs

# TODO: Remove once Xcode 12 is the minimum supported version
def _compile_cc_file_single_arch(repository_ctx, src_name, out_name):
def _compile_cc_file(repository_ctx, src_name, out_name):
env = repository_ctx.os.environ
xcrun_result = repository_ctx.execute([
"env",
Expand All @@ -60,12 +59,19 @@ def _compile_cc_file_single_arch(repository_ctx, src_name, out_name):
"-mmacosx-version-min=10.13",
"-std=c++11",
"-lc++",
"-arch",
"arm64",
"-arch",
"x86_64",
"-Wl,-no_adhoc_codesign",
"-Wl,-no_uuid",
"-O3",
"-o",
out_name,
src_name,
])
if (xcrun_result.return_code != 0):

if xcrun_result.return_code != 0:
error_msg = (
"return code {code}, stderr: {err}, stdout: {out}"
).format(
Expand All @@ -74,59 +80,31 @@ def _compile_cc_file_single_arch(repository_ctx, src_name, out_name):
out = xcrun_result.stdout,
)
fail(out_name + " failed to generate. Please file an issue at " +
"https://github.com/bazelbuild/bazel/issues with the following:\n" +
"https://github.com/bazelbuild/apple_support/issues with the following:\n" +
error_msg)

def _compile_cc_file(repository_ctx, src_name, out_name):
env = repository_ctx.os.environ
xcrun_result = repository_ctx.execute([
"env",
"-i",
"DEVELOPER_DIR={}".format(env.get("DEVELOPER_DIR", default = "")),
"xcrun",
"--sdk",
"macosx",
"clang",
"-mmacosx-version-min=10.13",
"-std=c++11",
"-lc++",
"-arch",
"arm64",
"-arch",
"x86_64",
"-Wl,-no_adhoc_codesign",
"-Wl,-no_uuid",
"-O3",
"-o",
"codesign",
"--identifier", # Required to be reproducible across archs
out_name,
"--force",
"--sign",
"-",
out_name,
src_name,
])

if xcrun_result.return_code == 0:
xcrun_result = repository_ctx.execute([
"env",
"-i",
"codesign",
"--identifier", # Required to be reproducible across archs
out_name,
"--force",
"--sign",
"-",
out_name,
])
if xcrun_result.return_code != 0:
error_msg = (
"codesign return code {code}, stderr: {err}, stdout: {out}"
).format(
code = xcrun_result.return_code,
err = xcrun_result.stderr,
out = xcrun_result.stdout,
)
fail(out_name + " failed to generate. Please file an issue at " +
"https://github.com/bazelbuild/bazel/issues with the following:\n" +
error_msg)
else:
_compile_cc_file_single_arch(repository_ctx, src_name, out_name)
if xcrun_result.return_code != 0:
error_msg = (
"codesign return code {code}, stderr: {err}, stdout: {out}"
).format(
code = xcrun_result.return_code,
err = xcrun_result.stderr,
out = xcrun_result.stdout,
)
fail(out_name + " failed to generate. Please file an issue at " +
"https://github.com/bazelbuild/apple_support/issues with the following:\n" +
error_msg)

def configure_osx_toolchain(repository_ctx):
"""Configure C++ toolchain on macOS.
Expand Down

0 comments on commit 3cc7250

Please sign in to comment.