Loading android/arch.go +19 −0 Original line number Diff line number Diff line Loading @@ -15,9 +15,11 @@ package android import ( "encoding" "fmt" "reflect" "runtime" "strconv" "strings" "github.com/google/blueprint/proptools" Loading Loading @@ -369,6 +371,23 @@ func (a ArchType) String() string { return a.Name } var _ encoding.TextMarshaler = ArchType{} func (a ArchType) MarshalText() ([]byte, error) { return []byte(strconv.Quote(a.String())), nil } var _ encoding.TextUnmarshaler = &ArchType{} func (a *ArchType) UnmarshalText(text []byte) error { if u, ok := archTypeMap[string(text)]; ok { *a = u return nil } return fmt.Errorf("unknown ArchType %q", text) } var BuildOs = func() OsType { switch runtime.GOOS { case "linux": Loading dexpreopt/config.go +6 −4 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 } Loading Loading @@ -103,7 +105,7 @@ type ModuleConfig struct { UsesLibraries []string LibraryPaths map[string]string Archs []string Archs []android.ArchType DexPreoptImages []string PreoptExtractedApk bool // Overrides OnlyPreoptModules Loading dexpreopt/dexpreopt.go +7 −7 Original line number Diff line number Diff line Loading @@ -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) } } } Loading Loading @@ -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) Loading @@ -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")) } Loading Loading @@ -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"). Loading Loading @@ -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)) } Loading dexpreopt/dexpreopt_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -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, Loading java/dexpreopt.go +3 −3 Original line number Diff line number Diff line Loading @@ -100,14 +100,14 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo return dexpreopt.GlobalConfig{} }).(dexpreopt.GlobalConfig) var archs []string var archs []android.ArchType for _, a := range ctx.MultiTargets() { archs = append(archs, a.Arch.ArchType.String()) archs = append(archs, a.Arch.ArchType) } if len(archs) == 0 { // assume this is a java library, dexpreopt for all arches for now for _, target := range ctx.Config().Targets[android.Android] { archs = append(archs, target.Arch.ArchType.String()) archs = append(archs, target.Arch.ArchType) } if inList(ctx.ModuleName(), globalConfig.SystemServerJars) && !d.isSDKLibrary { // If the module is not an SDK library and it's a system server jar, only preopt the primary arch. Loading Loading
android/arch.go +19 −0 Original line number Diff line number Diff line Loading @@ -15,9 +15,11 @@ package android import ( "encoding" "fmt" "reflect" "runtime" "strconv" "strings" "github.com/google/blueprint/proptools" Loading Loading @@ -369,6 +371,23 @@ func (a ArchType) String() string { return a.Name } var _ encoding.TextMarshaler = ArchType{} func (a ArchType) MarshalText() ([]byte, error) { return []byte(strconv.Quote(a.String())), nil } var _ encoding.TextUnmarshaler = &ArchType{} func (a *ArchType) UnmarshalText(text []byte) error { if u, ok := archTypeMap[string(text)]; ok { *a = u return nil } return fmt.Errorf("unknown ArchType %q", text) } var BuildOs = func() OsType { switch runtime.GOOS { case "linux": Loading
dexpreopt/config.go +6 −4 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 } Loading Loading @@ -103,7 +105,7 @@ type ModuleConfig struct { UsesLibraries []string LibraryPaths map[string]string Archs []string Archs []android.ArchType DexPreoptImages []string PreoptExtractedApk bool // Overrides OnlyPreoptModules Loading
dexpreopt/dexpreopt.go +7 −7 Original line number Diff line number Diff line Loading @@ -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) } } } Loading Loading @@ -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) Loading @@ -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")) } Loading Loading @@ -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"). Loading Loading @@ -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)) } Loading
dexpreopt/dexpreopt_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -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, Loading
java/dexpreopt.go +3 −3 Original line number Diff line number Diff line Loading @@ -100,14 +100,14 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo return dexpreopt.GlobalConfig{} }).(dexpreopt.GlobalConfig) var archs []string var archs []android.ArchType for _, a := range ctx.MultiTargets() { archs = append(archs, a.Arch.ArchType.String()) archs = append(archs, a.Arch.ArchType) } if len(archs) == 0 { // assume this is a java library, dexpreopt for all arches for now for _, target := range ctx.Config().Targets[android.Android] { archs = append(archs, target.Arch.ArchType.String()) archs = append(archs, target.Arch.ArchType) } if inList(ctx.ModuleName(), globalConfig.SystemServerJars) && !d.isSDKLibrary { // If the module is not an SDK library and it's a system server jar, only preopt the primary arch. Loading