Skip to content

Commit 9fc4140

Browse files
Merge pull request #4 from CACI-International/absolute-sdk-dirs
Use absolute directory path for Xcode
2 parents cae7ba0 + 728bfb4 commit 9fc4140

File tree

5 files changed

+17
-28
lines changed

5 files changed

+17
-28
lines changed

bazel/MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module(
33
version = "0.0.0",
44
)
55

6-
bazel_dep(name = "rules_cc", version = "0.1.4")
6+
bazel_dep(name = "rules_cc", version = "0.2.8")
77
bazel_dep(name = "platforms", version = "1.0.0")
88
bazel_dep(name = "bazel_skylib", version = "1.8.1")
99
bazel_dep(name = "aspect_bazel_lib", version = "2.20.0")

bazel/MODULE.bazel.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bazel/detail/xcode/find.bzl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ def _find_xcode_sdk(rctx):
55
fail("could not find sdk `{}`, do you have xcode installed?\n{}".format(rctx.attr.sdk, result.stderr))
66
sdk_path = str(rctx.path(result.stdout.strip()).realpath)
77

8-
# Copy the SDK to this repository, but exclude the Ruby framework, which has recursive symlinks that break Bazel glob
9-
ruby_framework = "System/Library/Frameworks/Ruby.framework"
10-
result = rctx.execute(["rsync", "-a", "--exclude", ruby_framework, sdk_path + "/", "."])
11-
if result.return_code != 0:
12-
fail("could not copy sdk:\n{}".format(result.stderr))
13-
rctx.file("BUILD", rctx.read(Label("sdk.BUILD")))
8+
rctx.file("BUILD", rctx.read(Label("sdk.BUILD")).replace("{{XCODE_PATH}}", sdk_path))
149

1510
find_xcode_sdk = repository_rule(
1611
implementation = _find_xcode_sdk,

bazel/detail/xcode/sdk.BUILD

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
load("@bazel_skylib//rules/directory:directory.bzl", "directory")
2-
load("@rules_cc//cc/toolchains/args:sysroot.bzl", "cc_sysroot")
1+
load("@rules_cc//cc/toolchains:args.bzl", "cc_args")
32

4-
directory(
5-
name = "sdk_link",
6-
srcs = glob(
7-
[
8-
"usr/include/**/*",
9-
"usr/lib/**/*",
10-
"System/Library/Frameworks/**/*",
11-
],
12-
),
13-
)
14-
15-
cc_sysroot(
3+
cc_args(
164
name = "sdk",
17-
data = ["sdk_link"],
18-
sysroot = "sdk_link",
5+
actions = [
6+
"@rules_cc//cc/toolchains/actions:assembly_actions",
7+
"@rules_cc//cc/toolchains/actions:c_compile",
8+
"@rules_cc//cc/toolchains/actions:cpp_compile_actions",
9+
"@rules_cc//cc/toolchains/actions:link_actions",
10+
],
11+
allowlist_absolute_include_directories = ["{{XCODE_PATH}}"],
12+
args = ["--sysroot={{XCODE_PATH}}"],
1913
visibility = ["//visibility:public"],
2014
)

bazel/test/MODULE.bazel.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)