-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create cc_toolchains for multiple exec platforms (#196)
This change aims to allow hermetic_cc_toolchain to create toolchains for multiple exec platforms. It now generates repositories of the format {exec}-zig_sdk and registers each toolchain to only be exec_compatible_with those specific platform constraints. I want this PR to be a WIP as we discuss how we want this to look and if you're happy with it's general flow. This is an attempt at fixing #148 So far I have tested that my local client (mac) can build c code using the toolchains registered on a `x86_64` remote executor and have seen success. It'll will be hard for me to test every combination; but I will be able to local (x86_64) -> remote (arm64) tests as well.
- Loading branch information
1 parent
0f53271
commit aefb7a1
Showing
9 changed files
with
170 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,21 @@ | ||
load("@hermetic_cc_toolchain//toolchain:defs.bzl", zig_toolchains = "toolchains") | ||
load("@hermetic_cc_toolchain//toolchain:defs.bzl", "host_zig_repository", zig_toolchains = "toolchains") | ||
|
||
_COMMON_EXEC_PLATFORMS = [ | ||
("linux", "amd64"), | ||
("linux", "arm64"), | ||
("windows", "amd64"), | ||
("macos", "arm64"), | ||
("macos", "amd64"), | ||
] | ||
|
||
def _toolchains_impl(ctx): | ||
zig_toolchains() | ||
for os, arch in _COMMON_EXEC_PLATFORMS: | ||
zig_toolchains(exec_os = os, exec_arch = arch) | ||
|
||
host_zig_repository(name = "zig_sdk") | ||
return ctx.extension_metadata( | ||
root_module_direct_deps = ["zig_sdk"] + ["zig_sdk-{}-{}".format(os, arch) for os, arch in _COMMON_EXEC_PLATFORMS], | ||
root_module_direct_dev_deps = [], | ||
) | ||
|
||
toolchains = module_extension(implementation = _toolchains_impl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters