OSDN Git Service

Rename vdex-fd to output-vdex-fd, add input-vdex-fd.
authorNicolas Geoffray <ngeoffray@google.com>
Mon, 7 Nov 2016 16:23:11 +0000 (16:23 +0000)
committerNicolas Geoffray <ngeoffray@google.com>
Wed, 9 Nov 2016 09:58:01 +0000 (09:58 +0000)
In preparation for installd changes around vdex.

bug:30937355
Test: device boots, oat_file_assistant_test

Change-Id: I7eba67f278a03d77b3e66fd24a96fbfd442db678

dex2oat/dex2oat.cc
runtime/oat_file_assistant.cc

index 28d6289..4923054 100644 (file)
@@ -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<File> 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<File> vdex_file(new File(vdex_fd_, vdex_location, /* check_usage */ true));
+      std::unique_ptr<File> 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<const char*> oat_filenames_;
   std::vector<const char*> oat_unstripped_;
   int oat_fd_;
-  int vdex_fd_;
+  int input_vdex_fd_;
+  int output_vdex_fd_;
   std::vector<const char*> dex_filenames_;
   std::vector<const char*> dex_locations_;
   int zip_fd_;
index ff00451..0679360 100644 (file)
@@ -595,7 +595,7 @@ OatFileAssistant::GenerateOatFile(std::string* error_msg) {
 
   std::vector<std::string> 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);