Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ examples/sys/complex/3rdparty/crates/** linguist-generated
extensions/bindgen/3rdparty/crates/** linguist-generated
extensions/prost/private/3rdparty/crates/** linguist-generated
extensions/wasm_bindgen/3rdparty/crates/** linguist-generated
test/unpretty/*.unpretty.expanded.rs text eol=lf
tools/rust_analyzer/3rdparty/crates/** linguist-generated
util/import/3rdparty/crates/** linguist-generated
15 changes: 14 additions & 1 deletion .github/workflows/bazel_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
if: runner.os == 'Windows'
shell: pwsh
run: |
'startup --output_user_root=C:/tmp/bazel' | Out-File -FilePath user.bazelrc -Encoding utf8
'startup --output_base=C:/b' | Out-File -FilePath user.bazelrc -Encoding utf8
'startup --windows_enable_symlinks' | Out-File -FilePath user.bazelrc -Append -Encoding utf8

- name: bazel test //...
Expand All @@ -71,9 +71,22 @@ jobs:
echo "BUILDBUDDY_API_KEY is not set; using BuildBuddy remote cache without an auth header."
fi

PLATFORM_ARGS=()
if [[ "${RUNNER_OS}" == "macOS" ]]; then
case "${RUNNER_ARCH}" in
ARM64) MACOS_PLATFORM="@llvm//platforms:macos_aarch64" ;;
X64) MACOS_PLATFORM="@llvm//platforms:macos_x86_64" ;;
*) echo "Unsupported macOS runner architecture: ${RUNNER_ARCH}"; exit 1 ;;
esac
PLATFORM_ARGS+=("--extra_toolchains=@llvm//toolchain:all")
PLATFORM_ARGS+=("--platforms=${MACOS_PLATFORM}")
PLATFORM_ARGS+=("--@rules_cc//cc/toolchains/args/archiver_flags:use_libtool_on_macos=False")
fi

bazel \
--bazelrc="$GITHUB_WORKSPACE/.github/github.bazelrc" \
test \
--config=remote \
"${REMOTE_ARGS[@]}" \
"${PLATFORM_ARGS[@]}" \
//...
5 changes: 3 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ register_toolchains(

rules_rs_toolchains = use_extension("@rules_rs//rs/toolchains:module_extension.bzl", "toolchains", dev_dependency = True)
rules_rs_toolchains.toolchain(name = "default_rust_toolchains")
use_repo(rules_rs_toolchains, "default_rust_toolchains")
rules_rs_toolchains.toolchain(name = "r")
use_repo(rules_rs_toolchains, "default_rust_toolchains", "r")

register_toolchains(
"@default_rust_toolchains//:all",
"@r//:all",
dev_dependency = True,
)

Expand Down
20 changes: 11 additions & 9 deletions cargo/private/cargo_build_script_runner/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,32 +92,34 @@ impl BuildScriptOutput {
}

fn contains_absolute_path(value: &str) -> bool {
let path_is_absolute = |candidate: &str| {
let path_is_rooted = |candidate: &str| {
let candidate = candidate.trim_matches(|character: char| {
character.is_ascii_whitespace()
|| matches!(character, '\'' | '"' | ',' | '(' | ')' | '[' | ']')
});
Path::new(candidate).is_absolute()
Path::new(candidate).has_root()
};

if path_is_absolute(value) {
if path_is_rooted(value) {
return true;
}

value
.split(|character: char| character.is_ascii_whitespace() || character == ';')
.any(|token| {
if path_is_absolute(token) {
if path_is_rooted(token) {
return true;
}
if token.contains("://") {
return false;
}
token.find(std::path::MAIN_SEPARATOR).is_some_and(|index| {
let prefix = &token[..index];
(prefix.starts_with('-') || prefix.ends_with('='))
&& path_is_absolute(&token[index..])
})
token
.find(|character| matches!(character, '/' | '\\'))
.is_some_and(|index| {
let prefix = &token[..index];
(prefix.starts_with('-') || prefix.ends_with('='))
&& path_is_rooted(&token[index..])
})
})
}

Expand Down
3 changes: 3 additions & 0 deletions test/determinism/3rdparty/crates/BUILD.serde-1.0.228.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ cargo_build_script(
include = ["**/*.rs"],
allow_empty = True,
),
build_script_env = {
"CARGO_PKG_VERSION_PATCH": "228",
},
compile_data = glob(
include = ["**"],
allow_empty = True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ cargo_build_script(
include = ["**/*.rs"],
allow_empty = True,
),
build_script_env = {
"CARGO_PKG_VERSION_PATCH": "228",
},
compile_data = glob(
include = ["**"],
allow_empty = True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ rust_proc_macro(
],
crate_root = "src/lib.rs",
edition = "2021",
rustc_env = {
"CARGO_PKG_VERSION_PATCH": "228",
},
rustc_flags = [
"--cap-lints=allow",
],
Expand Down
3 changes: 3 additions & 0 deletions test/rust_analyzer/3rdparty/crates/BUILD.serde-1.0.228.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ cargo_build_script(
include = ["**/*.rs"],
allow_empty = True,
),
build_script_env = {
"CARGO_PKG_VERSION_PATCH": "228",
},
compile_data = glob(
include = ["**"],
allow_empty = True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ cargo_build_script(
include = ["**/*.rs"],
allow_empty = True,
),
build_script_env = {
"CARGO_PKG_VERSION_PATCH": "228",
},
compile_data = glob(
include = ["**"],
allow_empty = True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ rust_proc_macro(
],
crate_root = "src/lib.rs",
edition = "2021",
rustc_env = {
"CARGO_PKG_VERSION_PATCH": "228",
},
rustc_flags = [
"--cap-lints=allow",
],
Expand Down
11 changes: 11 additions & 0 deletions test/unit/lto/lto_test_suite.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -373,18 +373,21 @@ def lto_test_suite(name):
name = "lib",
srcs = [":lib.rs"],
edition = "2021",
tags = ["manual"],
)

rust_proc_macro(
name = "proc_macro",
srcs = [":lib.rs"],
edition = "2021",
tags = ["manual"],
)

rust_library(
name = "distributed_lib",
srcs = [":lib.rs"],
edition = "2021",
tags = ["manual"],
)

rust_library(
Expand All @@ -393,6 +396,7 @@ def lto_test_suite(name):
crate_name = "distributed_lib",
edition = "2021",
features = ["thin_lto"],
tags = ["manual"],
)

rust_library(
Expand All @@ -401,25 +405,29 @@ def lto_test_suite(name):
crate_name = "distributed_lib",
edition = "2021",
features = ["-thin_lto"],
tags = ["manual"],
)

rust_library_group(
name = "distributed_lib_group",
deps = [":distributed_lib"],
tags = ["manual"],
)

rust_binary(
name = "distributed_bin",
srcs = [":main.rs"],
deps = [":distributed_lib_group"],
edition = "2021",
tags = ["manual"],
)

rust_binary(
name = "distributed_global_allocator_bin",
srcs = [":global_allocator_bin"],
deps = [":distributed_lib_group"],
edition = "2021",
tags = ["manual"],
)

rust_binary(
Expand All @@ -428,18 +436,21 @@ def lto_test_suite(name):
deps = [":distributed_lib_disabled_feature"],
edition = "2021",
features = ["-thin_lto"],
tags = ["manual"],
)

cc_binary(
name = "distributed_cc_bin",
srcs = [":main.cc"],
deps = [":distributed_lib_rule_feature"],
features = ["thin_lto"],
tags = ["manual"],
)

_with_exec_cfg(
name = "distributed_bin_exec",
target = ":distributed_bin",
tags = ["manual"],
)

_lto_level_default_test(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def _pipelined_compilation_test():
edition = "2021",
srcs = ["bin.rs"],
deps = [":second"],
tags = ["manual"],
)

second_lib_test(
Expand Down
20 changes: 19 additions & 1 deletion test/unit/remap_path_prefix/debug_transition.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,26 @@ def _dbg_rust_binary_impl(ctx):
is_executable = True,
)

pdb_files = []
dsym_folders = []
if OutputGroupInfo in binary:
for pdb_file in getattr(binary[OutputGroupInfo], "pdb_file", depset()).to_list():
new_pdb = ctx.actions.declare_file(paths.join(ctx.label.name, pdb_file.basename))
ctx.actions.symlink(
output = new_pdb,
target_file = pdb_file,
)
pdb_files.append(new_pdb)
for dsym_folder in getattr(binary[OutputGroupInfo], "dsym_folder", depset()).to_list():
new_dsym_folder = ctx.actions.declare_directory(paths.join(ctx.label.name, dsym_folder.basename))
ctx.actions.symlink(
output = new_dsym_folder,
target_file = dsym_folder,
)
dsym_folders.append(new_dsym_folder)

files = depset(direct = [new_executable])
runfiles = ctx.runfiles([new_executable])
runfiles = ctx.runfiles([new_executable] + pdb_files + dsym_folders)

result.append(
DefaultInfo(
Expand Down
8 changes: 6 additions & 2 deletions test/unit/remap_path_prefix/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ fn test_backtrace() {
let mut check_next = false;
for line in stderr.split('\n') {
if check_next {
if !line.contains("test/unit/remap_path_prefix/panic_bin.rs:6:5") {
panic!("Expected line to contain test/unit/remap_path_prefix/panic_bin.rs:6:5 but was {}", line);
let normalized_line = line.replace('\\', "/");
if !normalized_line.contains("test/unit/remap_path_prefix/panic_bin.rs:6") {
panic!(
"Expected line to contain test/unit/remap_path_prefix/panic_bin.rs:6 but was {}",
line
);
}
return;
}
Expand Down
3 changes: 3 additions & 0 deletions test/vscode/3rdparty/crates/BUILD.serde-1.0.228.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ cargo_build_script(
include = ["**/*.rs"],
allow_empty = True,
),
build_script_env = {
"CARGO_PKG_VERSION_PATCH": "228",
},
compile_data = glob(
include = ["**"],
allow_empty = True,
Expand Down
3 changes: 3 additions & 0 deletions test/vscode/3rdparty/crates/BUILD.serde_core-1.0.228.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ cargo_build_script(
include = ["**/*.rs"],
allow_empty = True,
),
build_script_env = {
"CARGO_PKG_VERSION_PATCH": "228",
},
compile_data = glob(
include = ["**"],
allow_empty = True,
Expand Down
3 changes: 3 additions & 0 deletions test/vscode/3rdparty/crates/BUILD.serde_derive-1.0.228.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ rust_proc_macro(
],
crate_root = "src/lib.rs",
edition = "2021",
rustc_env = {
"CARGO_PKG_VERSION_PATCH": "228",
},
rustc_flags = [
"--cap-lints=allow",
],
Expand Down
5 changes: 3 additions & 2 deletions test/vscode/vscode_test_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ register_toolchains("@rust_toolchains//:all")

rules_rs_toolchains = use_extension("@rules_rs//rs/toolchains:module_extension.bzl", "toolchains", dev_dependency = True)
rules_rs_toolchains.toolchain(name = "default_rust_toolchains")
use_repo(rules_rs_toolchains, "default_rust_toolchains")
rules_rs_toolchains.toolchain(name = "r")
use_repo(rules_rs_toolchains, "default_rust_toolchains", "r")
register_toolchains(
"@default_rust_toolchains//:all",
"@r//:all",
dev_dependency = True,
)

Expand Down
Loading