blob: 7838b69042a93d292b67214cd7627fc0e5fc6d51 [file] [log] [blame]
Alan Stokes46a1dff2021-12-14 10:56:05 +00001/*
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//! Helpers for running odrefresh
18
19use num_derive::FromPrimitive;
20use num_traits::FromPrimitive;
21
22/// The path to the odrefresh binary
23pub const ODREFRESH_PATH: &str = "/apex/com.android.art/bin/odrefresh";
24
25// TODO: What if this changes?
26const EX_MAX: i8 = 78;
27
28/// The defined odrefresh exit codes - see art/odrefresh/include/odrefresh/odrefresh.h
29#[derive(Debug, PartialEq, Eq, FromPrimitive)]
30#[repr(i8)]
31pub enum ExitCode {
32 /// No compilation required, all artifacts look good
33 Okay = 0i8,
34 /// Compilation required
35 CompilationRequired = EX_MAX + 1,
36 /// New artifacts successfully generated
37 CompilationSuccess = EX_MAX + 2,
38 /// Compilation failed
39 CompilationFailed = EX_MAX + 3,
40 /// Removal of existing invalid artifacts failed
41 CleanupFailed = EX_MAX + 4,
42}
43
44impl ExitCode {
45 /// Map an integer to the corresponding ExitCode enum, if there is one
46 pub fn from_i32(exit_code: i32) -> Option<Self> {
47 FromPrimitive::from_i32(exit_code)
48 }
49}