Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flags to prosecc_executor that say where to materialize output and what is output #7201

Merged
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
49 changes: 45 additions & 4 deletions src/rust/engine/process_executor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,29 @@ fn main() {
.last(true)
.required(true),
)
.arg(
Arg::with_name("output-file-path")
.long("output-file-path")
.takes_value(true)
.multiple(true)
.required(false)
.help("Path to file that is considered to be output."),
)
.arg(
Arg::with_name("output-directory-path")
.long("output-directory-path")
.takes_value(true)
.multiple(true)
.required(false)
.help("Path to directory that is considered to be output."),
)
.arg(
Arg::with_name("materialize-output-to")
.long("materialize-output-to")
.takes_value(true)
.required(false)
.help("The name of a directory (which may or may not exist), where the output tree will be materialized.")
)
.get_matches();

let argv: Vec<String> = args
Expand Down Expand Up @@ -187,6 +210,16 @@ fn main() {
let timer_thread = resettable::Resettable::new(|| futures_timer::HelperThread::new().unwrap());
let server_arg = args.value_of("server");
let remote_instance_arg = args.value_of("remote-instance-name").map(str::to_owned);
let output_files = if let Some(values) = args.values_of("output-file-path") {
values.map(PathBuf::from).collect()
} else {
BTreeSet::new()
};
let output_directories = if let Some(values) = args.values_of("output-directory-path") {
values.map(PathBuf::from).collect()
} else {
BTreeSet::new()
};

let store = match (server_arg, args.value_of("cas-server")) {
(Some(_server), Some(cas_server)) => {
Expand Down Expand Up @@ -241,8 +274,8 @@ fn main() {
argv,
env,
input_files,
output_files: BTreeSet::new(),
output_directories: BTreeSet::new(),
output_files,
output_directories,
timeout: Duration::new(15 * 60, 0),
description: "process_executor".to_string(),
jdk_home: args.value_of("jdk").map(PathBuf::from),
Expand All @@ -263,19 +296,27 @@ fn main() {
args.value_of("cache-key-gen-version").map(str::to_owned),
remote_instance_arg,
oauth_bearer_token,
store,
store.clone(),
timer_thread,
)
.expect("Could not initialize remote execution client"),
) as Box<dyn process_execution::CommandRunner>
}
None => Box::new(process_execution::local::CommandRunner::new(
store, pool, work_dir, true,
store.clone(),
pool,
work_dir,
true,
)) as Box<dyn process_execution::CommandRunner>,
};
let mut rt = tokio::runtime::Runtime::new().unwrap();
let result = rt.block_on(runner.run(request)).unwrap();

if let Some(output) = args.value_of("materialize-output-to").map(PathBuf::from) {
rt.block_on(store.materialize_directory(output, result.output_directory))
.unwrap();
};

print!("{}", String::from_utf8(result.stdout.to_vec()).unwrap());
eprint!("{}", String::from_utf8(result.stderr.to_vec()).unwrap());

Expand Down