Skip to content
Closed
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: 0 additions & 1 deletion .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ tasks:
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- "..."
- "-//bindgen/..."
- "-//test/test_env/..."
- "-//test/proto/..."
- "-//tools/rust_analyzer/..."
- "-//test/rustfmt/..."
Expand Down
6 changes: 5 additions & 1 deletion rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,11 @@ def construct_arguments(
if rust_common.crate_info in data:
dep_crate_info = data[rust_common.crate_info]
if dep_crate_info.type == "bin":
env["CARGO_BIN_EXE_" + dep_crate_info.output.basename] = dep_crate_info.output.short_path
# Trying to make CARGO_BIN_EXE_{} canonical across platform by strip out extension if exists
env_basename = dep_crate_info.output.basename
if len(dep_crate_info.output.extension) > 0:
env_basename = env_basename[:-(1 + len(dep_crate_info.output.extension))]
env["CARGO_BIN_EXE_" + env_basename] = dep_crate_info.output.short_path

# Update environment with user provided variables.
env.update(expand_dict_value_locations(
Expand Down
12 changes: 8 additions & 4 deletions test/test_env/tests/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ fn run() {
// Test the behavior of `rootpath` and that a binary can be found relative to current_dir
let hello_world_bin =
std::path::PathBuf::from(std::env::var_os("HELLO_WORLD_BIN_ROOTPATH").unwrap());
assert_eq!(
hello_world_bin.as_path(),
std::path::Path::new("test/test_env/hello-world"),
);

let expected_hello_world_bin = if cfg!(windows) {
std::path::Path::new("test/test_env/hello-world.exe")
} else {
std::path::Path::new("test/test_env/hello-world")
};

assert_eq!(hello_world_bin.as_path(), expected_hello_world_bin);
assert!(!hello_world_bin.is_absolute());
assert!(hello_world_bin.exists());

Expand Down