Skip to content

Commit

Permalink
Fix bzlmod examples on windows (#2454)
Browse files Browse the repository at this point in the history
On windows (and some other platforms), the file extension of cargo,
rustc, etc have an extension. The module extension for loading crates
did not take this into account, causing it to error on windows.

Additionally, when using bzlmod to build vendored crates, the runfiles
tree would exceed the 260 char windows path limit. To mitigate this, I
have shortened the internal_deps module extension to just `i` and
changed the build script suffix to `_bs` from `_build_script`. This
makes the path names below the 260 char limit.

This makes the bzlmod CI run on windows, to avoid regressing this.
Currently gen_rust_project does not run on windows for other reasons,
although we do build this.
  • Loading branch information
cameron-martin authored Feb 23, 2024
1 parent 0e0241e commit 33fdddd
Show file tree
Hide file tree
Showing 311 changed files with 654 additions and 618 deletions.
10 changes: 10 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,16 @@ tasks:
- "@rules_rust//tools/rust_analyzer:gen_rust_project"
test_targets:
- "//..."
windows_bzlmod_bcr:
name: bzlmod BCR presubmit
platform: windows
working_directory: examples/bzlmod/hello_world
run_targets:
- "//third-party:vendor"
build_targets:
- "@rules_rust//tools/rust_analyzer:gen_rust_project"
test_targets:
- "//..."

buildifier:
version: latest
Expand Down
17 changes: 17 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,20 @@ bcr_test_module:
- "@rules_rust//tools/rust_analyzer:gen_rust_project"
test_targets:
- "//..."
# Windows is run separately because currently gen_rust_project doesn't run on windows, although it does build
bcr_test_module_windows:
module_path: ""
matrix:
bazel: ["6.x", "7.x"]
tasks:
run_tests:
working_directory: examples/bzlmod/hello_world
name: "Run test module"
platform: windows
bazel: ${{ bazel }}
run_targets:
- "//third-party:vendor"
build_targets:
- "@rules_rust//tools/rust_analyzer:gen_rust_project"
test_targets:
- "//..."
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bazel_dep(
repo_name = "com_google_protobuf",
)

internal_deps = use_extension("//rust/private:extensions.bzl", "internal_deps")
internal_deps = use_extension("//rust/private:extensions.bzl", "i")
use_repo(
internal_deps,
"bazelci_rules",
Expand Down
4 changes: 2 additions & 2 deletions bindgen/3rdparty/crates/BUILD.bindgen-0.69.1.bazel

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

4 changes: 2 additions & 2 deletions bindgen/3rdparty/crates/BUILD.clang-sys-1.6.1.bazel

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

4 changes: 2 additions & 2 deletions bindgen/3rdparty/crates/BUILD.libc-0.2.146.bazel

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

4 changes: 2 additions & 2 deletions bindgen/3rdparty/crates/BUILD.rustix-0.37.20.bazel

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

4 changes: 2 additions & 2 deletions bindgen/3rdparty/crates/BUILD.winapi-0.3.9.bazel

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

4 changes: 2 additions & 2 deletions cargo/private/cargo_build_script.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ def name_to_pkg_name(name):
Returns:
str: A cleaned up name for a build script target.
"""
if name.endswith("_build_script"):
return name[:-len("_build_script")]
if name.endswith("_bs"):
return name[:-len("_bs")]
return name

def _cargo_dep_env_implementation(ctx):
Expand Down
4 changes: 2 additions & 2 deletions crate_universe/3rdparty/crates/BUILD.anyhow-1.0.75.bazel

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

4 changes: 2 additions & 2 deletions crate_universe/3rdparty/crates/BUILD.camino-1.1.6.bazel

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

4 changes: 2 additions & 2 deletions crate_universe/3rdparty/crates/BUILD.chrono-tz-0.8.4.bazel

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

4 changes: 2 additions & 2 deletions crate_universe/3rdparty/crates/BUILD.crc32fast-1.3.2.bazel

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

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

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

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

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

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

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

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

4 changes: 2 additions & 2 deletions crate_universe/3rdparty/crates/BUILD.libc-0.2.149.bazel

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

4 changes: 2 additions & 2 deletions crate_universe/3rdparty/crates/BUILD.libm-0.2.7.bazel

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

4 changes: 2 additions & 2 deletions crate_universe/3rdparty/crates/BUILD.lock_api-0.4.11.bazel

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

4 changes: 2 additions & 2 deletions crate_universe/3rdparty/crates/BUILD.memoffset-0.9.0.bazel

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

Loading

0 comments on commit 33fdddd

Please sign in to comment.