| Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 1 | // Copyright 2019 Google Inc. All rights reserved. | 
|  | 2 | // | 
|  | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 4 | // you may not use this file except in compliance with the License. | 
|  | 5 | // You may obtain a copy of the License at | 
|  | 6 | // | 
|  | 7 | //     http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 8 | // | 
|  | 9 | // Unless required by applicable law or agreed to in writing, software | 
|  | 10 | // distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 12 | // See the License for the specific language governing permissions and | 
|  | 13 | // limitations under the License. | 
|  | 14 |  | 
|  | 15 | package java | 
|  | 16 |  | 
|  | 17 | import ( | 
| Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 18 | "path/filepath" | 
|  | 19 | "strings" | 
| Colin Cross | 2d00f0d | 2019-05-09 21:50:00 -0700 | [diff] [blame] | 20 |  | 
|  | 21 | "android/soong/android" | 
|  | 22 | "android/soong/dexpreopt" | 
| Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 23 | ) | 
|  | 24 |  | 
| Colin Cross | c11e0c5 | 2019-05-08 15:18:22 -0700 | [diff] [blame] | 25 | // dexpreoptTargets returns the list of targets that are relevant to dexpreopting, which excludes architectures | 
|  | 26 | // supported through native bridge. | 
|  | 27 | func dexpreoptTargets(ctx android.PathContext) []android.Target { | 
|  | 28 | var targets []android.Target | 
| Colin Cross | 3b19f5d | 2019-09-17 14:45:31 -0700 | [diff] [blame] | 29 | for _, target := range ctx.Config().Targets[android.Android] { | 
| Colin Cross | c11e0c5 | 2019-05-08 15:18:22 -0700 | [diff] [blame] | 30 | if target.NativeBridge == android.NativeBridgeDisabled { | 
|  | 31 | targets = append(targets, target) | 
|  | 32 | } | 
|  | 33 | } | 
| David Srbecky | 7f8dac1 | 2020-02-13 16:00:45 +0000 | [diff] [blame] | 34 | // We may also need the images on host in order to run host-based tests. | 
| Colin Cross | 0c66bc6 | 2021-07-20 09:47:41 -0700 | [diff] [blame] | 35 | for _, target := range ctx.Config().Targets[ctx.Config().BuildOS] { | 
| David Srbecky | 7f8dac1 | 2020-02-13 16:00:45 +0000 | [diff] [blame] | 36 | targets = append(targets, target) | 
|  | 37 | } | 
| Colin Cross | c11e0c5 | 2019-05-08 15:18:22 -0700 | [diff] [blame] | 38 |  | 
|  | 39 | return targets | 
|  | 40 | } | 
|  | 41 |  | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 42 | var ( | 
| Ulya Trafimovich | 4cdada2 | 2020-02-10 15:29:28 +0000 | [diff] [blame] | 43 | bootImageConfigKey     = android.NewOnceKey("bootImageConfig") | 
| Jiakai Zhang | 6decef9 | 2022-01-12 17:56:19 +0000 | [diff] [blame] | 44 | bootImageConfigRawKey  = android.NewOnceKey("bootImageConfigRaw") | 
| Ulya Trafimovich | 4cdada2 | 2020-02-10 15:29:28 +0000 | [diff] [blame] | 45 | artBootImageName       = "art" | 
|  | 46 | frameworkBootImageName = "boot" | 
| Jiakai Zhang | b879620 | 2023-03-06 19:16:48 +0000 | [diff] [blame] | 47 | mainlineBootImageName  = "mainline" | 
|  | 48 | bootImageStem          = "boot" | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 49 | ) | 
| Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 50 |  | 
| Jiakai Zhang | 6decef9 | 2022-01-12 17:56:19 +0000 | [diff] [blame] | 51 | func genBootImageConfigRaw(ctx android.PathContext) map[string]*bootImageConfig { | 
|  | 52 | return ctx.Config().Once(bootImageConfigRawKey, func() interface{} { | 
| Martin Stjernholm | 40f9f3c | 2020-01-20 18:12:23 +0000 | [diff] [blame] | 53 | global := dexpreopt.GetGlobalConfig(ctx) | 
| Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 54 |  | 
| Paul Duffin | 7d584e9 | 2020-10-23 18:26:03 +0100 | [diff] [blame] | 55 | artModules := global.ArtApexJars | 
| Jiakai Zhang | c08c162 | 2023-05-10 18:38:34 +0100 | [diff] [blame] | 56 | frameworkModules := global.BootJars // This includes `artModules`. | 
| Jiakai Zhang | b879620 | 2023-03-06 19:16:48 +0000 | [diff] [blame] | 57 | mainlineBcpModules := global.ApexBootJars | 
|  | 58 | frameworkSubdir := "system/framework" | 
| Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 59 |  | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 60 | // ART config for the primary boot image in the ART apex. | 
|  | 61 | // It includes the Core Libraries. | 
|  | 62 | artCfg := bootImageConfig{ | 
| Jiakai Zhang | 49b1eb6 | 2021-11-26 18:09:27 +0000 | [diff] [blame] | 63 | name:                     artBootImageName, | 
| Jiakai Zhang | b879620 | 2023-03-06 19:16:48 +0000 | [diff] [blame] | 64 | stem:                     bootImageStem, | 
| Jiakai Zhang | 09d88df | 2023-05-10 17:04:53 +0100 | [diff] [blame] | 65 | installDir:               "apex/art_boot_images/javalib", | 
| Jiakai Zhang | 49b1eb6 | 2021-11-26 18:09:27 +0000 | [diff] [blame] | 66 | profileInstallPathInApex: "etc/boot-image.prof", | 
|  | 67 | modules:                  artModules, | 
| Nicolas Geoffray | b9a46fb | 2022-03-14 15:31:47 +0000 | [diff] [blame] | 68 | preloadedClassesFile:     "art/build/boot/preloaded-classes", | 
| Jiakai Zhang | 8e9ea8b | 2023-02-23 17:50:46 +0000 | [diff] [blame] | 69 | compilerFilter:           "speed-profile", | 
| Jiakai Zhang | b879620 | 2023-03-06 19:16:48 +0000 | [diff] [blame] | 70 | singleImage:              false, | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 71 | } | 
| Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 72 |  | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 73 | // Framework config for the boot image extension. | 
| Ulyana Trafimovich | 5a4ccd1 | 2019-12-18 17:32:33 +0000 | [diff] [blame] | 74 | // It includes framework libraries and depends on the ART config. | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 75 | frameworkCfg := bootImageConfig{ | 
| Nicolas Geoffray | b9a46fb | 2022-03-14 15:31:47 +0000 | [diff] [blame] | 76 | name:                 frameworkBootImageName, | 
| Jiakai Zhang | b879620 | 2023-03-06 19:16:48 +0000 | [diff] [blame] | 77 | stem:                 bootImageStem, | 
| Jiakai Zhang | 09d88df | 2023-05-10 17:04:53 +0100 | [diff] [blame] | 78 | installDir:           frameworkSubdir, | 
| Nicolas Geoffray | b9a46fb | 2022-03-14 15:31:47 +0000 | [diff] [blame] | 79 | modules:              frameworkModules, | 
|  | 80 | preloadedClassesFile: "frameworks/base/config/preloaded-classes", | 
| Jiakai Zhang | 8e9ea8b | 2023-02-23 17:50:46 +0000 | [diff] [blame] | 81 | compilerFilter:       "speed-profile", | 
| Jiakai Zhang | b879620 | 2023-03-06 19:16:48 +0000 | [diff] [blame] | 82 | singleImage:          false, | 
| Jiakai Zhang | c08c162 | 2023-05-10 18:38:34 +0100 | [diff] [blame] | 83 | profileImports:       []*bootImageConfig{&artCfg}, | 
| Jiakai Zhang | b879620 | 2023-03-06 19:16:48 +0000 | [diff] [blame] | 84 | } | 
|  | 85 |  | 
|  | 86 | mainlineCfg := bootImageConfig{ | 
| Jiakai Zhang | 09d88df | 2023-05-10 17:04:53 +0100 | [diff] [blame] | 87 | extends:        &frameworkCfg, | 
|  | 88 | name:           mainlineBootImageName, | 
|  | 89 | stem:           bootImageStem, | 
|  | 90 | installDir:     frameworkSubdir, | 
|  | 91 | modules:        mainlineBcpModules, | 
|  | 92 | compilerFilter: "verify", | 
|  | 93 | singleImage:    true, | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 94 | } | 
|  | 95 |  | 
| Jiakai Zhang | 6decef9 | 2022-01-12 17:56:19 +0000 | [diff] [blame] | 96 | return map[string]*bootImageConfig{ | 
| Ulya Trafimovich | 4cdada2 | 2020-02-10 15:29:28 +0000 | [diff] [blame] | 97 | artBootImageName:       &artCfg, | 
|  | 98 | frameworkBootImageName: &frameworkCfg, | 
| Jiakai Zhang | b879620 | 2023-03-06 19:16:48 +0000 | [diff] [blame] | 99 | mainlineBootImageName:  &mainlineCfg, | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 100 | } | 
| Jiakai Zhang | 6decef9 | 2022-01-12 17:56:19 +0000 | [diff] [blame] | 101 | }).(map[string]*bootImageConfig) | 
|  | 102 | } | 
|  | 103 |  | 
|  | 104 | // Construct the global boot image configs. | 
|  | 105 | func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig { | 
|  | 106 | return ctx.Config().Once(bootImageConfigKey, func() interface{} { | 
|  | 107 | targets := dexpreoptTargets(ctx) | 
| Jiakai Zhang | b1639db | 2023-07-11 15:03:13 +0100 | [diff] [blame] | 108 | deviceDir := android.PathForOutput(ctx, getDexpreoptDirName(ctx)) | 
| Jiakai Zhang | 6decef9 | 2022-01-12 17:56:19 +0000 | [diff] [blame] | 109 |  | 
|  | 110 | configs := genBootImageConfigRaw(ctx) | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 111 |  | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 112 | for _, c := range configs { | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 113 | c.dir = deviceDir.Join(ctx, "dex_"+c.name+"jars") | 
|  | 114 | c.symbolsDir = deviceDir.Join(ctx, "dex_"+c.name+"jars_unstripped") | 
|  | 115 |  | 
|  | 116 | // expands to <stem>.art for primary image and <stem>-<1st module>.art for extension | 
| Ulya Trafimovich | 8640ab9 | 2020-05-11 18:06:15 +0100 | [diff] [blame] | 117 | imageName := c.firstModuleNameOrStem(ctx) + ".art" | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 118 |  | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 119 | // The path to bootclasspath dex files needs to be known at module | 
|  | 120 | // GenerateAndroidBuildAction time, before the bootclasspath modules have been compiled. | 
|  | 121 | // Set up known paths for them, the singleton rules will copy them there. | 
|  | 122 | // TODO(b/143682396): use module dependencies instead | 
|  | 123 | inputDir := deviceDir.Join(ctx, "dex_"+c.name+"jars_input") | 
| Ulya Trafimovich | 249386a | 2020-07-01 14:31:13 +0100 | [diff] [blame] | 124 | c.dexPaths = c.modules.BuildPaths(ctx, inputDir) | 
| Paul Duffin | 5f148ca | 2021-06-02 17:24:22 +0100 | [diff] [blame] | 125 | c.dexPathsByModule = c.modules.BuildPathsByModule(ctx, inputDir) | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 126 | c.dexPathsDeps = c.dexPaths | 
|  | 127 |  | 
| David Srbecky | c177ebe | 2020-02-18 20:43:06 +0000 | [diff] [blame] | 128 | // Create target-specific variants. | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 129 | for _, target := range targets { | 
|  | 130 | arch := target.Arch.ArchType | 
| Jiakai Zhang | 09d88df | 2023-05-10 17:04:53 +0100 | [diff] [blame] | 131 | imageDir := c.dir.Join(ctx, target.Os.String(), c.installDir, arch.String()) | 
| David Srbecky | c177ebe | 2020-02-18 20:43:06 +0000 | [diff] [blame] | 132 | variant := &bootImageVariant{ | 
| Jeongik Cha | 4dda75e | 2021-04-27 23:56:44 +0900 | [diff] [blame] | 133 | bootImageConfig:   c, | 
|  | 134 | target:            target, | 
|  | 135 | imagePathOnHost:   imageDir.Join(ctx, imageName), | 
| Jiakai Zhang | 09d88df | 2023-05-10 17:04:53 +0100 | [diff] [blame] | 136 | imagePathOnDevice: filepath.Join("/", c.installDir, arch.String(), imageName), | 
| Jeongik Cha | 4dda75e | 2021-04-27 23:56:44 +0900 | [diff] [blame] | 137 | imagesDeps:        c.moduleFiles(ctx, imageDir, ".art", ".oat", ".vdex"), | 
|  | 138 | dexLocations:      c.modules.DevicePaths(ctx.Config(), target.Os), | 
| David Srbecky | ab99498 | 2020-03-30 17:24:13 +0100 | [diff] [blame] | 139 | } | 
|  | 140 | variant.dexLocationsDeps = variant.dexLocations | 
| David Srbecky | c177ebe | 2020-02-18 20:43:06 +0000 | [diff] [blame] | 141 | c.variants = append(c.variants, variant) | 
| Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 142 | } | 
| Colin Cross | 31bf00d | 2019-12-04 13:16:01 -0800 | [diff] [blame] | 143 |  | 
|  | 144 | c.zip = c.dir.Join(ctx, c.name+".zip") | 
| Nicolas Geoffray | feef2ef | 2019-04-30 09:43:22 +0100 | [diff] [blame] | 145 | } | 
|  | 146 |  | 
| Jiakai Zhang | 8fe3a41 | 2023-02-23 17:37:16 +0000 | [diff] [blame] | 147 | visited := make(map[string]bool) | 
|  | 148 | for _, c := range configs { | 
|  | 149 | calculateDepsRecursive(c, targets, visited) | 
| David Srbecky | c177ebe | 2020-02-18 20:43:06 +0000 | [diff] [blame] | 150 | } | 
| Ulyana Trafimovich | 5a4ccd1 | 2019-12-18 17:32:33 +0000 | [diff] [blame] | 151 |  | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 152 | return configs | 
|  | 153 | }).(map[string]*bootImageConfig) | 
| Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 154 | } | 
|  | 155 |  | 
| Jiakai Zhang | 8fe3a41 | 2023-02-23 17:37:16 +0000 | [diff] [blame] | 156 | // calculateDepsRecursive calculates the dependencies of the given boot image config and all its | 
|  | 157 | // ancestors, if they are not visited. | 
|  | 158 | // The boot images are supposed to form a tree, where the root is the primary boot image. We do not | 
|  | 159 | // expect loops (e.g., A extends B, B extends C, C extends A), and we let them crash soong with a | 
|  | 160 | // stack overflow. | 
|  | 161 | // Note that a boot image config only has a pointer to the parent, not to children. Therefore, we | 
|  | 162 | // first go up through the parent chain, and then go back down to visit every code along the path. | 
|  | 163 | // `visited` is a map where a key is a boot image name and the value indicates whether the boot | 
|  | 164 | // image config is visited. The boot image names are guaranteed to be unique because they come from | 
|  | 165 | // `genBootImageConfigRaw` above, which also returns a map and would fail in the first place if the | 
|  | 166 | // names were not unique. | 
|  | 167 | func calculateDepsRecursive(c *bootImageConfig, targets []android.Target, visited map[string]bool) { | 
|  | 168 | if c.extends == nil || visited[c.name] { | 
|  | 169 | return | 
|  | 170 | } | 
|  | 171 | if c.extends.extends != nil { | 
|  | 172 | calculateDepsRecursive(c.extends, targets, visited) | 
|  | 173 | } | 
|  | 174 | visited[c.name] = true | 
|  | 175 | c.dexPathsDeps = android.Concat(c.extends.dexPathsDeps, c.dexPathsDeps) | 
|  | 176 | for i := range targets { | 
|  | 177 | c.variants[i].baseImages = android.Concat(c.extends.variants[i].baseImages, android.OutputPaths{c.extends.variants[i].imagePathOnHost}) | 
|  | 178 | c.variants[i].baseImagesDeps = android.Concat(c.extends.variants[i].baseImagesDeps, c.extends.variants[i].imagesDeps.Paths()) | 
|  | 179 | c.variants[i].dexLocationsDeps = android.Concat(c.extends.variants[i].dexLocationsDeps, c.variants[i].dexLocationsDeps) | 
|  | 180 | } | 
|  | 181 | } | 
|  | 182 |  | 
| David Srbecky | c177ebe | 2020-02-18 20:43:06 +0000 | [diff] [blame] | 183 | func artBootImageConfig(ctx android.PathContext) *bootImageConfig { | 
|  | 184 | return genBootImageConfigs(ctx)[artBootImageName] | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 185 | } | 
|  | 186 |  | 
| David Srbecky | c177ebe | 2020-02-18 20:43:06 +0000 | [diff] [blame] | 187 | func defaultBootImageConfig(ctx android.PathContext) *bootImageConfig { | 
|  | 188 | return genBootImageConfigs(ctx)[frameworkBootImageName] | 
| Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 189 | } | 
|  | 190 |  | 
| Jiakai Zhang | b879620 | 2023-03-06 19:16:48 +0000 | [diff] [blame] | 191 | func mainlineBootImageConfig(ctx android.PathContext) *bootImageConfig { | 
|  | 192 | return genBootImageConfigs(ctx)[mainlineBootImageName] | 
|  | 193 | } | 
|  | 194 |  | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 195 | // Apex boot config allows to access build/install paths of apex boot jars without going | 
| Ulya Trafimovich | 9023b02 | 2021-03-22 16:02:28 +0000 | [diff] [blame] | 196 | // through the usual trouble of registering dependencies on those modules and extracting build paths | 
|  | 197 | // from those dependencies. | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 198 | type apexBootConfig struct { | 
|  | 199 | // A list of apex boot jars. | 
| Ulya Trafimovich | 9023b02 | 2021-03-22 16:02:28 +0000 | [diff] [blame] | 200 | modules android.ConfiguredJarList | 
|  | 201 |  | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 202 | // A list of predefined build paths to apex boot jars. They are configured very early, | 
| Ulya Trafimovich | 9023b02 | 2021-03-22 16:02:28 +0000 | [diff] [blame] | 203 | // before the modules for these jars are processed and the actual paths are generated, and | 
|  | 204 | // later on a singleton adds commands to copy actual jars to the predefined paths. | 
|  | 205 | dexPaths android.WritablePaths | 
|  | 206 |  | 
| Paul Duffin | 5f148ca | 2021-06-02 17:24:22 +0100 | [diff] [blame] | 207 | // Map from module name (without prebuilt_ prefix) to the predefined build path. | 
|  | 208 | dexPathsByModule map[string]android.WritablePath | 
|  | 209 |  | 
| Ulya Trafimovich | 9023b02 | 2021-03-22 16:02:28 +0000 | [diff] [blame] | 210 | // A list of dex locations (a.k.a. on-device paths) to the boot jars. | 
|  | 211 | dexLocations []string | 
|  | 212 | } | 
|  | 213 |  | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 214 | var updatableBootConfigKey = android.NewOnceKey("apexBootConfig") | 
| Ulya Trafimovich | 9023b02 | 2021-03-22 16:02:28 +0000 | [diff] [blame] | 215 |  | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 216 | // Returns apex boot config. | 
|  | 217 | func GetApexBootConfig(ctx android.PathContext) apexBootConfig { | 
| Ulya Trafimovich | 9023b02 | 2021-03-22 16:02:28 +0000 | [diff] [blame] | 218 | return ctx.Config().Once(updatableBootConfigKey, func() interface{} { | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 219 | apexBootJars := dexpreopt.GetGlobalConfig(ctx).ApexBootJars | 
| Jiakai Zhang | b1639db | 2023-07-11 15:03:13 +0100 | [diff] [blame] | 220 | dir := android.PathForOutput(ctx, getDexpreoptDirName(ctx), "apex_bootjars") | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 221 | dexPaths := apexBootJars.BuildPaths(ctx, dir) | 
|  | 222 | dexPathsByModuleName := apexBootJars.BuildPathsByModule(ctx, dir) | 
| Ulya Trafimovich | 9023b02 | 2021-03-22 16:02:28 +0000 | [diff] [blame] | 223 |  | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 224 | dexLocations := apexBootJars.DevicePaths(ctx.Config(), android.Android) | 
| Ulya Trafimovich | 9023b02 | 2021-03-22 16:02:28 +0000 | [diff] [blame] | 225 |  | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 226 | return apexBootConfig{apexBootJars, dexPaths, dexPathsByModuleName, dexLocations} | 
|  | 227 | }).(apexBootConfig) | 
| Ulya Trafimovich | 9023b02 | 2021-03-22 16:02:28 +0000 | [diff] [blame] | 228 | } | 
|  | 229 |  | 
|  | 230 | // Returns a list of paths and a list of locations for the boot jars used in dexpreopt (to be | 
|  | 231 | // passed in -Xbootclasspath and -Xbootclasspath-locations arguments for dex2oat). | 
|  | 232 | func bcpForDexpreopt(ctx android.PathContext, withUpdatable bool) (android.WritablePaths, []string) { | 
|  | 233 | // Non-updatable boot jars (they are used both in the boot image and in dexpreopt). | 
|  | 234 | bootImage := defaultBootImageConfig(ctx) | 
|  | 235 | dexPaths := bootImage.dexPathsDeps | 
|  | 236 | // The dex locations for all Android variants are identical. | 
|  | 237 | dexLocations := bootImage.getAnyAndroidVariant().dexLocationsDeps | 
|  | 238 |  | 
|  | 239 | if withUpdatable { | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 240 | // Apex boot jars (they are used only in dexpreopt, but not in the boot image). | 
|  | 241 | apexBootConfig := GetApexBootConfig(ctx) | 
|  | 242 | dexPaths = append(dexPaths, apexBootConfig.dexPaths...) | 
|  | 243 | dexLocations = append(dexLocations, apexBootConfig.dexLocations...) | 
| Ulya Trafimovich | 9023b02 | 2021-03-22 16:02:28 +0000 | [diff] [blame] | 244 | } | 
|  | 245 |  | 
|  | 246 | return dexPaths, dexLocations | 
|  | 247 | } | 
|  | 248 |  | 
| Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 249 | var defaultBootclasspathKey = android.NewOnceKey("defaultBootclasspath") | 
|  | 250 |  | 
| Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 251 | func init() { | 
|  | 252 | android.RegisterMakeVarsProvider(pctx, dexpreoptConfigMakevars) | 
|  | 253 | } | 
|  | 254 |  | 
|  | 255 | func dexpreoptConfigMakevars(ctx android.MakeVarsContext) { | 
| Ulya Trafimovich | 249386a | 2020-07-01 14:31:13 +0100 | [diff] [blame] | 256 | ctx.Strict("DEXPREOPT_BOOT_JARS_MODULES", strings.Join(defaultBootImageConfig(ctx).modules.CopyOfApexJarPairs(), ":")) | 
| Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 257 | } | 
| Jeongik Cha | 4753b39 | 2023-04-19 23:25:41 +0900 | [diff] [blame] | 258 |  | 
| Jiakai Zhang | b1639db | 2023-07-11 15:03:13 +0100 | [diff] [blame] | 259 | func getDexpreoptDirName(ctx android.PathContext) string { | 
|  | 260 | prefix := "dexpreopt_" | 
|  | 261 | targets := ctx.Config().Targets[android.Android] | 
|  | 262 | if len(targets) > 0 { | 
|  | 263 | return prefix+targets[0].Arch.ArchType.String() | 
|  | 264 | } | 
|  | 265 | return prefix+"unknown_target" | 
| Jeongik Cha | 4753b39 | 2023-04-19 23:25:41 +0900 | [diff] [blame] | 266 | } |