Support custom path to the `rustfmt` executable.
This CL avoids hardcoding ".../bin/rustfmt" path in the rustfmt function
in token_stream_printer.rs. This is replaced with an argument of a new
cmdline parameter: --rustfmt_exe_path.
PiperOrigin-RevId: 451159464
diff --git a/rs_bindings_from_cc/test/rs_bindings_from_cc_test.sh b/rs_bindings_from_cc/test/rs_bindings_from_cc_test.sh
index a725993..5872ade 100755
--- a/rs_bindings_from_cc/test/rs_bindings_from_cc_test.sh
+++ b/rs_bindings_from_cc/test/rs_bindings_from_cc_test.sh
@@ -7,8 +7,8 @@
source gbash.sh || exit
source module gbash_unit.sh
-# Find input files
readonly RS_BINDINGS_FROM_CC="${RUNFILES}/rs_bindings_from_cc/rs_bindings_from_cc"
+readonly DEFAULT_RUSTFMT_EXE_PATH="third_party/unsupported_toolchains/rust/toolchains/nightly/bin/rustfmt"
function quote_escape() {
sed 's/"/\\"/g'
@@ -39,6 +39,15 @@
--rs_out=\"${rs_out}\" \
--cc_out=\"${cc_out}\" 2>&1 \
--crubit_support_path=test/crubit/support/path | \
+ grep 'please specify --rustfmt_exe_path' > /dev/null" \
+ "generator should show help message for --rustfmt_exe_path"
+
+ EXPECT_SUCCEED \
+ "\"${RS_BINDINGS_FROM_CC}\" \
+ --rs_out=\"${rs_out}\" \
+ --cc_out=\"${cc_out}\" 2>&1 \
+ --crubit_support_path=test/crubit/support/path \
+ --rustfmt_exe_path=\"${DEFAULT_RUSTFMT_EXE_PATH}\" | \
grep 'please specify --public_headers' > /dev/null" \
"generator should show help message for --public_headers"
@@ -50,6 +59,7 @@
--rs_out=\"${rs_out}\" \
--cc_out=\"${cc_out}\" \
--crubit_support_path=test/crubit/support/path \
+ --rustfmt_exe_path=\"${DEFAULT_RUSTFMT_EXE_PATH}\" \
--public_headers=\"${hdr}\" 2>&1 | \
grep 'please specify --targets_and_headers' > /dev/null" \
"generator should show help message for --targets_and_headers"
@@ -65,6 +75,7 @@
--rs_out=\"${rs_out}\" \
--cc_out=\"${cc_out}\" \
--crubit_support_path=test/crubit/support/path \
+ --rustfmt_exe_path=\"${DEFAULT_RUSTFMT_EXE_PATH}\" \
--public_headers=\"${hdr}\" \
--targets_and_headers=\"$(echo "${json}" | quote_escape)\""
@@ -87,6 +98,7 @@
--rs_out=\"${rs_out}\" \
--cc_out=\"${cc_out}\" \
--crubit_support_path=test/crubit/support/path \
+ --rustfmt_exe_path=\"${DEFAULT_RUSTFMT_EXE_PATH}\" \
--public_headers=\"${hdr}\" \
--targets_and_headers=\"$(echo "${json}" | quote_escape)\" \
--do_nothing"
@@ -117,6 +129,7 @@
--rs_out=\"${rs_out}\" \
--cc_out=\"${cc_out}\" \
--crubit_support_path=test/crubit/support/path \
+ --rustfmt_exe_path=\"${DEFAULT_RUSTFMT_EXE_PATH}\" \
--public_headers=\"${hdr}\" \
--targets_and_headers=\"$(echo "${json}" | quote_escape)\" 2>&1"
@@ -145,6 +158,7 @@
--rs_out=\"${rs_out}\" \
--cc_out=\"${cc_out}\" \
--crubit_support_path=test/crubit/support/path \
+ --rustfmt_exe_path=\"${DEFAULT_RUSTFMT_EXE_PATH}\" \
--public_headers=\"${header_1},${header_2}\" \
--targets_and_headers=\"$(echo "${json}" | quote_escape)\" 2>&1"
@@ -172,6 +186,7 @@
--rs_out=\"${rs_out}\" \
--cc_out=\"${cc_out}\" \
--crubit_support_path=test/crubit/support/path \
+ --rustfmt_exe_path=\"${DEFAULT_RUSTFMT_EXE_PATH}\" \
--public_headers=\"${hdr}\" \
--targets_and_headers=\"$(echo "${json}" | quote_escape)\""
@@ -199,6 +214,7 @@
--rs_out=\"${rs_out}\" \
--cc_out=\"${cc_out}\" \
--crubit_support_path=test/crubit/support/path \
+ --rustfmt_exe_path=\"${DEFAULT_RUSTFMT_EXE_PATH}\" \
--rustfmt_config_path=\"${rustfmt_config_path}\" \
--public_headers=\"${hdr}\" \
--targets_and_headers=\"$(echo "${json}" | quote_escape)\""
@@ -236,6 +252,7 @@
--rs_out=\"${rs_out}\" \
--cc_out=\"${cc_out}\" \
--crubit_support_path=test/specific/crubit/support/path \
+ --rustfmt_exe_path=\"${DEFAULT_RUSTFMT_EXE_PATH}\" \
--public_headers=\"${hdr}\" \
--targets_and_headers=\"$(echo "${json}" | quote_escape)\""