using ::android::base::ConsumePrefix; using ::android::base::ConsumeSuffix; using ::android::base::Join; using ::android::base::ParseBool; using ::android::base::ParseBoolResult; using ::android::base::StringPrintf; using ::art::testing::GetLibCoreDexFileNames;
constexpr constchar* kUsage = R"(
A commandline tool to generate a primary boot image for testing.
Supported options:
--help: Print this text.
--output-dir=OUTPUT_DIR: The directory to output the boot image. Required.
--compiler-filter=COMPILER_FILTER: The compiler filter option to pass to dex2oat. Default: verify
--use-profile=true|false: Iftrue, use a profile. Default: true
--dex2oat-bin=DEX2OAT_BIN: The path to the dex2oat binary. Required when running on host. Default
on target: /apex/com.android.art/bin/dex2oat{32,64,32d,64d}
--android-root=ANDROID_ROOT: The root directory to search for bootclasspath jars. The file
structure under the root must be in the form of:
/apex
/com.android.art
/javalib
/core-oj.jar
...
/com.android.i18n
/javalib
...
/com.android.conscrypt
/javalib
...
Required when running on host. Default on target: /
--profile-file=PROFILE_FILE: The path to the profile file. Required when running on host and
--use-profile is true. Default on target: /apex/com.android.art/etc/boot-image.prof
--instruction-set=ISA: The instruction set option to pass to dex2oat. Required when running on
host. The default on target is based on the ISA of this binary.
--core-only=true|false: Iftrue, only compile ART jars. Otherwise, also compile core-icu4j and
conscrypt. Default: false
--android-root-for-location=true|false: Iftrue, 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.
)";
struct Options {
std::string output_dir = ""; // Set the compiler filter to `verify` by default to make test preparation // faster.
std::string compiler_filter = "verify"; bool use_profile = true;
std::string dex2oat_bin = "";
std::string android_root = "";
std::string profile_file = "";
std::string instruction_set = ""; bool core_only = false; bool android_root_for_location = false;
std::vector<std::string> dex2oat_options;
};
// Joins a list of commandline args into a single string, where each part is quoted with double // quotes. Note that this is a naive implementation that does NOT escape existing double quotes, // which is fine since we don't have existing double quotes in the args in this particular use case // and this code is never used in production.
std::string BuildCommand(const std::vector<std::string>& args) {
std::string command = ""; for (const std::string& arg : args) { if (!command.empty()) {
command += " ";
}
command += '"' + arg + '"';
} return command;
}
int GenerateBootImage(const Options& options) {
std::vector<std::string> args;
args.push_back(options.dex2oat_bin);
if (options.output_dir.empty()) {
Usage("--output-dir must be specified");
}
if (options.dex2oat_bin.empty()) { if (kIsTargetBuild) {
options.dex2oat_bin = GetCompilerExecutable();
} else {
Usage("--dex2oat-bin must be specified when running on host");
}
}
if (options.android_root.empty()) { if (!kIsTargetBuild) {
Usage("--android-root must be specified when running on host");
}
}
if (options.use_profile && options.profile_file.empty()) { if (kIsTargetBuild) {
options.profile_file = ART_FORMAT("{}/etc/boot-image.prof", GetArtRoot());
} else {
Usage("--profile-file must be specified when running on host and --use-profile is true");
}
}
if (options.instruction_set.empty()) { if (kIsTargetBuild) {
options.instruction_set = GetInstructionSetString(kRuntimeISA);
} else {
Usage("--instruction-set must be specified when running on host");
}
}
return GenerateBootImage(options);
}
} // namespace
} // namespace gbi
} // namespace art
int main(int argc, char** argv) { return art::gbi::Main(argc, argv); }
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.