diff options
author | 2013-03-07 00:02:40 -0800 | |
---|---|---|
committer | 2013-03-07 00:02:40 -0800 | |
commit | 3f47c12487250f61f3be95e9f275e3b08e2c49fb (patch) | |
tree | 940732d0835af1cf80e8ec41eac6cafaca102a4c | |
parent | 650d7a60716a05680f13d2bd9190b633507e958f (diff) |
Fix portable build on build server by removing depenency on ANDROID_HOST_OUT
Change-Id: I713a156468d14e07c784013c3c37a18c3c075a71
-rw-r--r-- | Android.mk | 6 | ||||
-rw-r--r-- | build/Android.oat.mk | 6 | ||||
-rw-r--r-- | build/Android.oattest.mk | 2 | ||||
-rw-r--r-- | src/common_test.h | 9 | ||||
-rw-r--r-- | src/compiler/dex/write_elf.cc | 4 | ||||
-rw-r--r-- | src/compiler/driver/compiler_driver.cc | 6 | ||||
-rw-r--r-- | src/compiler/driver/compiler_driver.h | 2 | ||||
-rw-r--r-- | src/dex2oat.cc | 37 | ||||
-rw-r--r-- | src/elf_writer.cc | 24 | ||||
-rw-r--r-- | src/elf_writer.h | 6 | ||||
-rw-r--r-- | src/image_test.cc | 2 | ||||
-rw-r--r-- | src/oat_test.cc | 2 |
12 files changed, 59 insertions, 47 deletions
diff --git a/Android.mk b/Android.mk index a20ee9fa96..e28f3b05f9 100644 --- a/Android.mk +++ b/Android.mk @@ -82,7 +82,7 @@ clean-oat-host: rm -f $(TARGET_OUT_UNSTRIPPED)/system/framework/*.oat rm -f $(TARGET_OUT_APPS)/*.oat rm -f $(TARGET_OUT_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/javalib.jar.oat - rm -f $(TARGET_OUT_INTERMEDIATES)/APPS/*_intermediates/package.apk.oat + rm -f $(TARGET_OUT_INTERMEDIATES)/APPS/*_intermediates/*.apk.oat rm -rf /tmp/test-*/art-cache/*.oat .PHONY: clean-oat-target @@ -276,14 +276,14 @@ endif ifeq ($(ONE_SHOT_MAKEFILE),) .PHONY: oat-target-$(1) oat-target-$(1): $(PRODUCT_OUT)/$(1) $(TARGET_BOOT_IMG_OUT) $(DEX2OAT_DEPENDENCY) - $(DEX2OAT) $(PARALLEL_ART_COMPILE_JOBS) --runtime-arg -Xms64m --runtime-arg -Xmx64m --boot-image=$(TARGET_BOOT_IMG_OUT) --dex-file=$(PRODUCT_OUT)/$(1) --dex-location=/$(1) --oat-file=$$(OUT_OAT_FILE) --host-prefix=$(PRODUCT_OUT) --instruction-set=$(TARGET_ARCH) + $(DEX2OAT) $(PARALLEL_ART_COMPILE_JOBS) --runtime-arg -Xms64m --runtime-arg -Xmx64m --boot-image=$(TARGET_BOOT_IMG_OUT) --dex-file=$(PRODUCT_OUT)/$(1) --dex-location=/$(1) --oat-file=$$(OUT_OAT_FILE) --host-prefix=$(PRODUCT_OUT) --instruction-set=$(TARGET_ARCH) --android-root=$(PRODUCT_OUT)/system else .PHONY: oat-target-$(1) oat-target-$(1): $$(OUT_OAT_FILE) $$(OUT_OAT_FILE): $(PRODUCT_OUT)/$(1) $(TARGET_BOOT_IMG_OUT) $(DEX2OAT_DEPENDENCY) - $(DEX2OAT) $(PARALLEL_ART_COMPILE_JOBS) --runtime-arg -Xms64m --runtime-arg -Xmx64m --boot-image=$(TARGET_BOOT_IMG_OUT) --dex-file=$(PRODUCT_OUT)/$(1) --dex-location=/$(1) --oat-file=$$@ --host-prefix=$(PRODUCT_OUT) --instruction-set=$(TARGET_ARCH) + $(DEX2OAT) $(PARALLEL_ART_COMPILE_JOBS) --runtime-arg -Xms64m --runtime-arg -Xmx64m --boot-image=$(TARGET_BOOT_IMG_OUT) --dex-file=$(PRODUCT_OUT)/$(1) --dex-location=/$(1) --oat-file=$$@ --host-prefix=$(PRODUCT_OUT) --instruction-set=$(TARGET_ARCH) --android-root=$(PRODUCT_OUT)/system endif diff --git a/build/Android.oat.mk b/build/Android.oat.mk index feeede54c8..92a86c73e7 100644 --- a/build/Android.oat.mk +++ b/build/Android.oat.mk @@ -60,12 +60,12 @@ TARGET_CORE_IMG_OUT := $(ART_TEST_OUT)/core.art $(HOST_CORE_IMG_OUT): $(HOST_CORE_DEX_FILES) $(DEX2OAT_DEPENDENCY) @echo "host dex2oat: $@ ($?)" @mkdir -p $(dir $@) - $(hide) $(DEX2OAT) $(PARALLEL_ART_COMPILE_JOBS) --runtime-arg -Xms16m --runtime-arg -Xmx16m --image-classes=$(PRELOADED_CLASSES) $(addprefix --dex-file=,$(HOST_CORE_DEX_FILES)) $(addprefix --dex-location=,$(HOST_CORE_DEX_LOCATIONS)) --oat-file=$(HOST_CORE_OAT_OUT) --oat-location=$(HOST_CORE_OAT) --image=$(HOST_CORE_IMG_OUT) --base=$(IMG_HOST_BASE_ADDRESS) --instruction-set=$(HOST_ARCH) --host + $(hide) $(DEX2OAT) $(PARALLEL_ART_COMPILE_JOBS) --runtime-arg -Xms16m --runtime-arg -Xmx16m --image-classes=$(PRELOADED_CLASSES) $(addprefix --dex-file=,$(HOST_CORE_DEX_FILES)) $(addprefix --dex-location=,$(HOST_CORE_DEX_LOCATIONS)) --oat-file=$(HOST_CORE_OAT_OUT) --oat-location=$(HOST_CORE_OAT) --image=$(HOST_CORE_IMG_OUT) --base=$(IMG_HOST_BASE_ADDRESS) --instruction-set=$(HOST_ARCH) --host --android-root=$(HOST_OUT) $(TARGET_CORE_IMG_OUT): $(TARGET_CORE_DEX_FILES) $(DEX2OAT_DEPENDENCY) @echo "target dex2oat: $@ ($?)" @mkdir -p $(dir $@) - $(hide) $(DEX2OAT) $(PARALLEL_ART_COMPILE_JOBS) --runtime-arg -Xms16m --runtime-arg -Xmx16m --image-classes=$(PRELOADED_CLASSES) $(addprefix --dex-file=,$(TARGET_CORE_DEX_FILES)) $(addprefix --dex-location=,$(TARGET_CORE_DEX_LOCATIONS)) --oat-file=$(TARGET_CORE_OAT_OUT) --oat-location=$(TARGET_CORE_OAT) --image=$(TARGET_CORE_IMG_OUT) --base=$(IMG_TARGET_BASE_ADDRESS) --instruction-set=$(TARGET_ARCH) --host-prefix=$(PRODUCT_OUT) + $(hide) $(DEX2OAT) $(PARALLEL_ART_COMPILE_JOBS) --runtime-arg -Xms16m --runtime-arg -Xmx16m --image-classes=$(PRELOADED_CLASSES) $(addprefix --dex-file=,$(TARGET_CORE_DEX_FILES)) $(addprefix --dex-location=,$(TARGET_CORE_DEX_LOCATIONS)) --oat-file=$(TARGET_CORE_OAT_OUT) --oat-location=$(TARGET_CORE_OAT) --image=$(TARGET_CORE_IMG_OUT) --base=$(IMG_TARGET_BASE_ADDRESS) --instruction-set=$(TARGET_ARCH) --host-prefix=$(PRODUCT_OUT) --android-root=$(PRODUCT_OUT)/system $(HOST_CORE_OAT_OUT): $(HOST_CORE_IMG_OUT) @@ -94,7 +94,7 @@ $(TARGET_BOOT_IMG_OUT): $(TARGET_BOOT_DEX_FILES) $(DEX2OAT_DEPENDENCY) @echo "target dex2oat: $@ ($?)" @mkdir -p $(dir $@) @mkdir -p $(dir $(TARGET_BOOT_OAT_UNSTRIPPED_OUT)) - $(hide) $(DEX2OAT) $(PARALLEL_ART_COMPILE_JOBS) --runtime-arg -Xms256m --runtime-arg -Xmx256m --image-classes=$(PRELOADED_CLASSES) $(addprefix --dex-file=,$(TARGET_BOOT_DEX_FILES)) $(addprefix --dex-location=,$(TARGET_BOOT_DEX_LOCATIONS)) --oat-symbols=$(TARGET_BOOT_OAT_UNSTRIPPED_OUT) --oat-file=$(TARGET_BOOT_OAT_OUT) --oat-location=$(TARGET_BOOT_OAT) --image=$(TARGET_BOOT_IMG_OUT) --base=$(IMG_TARGET_BASE_ADDRESS) --instruction-set=$(TARGET_ARCH) --host-prefix=$(PRODUCT_OUT) + $(hide) $(DEX2OAT) $(PARALLEL_ART_COMPILE_JOBS) --runtime-arg -Xms256m --runtime-arg -Xmx256m --image-classes=$(PRELOADED_CLASSES) $(addprefix --dex-file=,$(TARGET_BOOT_DEX_FILES)) $(addprefix --dex-location=,$(TARGET_BOOT_DEX_LOCATIONS)) --oat-symbols=$(TARGET_BOOT_OAT_UNSTRIPPED_OUT) --oat-file=$(TARGET_BOOT_OAT_OUT) --oat-location=$(TARGET_BOOT_OAT) --image=$(TARGET_BOOT_IMG_OUT) --base=$(IMG_TARGET_BASE_ADDRESS) --instruction-set=$(TARGET_ARCH) --host-prefix=$(PRODUCT_OUT) --android-root=$(PRODUCT_OUT)/system $(TARGET_BOOT_OAT_UNSTRIPPED_OUT): $(TARGET_BOOT_IMG_OUT) diff --git a/build/Android.oattest.mk b/build/Android.oattest.mk index c2163bde58..034e475446 100644 --- a/build/Android.oattest.mk +++ b/build/Android.oattest.mk @@ -70,7 +70,7 @@ test-art-target-oat-$(1): $(ART_TEST_OUT)/oat-test-dex-$(1).jar test-art-target- $(hide) rm /tmp/test-art-target-oat-$(1) $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).jar.oat: $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).jar $(HOST_CORE_IMG_OUT) | $(DEX2OAT) - $(DEX2OAT) --runtime-arg -Xms16m --runtime-arg -Xmx16m --boot-image=$(HOST_CORE_IMG_OUT) --dex-file=$$< --oat-file=$$@ --instruction-set=$(HOST_ARCH) --host --host-prefix="" + $(DEX2OAT) --runtime-arg -Xms16m --runtime-arg -Xmx16m --boot-image=$(HOST_CORE_IMG_OUT) --dex-file=$$< --oat-file=$$@ --instruction-set=$(HOST_ARCH) --host --host-prefix="" --android-root=$(HOST_OUT) .PHONY: test-art-host-oat-$(1) test-art-host-oat-$(1): $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).jar.oat test-art-host-dependencies diff --git a/src/common_test.h b/src/common_test.h index 0167424092..62e75614e9 100644 --- a/src/common_test.h +++ b/src/common_test.h @@ -446,6 +446,15 @@ class CommonTest : public testing::Test { return StringPrintf("%s/framework/%s.jar", GetAndroidRoot(), jar_prefix.c_str()); } + std::string GetTestAndroidRoot() { + if (IsHost()) { + const char* host_dir = getenv("ANDROID_HOST_OUT"); + CHECK(host_dir != NULL); + return host_dir; + } + return GetAndroidRoot(); + } + const DexFile* OpenTestDexFile(const char* name) { CHECK(name != NULL); std::string filename; diff --git a/src/compiler/dex/write_elf.cc b/src/compiler/dex/write_elf.cc index 7e3d51283a..acec531b6a 100644 --- a/src/compiler/dex/write_elf.cc +++ b/src/compiler/dex/write_elf.cc @@ -23,13 +23,13 @@ class DexFile; } // namespace art extern "C" bool WriteElf(art::CompilerDriver& driver, - const std::string* host_prefix, + const std::string& android_root, bool is_host, const std::vector<const art::DexFile*>& dex_files, std::vector<uint8_t>& oat_contents, art::File* file) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return art::ElfWriter::Create(file, oat_contents, dex_files, host_prefix, is_host, driver); + return art::ElfWriter::Create(file, oat_contents, dex_files, android_root, is_host, driver); } extern "C" bool FixupElf(art::File* file, uintptr_t oat_data_begin) { return art::ElfWriter::Fixup(file, oat_data_begin); diff --git a/src/compiler/driver/compiler_driver.cc b/src/compiler/driver/compiler_driver.cc index 8856a00597..8556cc8366 100644 --- a/src/compiler/driver/compiler_driver.cc +++ b/src/compiler/driver/compiler_driver.cc @@ -1793,13 +1793,13 @@ bool CompilerDriver::RequiresConstructorBarrier(Thread* self, const DexFile* dex return freezing_constructor_classes_.count(ClassReference(dex_file, class_def_index)) != 0; } -bool CompilerDriver::WriteElf(const std::string* host_prefix, +bool CompilerDriver::WriteElf(const std::string& android_root, bool is_host, const std::vector<const DexFile*>& dex_files, std::vector<uint8_t>& oat_contents, File* file) { typedef bool (*WriteElfFn)(CompilerDriver&, - const std::string* host_prefix, + const std::string& android_root, bool is_host, const std::vector<const DexFile*>& dex_files, std::vector<uint8_t>&, @@ -1807,7 +1807,7 @@ bool CompilerDriver::WriteElf(const std::string* host_prefix, WriteElfFn WriteElf = FindFunction<WriteElfFn>(MakeCompilerSoName(compiler_backend_), compiler_library_, "WriteElf"); Locks::mutator_lock_->AssertSharedHeld(Thread::Current()); - return WriteElf(*this, host_prefix, is_host, dex_files, oat_contents, file); + return WriteElf(*this, android_root, is_host, dex_files, oat_contents, file); } bool CompilerDriver::FixupElf(File* file, uintptr_t oat_data_begin) const { diff --git a/src/compiler/driver/compiler_driver.h b/src/compiler/driver/compiler_driver.h index 7f67c212e9..54a2f55b74 100644 --- a/src/compiler/driver/compiler_driver.h +++ b/src/compiler/driver/compiler_driver.h @@ -187,7 +187,7 @@ class CompilerDriver { void SetBitcodeFileName(std::string const& filename); // TODO: remove these Elf wrappers when libart links against LLVM (when separate compiler library is gone) - bool WriteElf(const std::string* host_prefix, + bool WriteElf(const std::string& android_root, bool is_host, const std::vector<const DexFile*>& dex_files, std::vector<uint8_t>& oat_contents, diff --git a/src/dex2oat.cc b/src/dex2oat.cc index 6892bb3623..cce927659e 100644 --- a/src/dex2oat.cc +++ b/src/dex2oat.cc @@ -115,6 +115,10 @@ static void Usage(const char* fmt, ...) { 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 @@ class Dex2Oat { } 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 @@ class Dex2Oat { 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 @@ static int dex2oat(int argc, char** argv) { 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 @@ static int dex2oat(int argc, char** argv) { 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 @@ static int dex2oat(int argc, char** argv) { } } + 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 @@ static int dex2oat(int argc, char** argv) { UniquePtr<const CompilerDriver> compiler(dex2oat->CreateOatFile(boot_image_option, host_prefix.get(), + android_root, is_host, dex_files, oat_file.get(), diff --git a/src/elf_writer.cc b/src/elf_writer.cc index 88b35435c5..fc6561fc4a 100644 --- a/src/elf_writer.cc +++ b/src/elf_writer.cc @@ -44,11 +44,11 @@ namespace art { bool ElfWriter::Create(File* elf_file, std::vector<uint8_t>& oat_contents, const std::vector<const DexFile*>& dex_files, - const std::string* host_prefix, + const std::string& android_root, bool is_host, const CompilerDriver& driver) { ElfWriter elf_writer(driver, elf_file); - return elf_writer.Write(oat_contents, dex_files, host_prefix, is_host); + return elf_writer.Write(oat_contents, dex_files, android_root, is_host); } ElfWriter::ElfWriter(const CompilerDriver& driver, File* elf_file) @@ -58,13 +58,13 @@ ElfWriter::~ElfWriter() {} bool ElfWriter::Write(std::vector<uint8_t>& oat_contents, const std::vector<const DexFile*>& dex_files, - const std::string* host_prefix, + const std::string& android_root, bool is_host) { Init(); AddOatInput(oat_contents); #if defined(ART_USE_PORTABLE_COMPILER) AddMethodInputs(dex_files); - AddRuntimeInputs(host_prefix, is_host); + AddRuntimeInputs(android_root, is_host); #endif if (!Link()) { return false; @@ -267,21 +267,7 @@ void ElfWriter::AddCompiledCodeInput(const CompiledCode& compiled_code) { CHECK(code_input != NULL); } -void ElfWriter::AddRuntimeInputs(const std::string* host_prefix, bool is_host) { - std::string android_root; - if (is_host) { - const char* android_host_out = getenv("ANDROID_HOST_OUT"); - CHECK(android_host_out != NULL) << "ANDROID_HOST_OUT environment variable not set"; - android_root += android_host_out; - } else { - if (host_prefix != NULL) { - android_root += *host_prefix; - android_root += "/system"; - } else { - android_root += GetAndroidRoot(); - } - } - +void ElfWriter::AddRuntimeInputs(const std::string& android_root, bool is_host) { std::string libart_so(android_root); libart_so += kIsDebugBuild ? "/lib/libartd.so" : "/lib/libart.so"; // TODO: ownership of libart_so_input? diff --git a/src/elf_writer.h b/src/elf_writer.h index 6f22db146e..1dd0131b6f 100644 --- a/src/elf_writer.h +++ b/src/elf_writer.h @@ -50,7 +50,7 @@ class ElfWriter { static bool Create(File* file, std::vector<uint8_t>& oat_contents, const std::vector<const DexFile*>& dex_files, - const std::string* host_prefix, + const std::string& android_root, bool is_host, const CompilerDriver& driver) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -75,7 +75,7 @@ class ElfWriter { bool Write(std::vector<uint8_t>& oat_contents, const std::vector<const DexFile*>& dex_files, - const std::string* host_prefix, + const std::string& android_root, bool is_host) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -83,7 +83,7 @@ class ElfWriter { void AddOatInput(std::vector<uint8_t>& oat_contents); void AddMethodInputs(const std::vector<const DexFile*>& dex_files); void AddCompiledCodeInput(const CompiledCode& compiled_code); - void AddRuntimeInputs(const std::string* host_prefix, bool is_host); + void AddRuntimeInputs(const std::string& android_root, bool is_host); bool Link(); #if defined(ART_USE_PORTABLE_COMPILER) void FixupOatMethodOffsets(const std::vector<const DexFile*>& dex_files) diff --git a/src/image_test.cc b/src/image_test.cc index dc16a6c2e7..e4deda3e6d 100644 --- a/src/image_test.cc +++ b/src/image_test.cc @@ -57,7 +57,7 @@ TEST_F(ImageTest, WriteRead) { mirror::Class* klass = class_linker_->FindSystemClass(descriptor); EXPECT_TRUE(klass != NULL) << descriptor; } - bool success_elf = compiler_driver_->WriteElf(NULL, + bool success_elf = compiler_driver_->WriteElf(GetTestAndroidRoot(), !kIsTargetBuild, dex_files, oat_contents, diff --git a/src/oat_test.cc b/src/oat_test.cc index ace52f4a26..c4bd60e858 100644 --- a/src/oat_test.cc +++ b/src/oat_test.cc @@ -90,7 +90,7 @@ TEST_F(OatTest, WriteRead) { "lue.art", *compiler_driver_.get()); ASSERT_TRUE(success_oat); - bool success_elf = compiler_driver_->WriteElf(NULL, + bool success_elf = compiler_driver_->WriteElf(GetTestAndroidRoot(), !kIsTargetBuild, class_linker->GetBootClassPath(), oat_contents, |