blob: 04398c0ae26e47e0bc56538ad51be727143ae741 [file] [log] [blame]
Alan Stokesb2cc79e2021-09-14 14:08:46 +01001/*
2 * Copyright (C) 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//! Simple command-line tool to drive composd for testing and debugging.
18
19use android_system_composd::{
20 aidl::android::system::composd::IIsolatedCompilationService::IIsolatedCompilationService,
21 binder::{wait_for_interface, ProcessState},
22};
23use anyhow::{Context, Result};
24
25fn main() -> Result<()> {
Alan Stokes388b88a2021-10-13 16:03:17 +010026 let app = clap::App::new("composd_cmd").arg(
27 clap::Arg::with_name("command")
28 .index(1)
29 .takes_value(true)
30 .required(true)
31 .possible_values(&["forced-compile-test"]),
32 );
33 let args = app.get_matches();
34 let command = args.value_of("command").unwrap();
35
Alan Stokesb2cc79e2021-09-14 14:08:46 +010036 ProcessState::start_thread_pool();
37
38 let service = wait_for_interface::<dyn IIsolatedCompilationService>("android.system.composd")
39 .context("Failed to connect to composd service")?;
40
Alan Stokes388b88a2021-10-13 16:03:17 +010041 match command {
42 "forced-compile-test" => service.runForcedCompileForTest().context("Compilation failed")?,
43 _ => panic!("Unexpected command {}", command),
44 }
Alan Stokesb2cc79e2021-09-14 14:08:46 +010045
46 println!("All Ok!");
47
48 Ok(())
49}