Skip to content

Commit

Permalink
Merge branch 'master' into mergify/configuration-deprecated-update
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Nov 29, 2024
2 parents 53989a4 + 159cb43 commit 00180ce
Show file tree
Hide file tree
Showing 26 changed files with 135 additions and 44 deletions.
2 changes: 1 addition & 1 deletion core/.bazelignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bazel-*
bazel-core
testing
1 change: 1 addition & 0 deletions core/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ bzl_library(
srcs = [
"nixpkgs.bzl",
"util.bzl",
"private/get_cpu_value.bzl",
],
deps = [
":bazel_tools",
Expand Down
48 changes: 48 additions & 0 deletions core/private/get_cpu_value.bzl
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"
2 changes: 1 addition & 1 deletion core/util.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@bazel_tools//tools/cpp:lib_cc_configure.bzl", "get_cpu_value")
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_skylib//lib:versions.bzl", "versions")
load("//:private/get_cpu_value.bzl", "get_cpu_value")

def fail_on_err(return_value, prefix = None):
"""Fail if the given return value indicates an error.
Expand Down
2 changes: 1 addition & 1 deletion examples/toolchains/cc_cross_osx_to_linux_amd64/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ load("@rules_oci//oci:pull.bzl", "oci_pull")

oci_pull(
name = "distroless_base",
digest = "sha256:c925d12234f8d3fbef2256012b168004d4c47a82c4f06afcfd06fd208732fbe0",
digest = "sha256:e9d0321de8927f69ce20e39bfc061343cce395996dfc1f0db6540e5145bc63a5",
image = "gcr.io/distroless/base",
platforms = [
"linux/amd64",
Expand Down
23 changes: 17 additions & 6 deletions examples/toolchains/rust/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# https://bazelbuild.github.io/rules_rust/#setup
http_archive(
name = "rules_rust",
sha256 = "85e2013727ab26fb22abdffe4b2ac0c27a2d5b6296167ba63d8f6e13140f51f9",
sha256 = "af4f56caae50a99a68bfce39b141b509dd68548c8204b98ab7a1cafc94d5bb02",
urls = [
"https://github.com/bazelbuild/rules_rust/releases/download/0.53.0/rules_rust-v0.53.0.tar.gz",
"https://github.com/bazelbuild/rules_rust/releases/download/0.54.1/rules_rust-v0.54.1.tar.gz",
],
)

Expand Down Expand Up @@ -62,15 +62,14 @@ nixpkgs_package(
],
)

load("@rules_rust//rust:repositories.bzl", "rust_repositories")
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies")

rust_repositories()
rules_rust_dependencies()

# crate_universe as a way of governing deps
load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")

crate_universe_dependencies(
bootstrap = True,
rust_toolchain_cargo_template = "@nix_rust//:bin/{tool}",
rust_toolchain_rustc_template = "@nix_rust//:bin/{tool}",
)
Expand All @@ -94,6 +93,10 @@ OPENSSL_CRATE_ANNOTATION = crate.annotation(
],
)

# buildifier: disable=bzl-visibility
load("@rules_rust//crate_universe/private:urls.bzl", "CARGO_BAZEL_URLS", "CARGO_BAZEL_SHA256S")
load("@rules_rust//rust/platform:triple_mappings.bzl", "SUPPORTED_PLATFORM_TRIPLES")

crates_repository(
name = "crate_index",
# Ensure the caro openssl-sys crate
Expand All @@ -111,12 +114,20 @@ crates_repository(
features = [],
),
},
generator = "@cargo_bazel_bootstrap//:cargo-bazel",
# rules_rust provides static binaries for linux, but does not use them by default
generator_urls = CARGO_BAZEL_URLS | {
"x86_64-unknown-linux-gnu": CARGO_BAZEL_URLS["x86_64-unknown-linux-musl"],
},
generator_sha256s = CARGO_BAZEL_SHA256S | {
"x86_64-unknown-linux-gnu": CARGO_BAZEL_SHA256S["x86_64-unknown-linux-musl"],
},
render_config = render_config(
default_package_name = "",
),
rust_toolchain_cargo_template = "@nix_rust//:bin/{tool}",
rust_toolchain_rustc_template = "@nix_rust//:bin/{tool}",
# the `wasm32-wasip1` target is not supported by nix_rustc (or named differently)
supported_platform_triples = [ triple for triple in SUPPORTED_PLATFORM_TRIPLES if triple != "wasm32-wasip1"],
)

load("@crate_index//:defs.bzl", "crate_repositories")
Expand Down
14 changes: 7 additions & 7 deletions examples/toolchains/rust/cargo-bazel-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "37bb718b562c2aa348987c089bf229259fefd493217783470d5cbab635f5d96c",
"checksum": "7f7d82ec2821b07887547659086f5c71632af4fda0f7f74885ff887df2547043",
"crates": {
"autocfg 1.1.0": {
"name": "autocfg",
Expand Down Expand Up @@ -1093,15 +1093,15 @@
"aarch64-apple-ios-sim": [
"aarch64-apple-ios-sim"
],
"aarch64-fuchsia": [
"aarch64-fuchsia"
],
"aarch64-linux-android": [
"aarch64-linux-android"
],
"aarch64-pc-windows-msvc": [
"aarch64-pc-windows-msvc"
],
"aarch64-unknown-fuchsia": [
"aarch64-unknown-fuchsia"
],
"aarch64-unknown-linux-gnu": [
"aarch64-unknown-linux-gnu"
],
Expand Down Expand Up @@ -1170,9 +1170,6 @@
"x86_64-apple-ios": [
"x86_64-apple-ios"
],
"x86_64-fuchsia": [
"x86_64-fuchsia"
],
"x86_64-linux-android": [
"x86_64-linux-android"
],
Expand All @@ -1182,6 +1179,9 @@
"x86_64-unknown-freebsd": [
"x86_64-unknown-freebsd"
],
"x86_64-unknown-fuchsia": [
"x86_64-unknown-fuchsia"
],
"x86_64-unknown-linux-gnu": [
"x86_64-unknown-linux-gnu"
],
Expand Down
2 changes: 1 addition & 1 deletion nixpkgs/nixpkgs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ nixpkgs_package(

load("@bazel_tools//tools/cpp:cc_configure.bzl", "cc_autoconf_impl")
load(
"@bazel_tools//tools/cpp:lib_cc_configure.bzl",
"@rules_nixpkgs_core//:private/get_cpu_value.bzl",
"get_cpu_value",
)
load(
Expand Down
6 changes: 3 additions & 3 deletions testing/posix/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ bazel_skylib_workspace()

http_archive(
name = "rules_sh",
sha256 = "23a4571ec8afc83db1eae99c0efd0b8b4fa1644069f0340a10f8859e086ba02c",
strip_prefix = "rules_sh-0.4.0",
urls = ["https://github.com/tweag/rules_sh/archive/v0.4.0.tar.gz"],
sha256 = "f96b39c5a07d38424b48b5cc2e5f4b820f2877682a0488faa43f0948def95e28",
strip_prefix = "rules_sh-0.5.0",
urls = ["https://github.com/tweag/rules_sh/archive/v0.5.0.tar.gz"],
)

load("@rules_sh//sh:repositories.bzl", "rules_sh_dependencies")
Expand Down
1 change: 1 addition & 0 deletions testing/python/.bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bazel-python
34 changes: 17 additions & 17 deletions testing/python/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion testing/rust/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ local_path_override(

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_rust", version = "0.53.0")
bazel_dep(name = "rules_rust", version = "0.54.1")

# TODO[AH] Remove these transitive dependencies once nixpkgs_java_configure has
# become a module extension in rules_nixpkgs_java.
Expand Down
4 changes: 2 additions & 2 deletions testing/rust/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ bazel_skylib_workspace()

http_archive(
name = "rules_rust",
sha256 = "85e2013727ab26fb22abdffe4b2ac0c27a2d5b6296167ba63d8f6e13140f51f9",
sha256 = "af4f56caae50a99a68bfce39b141b509dd68548c8204b98ab7a1cafc94d5bb02",
urls = [
"https://github.com/bazelbuild/rules_rust/releases/download/0.53.0/rules_rust-v0.53.0.tar.gz"
"https://github.com/bazelbuild/rules_rust/releases/download/0.54.1/rules_rust-v0.54.1.tar.gz"
],
)

Expand Down
5 changes: 4 additions & 1 deletion toolchains/cc/cc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ using `nixpkgs_cc_configure(..., cc_lang = "cuda")` or similar.
load("@bazel_skylib//lib:sets.bzl", "sets")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load(
"@bazel_tools//tools/cpp:lib_cc_configure.bzl",
"@rules_nixpkgs_core//:private/get_cpu_value.bzl",
"get_cpu_value",
)
load(
"@bazel_tools//tools/cpp:lib_cc_configure.bzl",
"get_starlark_list",
"write_builtin_include_directory_paths",
)
Expand Down
4 changes: 4 additions & 0 deletions toolchains/go/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module(
)

bazel_dep(name = "rules_nixpkgs_core", version = "0.12.0")
local_path_override(
module_name = "rules_nixpkgs_core",
path = "../../core",
)
bazel_dep(name = "rules_go", repo_name = "io_bazel_rules_go", version = "0.39.1")
bazel_dep(name = "bazel_skylib", version = "1.0.3")
bazel_dep(name = "platforms", version = "0.0.4")
1 change: 1 addition & 0 deletions toolchains/java/.bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bazel-java
4 changes: 4 additions & 0 deletions toolchains/java/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module(
)

bazel_dep(name = "rules_nixpkgs_core", version = "0.12.0")
local_path_override(
module_name = "rules_nixpkgs_core",
path = "../../core",
)
bazel_dep(name = "rules_java", version = "7.3.1")
bazel_dep(name = "bazel_skylib", version = "1.0.3")

Expand Down
2 changes: 1 addition & 1 deletion toolchains/java/java.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""

load(
"@bazel_tools//tools/cpp:lib_cc_configure.bzl",
"@rules_nixpkgs_core//:private/get_cpu_value.bzl",
"get_cpu_value",
)
load(
Expand Down
2 changes: 1 addition & 1 deletion toolchains/nodejs/.bazelignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bazel-*
bazel-nodejs
testing
4 changes: 4 additions & 0 deletions toolchains/nodejs/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module(
)

bazel_dep(name = "rules_nixpkgs_core", version = "0.12.0")
local_path_override(
module_name = "rules_nixpkgs_core",
path = "../../core",
)
bazel_dep(name = "platforms", version = "0.0.4")
bazel_dep(name = "rules_nodejs", version = "5.5.3")
bazel_dep(name = "bazel_skylib", version = "1.0.3")
Expand Down
1 change: 1 addition & 0 deletions toolchains/nodejs/testing/.bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bazel-nodejs
4 changes: 4 additions & 0 deletions toolchains/posix/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ module(
)

bazel_dep(name = "rules_nixpkgs_core", version = "0.12.0")
local_path_override(
module_name = "rules_nixpkgs_core",
path = "../../core",
)
bazel_dep(name = "rules_sh", version = "0.3.0")
bazel_dep(name = "bazel_skylib", version = "1.0.3")
2 changes: 1 addition & 1 deletion toolchains/posix/posix.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Rules for importing a POSIX toolchain from Nixpkgs.
"""

load(
"@bazel_tools//tools/cpp:lib_cc_configure.bzl",
"@rules_nixpkgs_core//:private/get_cpu_value.bzl",
"get_cpu_value",
)
load("@rules_nixpkgs_core//:nixpkgs.bzl", "nixpkgs_package")
Expand Down
4 changes: 4 additions & 0 deletions toolchains/python/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ module(
)

bazel_dep(name = "rules_nixpkgs_core", version = "0.12.0")
local_path_override(
module_name = "rules_nixpkgs_core",
path = "../../core",
)
bazel_dep(name = "bazel_skylib", version = "1.0.3")
1 change: 1 addition & 0 deletions toolchains/rust/.bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bazel-rust
Loading

0 comments on commit 00180ce

Please sign in to comment.