From 33e4210b3631a99d40a6fbd022c7db217fa60a25 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Sun, 18 Jul 2021 16:37:20 -0700 Subject: [PATCH 1/3] fix(test_env): export canonical CARGO_BIN_EXE env variable --- rust/private/rustc.bzl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index ef94a119f4..539a00a5c1 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -505,7 +505,9 @@ 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[:-(1 + len(dep_crate_info.output.extension))] if len(dep_crate_info.output.extension) > 0 else dep_crate_info.output.basename + env["CARGO_BIN_EXE_" + env_basename] = dep_crate_info.output.short_path # Update environment with user provided variables. env.update(expand_dict_value_locations( From 42fa35fbe7ec6205ab02624e7769c0ee6172befd Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Sun, 18 Jul 2021 16:37:44 -0700 Subject: [PATCH 2/3] test(test_env): update test cases --- .bazelci/presubmit.yml | 1 - test/test_env/tests/run.rs | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 856f2f0cbe..90428ca37f 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -12,7 +12,6 @@ default_windows_targets: &default_windows_targets - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245 - "//..." - "-//bindgen/..." - - "-//test/test_env/..." - "-//test/proto/..." - "-//tools/rust_analyzer/..." - "-//test/rustfmt/..." diff --git a/test/test_env/tests/run.rs b/test/test_env/tests/run.rs index 1abaa7ab09..0ee58ecf92 100644 --- a/test/test_env/tests/run.rs +++ b/test/test_env/tests/run.rs @@ -15,9 +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"), + std::path::Path::new(if std::env::consts::OS == "windows" { + "test/test_env/hello-world.exe" + } else { + "test/test_env/hello-world" + }) ); assert!(!hello_world_bin.is_absolute()); assert!(hello_world_bin.exists()); From 51efd000b20fcf2fc29f537f3f98cdbd21b713d5 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Sun, 18 Jul 2021 16:38:10 -0700 Subject: [PATCH 3/3] build(bazelrc): enable symlink for windows platform --- .bazelrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.bazelrc b/.bazelrc index c54ffa8be3..5b3cd4157e 100644 --- a/.bazelrc +++ b/.bazelrc @@ -8,3 +8,6 @@ build:rustfmt --output_groups=+rustfmt_checks # Enable clippy for all targets in the workspace build:clippy --aspects=//rust:defs.bzl%rust_clippy_aspect build:clippy --output_groups=+clippy_checks + +# https://bazel.googlesource.com/bazel/+/master/site/docs/windows.md#enable-symlink-support +startup --windows_enable_symlinks \ No newline at end of file