-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #617 from tweag/cb/get-cpu-value
Use `get_cpu_value` from rules_nixpkgs_core in other modules
- Loading branch information
Showing
13 changed files
with
81 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
load("@bazel_skylib//lib:versions.bzl", "versions") | ||
|
||
# see https://github.com/tweag/rules_nixpkgs/pull/613 | ||
# taken from https://github.com/bazelbuild/rules_cc/blob/8395ec0172270f3bf92cd7b06c9b5b3f1f679e88/cc/private/toolchain/lib_cc_configure.bzl#L225 | ||
def get_cpu_value(repository_ctx): | ||
"""Compute the cpu_value based on the OS name. Doesn't %-escape the result! | ||
Args: | ||
repository_ctx: The repository context. | ||
Returns: | ||
One of (darwin, freebsd, x64_windows, ppc, s390x, arm, aarch64, k8, piii) | ||
""" | ||
os_name = repository_ctx.os.name | ||
arch = repository_ctx.os.arch | ||
if os_name.startswith("mac os"): | ||
# Check if we are on x86_64 or arm64 and return the corresponding cpu value. | ||
if arch == "aarch64": | ||
return "darwin_arm64" | ||
|
||
# NOTE(cb) for backward compatibility return "darwin" for Bazel < 7 on x86_64 | ||
if versions.is_at_least("7.0.0", versions.get()): | ||
return "darwin_x86_64" | ||
else: | ||
return "darwin" | ||
|
||
if os_name.find("freebsd") != -1: | ||
return "freebsd" | ||
if os_name.find("openbsd") != -1: | ||
return "openbsd" | ||
if os_name.find("windows") != -1: | ||
if arch == "aarch64": | ||
return "arm64_windows" | ||
else: | ||
return "x64_windows" | ||
|
||
if arch in ["power", "ppc64le", "ppc", "ppc64"]: | ||
return "ppc" | ||
if arch in ["s390x"]: | ||
return "s390x" | ||
if arch in ["mips64"]: | ||
return "mips64" | ||
if arch in ["riscv64"]: | ||
return "riscv64" | ||
if arch in ["arm", "armv7l"]: | ||
return "arm" | ||
if arch in ["aarch64"]: | ||
return "aarch64" | ||
return "k8" if arch in ["amd64", "x86_64", "x64"] else "piii" |
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
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
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