Fix portable build on build server by removing depenency on ANDROID_HOST_OUT
Change-Id: I713a156468d14e07c784013c3c37a18c3c075a71
diff --git a/src/dex2oat.cc b/src/dex2oat.cc
index 6892bb3..cce9276 100644
--- a/src/dex2oat.cc
+++ b/src/dex2oat.cc
@@ -115,6 +115,10 @@
UsageError(" Example: --host-prefix=out/target/product/crespo");
UsageError(" Default: $ANDROID_PRODUCT_OUT");
UsageError("");
+ UsageError(" --android-root=<path>: used to locate libraries for portable linking.");
+ UsageError(" Example: --android-root=out/host/linux-x86");
+ UsageError(" Default: $ANDROID_ROOT");
+ UsageError("");
UsageError(" --instruction-set=(arm|mips|x86): compile for a particular instruction");
UsageError(" set.");
UsageError(" Example: --instruction-set=x86");
@@ -223,15 +227,16 @@
}
const CompilerDriver* CreateOatFile(const std::string& boot_image_option,
- const std::string* host_prefix,
- bool is_host,
- const std::vector<const DexFile*>& dex_files,
- File* oat_file,
- const std::string& bitcode_filename,
- bool image,
- const std::set<std::string>* image_classes,
- bool dump_stats,
- bool dump_timings)
+ const std::string* host_prefix,
+ const std::string& android_root,
+ bool is_host,
+ const std::vector<const DexFile*>& dex_files,
+ File* oat_file,
+ const std::string& bitcode_filename,
+ bool image,
+ const std::set<std::string>* image_classes,
+ bool dump_stats,
+ bool dump_timings)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
// SirtRef and ClassLoader creation needs to come after Runtime::Create
jobject class_loader = NULL;
@@ -295,7 +300,7 @@
return NULL;
}
- if (!driver->WriteElf(host_prefix, is_host, dex_files, oat_contents, oat_file)) {
+ if (!driver->WriteElf(android_root, is_host, dex_files, oat_contents, oat_file)) {
LOG(ERROR) << "Failed to write ELF file " << oat_file->GetPath();
return NULL;
}
@@ -650,6 +655,7 @@
std::string boot_image_filename;
uintptr_t image_base = 0;
UniquePtr<std::string> host_prefix;
+ std::string android_root;
std::vector<const char*> runtime_args;
int thread_count = sysconf(_SC_NPROCESSORS_CONF);
bool support_debugging = false;
@@ -728,6 +734,8 @@
boot_image_filename = option.substr(strlen("--boot-image=")).data();
} else if (option.starts_with("--host-prefix=")) {
host_prefix.reset(new std::string(option.substr(strlen("--host-prefix=")).data()));
+ } else if (option.starts_with("--android-root=")) {
+ android_root = option.substr(strlen("--android-root=")).data();
} else if (option.starts_with("--instruction-set=")) {
StringPiece instruction_set_str = option.substr(strlen("--instruction-set=")).data();
if (instruction_set_str == "arm") {
@@ -788,6 +796,14 @@
}
}
+ if (android_root.empty()) {
+ const char* android_root_env_var = getenv("ANDROID_ROOT");
+ if (android_root_env_var == NULL) {
+ Usage("--android_root unspecified and ANDROID_ROOT not set");
+ }
+ android_root += android_root_env_var;
+ }
+
bool image = (!image_filename.empty());
if (!image && boot_image_filename.empty()) {
if (host_prefix.get() == NULL) {
@@ -946,6 +962,7 @@
UniquePtr<const CompilerDriver> compiler(dex2oat->CreateOatFile(boot_image_option,
host_prefix.get(),
+ android_root,
is_host,
dex_files,
oat_file.get(),