diff options
author | Colin Cross <ccross@android.com> | 2019-02-11 15:11:14 -0800 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2019-02-12 17:05:47 -0800 |
commit | 74ba962d29817be07507fbc8e549a9b31b1700a1 (patch) | |
tree | 390725df9c79d1c7fb57b7fee6db0c98b5107991 /dexpreopt | |
parent | 1cd8a5751086fc1cf10161f5529c728aace8e7ad (diff) | |
download | build_soong-74ba962d29817be07507fbc8e549a9b31b1700a1.tar.gz build_soong-74ba962d29817be07507fbc8e549a9b31b1700a1.tar.bz2 build_soong-74ba962d29817be07507fbc8e549a9b31b1700a1.zip |
Use ArchType in dexpreopt config
Make ArchType implement the encoding.TextMarshaller and
encoding.TextUnmarshaller interfaces so that it can be used
as a value in the dexpreopt config structs that are passed
through JSON files.
Test: m checkbuild
Change-Id: Ie4c12443e7ee5fe43f42d5403bcde12d62f617e2
Diffstat (limited to 'dexpreopt')
-rw-r--r-- | dexpreopt/config.go | 10 | ||||
-rw-r--r-- | dexpreopt/dexpreopt.go | 14 | ||||
-rw-r--r-- | dexpreopt/dexpreopt_test.go | 2 |
3 files changed, 14 insertions, 12 deletions
diff --git a/dexpreopt/config.go b/dexpreopt/config.go index 064992f1..8fef0109 100644 --- a/dexpreopt/config.go +++ b/dexpreopt/config.go @@ -17,6 +17,8 @@ package dexpreopt import ( "encoding/json" "io/ioutil" + + "android/soong/android" ) // GlobalConfig stores the configuration for dex preopting set by the product @@ -66,9 +68,9 @@ type GlobalConfig struct { EmptyDirectory string // path to an empty directory - DefaultDexPreoptImage map[string]string // default boot image location for each architecture - CpuVariant map[string]string // cpu variant for each architecture - InstructionSetFeatures map[string]string // instruction set for each architecture + DefaultDexPreoptImage map[android.ArchType]string // default boot image location for each architecture + CpuVariant map[android.ArchType]string // cpu variant for each architecture + InstructionSetFeatures map[android.ArchType]string // instruction set for each architecture Tools Tools // paths to tools possibly used by the generated commands } @@ -103,7 +105,7 @@ type ModuleConfig struct { UsesLibraries []string LibraryPaths map[string]string - Archs []string + Archs []android.ArchType DexPreoptImages []string PreoptExtractedApk bool // Overrides OnlyPreoptModules diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go index 660a6d04..cd931df9 100644 --- a/dexpreopt/dexpreopt.go +++ b/dexpreopt/dexpreopt.go @@ -115,7 +115,7 @@ func GenerateDexpreoptRule(global GlobalConfig, module ModuleConfig) (rule *andr for i, arch := range module.Archs { image := module.DexPreoptImages[i] - dexpreoptCommand(global, module, rule, profile, arch, image, appImage, generateDM) + dexpreoptCommand(global, module, rule, arch, profile, image, appImage, generateDM) } } } @@ -178,7 +178,7 @@ func profileCommand(global GlobalConfig, module ModuleConfig, rule *android.Rule } func dexpreoptCommand(global GlobalConfig, module ModuleConfig, rule *android.RuleBuilder, - profile, arch, bootImage string, appImage, generateDM bool) { + arch android.ArchType, profile, bootImage string, appImage, generateDM bool) { // HACK: make soname in Soong-generated .odex files match Make. base := filepath.Base(module.DexLocation) @@ -192,7 +192,7 @@ func dexpreoptCommand(global GlobalConfig, module ModuleConfig, rule *android.Ru return filepath.Join( filepath.Dir(path), "oat", - arch, + arch.String(), pathtools.ReplaceExtension(filepath.Base(path), "odex")) } @@ -328,7 +328,7 @@ func dexpreoptCommand(global GlobalConfig, module ModuleConfig, rule *android.Ru FlagWithOutput("--oat-file=", odexPath).ImplicitOutput(vdexPath). // Pass an empty directory, dex2oat shouldn't be reading arbitrary files FlagWithArg("--android-root=", global.EmptyDirectory). - FlagWithArg("--instruction-set=", arch). + FlagWithArg("--instruction-set=", arch.String()). FlagWithArg("--instruction-set-variant=", global.CpuVariant[arch]). FlagWithArg("--instruction-set-features=", global.InstructionSetFeatures[arch]). Flag("--no-generate-debug-info"). @@ -519,10 +519,10 @@ func odexOnSystemOther(module ModuleConfig, global GlobalConfig) bool { } // PathToLocation converts .../system/framework/arm64/boot.art to .../system/framework/boot.art -func PathToLocation(path, arch string) string { +func PathToLocation(path string, arch android.ArchType) string { pathArch := filepath.Base(filepath.Dir(path)) - if pathArch != arch { - panic(fmt.Errorf("last directory in %q must be %q", path, arch)) + if pathArch != arch.String() { + panic(fmt.Errorf("last directory in %q must be %q", path, arch.String())) } return filepath.Join(filepath.Dir(filepath.Dir(path)), filepath.Base(path)) } diff --git a/dexpreopt/dexpreopt_test.go b/dexpreopt/dexpreopt_test.go index bcfd73cf..be861901 100644 --- a/dexpreopt/dexpreopt_test.go +++ b/dexpreopt/dexpreopt_test.go @@ -76,7 +76,7 @@ var testModuleConfig = ModuleConfig{ OptionalUsesLibraries: nil, UsesLibraries: nil, LibraryPaths: nil, - Archs: []string{"arm"}, + Archs: []android.ArchType{android.Arm}, DexPreoptImages: []string{"system/framework/arm/boot.art"}, PreoptExtractedApk: false, NoCreateAppImage: false, |