OSDN Git Service

Add option to specify compiler executable.
authorTsu Chiang Chuang <tsu@google.com>
Thu, 22 May 2014 17:22:25 +0000 (10:22 -0700)
committerBrian Carlstrom <bdc@google.com>
Wed, 28 May 2014 05:55:53 +0000 (22:55 -0700)
Change-Id: I973da5e74be5a62461caacbc708288fb95e1b99b

runtime/class_linker.cc
runtime/gc/space/image_space.cc
runtime/parsed_options.cc
runtime/parsed_options.h
runtime/runtime.cc
runtime/runtime.h

index afff7a2..b9c42ee 100644 (file)
@@ -563,8 +563,7 @@ bool ClassLinker::GenerateOatFile(const char* dex_filename,
                                   const char* oat_cache_filename,
                                   std::string* error_msg) {
   Locks::mutator_lock_->AssertNotHeld(Thread::Current());  // Avoid starving GC.
-  std::string dex2oat(GetAndroidRoot());
-  dex2oat += (kIsDebugBuild ? "/bin/dex2oatd" : "/bin/dex2oat");
+  std::string dex2oat(Runtime::Current()->GetCompilerExecutable());
 
   gc::Heap* heap = Runtime::Current()->GetHeap();
   std::string boot_image_option("--boot-image=");
index 45fee14..3d35c00 100644 (file)
@@ -53,8 +53,7 @@ static bool GenerateImage(const std::string& image_filename, std::string* error_
 
   std::vector<std::string> arg_vector;
 
-  std::string dex2oat(GetAndroidRoot());
-  dex2oat += (kIsDebugBuild ? "/bin/dex2oatd" : "/bin/dex2oat");
+  std::string dex2oat(Runtime::Current()->GetCompilerExecutable());
   arg_vector.push_back(dex2oat);
 
   std::string image_option_string("--image=");
index 3756435..db2a61b 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include "parsed_options.h"
+#include "utils.h"
 #ifdef HAVE_ANDROID_OS
 #include "cutils/properties.h"
 #endif
@@ -604,6 +605,10 @@ bool ParsedOptions::Parse(const Runtime::Options& options, bool ignore_unrecogni
           return false;
         }
       }
+    } else if (StartsWith(option, "-Xcompiler:")) {
+      if (!ParseStringAfterChar(option, ':', &compiler_executable_)) {
+        return false;
+      }
     } else if (option == "-Xcompiler-option") {
       i++;
       if (i == options.size()) {
@@ -791,6 +796,7 @@ void ParsedOptions::Usage(const char* fmt, ...) {
   UsageMessage(stream, "  -Xprofile-duration:integervalue\n");
   UsageMessage(stream, "  -Xprofile-interval:integervalue\n");
   UsageMessage(stream, "  -Xprofile-backoff:doublevalue\n");
+  UsageMessage(stream, "  -Xcompiler:filename\n");
   UsageMessage(stream, "  -Xcompiler-option dex2oat-option\n");
   UsageMessage(stream, "  -Ximage-compiler-option dex2oat-option\n");
   UsageMessage(stream, "\n");
index e0b0fb5..25fc12a 100644 (file)
@@ -74,6 +74,7 @@ class ParsedOptions {
   void (*hook_exit_)(jint status);
   void (*hook_abort_)();
   std::vector<std::string> properties_;
+  std::string compiler_executable_;
   std::vector<std::string> compiler_options_;
   std::vector<std::string> image_compiler_options_;
   bool profile_;
index f76b580..23a49cb 100644 (file)
@@ -370,6 +370,15 @@ jobject CreateSystemClassLoader() {
   return env->NewGlobalRef(system_class_loader.get());
 }
 
+std::string Runtime::GetCompilerExecutable() const {
+  if (!compiler_executable_.empty()) {
+    return compiler_executable_;
+  }
+  std::string compiler_executable(GetAndroidRoot());
+  compiler_executable += (kIsDebugBuild ? "/bin/dex2oatd" : "/bin/dex2oat");
+  return compiler_executable;
+}
+
 bool Runtime::Start() {
   VLOG(startup) << "Runtime::Start entering";
 
@@ -536,6 +545,7 @@ bool Runtime::Init(const Options& raw_options, bool ignore_unrecognized) {
   default_stack_size_ = options->stack_size_;
   stack_trace_file_ = options->stack_trace_file_;
 
+  compiler_executable_ = options->compiler_executable_;
   compiler_options_ = options->compiler_options_;
   image_compiler_options_ = options->image_compiler_options_;
 
index f7074f6..261429e 100644 (file)
@@ -104,6 +104,8 @@ class Runtime {
     return is_explicit_gc_disabled_;
   }
 
+  std::string GetCompilerExecutable() const;
+
   const std::vector<std::string>& GetCompilerOptions() const {
     return compiler_options_;
   }
@@ -482,6 +484,7 @@ class Runtime {
   bool is_concurrent_gc_enabled_;
   bool is_explicit_gc_disabled_;
 
+  std::string compiler_executable_;
   std::vector<std::string> compiler_options_;
   std::vector<std::string> image_compiler_options_;