summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Orion Hodson <oth@google.com> 2021-03-22 17:02:05 +0000
committer Orion Hodson <oth@google.com> 2021-03-23 11:21:19 +0000
commitfcbbdd4f364969afac7fc5862d0899460fba3e33 (patch)
treeac3642c448ccf8998c350fd2be2c8e07d7cbd4e3
parent3b2629b90106b027ed5bcb7a9c1bf98be22b5d10 (diff)
odrefresh: make --compile single pass
Enable single pass use of odrefresh. Using --compile now checks artifacts (performing any necessary cleaning) and compiles them. Bug: 160683548 Test: manual Change-Id: I6293a2d0709e11e475bf20e1b7971e7fbf14b779
-rw-r--r--odrefresh/include/odrefresh/odrefresh.h11
-rw-r--r--odrefresh/odrefresh.cc7
2 files changed, 11 insertions, 7 deletions
diff --git a/odrefresh/include/odrefresh/odrefresh.h b/odrefresh/include/odrefresh/odrefresh.h
index d8917a06c5..1fe23821d8 100644
--- a/odrefresh/include/odrefresh/odrefresh.h
+++ b/odrefresh/include/odrefresh/odrefresh.h
@@ -37,18 +37,21 @@ enum ExitCode : int {
// `kOdrefreshArtifactDirectory`.
kOkay = EX_OK,
- // Compilation required. Re-run program with --compile on the command-line to generate
- // new artifacts under `kOdrefreshArtifactDirectory`.
+ // Compilation required (only returned for --check). Re-run program with --compile on the
+ // command-line to generate + new artifacts under `kOdrefreshArtifactDirectory`.
kCompilationRequired = EX__MAX + 1,
+ // New artifacts successfully generated under `kOdrefreshArtifactDirectory`.
+ kCompilationSuccess = EX__MAX + 2,
+
// Compilation failed. Any artifacts under `kOdrefreshArtifactDirectory` are valid and should not
// be removed. This may happen, for example, if compilation of boot extensions succeeds, but the
// compilation of the system_server jars fails due to lack of storage space.
- kCompilationFailed = EX__MAX + 2,
+ kCompilationFailed = EX__MAX + 3,
// Removal of existing artifacts (or files under `kOdrefreshArtifactDirectory`) failed. Artifacts
// should be treated as invalid and should be removed if possible.
- kCleanupFailed = EX__MAX + 3,
+ kCleanupFailed = EX__MAX + 4,
// Last exit code defined.
kLastExitCode = kCleanupFailed,
diff --git a/odrefresh/odrefresh.cc b/odrefresh/odrefresh.cc
index 1f1ef53a21..8368a64f4f 100644
--- a/odrefresh/odrefresh.cc
+++ b/odrefresh/odrefresh.cc
@@ -123,7 +123,7 @@ NO_RETURN static void UsageHelp(const char* argv0) {
UsageError(
"--check Check compilation artifacts are up-to-date based on metadata (fast).");
UsageError("--compile Compile boot class path extensions and system_server jars");
- UsageError(" when necessary).");
+ UsageError(" when necessary.");
UsageError("--force-compile Unconditionally compile the boot class path extensions and");
UsageError(" system_server jars.");
UsageError("--verify Verify artifacts are up-to-date with dexoptanalyzer (slow).");
@@ -1289,7 +1289,7 @@ class OnDeviceRefresh final {
}
}
- return ExitCode::kOkay;
+ return ExitCode::kCompilationSuccess;
}
static bool ArgumentMatches(std::string_view argument,
@@ -1416,7 +1416,8 @@ class OnDeviceRefresh final {
// Fast determination of whether artifacts are up to date.
return odr.CheckArtifactsAreUpToDate();
} else if (action == "--compile") {
- return odr.Compile(/*force_compile=*/false);
+ const ExitCode e = odr.CheckArtifactsAreUpToDate();
+ return (e == ExitCode::kCompilationRequired) ? odr.Compile(/*force_compile=*/false) : e;
} else if (action == "--force-compile") {
return odr.Compile(/*force_compile=*/true);
} else if (action == "--verify") {