Skip to content

Commit 922b8d0

Browse files
authored
Build windows without runfiles links by default. (#3366)
1 parent 1832faa commit 922b8d0

File tree

18 files changed

+28
-196
lines changed

18 files changed

+28
-196
lines changed

.bazelci/presubmit.yml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ default_macos_targets: &default_macos_targets
6969
default_windows_targets: &default_windows_targets
7070
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
7171
- "//..."
72-
default_windows_no_runfiles_targets: &default_windows_no_runfiles_targets
73-
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
74-
- "//..."
7572
crate_universe_vendor_example_targets: &crate_universe_vendor_example_targets
7673
- "//vendor_external:crates_vendor"
7774
- "//vendor_local_manifests:crates_vendor"
@@ -148,15 +145,14 @@ tasks:
148145
shell_commands: *no_bzlmod_shell_commands
149146
build_targets: *default_windows_targets
150147
test_targets: *default_windows_targets
151-
windows_no_runfiles:
152-
name: No Runfiles
148+
windows_with_runfiles:
149+
name: With Runfiles
153150
platform: windows
154-
build_flags:
155-
- "--noenable_runfiles"
156-
test_flags:
157-
- "--noenable_runfiles"
158-
build_targets: *default_windows_no_runfiles_targets
159-
test_targets: *default_windows_no_runfiles_targets
151+
batch_commands:
152+
- echo startup --windows_enable_symlinks > user.bazelrc
153+
- echo common --noenable_runfiles >> user.bazelrc
154+
build_targets: *default_windows_targets
155+
test_targets: *default_windows_targets
160156
ubuntu2004_split_coverage_postprocessing:
161157
name: Split Coverage Postprocessing
162158
platform: ubuntu2004
@@ -251,18 +247,19 @@ tasks:
251247
build_targets: *default_windows_targets
252248
test_targets: *default_windows_targets
253249
windows_no_runfiles_with_aspects:
254-
name: No Runfiles With Aspects
250+
name: With Runfiles With Aspects
255251
platform: windows
252+
batch_commands:
253+
- echo startup --windows_enable_symlinks > user.bazelrc
254+
- echo common --noenable_runfiles >> user.bazelrc
256255
build_flags:
257-
- "--noenable_runfiles"
258256
- "--config=rustfmt"
259257
- "--config=clippy"
260258
test_flags:
261-
- "--noenable_runfiles"
262259
- "--config=rustfmt"
263260
- "--config=clippy"
264-
build_targets: *default_windows_no_runfiles_targets
265-
test_targets: *default_windows_no_runfiles_targets
261+
build_targets: *default_windows_targets
262+
test_targets: *default_windows_targets
266263
windows_rolling_with_aspects:
267264
name: "Windows Rolling Bazel Version With Aspects"
268265
platform: windows

.bazelrc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ build --nobuild_runfile_links
1111
# https://bazel.build/reference/command-line-reference#flag--enable_platform_specific_config
1212
common --enable_platform_specific_config
1313

14-
# https://bazel.build/docs/windows#symlink
15-
startup --windows_enable_symlinks
16-
build:windows --enable_runfiles
17-
1814
# Enable the only currently supported report type
1915
# https://bazel.build/reference/command-line-reference#flag--combined_report
2016
coverage --combined_report=lcov

.github/github.bazelrc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
# Always display the flags being used
44
common --announce_rc
55

6-
# These settings make the windows workers behave similarly to unix workers
7-
startup --windows_enable_symlinks
8-
build --enable_runfiles
9-
106
# Show errors in CI
117
test --test_output=errors
128

cargo/cargo_build_script_runner/cargo_manifest_dir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl RunfilesMaker {
279279
/// Delete runfiles from the runfiles directory that do not match user defined suffixes
280280
///
281281
/// The Windows implementation assumes symlinks are not supported and real files will have
282-
/// been copied into the runfiles directoriy.
282+
/// been copied into the runfiles directory.
283283
fn drain_runfiles_dir_windows(&self) -> Result<(), String> {
284284
for dest in self.runfiles.values() {
285285
if !self

docs/src/index.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,3 @@ WORKSPACE support is officially tested with Bazel 7 for as long as that is the m
9898
We aim to support Linux and macOS.
9999

100100
We do not have sufficient maintainer expertise to support Windows. Most things probably work, but we have had to disable many tests in CI because we lack the expertise to fix them. We welcome contributions to help improve its support.
101-
102-
Windows support for some features requires `--enable_runfiles` to be passed to Bazel, we recommend putting it in your bazelrc. See [Using Bazel on Windows](https://bazel.build/configure/windows) for more Windows-specific recommendations.

examples/all_crate_deps/.bazelrc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# Required on windows
2-
common --enable_platform_specific_config
3-
startup --windows_enable_symlinks
4-
build:windows --enable_runfiles
5-
6-
build --experimental_enable_bzlmod
7-
81
# This isn't currently the defaut in Bazel, but we enable it to test we'll be ready if/when it flips.
92
build --incompatible_disallow_empty_glob
103

examples/compile_opt/.bazelrc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
# Required on windows
2-
common --enable_platform_specific_config
3-
startup --windows_enable_symlinks
4-
build:windows --enable_runfiles
5-
61
# This isn't currently the defaut in Bazel, but we enable it to test we'll be ready if/when it flips.
72
build --incompatible_disallow_empty_glob
83

examples/crate_universe/cargo_aliases/.bazelrc

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/crate_universe/cargo_remote/.bazelrc

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/crate_universe/cargo_workspace/.bazelrc

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/crate_universe/multi_package/.bazelrc

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/crate_universe/no_cargo_manifests/.bazelrc

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/override_target/.bazelrc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# Required on windows
2-
common --enable_platform_specific_config
3-
startup --windows_enable_symlinks
4-
build:windows --enable_runfiles
5-
6-
build --experimental_enable_bzlmod
7-
81
# This isn't currently the defaut in Bazel, but we enable it to test we'll be ready if/when it flips.
92
build --incompatible_disallow_empty_glob
103

examples/zig_cross_compiling/.bazelrc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
# Required on windows
2-
common --enable_platform_specific_config
3-
startup --windows_enable_symlinks
4-
build:windows --enable_runfiles
5-
61
build --incompatible_enable_cc_toolchain_resolution
72

8-
# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel
9-
# https://github.com/bazelbuild/rules_rust/issues/2181
10-
common --noenable_bzlmod
11-
123
# This isn't currently the defaut in Bazel, but we enable it to test we'll be ready if/when it flips.
134
build --incompatible_disallow_empty_glob

extensions/protobuf/.bazelrc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
# https://bazel.build/reference/command-line-reference#flag--enable_platform_specific_config
99
common --enable_platform_specific_config
1010

11-
# https://bazel.build/docs/windows#symlink
12-
startup --windows_enable_symlinks
13-
build:windows --enable_runfiles
14-
1511
# Enable the only currently supported report type
1612
# https://bazel.build/reference/command-line-reference#flag--combined_report
1713
coverage --combined_report=lcov

test/cargo_build_script/resolve_abs_symlink_out_dir/BUILD.bazel

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ cargo_build_script(
99
srcs = ["build.rs"],
1010
data = ["data.txt"],
1111
edition = "2018",
12+
# TODO: Fix flake on windows.
13+
target_compatible_with = select({
14+
"@platforms//os:windows": ["@platforms//:incompatible"],
15+
"//conditions:default": [],
16+
}),
1217
)
1318

1419
rust_test(
1520
name = "test",
1621
srcs = ["test.rs"],
1722
data = [":symlink_build_rs"],
1823
edition = "2018",
19-
# TODO: Fix flake on windows.
20-
target_compatible_with = select({
21-
"@platforms//os:windows": ["@platforms//:incompatible"],
22-
"//conditions:default": [],
23-
}),
2424
deps = [":symlink_build_rs"],
2525
)

test/cargo_build_script/resolve_abs_symlink_out_dir/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,4 @@ fn main() {
2424
symlink("data.txt", "relative_symlink.txt");
2525
symlink("../data.txt", "nested/relative_symlink.txt");
2626
std::env::set_current_dir(&original_cwd).unwrap();
27-
println!("{}", out_dir.display());
2827
}

test/unit/compile_data/compile_data_test.bzl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Unittest to verify compile_data (attribute) propagation"""
22

33
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
4+
load("@bazel_skylib//rules:write_file.bzl", "write_file")
45
load("//rust:defs.bzl", "rust_common", "rust_doc", "rust_library", "rust_test")
56
load(
67
"//test/unit:common.bzl",
@@ -95,10 +96,11 @@ def _define_test_targets():
9596
crate = ":compile_data_env",
9697
)
9798

98-
native.genrule(
99+
write_file(
99100
name = "generated_compile_data",
100-
outs = ["generated.txt"],
101-
cmd = "echo 'generated compile data contents' > $@",
101+
out = "generated.txt",
102+
content = ["generated compile data contents", ""],
103+
newline = "unix",
102104
)
103105

104106
rust_library(
@@ -113,10 +115,11 @@ def _define_test_targets():
113115
crate = ":compile_data_gen",
114116
)
115117

116-
native.genrule(
118+
write_file(
117119
name = "generated_src",
118-
outs = ["generated.rs"],
119-
cmd = """echo 'pub const GENERATED: &str = "generated";' > $@""",
120+
out = "generated.rs",
121+
content = ["pub const GENERATED: &str = \"generated\";", ""],
122+
newline = "unix",
120123
)
121124

122125
rust_library(

0 commit comments

Comments
 (0)