--- build/rust/gni_impl/crubit_shared_args.gni.orig 2026-11-17 11:49:09 UTC +++ build/rust/gni_impl/crubit_shared_args.gni @@ -5,24 +5,36 @@ # This `.gni` file defines constants that are shared / reused across # `cpp_api_from_rust.gni` and `rust_api_from_cpp.gni`. +import("//build/config/rust.gni") + crubit_support_path_format = "\"third_party/crubit/support/{header}\"" rustfmt_config_path = "//.rustfmt.toml" -_toolchain_bin_path = "//third_party/rust-toolchain/bin" -cpp_api_from_rust_exe_path = "${_toolchain_bin_path}/cc_bindings_from_rs" -rust_api_from_cpp_exe_path = "${_toolchain_bin_path}/rs_bindings_from_cc" -rustfmt_exe_path = "${_toolchain_bin_path}/rustfmt" +_crubit_bin_path = "${rust_crubit_root}/bin" +cpp_api_from_rust_exe_path = "${_crubit_bin_path}/cc_bindings_from_rs" +rust_api_from_cpp_exe_path = "${_crubit_bin_path}/rs_bindings_from_cc" if (host_os == "win") { cpp_api_from_rust_exe_path += ".exe" rust_api_from_cpp_exe_path += ".exe" - rustfmt_exe_path += ".exe" } -# TODO(lukasza): Make this also work on other host platforms. (Possibly -# hoisting this Crubit-agnostic functionality into some other, reusable -# location elsewhere.) -if (host_os == "linux") { - clang_format_exe_path = "//buildtools/linux64-format/clang-format" -} else if (host_os == "win") { - clang_format_exe_path = "//buildtools/win-format/clang-format.exe" +# Code generated by Crubit is only formatted when using Crubit from +# //third_party/rust-toolchain. Formatting only makes the generated code easier +# to read, and the formatting tools may not be available when using a +# system-provided Crubit. Therefore `rustfmt_exe_path` and +# `clang_format_exe_path` may be undefined. +if (rust_crubit_root == "//third_party/rust-toolchain") { + rustfmt_exe_path = "//third_party/rust-toolchain/bin/rustfmt" + if (host_os == "win") { + rustfmt_exe_path += ".exe" + } + + # TODO(lukasza): Make this also work on other host platforms. (Possibly + # hoisting this Crubit-agnostic functionality into some other, reusable + # location elsewhere.) + if (host_os == "linux") { + clang_format_exe_path = "//buildtools/linux64-format/clang-format" + } else if (host_os == "win") { + clang_format_exe_path = "//buildtools/win-format/clang-format.exe" + } }