-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
process_wrapper: replace C++ implementation with rust.
The main advantages of this work are that it eliminates a bunch of platform-specific C++ code in favor of the Rust standard library (mainly std::process::Command and std::fs::File) and it simplifies future improvements in the area of pipelining and incremental compilation. Building a Rust process_wrapper requires a way to use rust_binary without support from process_wrapper itself. This is achieved through a transition in //util/process_wrapper/transitions.bzl.
- Loading branch information
Showing
12 changed files
with
746 additions
and
988 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,46 @@ | ||
load("@rules_cc//cc:defs.bzl", "cc_binary") | ||
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") | ||
load("//rust:defs.bzl", "rust_binary", "rust_test") | ||
load("//util/process_wrapper:transitions.bzl", "without_process_wrapper") | ||
|
||
cc_binary( | ||
alias( | ||
name = "process_wrapper", | ||
srcs = [ | ||
"process_wrapper.cc", | ||
"system.h", | ||
"utils.h", | ||
"utils.cc", | ||
] + select({ | ||
"@bazel_tools//src/conditions:host_windows": [ | ||
"system_windows.cc", | ||
], | ||
"//conditions:default": [ | ||
"system_posix.cc", | ||
], | ||
}), | ||
defines = [] + select({ | ||
"@bazel_tools//src/conditions:host_windows": [ | ||
"UNICODE", | ||
"_UNICODE", | ||
], | ||
"//conditions:default": [], | ||
actual = select({ | ||
# This will never get used, it's only here to break the circular dependency to allow building process_wrapper | ||
":no_process_wrapper": ":process_wrapper_fake", | ||
"//conditions:default": ":process_wrapper_impl", | ||
}), | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
config_setting( | ||
name = "no_process_wrapper", | ||
flag_values = { | ||
":use_process_wrapper": "False", | ||
}, | ||
) | ||
|
||
# A flag that enables/disables the use of process_wrapper when invoking rustc. | ||
# This is useful for building process_wrapper itself without causing dependency cycles. | ||
bool_flag( | ||
name = "use_process_wrapper", | ||
build_setting_default = True, | ||
) | ||
|
||
# Changing the name of this rule requires a corresponding | ||
# change in //rust/private/rustc.bzl:925 | ||
without_process_wrapper( | ||
name = "process_wrapper_impl", | ||
target = ":process_wrapper_bin", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
rust_binary( | ||
name = "process_wrapper_bin", | ||
srcs = glob(["*.rs"]), | ||
) | ||
|
||
rust_test( | ||
name = "process_wrapper_test", | ||
srcs = glob(["*.rs"]), | ||
crate = "process_wrapper_bin", | ||
) |
Oops, something went wrong.