forked from bazelbuild/rules_rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate sys example to bzlmod (bazelbuild#3130)
Relates to bazelbuild#1839
- Loading branch information
1 parent
0e6ea40
commit 088209e
Showing
55 changed files
with
327 additions
and
128 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
############################################################################### | ||
## Bazel Configuration Flags | ||
## | ||
## `.bazelrc` is a Bazel configuration file. | ||
## https://bazel.build/docs/best-practices#bazelrc-file | ||
############################################################################### | ||
|
||
############################################################################### | ||
## Build configuration | ||
############################################################################### | ||
|
||
# Don't create bazel-* symlinks in the WORKSPACE directory. | ||
# Instead, set a prefix and put it in .gitignore | ||
# build --symlink_prefix=target-bzl/ | ||
|
||
############################################################################### | ||
## Test configuration | ||
############################################################################### | ||
|
||
# Reduce test output to just error cases | ||
test --test_output=errors | ||
test --verbose_failures | ||
|
||
############################################################################### | ||
## Common configuration | ||
############################################################################### | ||
|
||
# Enable Bzlmod for every Bazel command | ||
common --enable_bzlmod | ||
|
||
# Disable the bzlmod lockfile, so we don't accidentally commit MODULE.bazel.lock | ||
common --lockfile_mode=off | ||
|
||
# Write build outputs in a platform-specific directory; | ||
# avoid outputs being wiped and rewritten when switching between platforms. | ||
common --experimental_platform_in_output_dir | ||
|
||
# https://github.com/bazelbuild/bazel/issues/8195 | ||
build --incompatible_disallow_empty_glob=true | ||
|
||
# https://github.com/bazelbuild/bazel/issues/12821 | ||
build --nolegacy_external_runfiles | ||
|
||
# Required for cargo_build_script support before Bazel 7 | ||
build --incompatible_merge_fixed_and_default_shell_env | ||
|
||
############################################################################### | ||
## Rust configuration | ||
############################################################################### | ||
|
||
# Enable rustfmt for all targets in the workspace | ||
build:rustfmt --aspects=@rules_rust//rust:defs.bzl%rustfmt_aspect | ||
build:rustfmt --output_groups=+rustfmt_checks | ||
|
||
# Enable clippy for all targets in the workspace | ||
build:clippy --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect | ||
build:clippy --output_groups=+clippy_checks | ||
|
||
############################################################################### | ||
## Custom user flags | ||
## | ||
## This should always be the last thing in the `.bazelrc` file to ensure | ||
## consistent behavior when setting flags in that file as `.bazelrc` files are | ||
## evaluated top to bottom. | ||
############################################################################### | ||
|
||
try-import %workspace%/user.bazelrc |
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 @@ | ||
../.bazelversion |
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,2 @@ | ||
/bazel-* | ||
user.bazelrc |
File renamed without changes.
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,56 @@ | ||
module( | ||
name = "rules_rust_example_sys", | ||
version = "0.0.0", | ||
) | ||
|
||
############################################################################### | ||
# B A Z E L C E N T R A L R E G I S T R Y # https://registry.bazel.build/ | ||
############################################################################### | ||
# https://github.com/bazelbuild/rules_rust/releases | ||
bazel_dep(name = "rules_rust", version = "0.46.0") | ||
local_path_override( | ||
module_name = "rules_rust", | ||
path = "../../..", | ||
) | ||
|
||
bazel_dep( | ||
name = "bazel_skylib", | ||
version = "1.7.1", | ||
) | ||
bazel_dep( | ||
name = "platforms", | ||
version = "0.0.10", | ||
) | ||
bazel_dep( | ||
name = "rules_cc", | ||
version = "0.0.17", | ||
) | ||
|
||
deps = use_extension("//:extensions.bzl", "rust_example") | ||
use_repo( | ||
deps, | ||
"basic_sys", | ||
"basic_sys__bzip2-0.3.3", | ||
"complex_sys", | ||
"complex_sys__git2-0.14.4", | ||
"libgit2", | ||
"zlib", | ||
) | ||
|
||
############################################################################### | ||
# T O O L C H A I N S | ||
############################################################################### | ||
|
||
# Rust toolchain | ||
RUST_EDITION = "2021" | ||
|
||
RUST_VERSION = "1.79.0" | ||
|
||
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") | ||
rust.toolchain( | ||
edition = RUST_EDITION, | ||
versions = [RUST_VERSION], | ||
) | ||
use_repo(rust, "rust_toolchains") | ||
|
||
register_toolchains("@rust_toolchains//:all") |
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,10 @@ | ||
# Sys Crate Examples | ||
|
||
This repository demonstrates how to use `rules_rust` to build projects that depend on `-sys` crates. | ||
|
||
`-sys` crates provide low-level bindings to native libraries, allowing Rust code to interact with C libraries through the Foreign Function Interface (FFI). For more details, see the [Rust FFI documentation](https://doc.rust-lang.org/nomicon/ffi.html) or the [Rust-bindgen project](https://github.com/rust-lang/rust-bindgen). | ||
|
||
This workspace includes: | ||
|
||
1. **Basic Example**: Using `bzip2-sys` to interface with the `bzip2` compression library. | ||
2. **Complex Example**: Using `libgit2-sys` to interact with the `libgit2` library. |
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 @@ | ||
workspace(name = "rules_rust_example_sys") |
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
Oops, something went wrong.