Skip to content

Commit

Permalink
Nix example switched to using `crate_universe_dependencies(bootstrap …
Browse files Browse the repository at this point in the history
…= True)`.
  • Loading branch information
rickvanprim committed Dec 12, 2023
1 parent 00d3e4e commit 0773ade
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 134 deletions.
61 changes: 0 additions & 61 deletions crate_universe/flake.lock

This file was deleted.

26 changes: 0 additions & 26 deletions crate_universe/flake.nix

This file was deleted.

62 changes: 34 additions & 28 deletions examples/nix_cross_compiling/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,48 @@ load("//bazel:nix_repositories.bzl", "nix_repositories")

nix_repositories()

# Toolchains
register_toolchains(
"//bazel/toolchains/cc/aarch64-apple-darwin:toolchain",
"//bazel/toolchains/cc/aarch64-apple-ios:toolchain",
"//bazel/toolchains/cc/aarch64-linux-android:toolchain",
"//bazel/toolchains/cc/aarch64-unknown-linux-gnu:toolchain",
"//bazel/toolchains/cc/wasm32-unknown-unknown:toolchain",
"//bazel/toolchains/cc/wasm32-wasi:toolchain",
"//bazel/toolchains/cc/x86_64-apple-darwin:toolchain",
"//bazel/toolchains/cc/x86_64-pc-windows-msvc:toolchain",
"//bazel/toolchains/cc/x86_64-unknown-linux-gnu:toolchain",
"//bazel/toolchains/cc/x86_64-unknown-nixos-gnu:toolchain",
"//bazel/toolchains/rust/aarch64-apple-darwin:toolchain",
"//bazel/toolchains/rust/aarch64-apple-ios:toolchain",
"//bazel/toolchains/rust/aarch64-linux-android:toolchain",
"//bazel/toolchains/rust/aarch64-unknown-linux-gnu:toolchain",
"//bazel/toolchains/rust/wasm32-unknown-unknown:toolchain",
"//bazel/toolchains/rust/wasm32-wasi:toolchain",
"//bazel/toolchains/rust/x86_64-apple-darwin:toolchain",
"//bazel/toolchains/rust/x86_64-pc-windows-msvc:toolchain",
"//bazel/toolchains/rust/x86_64-unknown-linux-gnu:toolchain",
"//bazel/toolchains/rust/x86_64-unknown-nixos-gnu:toolchain",
)

# Rust
local_repository(
name = "rules_rust",
path = "../..",
)

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

rules_rust_dependencies()

rust_register_toolchains(
edition = "2021",
)

load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")

crate_universe_dependencies(bootstrap = True)

load("@rules_rust//crate_universe:defs.bzl", "crates_repository", "splicing_config")
load("//bazel/cargo:crates_repository.bzl", CARGO_ANNOTATIONS = "ANNOTATIONS", CARGO_PACKAGES = "PACKAGES")

Expand All @@ -34,11 +66,9 @@ crates_repository(
annotations = CARGO_ANNOTATIONS,
cargo_lockfile = "//bazel/cargo:Cargo.lock",
generate_build_scripts = False,
generator = "@cargo-bazel//:bin/cargo-bazel",
generator = "@cargo_bazel_bootstrap//:cargo-bazel",
lockfile = "//bazel/cargo:cargo-bazel-lock.json",
packages = CARGO_PACKAGES,
rust_toolchain_cargo_template = "@nix_rust//:bin/{tool}",
rust_toolchain_rustc_template = "@nix_rust//:bin/{tool}",
splicing_config = splicing_config(
resolver_version = "2",
),
Expand All @@ -59,27 +89,3 @@ crates_repository(
load("@crate_index//:defs.bzl", "crate_repositories")

crate_repositories()

# Toolchains
register_toolchains(
"//bazel/toolchains/cc/aarch64-apple-darwin:toolchain",
"//bazel/toolchains/cc/aarch64-apple-ios:toolchain",
"//bazel/toolchains/cc/aarch64-linux-android:toolchain",
"//bazel/toolchains/cc/aarch64-unknown-linux-gnu:toolchain",
"//bazel/toolchains/cc/wasm32-unknown-unknown:toolchain",
"//bazel/toolchains/cc/wasm32-wasi:toolchain",
"//bazel/toolchains/cc/x86_64-apple-darwin:toolchain",
"//bazel/toolchains/cc/x86_64-pc-windows-msvc:toolchain",
"//bazel/toolchains/cc/x86_64-unknown-linux-gnu:toolchain",
"//bazel/toolchains/cc/x86_64-unknown-nixos-gnu:toolchain",
"//bazel/toolchains/rust/aarch64-apple-darwin:toolchain",
"//bazel/toolchains/rust/aarch64-apple-ios:toolchain",
"//bazel/toolchains/rust/aarch64-linux-android:toolchain",
"//bazel/toolchains/rust/aarch64-unknown-linux-gnu:toolchain",
"//bazel/toolchains/rust/wasm32-unknown-unknown:toolchain",
"//bazel/toolchains/rust/wasm32-wasi:toolchain",
"//bazel/toolchains/rust/x86_64-apple-darwin:toolchain",
"//bazel/toolchains/rust/x86_64-pc-windows-msvc:toolchain",
"//bazel/toolchains/rust/x86_64-unknown-linux-gnu:toolchain",
"//bazel/toolchains/rust/x86_64-unknown-nixos-gnu:toolchain",
)

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

14 changes: 0 additions & 14 deletions examples/nix_cross_compiling/bazel/nix_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,6 @@ rust_stdlib_filegroup(
)
"""

_CARGO_BAZEL_BUILD_FILE_CONTENT = """
package(default_visibility = ["//visibility:public"])
exports_files(["bin/cargo-bazel"])
"""

def nix_repositories():
nixpkgs_flake_package(
name = "nix_config",
Expand All @@ -223,11 +217,3 @@ def nix_repositories():
package = "bazel.rust",
build_file_content = _RUST_BUILD_FILE_CONTENT,
)

nixpkgs_flake_package(
name = "cargo-bazel",
nix_flake_file = "@rules_rust//crate_universe:flake.nix",
nix_flake_lock_file = "@rules_rust//crate_universe:flake.lock",
package = "cargo-bazel",
build_file_content = _CARGO_BAZEL_BUILD_FILE_CONTENT,
)
11 changes: 7 additions & 4 deletions util/repin_all.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/bash -eu
#!/usr/bin/env bash
set -eu

# Re-generates all files which may need to be re-generated after changing crate_universe.
# Normalize working directory to root of repository.
cd "$(dirname "${BASH_SOURCE[0]}")"/..

# Re-generates all files which may need to be re-generated after changing crate_universe.
bazel run //crate_universe/3rdparty:crates_vendor

for d in examples/crate_universe* test/no_std
for d in examples/crate_universe* examples/nix_cross_compiling test/no_std
do
(cd ${d} && CARGO_BAZEL_REPIN=true bazel query ... >/dev/null)
(cd ${d} && CARGO_BAZEL_REPIN=true bazel query @crate_index//... >/dev/null)
done

0 comments on commit 0773ade

Please sign in to comment.