Alan Stokes | b2cc79e | 2021-09-14 14:08:46 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 19 | use android_system_composd::{ |
| 20 | aidl::android::system::composd::IIsolatedCompilationService::IIsolatedCompilationService, |
| 21 | binder::{wait_for_interface, ProcessState}, |
| 22 | }; |
| 23 | use anyhow::{Context, Result}; |
| 24 | |
| 25 | fn main() -> Result<()> { |
Alan Stokes | 388b88a | 2021-10-13 16:03:17 +0100 | [diff] [blame^] | 26 | 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 Stokes | b2cc79e | 2021-09-14 14:08:46 +0100 | [diff] [blame] | 36 | 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 Stokes | 388b88a | 2021-10-13 16:03:17 +0100 | [diff] [blame^] | 41 | match command { |
| 42 | "forced-compile-test" => service.runForcedCompileForTest().context("Compilation failed")?, |
| 43 | _ => panic!("Unexpected command {}", command), |
| 44 | } |
Alan Stokes | b2cc79e | 2021-09-14 14:08:46 +0100 | [diff] [blame] | 45 | |
| 46 | println!("All Ok!"); |
| 47 | |
| 48 | Ok(()) |
| 49 | } |