summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.mk46
-rw-r--r--test/generate-boot-image/generate-boot-image.cc17
-rwxr-xr-xtools/buildbot-build.sh8
3 files changed, 70 insertions, 1 deletions
diff --git a/Android.mk b/Android.mk
index 1405aa79ff..d784cf6842 100644
--- a/Android.mk
+++ b/Android.mk
@@ -274,6 +274,52 @@ build-art: build-art-target
.PHONY: build-art-target
build-art-target: $(TARGET_OUT_EXECUTABLES)/art $(ART_TARGET_DEPENDENCIES) $(TARGET_CORE_IMG_OUTS)
+TARGET_BOOT_IMAGE_SYSTEM_DIR := $(PRODUCT_OUT)/system/apex/art_boot_images
+TARGET_ART_APEX_SYSTEM := $(PRODUCT_OUT)/system/apex/com.android.art
+TARGET_BOOT_IMAGE_PROFILE := $(TARGET_ART_APEX_SYSTEM).testing/etc/boot-image.prof
+
+.PHONY: build-art-simulator-profile
+build-art-simulator-profile: $(HOST_OUT_EXECUTABLES)/profmand $(TARGET_CORE_IMG_DEX_FILES) \
+ $(PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION)
+ mkdir -p $(dir $(TARGET_BOOT_IMAGE_PROFILE))
+ # Generate a profile from the core boot jars. This allows the simulator and boot image to use a
+ # stable profile that is generated on the host.
+ $(HOST_OUT_EXECUTABLES)/profmand \
+ --output-profile-type=boot \
+ --create-profile-from=$(PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION) \
+ $(foreach jar,$(TARGET_CORE_IMG_DEX_FILES),--apk=$(jar)) \
+ $(foreach jar,$(TARGET_CORE_IMG_DEX_LOCATIONS),--dex-location=$(jar)) \
+ --reference-profile-file=$(TARGET_BOOT_IMAGE_PROFILE)
+
+.PHONY: build-art-simulator-boot-image
+build-art-simulator-boot-image: $(HOST_OUT_EXECUTABLES)/generate-boot-image64 \
+ $(HOST_OUT_EXECUTABLES)/dex2oatd $(TARGET_CORE_IMG_DEX_FILES) build-art-simulator-profile
+ # Note: The target boot image needs to be in a trusted system directory to be used by the
+ # zygote or if -Xonly-use-system-oat-files is passed to the runtime.
+ rm -rf $(TARGET_BOOT_IMAGE_SYSTEM_DIR)
+ mkdir -p $(TARGET_BOOT_IMAGE_SYSTEM_DIR)/javalib
+ mkdir -p $(TARGET_ART_APEX_SYSTEM)/javalib
+ # Copy the core boot jars to the expected directory for generate-boot-image.
+ $(foreach i,$(call int_range_list, 1, $(words $(TARGET_CORE_IMG_JARS))), \
+ cp $(word $(i),$(TARGET_CORE_IMG_DEX_FILES)) \
+ $(TARGET_ART_APEX_SYSTEM)/javalib/$(word $(i),$(TARGET_CORE_IMG_JARS)).jar;)
+ # Generate a target boot image using the host dex2oat. Note: a boot image using a profile is
+ # required for certain run tests to pass.
+ $(HOST_OUT_EXECUTABLES)/generate-boot-image64 \
+ --output-dir=$(TARGET_BOOT_IMAGE_SYSTEM_DIR)/javalib \
+ --compiler-filter=speed-profile \
+ --use-profile=true \
+ --profile-file=$(TARGET_BOOT_IMAGE_PROFILE) \
+ --dex2oat-bin=$(HOST_OUT_EXECUTABLES)/dex2oatd \
+ --android-root=$(TARGET_OUT) \
+ --android-root-for-location=true \
+ --core-only=true \
+ --instruction-set=$(TARGET_ARCH)
+
+# For simulator, build a target profile and boot image on the host.
+.PHONY: build-art-simulator
+build-art-simulator: build-art-simulator-profile build-art-simulator-boot-image
+
PRIVATE_ART_APEX_DEPENDENCY_FILES := \
bin/dalvikvm32 \
bin/dalvikvm64 \
diff --git a/test/generate-boot-image/generate-boot-image.cc b/test/generate-boot-image/generate-boot-image.cc
index 3cd992f0c6..454b63185a 100644
--- a/test/generate-boot-image/generate-boot-image.cc
+++ b/test/generate-boot-image/generate-boot-image.cc
@@ -80,6 +80,9 @@ Supported options:
host. The default on target is based on the ISA of this binary.
--core-only=true|false: If true, only compile ART jars. Otherwise, also compile core-icu4j and
conscrypt. Default: false
+ --android-root-for-location=true|false: If true, use --android-root as a prefix to the dex
+ locations. This allows non-device paths to the bootclasspath jars to be used, for example: to
+ generate a boot image on host that can be used on host. Default: false
--: Arguments following '--' are directly passed to dex2oat.
)";
@@ -94,6 +97,7 @@ struct Options {
std::string profile_file = "";
std::string instruction_set = "";
bool core_only = false;
+ bool android_root_for_location = false;
std::vector<std::string> dex2oat_options;
};
@@ -133,7 +137,12 @@ int GenerateBootImage(const Options& options) {
std::vector<std::string> dex_files =
GetLibCoreDexFileNames(options.android_root, options.core_only);
- std::vector<std::string> dex_locations = GetLibCoreDexLocations(options.core_only);
+ std::vector<std::string> dex_locations;
+ if (options.android_root_for_location) {
+ dex_locations = dex_files;
+ } else {
+ dex_locations = GetLibCoreDexLocations(options.core_only);
+ }
args.push_back("--runtime-arg");
args.push_back("-Xbootclasspath:" + Join(dex_files, ":"));
args.push_back("--runtime-arg");
@@ -209,6 +218,12 @@ int Main(int argc, char** argv) {
Usage(ART_FORMAT("Unrecognized --core-only value: '{}'", arg));
}
options.core_only = result == ParseBoolResult::kTrue;
+ } else if (ConsumePrefix(&arg, "--android-root-for-location=")) {
+ ParseBoolResult result = ParseBool(arg);
+ if (result == ParseBoolResult::kError) {
+ Usage(ART_FORMAT("Unrecognized --android-root-for-location value: '{}'", arg));
+ }
+ options.android_root_for_location = result == ParseBoolResult::kTrue;
} else if (arg == "--") {
for (i++; i < argc; i++) {
options.dex2oat_options.push_back(argv[i]);
diff --git a/tools/buildbot-build.sh b/tools/buildbot-build.sh
index 861664839f..acc0ad78d8 100755
--- a/tools/buildbot-build.sh
+++ b/tools/buildbot-build.sh
@@ -179,6 +179,14 @@ if [[ $build_target == "yes" ]]; then
# Build/install the required APEXes.
make_command+=" ${apexes[*]}"
make_command+=" ${specific_targets}"
+
+ # Although the simulator is run on the host, we reuse the target build to
+ # build the target run tests on the host.
+ if [[ -n "${ART_USE_SIMULATOR}" ]]; then
+ # Build any simulator specific components, such as a target boot image, on
+ # the host.
+ make_command+=" build-art-simulator"
+ fi
fi
if [[ $installclean == "yes" ]]; then