From f75c415810c29a4edb6ae0364473ad3feb161f79 Mon Sep 17 00:00:00 2001 From: Inseob Kim Date: Mon, 14 Jun 2021 12:03:51 +0900 Subject: [PATCH 1/5] Add install_in_root to cc_binary To support init_first_stage, install_in_root property is added to cc_binary. The output is installed to {partition}, rather than {partition}/{mount_point}/bin. Bug: 187196593 Test: build init_first_stage Change-Id: Ibc351645308676ed188f748972eb6312c9cbd64f Merged-In: Ibc351645308676ed188f748972eb6312c9cbd64f --- android/neverallow.go | 10 ++++++++++ cc/cc.go | 5 +++++ cc/installer.go | 13 +++++++++++++ 3 files changed, 28 insertions(+) diff --git a/android/neverallow.go b/android/neverallow.go index 41b399a70..19b58a775 100644 --- a/android/neverallow.go +++ b/android/neverallow.go @@ -55,6 +55,7 @@ func init() { AddNeverAllowRules(createCcSdkVariantRules()...) AddNeverAllowRules(createUncompressDexRules()...) AddNeverAllowRules(createMakefileGoalRules()...) + AddNeverAllowRules(createInitFirstStageRules()...) } // Add a NeverAllow rule to the set of rules to apply. @@ -216,6 +217,15 @@ func createMakefileGoalRules() []Rule { } } +func createInitFirstStageRules() []Rule { + return []Rule{ + NeverAllow(). + Without("name", "init_first_stage"). + With("install_in_root", "true"). + Because("install_in_root is only for init_first_stage."), + } +} + func neverallowMutator(ctx BottomUpMutatorContext) { m, ok := ctx.Module().(Module) if !ok { diff --git a/cc/cc.go b/cc/cc.go index be2c0a39a..89c4fc38e 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -580,6 +580,7 @@ type installer interface { hostToolPath() android.OptionalPath relativeInstallPath() string makeUninstallable(mod *Module) + installInRoot() bool } // bazelHandler is the interface for a helper object related to deferring to Bazel for @@ -1306,6 +1307,10 @@ func (c *Module) isCfiAssemblySupportEnabled() bool { Bool(c.sanitize.Properties.Sanitize.Config.Cfi_assembly_support) } +func (c *Module) InstallInRoot() bool { + return c.installer != nil && c.installer.installInRoot() +} + type baseModuleContext struct { android.BaseModuleContext moduleContextImpl diff --git a/cc/installer.go b/cc/installer.go index e551c63e2..f95b49346 100644 --- a/cc/installer.go +++ b/cc/installer.go @@ -25,6 +25,10 @@ import ( type InstallerProperties struct { // install to a subdirectory of the default install path for the module Relative_install_path *string `android:"arch_variant"` + + // Install output directly in {partition}/, not in any subdir. This is only intended for use by + // init_first_stage. + Install_in_root *bool `android:"arch_variant"` } type installLocation int @@ -66,6 +70,11 @@ func (installer *baseInstaller) installDir(ctx ModuleContext) android.InstallPat if ctx.toolchain().Is64Bit() && installer.dir64 != "" { dir = installer.dir64 } + + if installer.installInRoot() { + dir = "" + } + if ctx.Target().NativeBridge == android.NativeBridgeEnabled { dir = filepath.Join(dir, ctx.Target().NativeBridgeRelativePath) } else if !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) { @@ -110,3 +119,7 @@ func (installer *baseInstaller) relativeInstallPath() string { func (installer *baseInstaller) makeUninstallable(mod *Module) { mod.ModuleBase.MakeUninstallable() } + +func (installer *baseInstaller) installInRoot() bool { + return Bool(installer.Properties.Install_in_root) +} From edca3f43234944110c6ff8a53091ee10d62850a9 Mon Sep 17 00:00:00 2001 From: Inseob Kim Date: Mon, 14 Jun 2021 12:03:59 +0900 Subject: [PATCH 2/5] Add ramdisk_available to sysprop_library Bug: 187196593 Test: build Change-Id: Ib8d92904a9004ccbc18634a97f9d75c2093ac2ae Merged-In: Ib8d92904a9004ccbc18634a97f9d75c2093ac2ae --- sysprop/sysprop_library.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go index f1c2d0df0..a29d4c3ac 100644 --- a/sysprop/sysprop_library.go +++ b/sysprop/sysprop_library.go @@ -145,6 +145,9 @@ type syspropLibraryProperties struct { // If set to true, allow this module to be dexed and installed on devices. Installable *bool + // Make this module available when building for ramdisk + Ramdisk_available *bool + // Make this module available when building for recovery Recovery_available *bool @@ -396,6 +399,7 @@ type ccLibraryProperties struct { Recovery_available *bool Vendor_available *bool Product_available *bool + Ramdisk_available *bool Host_supported *bool Apex_available []string Min_sdk_version *string @@ -475,6 +479,7 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) { ccProps.Recovery_available = m.properties.Recovery_available ccProps.Vendor_available = m.properties.Vendor_available ccProps.Product_available = m.properties.Product_available + ccProps.Ramdisk_available = m.properties.Ramdisk_available ccProps.Host_supported = m.properties.Host_supported ccProps.Apex_available = m.ApexProperties.Apex_available ccProps.Min_sdk_version = m.properties.Cpp.Min_sdk_version From 8ddb08c8ec97b2fcd29bd5d8daf926a4a8ab7945 Mon Sep 17 00:00:00 2001 From: Inseob Kim Date: Thu, 17 Jun 2021 00:33:00 +0900 Subject: [PATCH 3/5] Fix ndk and aml arch order Some codes assume that the first arch is the primary arch. But ndk/aml arch order have been [arm, arm64, x86, x86_64]. This fixes the order to workaround possible breakage while building ndk. Bug: 187196593 Test: OUT_DIR=out build/soong/scripts/build-ndk-prebuilts.sh Change-Id: I33164a7e7c64a23f2cc1860acb24a2584f4dffad Merged-In: I33164a7e7c64a23f2cc1860acb24a2584f4dffad --- android/arch.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/android/arch.go b/android/arch.go index bb1b61366..84d1d59a0 100644 --- a/android/arch.go +++ b/android/arch.go @@ -1543,20 +1543,20 @@ type archConfig struct { // getNdkAbisConfig returns a list of archConfigs for the ABIs supported by the NDK. func getNdkAbisConfig() []archConfig { return []archConfig{ - {"arm", "armv7-a", "", []string{"armeabi-v7a"}}, {"arm64", "armv8-a-branchprot", "", []string{"arm64-v8a"}}, - {"x86", "", "", []string{"x86"}}, + {"arm", "armv7-a", "", []string{"armeabi-v7a"}}, {"x86_64", "", "", []string{"x86_64"}}, + {"x86", "", "", []string{"x86"}}, } } // getAmlAbisConfig returns a list of archConfigs for the ABIs supported by mainline modules. func getAmlAbisConfig() []archConfig { return []archConfig{ - {"arm", "armv7-a-neon", "", []string{"armeabi-v7a"}}, {"arm64", "armv8-a", "", []string{"arm64-v8a"}}, - {"x86", "", "", []string{"x86"}}, + {"arm", "armv7-a-neon", "", []string{"armeabi-v7a"}}, {"x86_64", "", "", []string{"x86_64"}}, + {"x86", "", "", []string{"x86"}}, } } From ec9c82da9fc00704d5f2856c10649b56cdc2e58f Mon Sep 17 00:00:00 2001 From: Jeongik Cha Date: Wed, 23 Jun 2021 23:18:50 +0900 Subject: [PATCH 4/5] Expose imageLocationsOnDevice as well as imageLocationsOnHost Bug: 158843648 Test: check if dexpreopt.config for the module defined in mk file has DexPreoptImageLocationsOnDevice field Change-Id: Idb2de398871ff114245393a9dd92b5a1b5c942e7 Merged-In: Idb2de398871ff114245393a9dd92b5a1b5c942e7 (cherry picked from commit e3165c8de302839c8ab15f53d8024b585c62061f) --- java/dexpreopt_bootjars.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index bb857845a..03769fab7 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -884,8 +884,9 @@ func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) { ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+sfx, variant.installs.String()) ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+sfx, variant.unstrippedInstalls.String()) } - imageLocationsOnHost, _ := current.getAnyAndroidVariant().imageLocations() - ctx.Strict("DEXPREOPT_IMAGE_LOCATIONS_"+current.name, strings.Join(imageLocationsOnHost, ":")) + imageLocationsOnHost, imageLocationsOnDevice := current.getAnyAndroidVariant().imageLocations() + ctx.Strict("DEXPREOPT_IMAGE_LOCATIONS_ON_HOST"+current.name, strings.Join(imageLocationsOnHost, ":")) + ctx.Strict("DEXPREOPT_IMAGE_LOCATIONS_ON_DEVICE"+current.name, strings.Join(imageLocationsOnDevice, ":")) ctx.Strict("DEXPREOPT_IMAGE_ZIP_"+current.name, current.zip.String()) } ctx.Strict("DEXPREOPT_IMAGE_NAMES", strings.Join(imageNames, " ")) From b12c1404cd40be22b051099e6179c091c474ed69 Mon Sep 17 00:00:00 2001 From: Liz Kammer Date: Thu, 24 Jun 2021 13:03:06 -0400 Subject: [PATCH 5/5] Make prebuilt properties customizable Previously whether prebuilt properties were customizable was dependent on the order of calling various inits. Test: go test soong tests Bug: 191975220 Change-Id: Icaa1fe811a5f5fc4aa5fc9fa0ec0b90debe3d537 Merged-In: Icaa1fe811a5f5fc4aa5fc9fa0ec0b90debe3d537 (cherry picked from commit 69d6413dd0a0dad94335a4b0c8e9eef5c9383b70) --- android/prebuilt.go | 1 + android/prebuilt_test.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/android/prebuilt.go b/android/prebuilt.go index 43b7cbefd..f3493bd5a 100644 --- a/android/prebuilt.go +++ b/android/prebuilt.go @@ -166,6 +166,7 @@ type PrebuiltSrcsSupplier func(ctx BaseModuleContext, prebuilt Module) []string func InitPrebuiltModuleWithSrcSupplier(module PrebuiltInterface, srcsSupplier PrebuiltSrcsSupplier, srcsPropertyName string) { p := module.Prebuilt() module.AddProperties(&p.properties) + module.base().customizableProperties = module.GetProperties() if srcsSupplier == nil { panic(fmt.Errorf("srcsSupplier must not be nil")) diff --git a/android/prebuilt_test.go b/android/prebuilt_test.go index ced37fe64..23524a533 100644 --- a/android/prebuilt_test.go +++ b/android/prebuilt_test.go @@ -259,6 +259,38 @@ var prebuiltsTests = []struct { }`, prebuilt: []OsType{Android, BuildOs}, }, + { + name: "prebuilt properties customizable", + replaceBp: true, + modules: ` + source { + name: "foo", + deps: [":bar"], + } + + soong_config_module_type { + name: "prebuilt_with_config", + module_type: "prebuilt", + config_namespace: "any_namespace", + bool_variables: ["bool_var"], + properties: ["prefer"], + } + + prebuilt_with_config { + name: "bar", + prefer: true, + srcs: ["prebuilt_file"], + soong_config_variables: { + bool_var: { + prefer: false, + conditions_default: { + prefer: true, + }, + }, + }, + }`, + prebuilt: []OsType{Android, BuildOs}, + }, } func TestPrebuilts(t *testing.T) { @@ -394,6 +426,9 @@ func registerTestPrebuiltModules(ctx RegistrationContext) { ctx.RegisterModuleType("prebuilt", newPrebuiltModule) ctx.RegisterModuleType("source", newSourceModule) ctx.RegisterModuleType("override_source", newOverrideSourceModule) + ctx.RegisterModuleType("soong_config_module_type", soongConfigModuleTypeFactory) + ctx.RegisterModuleType("soong_config_string_variable", soongConfigStringVariableDummyFactory) + ctx.RegisterModuleType("soong_config_bool_variable", soongConfigBoolVariableDummyFactory) } type prebuiltModule struct {