From bc654d0cbb4f45057f9482ad81cb613386bbce34 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Mon, 7 Nov 2016 16:23:11 +0000 Subject: [PATCH] Rename vdex-fd to output-vdex-fd, add input-vdex-fd. In preparation for installd changes around vdex. bug:30937355 Test: device boots, oat_file_assistant_test Change-Id: I7eba67f278a03d77b3e66fd24a96fbfd442db678 --- dex2oat/dex2oat.cc | 34 +++++++++++++++++++++------------- runtime/oat_file_assistant.cc | 2 +- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index 28d628920..492305425 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -517,7 +517,8 @@ class Dex2Oat FINAL { thread_count_(sysconf(_SC_NPROCESSORS_CONF)), start_ns_(NanoTime()), oat_fd_(-1), - vdex_fd_(-1), + input_vdex_fd_(-1), + output_vdex_fd_(-1), zip_fd_(-1), image_base_(0U), image_classes_zip_filename_(nullptr), @@ -590,8 +591,12 @@ class Dex2Oat FINAL { ParseUintOption(option, "--zip-fd", &zip_fd_, Usage); } - void ParseVdexFd(const StringPiece& option) { - ParseUintOption(option, "--vdex-fd", &vdex_fd_, Usage); + void ParseInputVdexFd(const StringPiece& option) { + ParseUintOption(option, "--input-vdex-fd", &input_vdex_fd_, Usage); + } + + void ParseOutputVdexFd(const StringPiece& option) { + ParseUintOption(option, "--output-vdex-fd", &output_vdex_fd_, Usage); } void ParseOatFd(const StringPiece& option) { @@ -707,9 +712,9 @@ class Dex2Oat FINAL { Usage("--oat-file should not be used with --oat-fd"); } - if ((vdex_fd_ == -1) != (oat_fd_ == -1)) { + if ((output_vdex_fd_ == -1) != (oat_fd_ == -1)) { Usage("VDEX and OAT output must be specified either with one --oat-filename " - "or with --oat-fd and --vdex-fd file descriptors"); + "or with --oat-fd and --output-vdex-fd file descriptors"); } if (!parser_options->oat_symbols.empty() && oat_fd_ != -1) { @@ -720,8 +725,8 @@ class Dex2Oat FINAL { Usage("--oat-symbols should not be used with --host"); } - if (vdex_fd_ != -1 && !image_filenames_.empty()) { - Usage("--vdex-fd should not be used with --image"); + if (output_vdex_fd_ != -1 && !image_filenames_.empty()) { + Usage("--output-vdex-fd should not be used with --image"); } if (oat_fd_ != -1 && !image_filenames_.empty()) { @@ -1114,8 +1119,10 @@ class Dex2Oat FINAL { ParseZipFd(option); } else if (option.starts_with("--zip-location=")) { zip_location_ = option.substr(strlen("--zip-location=")).data(); - } else if (option.starts_with("--vdex-fd=")) { - ParseVdexFd(option); + } else if (option.starts_with("--input-vdex-fd=")) { + ParseInputVdexFd(option); + } else if (option.starts_with("--output-vdex-fd=")) { + ParseOutputVdexFd(option); } else if (option.starts_with("--oat-file=")) { oat_filenames_.push_back(option.substr(strlen("--oat-file=")).data()); } else if (option.starts_with("--oat-symbols=")) { @@ -1258,7 +1265,7 @@ class Dex2Oat FINAL { } oat_files_.push_back(std::move(oat_file)); - DCHECK_EQ(vdex_fd_, -1); + DCHECK_EQ(output_vdex_fd_, -1); std::string vdex_filename = ReplaceFileExtension(oat_filename, "vdex"); std::unique_ptr vdex_file(OS::CreateEmptyFile(vdex_filename.c_str())); if (vdex_file.get() == nullptr) { @@ -1284,9 +1291,9 @@ class Dex2Oat FINAL { } oat_files_.push_back(std::move(oat_file)); - DCHECK_NE(vdex_fd_, -1); + DCHECK_NE(output_vdex_fd_, -1); std::string vdex_location = ReplaceFileExtension(oat_location_, "vdex"); - std::unique_ptr vdex_file(new File(vdex_fd_, vdex_location, /* check_usage */ true)); + std::unique_ptr vdex_file(new File(output_vdex_fd_, vdex_location, /* check_usage */ true)); if (vdex_file.get() == nullptr) { PLOG(ERROR) << "Failed to create vdex file: " << vdex_location; return false; @@ -2582,7 +2589,8 @@ class Dex2Oat FINAL { std::vector oat_filenames_; std::vector oat_unstripped_; int oat_fd_; - int vdex_fd_; + int input_vdex_fd_; + int output_vdex_fd_; std::vector dex_filenames_; std::vector dex_locations_; int zip_fd_; diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc index ff0045134..0679360a1 100644 --- a/runtime/oat_file_assistant.cc +++ b/runtime/oat_file_assistant.cc @@ -595,7 +595,7 @@ OatFileAssistant::GenerateOatFile(std::string* error_msg) { std::vector args; args.push_back("--dex-file=" + dex_location_); - args.push_back("--vdex-fd=" + std::to_string(vdex_file->Fd())); + args.push_back("--output-vdex-fd=" + std::to_string(vdex_file->Fd())); args.push_back("--oat-fd=" + std::to_string(oat_file->Fd())); args.push_back("--oat-location=" + oat_file_name); -- 2.11.0