blob: 7a404f5a694fb7bd8581d9b01098e467e1710c7e [file] [log] [blame]
Colin Cross43f08db2018-11-12 10:13:39 -08001// Copyright 2018 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
15package dexpreopt
16
17import (
18 "encoding/json"
Colin Cross69f59a32019-02-15 10:39:37 -080019 "strings"
Colin Cross74ba9622019-02-11 15:11:14 -080020
21 "android/soong/android"
Colin Cross43f08db2018-11-12 10:13:39 -080022)
23
Martin Stjernholmc52aaf12020-01-06 23:11:37 +000024// GlobalConfig stores the configuration for dex preopting. The fields are set
Martin Stjernholm75a48d82020-01-10 20:32:59 +000025// from product variables via dex_preopt_config.mk.
Colin Cross43f08db2018-11-12 10:13:39 -080026type GlobalConfig struct {
Colin Cross69f59a32019-02-15 10:39:37 -080027 DisablePreopt bool // disable preopt for all modules
Colin Cross43f08db2018-11-12 10:13:39 -080028 DisablePreoptModules []string // modules with preopt disabled by product-specific config
29
30 OnlyPreoptBootImageAndSystemServer bool // only preopt jars in the boot image or system server
31
Vladimir Marko40139d62020-02-06 15:14:29 +000032 UseArtImage bool // use the art image (use other boot class path dex files without image)
33
Colin Cross43f08db2018-11-12 10:13:39 -080034 HasSystemOther bool // store odex files that match PatternsOnSystemOther on the system_other partition
35 PatternsOnSystemOther []string // patterns (using '%' to denote a prefix match) to put odex on the system_other partition
36
Colin Cross69f59a32019-02-15 10:39:37 -080037 DisableGenerateProfile bool // don't generate profiles
38 ProfileDir string // directory to find profiles in
Colin Cross43f08db2018-11-12 10:13:39 -080039
Roshan Piusccc26ef2019-11-27 09:37:46 -080040 BootJars []string // modules for jars that form the boot class path
41 UpdatableBootJars []string // jars within apex that form the boot class path
Vladimir Markod2ee5322018-12-19 17:57:57 +000042
Ulya Trafimovich4d2eeed2019-11-08 10:54:21 +000043 ArtApexJars []string // modules for jars that are in the ART APEX
Colin Cross800fe132019-02-11 14:21:24 -080044
Roshan Pius9b51a402019-11-21 12:36:53 -080045 SystemServerJars []string // jars that form the system server
46 SystemServerApps []string // apps that are loaded into system server
47 UpdatableSystemServerJars []string // jars within apex that are loaded into system server
48 SpeedApps []string // apps that should be speed optimized
Colin Cross43f08db2018-11-12 10:13:39 -080049
50 PreoptFlags []string // global dex2oat flags that should be used if no module-specific dex2oat flags are specified
51
52 DefaultCompilerFilter string // default compiler filter to pass to dex2oat, overridden by --compiler-filter= in module-specific dex2oat flags
53 SystemServerCompilerFilter string // default compiler filter to pass to dex2oat for system server jars
54
Nicolas Geoffrayc1bf7242019-10-18 14:51:38 +010055 GenerateDMFiles bool // generate Dex Metadata files
Colin Cross43f08db2018-11-12 10:13:39 -080056
57 NoDebugInfo bool // don't generate debug info by default
Mathieu Chartier3f7ddbb2019-04-29 09:33:50 -070058 DontResolveStartupStrings bool // don't resolve string literals loaded during application startup.
Colin Cross43f08db2018-11-12 10:13:39 -080059 AlwaysSystemServerDebugInfo bool // always generate mini debug info for system server modules (overrides NoDebugInfo=true)
60 NeverSystemServerDebugInfo bool // never generate mini debug info for system server modules (overrides NoDebugInfo=false)
61 AlwaysOtherDebugInfo bool // always generate mini debug info for non-system server modules (overrides NoDebugInfo=true)
62 NeverOtherDebugInfo bool // never generate mini debug info for non-system server modules (overrides NoDebugInfo=true)
63
Colin Cross43f08db2018-11-12 10:13:39 -080064 IsEng bool // build is a eng variant
65 SanitizeLite bool // build is the second phase of a SANITIZE_LITE build
66
67 DefaultAppImages bool // build app images (TODO: .art files?) by default
68
Colin Cross800fe132019-02-11 14:21:24 -080069 Dex2oatXmx string // max heap size for dex2oat
70 Dex2oatXms string // initial heap size for dex2oat
Colin Cross43f08db2018-11-12 10:13:39 -080071
72 EmptyDirectory string // path to an empty directory
73
Colin Cross74ba9622019-02-11 15:11:14 -080074 CpuVariant map[android.ArchType]string // cpu variant for each architecture
75 InstructionSetFeatures map[android.ArchType]string // instruction set for each architecture
Colin Cross43f08db2018-11-12 10:13:39 -080076
Colin Cross800fe132019-02-11 14:21:24 -080077 // Only used for boot image
Mathieu Chartier6adeee12019-06-26 10:01:36 -070078 DirtyImageObjects android.OptionalPath // path to a dirty-image-objects file
79 BootImageProfiles android.Paths // path to a boot-image-profile.txt file
80 BootFlags string // extra flags to pass to dex2oat for the boot image
81 Dex2oatImageXmx string // max heap size for dex2oat for the boot image
82 Dex2oatImageXms string // initial heap size for dex2oat for the boot image
Colin Cross43f08db2018-11-12 10:13:39 -080083}
84
Martin Stjernholmc52aaf12020-01-06 23:11:37 +000085// GlobalSoongConfig contains the global config that is generated from Soong,
86// stored in dexpreopt_soong.config.
87type GlobalSoongConfig struct {
88 // Paths to tools possibly used by the generated commands.
89 Profman android.Path
90 Dex2oat android.Path
91 Aapt android.Path
92 SoongZip android.Path
93 Zip2zip android.Path
94 ManifestCheck android.Path
Colin Cross38b96852019-05-22 10:21:09 -070095 ConstructContext android.Path
Colin Cross43f08db2018-11-12 10:13:39 -080096}
97
98type ModuleConfig struct {
Victor Hsiehd181c8b2019-01-29 13:00:33 -080099 Name string
100 DexLocation string // dex location on device
Colin Cross69f59a32019-02-15 10:39:37 -0800101 BuildPath android.OutputPath
102 DexPath android.Path
Colin Cross38b96852019-05-22 10:21:09 -0700103 ManifestPath android.Path
Victor Hsiehd181c8b2019-01-29 13:00:33 -0800104 UncompressedDex bool
105 HasApkLibraries bool
106 PreoptFlags []string
Colin Cross43f08db2018-11-12 10:13:39 -0800107
Colin Cross69f59a32019-02-15 10:39:37 -0800108 ProfileClassListing android.OptionalPath
Colin Cross43f08db2018-11-12 10:13:39 -0800109 ProfileIsTextListing bool
Nicolas Geoffraye7102422019-07-24 13:19:29 +0100110 ProfileBootListing android.OptionalPath
Colin Cross43f08db2018-11-12 10:13:39 -0800111
Colin Cross50ddcc42019-05-16 12:28:22 -0700112 EnforceUsesLibraries bool
113 PresentOptionalUsesLibraries []string
114 UsesLibraries []string
115 LibraryPaths map[string]android.Path
Colin Cross43f08db2018-11-12 10:13:39 -0800116
Ulya Trafimovich4d2eeed2019-11-08 10:54:21 +0000117 Archs []android.ArchType
118 DexPreoptImages []android.Path
119 DexPreoptImagesDeps []android.OutputPaths
120 DexPreoptImageLocations []string
Colin Cross43f08db2018-11-12 10:13:39 -0800121
Colin Cross69f59a32019-02-15 10:39:37 -0800122 PreoptBootClassPathDexFiles android.Paths // file paths of boot class path files
123 PreoptBootClassPathDexLocations []string // virtual locations of boot class path files
Colin Cross800fe132019-02-11 14:21:24 -0800124
Colin Cross43f08db2018-11-12 10:13:39 -0800125 PreoptExtractedApk bool // Overrides OnlyPreoptModules
126
127 NoCreateAppImage bool
128 ForceCreateAppImage bool
129
130 PresignedPrebuilt bool
Colin Cross43f08db2018-11-12 10:13:39 -0800131}
132
Martin Stjernholmc52aaf12020-01-06 23:11:37 +0000133type globalSoongConfigSingleton struct{}
134
135var pctx = android.NewPackageContext("android/soong/dexpreopt")
136
137func init() {
138 pctx.Import("android/soong/android")
139 android.RegisterSingletonType("dexpreopt-soong-config", func() android.Singleton {
140 return &globalSoongConfigSingleton{}
141 })
142}
143
Colin Cross69f59a32019-02-15 10:39:37 -0800144func constructPath(ctx android.PathContext, path string) android.Path {
145 buildDirPrefix := ctx.Config().BuildDir() + "/"
146 if path == "" {
147 return nil
148 } else if strings.HasPrefix(path, buildDirPrefix) {
149 return android.PathForOutput(ctx, strings.TrimPrefix(path, buildDirPrefix))
150 } else {
151 return android.PathForSource(ctx, path)
152 }
Colin Cross43f08db2018-11-12 10:13:39 -0800153}
154
Colin Cross69f59a32019-02-15 10:39:37 -0800155func constructPaths(ctx android.PathContext, paths []string) android.Paths {
156 var ret android.Paths
157 for _, path := range paths {
158 ret = append(ret, constructPath(ctx, path))
159 }
160 return ret
Colin Cross43f08db2018-11-12 10:13:39 -0800161}
162
Colin Cross69f59a32019-02-15 10:39:37 -0800163func constructPathMap(ctx android.PathContext, paths map[string]string) map[string]android.Path {
164 ret := map[string]android.Path{}
165 for key, path := range paths {
166 ret[key] = constructPath(ctx, path)
167 }
168 return ret
169}
170
171func constructWritablePath(ctx android.PathContext, path string) android.WritablePath {
172 if path == "" {
173 return nil
174 }
175 return constructPath(ctx, path).(android.WritablePath)
176}
177
Martin Stjernholm40f9f3c2020-01-20 18:12:23 +0000178// ParseGlobalConfig parses the given data assumed to be read from the global
179// dexpreopt.config file into a GlobalConfig struct.
180func ParseGlobalConfig(ctx android.PathContext, data []byte) (GlobalConfig, error) {
Colin Cross69f59a32019-02-15 10:39:37 -0800181 type GlobalJSONConfig struct {
182 GlobalConfig
183
184 // Copies of entries in GlobalConfig that are not constructable without extra parameters. They will be
185 // used to construct the real value manually below.
186 DirtyImageObjects string
Colin Cross69f59a32019-02-15 10:39:37 -0800187 BootImageProfiles []string
Colin Cross69f59a32019-02-15 10:39:37 -0800188 }
189
190 config := GlobalJSONConfig{}
Colin Cross988414c2020-01-11 01:11:46 +0000191 err := json.Unmarshal(data, &config)
Colin Cross69f59a32019-02-15 10:39:37 -0800192 if err != nil {
Colin Cross988414c2020-01-11 01:11:46 +0000193 return config.GlobalConfig, err
Colin Cross69f59a32019-02-15 10:39:37 -0800194 }
195
196 // Construct paths that require a PathContext.
197 config.GlobalConfig.DirtyImageObjects = android.OptionalPathForPath(constructPath(ctx, config.DirtyImageObjects))
Colin Cross69f59a32019-02-15 10:39:37 -0800198 config.GlobalConfig.BootImageProfiles = constructPaths(ctx, config.BootImageProfiles)
199
Colin Cross988414c2020-01-11 01:11:46 +0000200 return config.GlobalConfig, nil
Colin Cross69f59a32019-02-15 10:39:37 -0800201}
202
Martin Stjernholm40f9f3c2020-01-20 18:12:23 +0000203type globalConfigAndRaw struct {
204 global GlobalConfig
205 data []byte
206}
207
208// GetGlobalConfig returns the global dexpreopt.config that's created in the
209// make config phase. It is loaded once the first time it is called for any
210// ctx.Config(), and returns the same data for all future calls with the same
211// ctx.Config(). A value can be inserted for tests using
212// setDexpreoptTestGlobalConfig.
213func GetGlobalConfig(ctx android.PathContext) GlobalConfig {
214 return getGlobalConfigRaw(ctx).global
215}
216
217// GetGlobalConfigRawData is the same as GetGlobalConfig, except that it returns
218// the literal content of dexpreopt.config.
219func GetGlobalConfigRawData(ctx android.PathContext) []byte {
220 return getGlobalConfigRaw(ctx).data
221}
222
223var globalConfigOnceKey = android.NewOnceKey("DexpreoptGlobalConfig")
224var testGlobalConfigOnceKey = android.NewOnceKey("TestDexpreoptGlobalConfig")
225
226func getGlobalConfigRaw(ctx android.PathContext) globalConfigAndRaw {
227 return ctx.Config().Once(globalConfigOnceKey, func() interface{} {
228 if data, err := ctx.Config().DexpreoptGlobalConfig(ctx); err != nil {
229 panic(err)
230 } else if data != nil {
231 globalConfig, err := ParseGlobalConfig(ctx, data)
232 if err != nil {
233 panic(err)
234 }
235 return globalConfigAndRaw{globalConfig, data}
236 }
237
238 // No global config filename set, see if there is a test config set
239 return ctx.Config().Once(testGlobalConfigOnceKey, func() interface{} {
240 // Nope, return a config with preopting disabled
241 return globalConfigAndRaw{GlobalConfig{
242 DisablePreopt: true,
243 DisableGenerateProfile: true,
244 }, nil}
245 })
246 }).(globalConfigAndRaw)
247}
248
249// SetTestGlobalConfig sets a GlobalConfig that future calls to GetGlobalConfig
250// will return. It must be called before the first call to GetGlobalConfig for
251// the config.
252func SetTestGlobalConfig(config android.Config, globalConfig GlobalConfig) {
253 config.Once(testGlobalConfigOnceKey, func() interface{} { return globalConfigAndRaw{globalConfig, nil} })
254}
255
256// ParseModuleConfig parses a per-module dexpreopt.config file into a
257// ModuleConfig struct. It is not used in Soong, which receives a ModuleConfig
258// struct directly from java/dexpreopt.go. It is used in dexpreopt_gen called
259// from Make to read the module dexpreopt.config written in the Make config
260// stage.
261func ParseModuleConfig(ctx android.PathContext, data []byte) (ModuleConfig, error) {
Colin Cross69f59a32019-02-15 10:39:37 -0800262 type ModuleJSONConfig struct {
263 ModuleConfig
264
265 // Copies of entries in ModuleConfig that are not constructable without extra parameters. They will be
266 // used to construct the real value manually below.
267 BuildPath string
268 DexPath string
Colin Cross38b96852019-05-22 10:21:09 -0700269 ManifestPath string
Colin Cross69f59a32019-02-15 10:39:37 -0800270 ProfileClassListing string
271 LibraryPaths map[string]string
272 DexPreoptImages []string
Ulya Trafimovich4d2eeed2019-11-08 10:54:21 +0000273 DexPreoptImageLocations []string
Colin Cross69f59a32019-02-15 10:39:37 -0800274 PreoptBootClassPathDexFiles []string
Colin Cross69f59a32019-02-15 10:39:37 -0800275 }
276
277 config := ModuleJSONConfig{}
278
Colin Cross988414c2020-01-11 01:11:46 +0000279 err := json.Unmarshal(data, &config)
Colin Cross69f59a32019-02-15 10:39:37 -0800280 if err != nil {
281 return config.ModuleConfig, err
282 }
283
284 // Construct paths that require a PathContext.
285 config.ModuleConfig.BuildPath = constructPath(ctx, config.BuildPath).(android.OutputPath)
286 config.ModuleConfig.DexPath = constructPath(ctx, config.DexPath)
Colin Cross38b96852019-05-22 10:21:09 -0700287 config.ModuleConfig.ManifestPath = constructPath(ctx, config.ManifestPath)
Colin Cross69f59a32019-02-15 10:39:37 -0800288 config.ModuleConfig.ProfileClassListing = android.OptionalPathForPath(constructPath(ctx, config.ProfileClassListing))
289 config.ModuleConfig.LibraryPaths = constructPathMap(ctx, config.LibraryPaths)
290 config.ModuleConfig.DexPreoptImages = constructPaths(ctx, config.DexPreoptImages)
Ulya Trafimovich4d2eeed2019-11-08 10:54:21 +0000291 config.ModuleConfig.DexPreoptImageLocations = config.DexPreoptImageLocations
Colin Cross69f59a32019-02-15 10:39:37 -0800292 config.ModuleConfig.PreoptBootClassPathDexFiles = constructPaths(ctx, config.PreoptBootClassPathDexFiles)
Colin Cross69f59a32019-02-15 10:39:37 -0800293
Dan Willemsen0f416782019-06-13 21:44:53 +0000294 // This needs to exist, but dependencies are already handled in Make, so we don't need to pass them through JSON.
Ulya Trafimovich4d2eeed2019-11-08 10:54:21 +0000295 config.ModuleConfig.DexPreoptImagesDeps = make([]android.OutputPaths, len(config.ModuleConfig.DexPreoptImages))
Dan Willemsen0f416782019-06-13 21:44:53 +0000296
Colin Cross69f59a32019-02-15 10:39:37 -0800297 return config.ModuleConfig, nil
298}
299
Martin Stjernholm75a48d82020-01-10 20:32:59 +0000300// createGlobalSoongConfig creates a GlobalSoongConfig from the current context.
Martin Stjernholmc52aaf12020-01-06 23:11:37 +0000301// Should not be used in dexpreopt_gen.
Martin Stjernholm75a48d82020-01-10 20:32:59 +0000302func createGlobalSoongConfig(ctx android.ModuleContext) GlobalSoongConfig {
303 if ctx.Config().TestProductVariables != nil {
304 // If we're called in a test there'll be a confusing error from the path
305 // functions below that gets reported without a stack trace, so let's panic
306 // properly with a more helpful message.
307 panic("This should not be called from tests. Please call GlobalSoongConfigForTests somewhere in the test setup.")
308 }
309
Hans Boehm7b2e6f32020-01-25 01:44:30 +0000310 // Default to debug version to help find bugs.
311 // Set USE_DEX2OAT_DEBUG to false for only building non-debug versions.
312 var dex2oatBinary string
313 if ctx.Config().Getenv("USE_DEX2OAT_DEBUG") == "false" {
314 dex2oatBinary = "dex2oat"
315 } else {
316 dex2oatBinary = "dex2oatd"
317 }
318
Martin Stjernholmc52aaf12020-01-06 23:11:37 +0000319 return GlobalSoongConfig{
320 Profman: ctx.Config().HostToolPath(ctx, "profman"),
Hans Boehm7b2e6f32020-01-25 01:44:30 +0000321 Dex2oat: ctx.Config().HostToolPath(ctx, dex2oatBinary),
Martin Stjernholmc52aaf12020-01-06 23:11:37 +0000322 Aapt: ctx.Config().HostToolPath(ctx, "aapt"),
323 SoongZip: ctx.Config().HostToolPath(ctx, "soong_zip"),
324 Zip2zip: ctx.Config().HostToolPath(ctx, "zip2zip"),
325 ManifestCheck: ctx.Config().HostToolPath(ctx, "manifest_check"),
326 ConstructContext: android.PathForSource(ctx, "build/make/core/construct_context.sh"),
327 }
328}
329
Martin Stjernholm75a48d82020-01-10 20:32:59 +0000330var globalSoongConfigOnceKey = android.NewOnceKey("DexpreoptGlobalSoongConfig")
331
332// GetGlobalSoongConfig creates a GlobalSoongConfig the first time it's called,
333// and later returns the same cached instance.
334func GetGlobalSoongConfig(ctx android.ModuleContext) GlobalSoongConfig {
335 globalSoong := ctx.Config().Once(globalSoongConfigOnceKey, func() interface{} {
336 return createGlobalSoongConfig(ctx)
337 }).(GlobalSoongConfig)
338 return globalSoong
339}
340
341// GetCachedGlobalSoongConfig returns a cached GlobalSoongConfig created by an
342// earlier GetGlobalSoongConfig call. This function works with any context
343// compatible with a basic PathContext, since it doesn't try to create a
344// GlobalSoongConfig (which requires a full ModuleContext). It will panic if
345// called before the first GetGlobalSoongConfig call.
346func GetCachedGlobalSoongConfig(ctx android.PathContext) GlobalSoongConfig {
347 return ctx.Config().Get(globalSoongConfigOnceKey).(GlobalSoongConfig)
348}
349
Martin Stjernholmc52aaf12020-01-06 23:11:37 +0000350type globalJsonSoongConfig struct {
351 Profman string
352 Dex2oat string
353 Aapt string
354 SoongZip string
355 Zip2zip string
356 ManifestCheck string
357 ConstructContext string
358}
359
Martin Stjernholm40f9f3c2020-01-20 18:12:23 +0000360// ParseGlobalSoongConfig parses the given data assumed to be read from the
361// global dexpreopt_soong.config file into a GlobalSoongConfig struct. It is
362// only used in dexpreopt_gen.
363func ParseGlobalSoongConfig(ctx android.PathContext, data []byte) (GlobalSoongConfig, error) {
Martin Stjernholmc52aaf12020-01-06 23:11:37 +0000364 var jc globalJsonSoongConfig
365
Colin Cross988414c2020-01-11 01:11:46 +0000366 err := json.Unmarshal(data, &jc)
Martin Stjernholmc52aaf12020-01-06 23:11:37 +0000367 if err != nil {
368 return GlobalSoongConfig{}, err
369 }
370
371 config := GlobalSoongConfig{
372 Profman: constructPath(ctx, jc.Profman),
373 Dex2oat: constructPath(ctx, jc.Dex2oat),
374 Aapt: constructPath(ctx, jc.Aapt),
375 SoongZip: constructPath(ctx, jc.SoongZip),
376 Zip2zip: constructPath(ctx, jc.Zip2zip),
377 ManifestCheck: constructPath(ctx, jc.ManifestCheck),
378 ConstructContext: constructPath(ctx, jc.ConstructContext),
379 }
380
381 return config, nil
382}
383
384func (s *globalSoongConfigSingleton) GenerateBuildActions(ctx android.SingletonContext) {
Martin Stjernholm75a48d82020-01-10 20:32:59 +0000385 config := GetCachedGlobalSoongConfig(ctx)
Martin Stjernholmc52aaf12020-01-06 23:11:37 +0000386 jc := globalJsonSoongConfig{
387 Profman: config.Profman.String(),
388 Dex2oat: config.Dex2oat.String(),
389 Aapt: config.Aapt.String(),
390 SoongZip: config.SoongZip.String(),
391 Zip2zip: config.Zip2zip.String(),
392 ManifestCheck: config.ManifestCheck.String(),
393 ConstructContext: config.ConstructContext.String(),
394 }
395
396 data, err := json.Marshal(jc)
397 if err != nil {
398 ctx.Errorf("failed to JSON marshal GlobalSoongConfig: %v", err)
399 return
400 }
401
402 ctx.Build(pctx, android.BuildParams{
403 Rule: android.WriteFile,
404 Output: android.PathForOutput(ctx, "dexpreopt_soong.config"),
405 Args: map[string]string{
406 "content": string(data),
407 },
408 })
409}
410
411func (s *globalSoongConfigSingleton) MakeVars(ctx android.MakeVarsContext) {
Martin Stjernholm75a48d82020-01-10 20:32:59 +0000412 config := GetCachedGlobalSoongConfig(ctx)
Martin Stjernholmc52aaf12020-01-06 23:11:37 +0000413
414 ctx.Strict("DEX2OAT", config.Dex2oat.String())
415 ctx.Strict("DEXPREOPT_GEN_DEPS", strings.Join([]string{
416 config.Profman.String(),
417 config.Dex2oat.String(),
418 config.Aapt.String(),
419 config.SoongZip.String(),
420 config.Zip2zip.String(),
421 config.ManifestCheck.String(),
422 config.ConstructContext.String(),
423 }, " "))
424}
425
Colin Cross69f59a32019-02-15 10:39:37 -0800426func GlobalConfigForTests(ctx android.PathContext) GlobalConfig {
427 return GlobalConfig{
Colin Cross69f59a32019-02-15 10:39:37 -0800428 DisablePreopt: false,
429 DisablePreoptModules: nil,
430 OnlyPreoptBootImageAndSystemServer: false,
431 HasSystemOther: false,
432 PatternsOnSystemOther: nil,
433 DisableGenerateProfile: false,
434 ProfileDir: "",
435 BootJars: nil,
Roshan Piusccc26ef2019-11-27 09:37:46 -0800436 UpdatableBootJars: nil,
Martin Stjernholmcc4b0ad2019-07-05 22:38:25 +0100437 ArtApexJars: nil,
Colin Cross69f59a32019-02-15 10:39:37 -0800438 SystemServerJars: nil,
439 SystemServerApps: nil,
Roshan Pius9b51a402019-11-21 12:36:53 -0800440 UpdatableSystemServerJars: nil,
Colin Cross69f59a32019-02-15 10:39:37 -0800441 SpeedApps: nil,
442 PreoptFlags: nil,
443 DefaultCompilerFilter: "",
444 SystemServerCompilerFilter: "",
445 GenerateDMFiles: false,
Colin Cross69f59a32019-02-15 10:39:37 -0800446 NoDebugInfo: false,
Mathieu Chartier3f7ddbb2019-04-29 09:33:50 -0700447 DontResolveStartupStrings: false,
Colin Cross69f59a32019-02-15 10:39:37 -0800448 AlwaysSystemServerDebugInfo: false,
449 NeverSystemServerDebugInfo: false,
450 AlwaysOtherDebugInfo: false,
451 NeverOtherDebugInfo: false,
Colin Cross69f59a32019-02-15 10:39:37 -0800452 IsEng: false,
453 SanitizeLite: false,
454 DefaultAppImages: false,
455 Dex2oatXmx: "",
456 Dex2oatXms: "",
457 EmptyDirectory: "empty_dir",
458 CpuVariant: nil,
459 InstructionSetFeatures: nil,
460 DirtyImageObjects: android.OptionalPath{},
Colin Cross69f59a32019-02-15 10:39:37 -0800461 BootImageProfiles: nil,
Colin Cross69f59a32019-02-15 10:39:37 -0800462 BootFlags: "",
463 Dex2oatImageXmx: "",
464 Dex2oatImageXms: "",
Martin Stjernholm75a48d82020-01-10 20:32:59 +0000465 }
466}
467
468func GlobalSoongConfigForTests(config android.Config) GlobalSoongConfig {
469 // Install the test GlobalSoongConfig in the Once cache so that later calls to
470 // Get(Cached)GlobalSoongConfig returns it without trying to create a real one.
471 return config.Once(globalSoongConfigOnceKey, func() interface{} {
472 return GlobalSoongConfig{
Colin Cross38b96852019-05-22 10:21:09 -0700473 Profman: android.PathForTesting("profman"),
474 Dex2oat: android.PathForTesting("dex2oat"),
475 Aapt: android.PathForTesting("aapt"),
476 SoongZip: android.PathForTesting("soong_zip"),
477 Zip2zip: android.PathForTesting("zip2zip"),
478 ManifestCheck: android.PathForTesting("manifest_check"),
479 ConstructContext: android.PathForTesting("construct_context.sh"),
Martin Stjernholm75a48d82020-01-10 20:32:59 +0000480 }
481 }).(GlobalSoongConfig)
Colin Cross69f59a32019-02-15 10:39:37 -0800482}