diff options
| -rw-r--r-- | odrefresh/odrefresh_main.cc | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/odrefresh/odrefresh_main.cc b/odrefresh/odrefresh_main.cc index 0798adea47..a70e2fb451 100644 --- a/odrefresh/odrefresh_main.cc +++ b/odrefresh/odrefresh_main.cc @@ -182,6 +182,7 @@ int InitializeHostConfig(int argc, char** argv, OdrConfig* config) { config->SetZygoteKind(zygote_kind); } else if (!InitializeCommonConfig(arg, config)) { UsageError("Unrecognized argument: '%s'", arg); + exit(EX_USAGE); } } return n; @@ -322,48 +323,48 @@ int main(int argc, char** argv) { argc -= n; if (argc != 1) { UsageError("Expected 1 argument, but have %d.", argc); + exit(EX_USAGE); } OdrMetrics metrics(config.GetArtifactDirectory()); OnDeviceRefresh odr(config); - for (int i = 0; i < argc; ++i) { - std::string_view action(argv[i]); - CompilationOptions compilation_options; - if (action == "--check") { - // Fast determination of whether artifacts are up to date. - return odr.CheckArtifactsAreUpToDate(metrics, &compilation_options); - } else if (action == "--compile") { - const ExitCode exit_code = odr.CheckArtifactsAreUpToDate(metrics, &compilation_options); - if (exit_code != ExitCode::kCompilationRequired) { - return exit_code; - } - OdrCompilationLog compilation_log; - if (!compilation_log.ShouldAttemptCompile(metrics.GetTrigger())) { - LOG(INFO) << "Compilation skipped because it was attempted recently"; - return ExitCode::kOkay; - } - ExitCode compile_result = odr.Compile(metrics, compilation_options); - compilation_log.Log(metrics.GetArtApexVersion(), - metrics.GetArtApexLastUpdateMillis(), - metrics.GetTrigger(), - compile_result); - return compile_result; - } else if (action == "--force-compile") { - // Clean-up existing files. - if (!odr.RemoveArtifactsDirectory()) { - metrics.SetStatus(OdrMetrics::Status::kIoError); - return ExitCode::kCleanupFailed; - } - return odr.Compile(metrics, - CompilationOptions{ - .compile_boot_extensions_for_isas = config.GetBootExtensionIsas(), - .system_server_jars_to_compile = odr.AllSystemServerJars(), - }); - } else if (action == "--help") { - UsageHelp(argv[0]); - } else { - UsageError("Unknown argument: ", argv[i]); + + std::string_view action(argv[0]); + CompilationOptions compilation_options; + if (action == "--check") { + // Fast determination of whether artifacts are up to date. + return odr.CheckArtifactsAreUpToDate(metrics, &compilation_options); + } else if (action == "--compile") { + const ExitCode exit_code = odr.CheckArtifactsAreUpToDate(metrics, &compilation_options); + if (exit_code != ExitCode::kCompilationRequired) { + return exit_code; } + OdrCompilationLog compilation_log; + if (!compilation_log.ShouldAttemptCompile(metrics.GetTrigger())) { + LOG(INFO) << "Compilation skipped because it was attempted recently"; + return ExitCode::kOkay; + } + ExitCode compile_result = odr.Compile(metrics, compilation_options); + compilation_log.Log(metrics.GetArtApexVersion(), + metrics.GetArtApexLastUpdateMillis(), + metrics.GetTrigger(), + compile_result); + return compile_result; + } else if (action == "--force-compile") { + // Clean-up existing files. + if (!odr.RemoveArtifactsDirectory()) { + metrics.SetStatus(OdrMetrics::Status::kIoError); + return ExitCode::kCleanupFailed; + } + return odr.Compile(metrics, + CompilationOptions{ + .compile_boot_extensions_for_isas = config.GetBootExtensionIsas(), + .system_server_jars_to_compile = odr.AllSystemServerJars(), + }); + } else if (action == "--help") { + UsageHelp(argv[0]); + } else { + UsageError("Unknown argument: ", action); + exit(EX_USAGE); } - return ExitCode::kOkay; } |