1. static int dex2oat(int argc, char** argv) {
2. ......
3.
#if defined(ART_USE_PORTABLE_COMPILER)
4. CompilerBackend compiler_backend = kPortable;
5.
#else
6. CompilerBackend compiler_backend = kQuick;
7.
#endif
8.
#if defined(__arm__)
9. InstructionSet instruction_set = kThumb2;
10.
#elif defined(__i386__)
11. InstructionSet instruction_set = kX86;
12.
#elif defined(__mips__)
13. InstructionSet instruction_set = kMips;
14.
#else
15.
#error "Unsupported architecture"
16.
#endif
17. ......
18.
for
(int i = 0; i < argc; i++) {
19. const StringPiece option(argv[i]);
20. ......
21.
else
if
(option.starts_with(
"--zip-fd="
)) {
22. const char* zip_fd_str = option.substr(strlen(
"--zip-fd="
)).data();
23.
if
(!ParseInt(zip_fd_str, &zip_fd)) {
24. Usage(
"Failed to parse --zip-fd argument '%s' as an integer"
, zip_fd_str);
25. }
26. }
else
if
(option.starts_with(
"--zip-location="
)) {
27. zip_location = option.substr(strlen(
"--zip-location="
)).data();
28. }
29. ......
30. }
else
if
(option.starts_with(
"--oat-fd="
)) {
31. const char* oat_fd_str = option.substr(strlen(
"--oat-fd="
)).data();
32.
if
(!ParseInt(oat_fd_str, &oat_fd)) {
33. Usage(
"Failed to parse --oat-fd argument '%s' as an integer"
, oat_fd_str);
34. }
35. }
36. ......
37. }
else
if
(option.starts_with(
"--oat-location="
)) {
38. oat_location = option.substr(strlen(
"--oat-location="
)).data();
39. }
40. ......
41. }
42.
if
(oat_filename.empty() && oat_fd == -1) {
43. Usage(
"Output must be supplied with either --oat-file or --oat-fd"
);
44. }
45.
if
(!oat_filename.empty() && oat_fd != -1) {
46. Usage(
"--oat-file should not be used with --oat-fd"
);
47. }
48. ......
49.
if
(oat_fd != -1 && !image_filename.empty()) {
50. Usage(
"--oat-fd should not be used with --image"
);
51. }
52.
if
(host_prefix.get() == NULL) {
53. const char* android_product_out = getenv(
"ANDROID_PRODUCT_OUT"
);
54.
if
(android_product_out != NULL) {
55. host_prefix.reset(new std::string(android_product_out));
56. }
57. }
58.
if
(android_root.empty()) {
59. const char* android_root_env_var = getenv(
"ANDROID_ROOT"
);
60.
if
(android_root_env_var == NULL) {
61. Usage(
"--android-root unspecified and ANDROID_ROOT not set"
);
62. }
63. android_root += android_root_env_var;
64. }
65. bool image = (!image_filename.empty());
66.
if
(!image && boot_image_filename.empty()) {
67.
if
(host_prefix.get() == NULL) {
68. boot_image_filename += GetAndroidRoot();
69. }
else
{
70. boot_image_filename += *host_prefix.get();
71. boot_image_filename +=
"/system"
;
72. }
73. boot_image_filename +=
"/framework/boot.art"
;
74. }
75. std::string boot_image_option;
76.
if
(!boot_image_filename.empty()) {
77. boot_image_option +=
"-Ximage:"
;
78. boot_image_option += boot_image_filename;
79. }
80. ......
81.
if
(dex_locations.empty()) {
82.
for
(size_t i = 0; i < dex_filenames.size(); i++) {
83. dex_locations.push_back(dex_filenames[i]);
84. }
85. }
else
if
(dex_locations.size() != dex_filenames.size()) {
86. Usage(
"--dex-location arguments do not match --dex-file arguments"
);
87. }
88. ......
89. }