Loading android/arch.go +1 −1 Original line number Diff line number Diff line Loading @@ -618,7 +618,7 @@ func archMutator(bpctx blueprint.BottomUpMutatorContext) { } // only the primary arch in the ramdisk / vendor_ramdisk / recovery partition if os == Android && (module.InstallInRecovery() || module.InstallInRamdisk() || module.InstallInVendorRamdisk()) { if os == Android && (module.InstallInRecovery() || module.InstallInRamdisk() || module.InstallInVendorRamdisk() || module.InstallInDebugRamdisk()) { osTargets = []Target{osTargets[0]} } Loading android/image.go +11 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,11 @@ type ImageInterface interface { // vendor ramdisk partition). VendorRamdiskVariantNeeded(ctx BaseModuleContext) bool // DebugRamdiskVariantNeeded should return true if the module needs a debug ramdisk variant (installed on the // debug ramdisk partition: $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk if BOARD_USES_RECOVERY_AS_ROOT is // true, $(PRODUCT_OUT)/debug_ramdisk otherise). DebugRamdiskVariantNeeded(ctx BaseModuleContext) bool // RecoveryVariantNeeded should return true if the module needs a recovery variant (installed on the // recovery partition). RecoveryVariantNeeded(ctx BaseModuleContext) bool Loading Loading @@ -60,6 +65,9 @@ const ( // VendorRamdiskVariation means a module to be installed to vendor ramdisk image. VendorRamdiskVariation string = "vendor_ramdisk" // DebugRamdiskVariation means a module to be installed to debug ramdisk image. DebugRamdiskVariation string = "debug_ramdisk" ) // imageMutator creates variants for modules that implement the ImageInterface that Loading @@ -83,6 +91,9 @@ func imageMutator(ctx BottomUpMutatorContext) { if m.VendorRamdiskVariantNeeded(ctx) { variations = append(variations, VendorRamdiskVariation) } if m.DebugRamdiskVariantNeeded(ctx) { variations = append(variations, DebugRamdiskVariation) } if m.RecoveryVariantNeeded(ctx) { variations = append(variations, RecoveryVariation) } Loading android/module.go +17 −0 Original line number Diff line number Diff line Loading @@ -393,6 +393,7 @@ type ModuleContext interface { InstallInSanitizerDir() bool InstallInRamdisk() bool InstallInVendorRamdisk() bool InstallInDebugRamdisk() bool InstallInRecovery() bool InstallInRoot() bool InstallBypassMake() bool Loading Loading @@ -450,6 +451,7 @@ type Module interface { InstallInSanitizerDir() bool InstallInRamdisk() bool InstallInVendorRamdisk() bool InstallInDebugRamdisk() bool InstallInRecovery() bool InstallInRoot() bool InstallBypassMake() bool Loading Loading @@ -753,6 +755,9 @@ type commonProperties struct { // Whether this module is installed to vendor ramdisk Vendor_ramdisk *bool // Whether this module is installed to debug ramdisk Debug_ramdisk *bool // Whether this module is built for non-native architectures (also known as native bridge binary) Native_bridge_supported *bool `android:"arch_variant"` Loading Loading @@ -1540,6 +1545,10 @@ func (m *ModuleBase) InstallInVendorRamdisk() bool { return Bool(m.commonProperties.Vendor_ramdisk) } func (m *ModuleBase) InstallInDebugRamdisk() bool { return Bool(m.commonProperties.Debug_ramdisk) } func (m *ModuleBase) InstallInRecovery() bool { return Bool(m.commonProperties.Recovery) } Loading Loading @@ -1593,6 +1602,10 @@ func (m *ModuleBase) InVendorRamdisk() bool { return m.base().commonProperties.ImageVariation == VendorRamdiskVariation } func (m *ModuleBase) InDebugRamdisk() bool { return m.base().commonProperties.ImageVariation == DebugRamdiskVariation } func (m *ModuleBase) InRecovery() bool { return m.base().commonProperties.ImageVariation == RecoveryVariation } Loading Loading @@ -2548,6 +2561,10 @@ func (m *moduleContext) InstallInVendorRamdisk() bool { return m.module.InstallInVendorRamdisk() } func (m *moduleContext) InstallInDebugRamdisk() bool { return m.module.InstallInDebugRamdisk() } func (m *moduleContext) InstallInRecovery() bool { return m.module.InstallInRecovery() } Loading android/paths.go +16 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,7 @@ type ModuleInstallPathContext interface { InstallInSanitizerDir() bool InstallInRamdisk() bool InstallInVendorRamdisk() bool InstallInDebugRamdisk() bool InstallInRecovery() bool InstallInRoot() bool InstallBypassMake() bool Loading Loading @@ -1849,6 +1850,16 @@ func modulePartition(ctx ModuleInstallPathContext, os OsType) string { if !ctx.InstallInRoot() { partition += "/system" } } else if ctx.InstallInDebugRamdisk() { // The module is only available after switching root into // /first_stage_ramdisk. To expose the module before switching root // on a device without a dedicated recovery partition, install the // recovery variant. if ctx.DeviceConfig().BoardUsesRecoveryAsBoot() { partition = "debug_ramdisk/first_stage_ramdisk" } else { partition = "debug_ramdisk" } } else if ctx.InstallInRecovery() { if ctx.InstallInRoot() { partition = "recovery/root" Loading Loading @@ -2019,6 +2030,7 @@ type testModuleInstallPathContext struct { inSanitizerDir bool inRamdisk bool inVendorRamdisk bool inDebugRamdisk bool inRecovery bool inRoot bool forceOS *OsType Loading Loading @@ -2051,6 +2063,10 @@ func (m testModuleInstallPathContext) InstallInVendorRamdisk() bool { return m.inVendorRamdisk } func (m testModuleInstallPathContext) InstallInDebugRamdisk() bool { return m.inDebugRamdisk } func (m testModuleInstallPathContext) InstallInRecovery() bool { return m.inRecovery } Loading android/paths_test.go +143 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import ( "strconv" "strings" "testing" "github.com/google/blueprint/proptools" ) type strsTestCase struct { Loading Loading @@ -338,6 +340,73 @@ func TestPathForModuleInstall(t *testing.T) { partitionDir: "target/product/test_device/recovery/root", }, { name: "ramdisk binary", ctx: &testModuleInstallPathContext{ baseModuleContext: baseModuleContext{ os: deviceTarget.Os, target: deviceTarget, }, inRamdisk: true, }, in: []string{"my_test"}, out: "target/product/test_device/ramdisk/system/my_test", partitionDir: "target/product/test_device/ramdisk/system", }, { name: "ramdisk root binary", ctx: &testModuleInstallPathContext{ baseModuleContext: baseModuleContext{ os: deviceTarget.Os, target: deviceTarget, }, inRamdisk: true, inRoot: true, }, in: []string{"my_test"}, out: "target/product/test_device/ramdisk/my_test", partitionDir: "target/product/test_device/ramdisk", }, { name: "vendor_ramdisk binary", ctx: &testModuleInstallPathContext{ baseModuleContext: baseModuleContext{ os: deviceTarget.Os, target: deviceTarget, }, inVendorRamdisk: true, }, in: []string{"my_test"}, out: "target/product/test_device/vendor_ramdisk/system/my_test", partitionDir: "target/product/test_device/vendor_ramdisk/system", }, { name: "vendor_ramdisk root binary", ctx: &testModuleInstallPathContext{ baseModuleContext: baseModuleContext{ os: deviceTarget.Os, target: deviceTarget, }, inVendorRamdisk: true, inRoot: true, }, in: []string{"my_test"}, out: "target/product/test_device/vendor_ramdisk/my_test", partitionDir: "target/product/test_device/vendor_ramdisk", }, { name: "debug_ramdisk binary", ctx: &testModuleInstallPathContext{ baseModuleContext: baseModuleContext{ os: deviceTarget.Os, target: deviceTarget, }, inDebugRamdisk: true, }, in: []string{"my_test"}, out: "target/product/test_device/debug_ramdisk/my_test", partitionDir: "target/product/test_device/debug_ramdisk", }, { name: "system native test binary", ctx: &testModuleInstallPathContext{ Loading Loading @@ -635,6 +704,80 @@ func TestPathForModuleInstall(t *testing.T) { } } func TestPathForModuleInstallRecoveryAsBoot(t *testing.T) { testConfig := pathTestConfig("") testConfig.TestProductVariables.BoardUsesRecoveryAsBoot = proptools.BoolPtr(true) testConfig.TestProductVariables.BoardMoveRecoveryResourcesToVendorBoot = proptools.BoolPtr(true) deviceTarget := Target{Os: Android, Arch: Arch{ArchType: Arm64}} testCases := []struct { name string ctx *testModuleInstallPathContext in []string out string partitionDir string }{ { name: "ramdisk binary", ctx: &testModuleInstallPathContext{ baseModuleContext: baseModuleContext{ os: deviceTarget.Os, target: deviceTarget, }, inRamdisk: true, inRoot: true, }, in: []string{"my_test"}, out: "target/product/test_device/recovery/root/first_stage_ramdisk/my_test", partitionDir: "target/product/test_device/recovery/root/first_stage_ramdisk", }, { name: "vendor_ramdisk binary", ctx: &testModuleInstallPathContext{ baseModuleContext: baseModuleContext{ os: deviceTarget.Os, target: deviceTarget, }, inVendorRamdisk: true, inRoot: true, }, in: []string{"my_test"}, out: "target/product/test_device/vendor_ramdisk/first_stage_ramdisk/my_test", partitionDir: "target/product/test_device/vendor_ramdisk/first_stage_ramdisk", }, { name: "debug_ramdisk binary", ctx: &testModuleInstallPathContext{ baseModuleContext: baseModuleContext{ os: deviceTarget.Os, target: deviceTarget, }, inDebugRamdisk: true, }, in: []string{"my_test"}, out: "target/product/test_device/debug_ramdisk/first_stage_ramdisk/my_test", partitionDir: "target/product/test_device/debug_ramdisk/first_stage_ramdisk", }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { tc.ctx.baseModuleContext.config = testConfig output := PathForModuleInstall(tc.ctx, tc.in...) if output.basePath.path != tc.out { t.Errorf("unexpected path:\n got: %q\nwant: %q\n", output.basePath.path, tc.out) } if output.partitionDir != tc.partitionDir { t.Errorf("unexpected partitionDir:\n got: %q\nwant: %q\n", output.partitionDir, tc.partitionDir) } }) } } func TestBaseDirForInstallPath(t *testing.T) { testConfig := pathTestConfig("") deviceTarget := Target{Os: Android, Arch: Arch{ArchType: Arm64}} Loading Loading
android/arch.go +1 −1 Original line number Diff line number Diff line Loading @@ -618,7 +618,7 @@ func archMutator(bpctx blueprint.BottomUpMutatorContext) { } // only the primary arch in the ramdisk / vendor_ramdisk / recovery partition if os == Android && (module.InstallInRecovery() || module.InstallInRamdisk() || module.InstallInVendorRamdisk()) { if os == Android && (module.InstallInRecovery() || module.InstallInRamdisk() || module.InstallInVendorRamdisk() || module.InstallInDebugRamdisk()) { osTargets = []Target{osTargets[0]} } Loading
android/image.go +11 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,11 @@ type ImageInterface interface { // vendor ramdisk partition). VendorRamdiskVariantNeeded(ctx BaseModuleContext) bool // DebugRamdiskVariantNeeded should return true if the module needs a debug ramdisk variant (installed on the // debug ramdisk partition: $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk if BOARD_USES_RECOVERY_AS_ROOT is // true, $(PRODUCT_OUT)/debug_ramdisk otherise). DebugRamdiskVariantNeeded(ctx BaseModuleContext) bool // RecoveryVariantNeeded should return true if the module needs a recovery variant (installed on the // recovery partition). RecoveryVariantNeeded(ctx BaseModuleContext) bool Loading Loading @@ -60,6 +65,9 @@ const ( // VendorRamdiskVariation means a module to be installed to vendor ramdisk image. VendorRamdiskVariation string = "vendor_ramdisk" // DebugRamdiskVariation means a module to be installed to debug ramdisk image. DebugRamdiskVariation string = "debug_ramdisk" ) // imageMutator creates variants for modules that implement the ImageInterface that Loading @@ -83,6 +91,9 @@ func imageMutator(ctx BottomUpMutatorContext) { if m.VendorRamdiskVariantNeeded(ctx) { variations = append(variations, VendorRamdiskVariation) } if m.DebugRamdiskVariantNeeded(ctx) { variations = append(variations, DebugRamdiskVariation) } if m.RecoveryVariantNeeded(ctx) { variations = append(variations, RecoveryVariation) } Loading
android/module.go +17 −0 Original line number Diff line number Diff line Loading @@ -393,6 +393,7 @@ type ModuleContext interface { InstallInSanitizerDir() bool InstallInRamdisk() bool InstallInVendorRamdisk() bool InstallInDebugRamdisk() bool InstallInRecovery() bool InstallInRoot() bool InstallBypassMake() bool Loading Loading @@ -450,6 +451,7 @@ type Module interface { InstallInSanitizerDir() bool InstallInRamdisk() bool InstallInVendorRamdisk() bool InstallInDebugRamdisk() bool InstallInRecovery() bool InstallInRoot() bool InstallBypassMake() bool Loading Loading @@ -753,6 +755,9 @@ type commonProperties struct { // Whether this module is installed to vendor ramdisk Vendor_ramdisk *bool // Whether this module is installed to debug ramdisk Debug_ramdisk *bool // Whether this module is built for non-native architectures (also known as native bridge binary) Native_bridge_supported *bool `android:"arch_variant"` Loading Loading @@ -1540,6 +1545,10 @@ func (m *ModuleBase) InstallInVendorRamdisk() bool { return Bool(m.commonProperties.Vendor_ramdisk) } func (m *ModuleBase) InstallInDebugRamdisk() bool { return Bool(m.commonProperties.Debug_ramdisk) } func (m *ModuleBase) InstallInRecovery() bool { return Bool(m.commonProperties.Recovery) } Loading Loading @@ -1593,6 +1602,10 @@ func (m *ModuleBase) InVendorRamdisk() bool { return m.base().commonProperties.ImageVariation == VendorRamdiskVariation } func (m *ModuleBase) InDebugRamdisk() bool { return m.base().commonProperties.ImageVariation == DebugRamdiskVariation } func (m *ModuleBase) InRecovery() bool { return m.base().commonProperties.ImageVariation == RecoveryVariation } Loading Loading @@ -2548,6 +2561,10 @@ func (m *moduleContext) InstallInVendorRamdisk() bool { return m.module.InstallInVendorRamdisk() } func (m *moduleContext) InstallInDebugRamdisk() bool { return m.module.InstallInDebugRamdisk() } func (m *moduleContext) InstallInRecovery() bool { return m.module.InstallInRecovery() } Loading
android/paths.go +16 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,7 @@ type ModuleInstallPathContext interface { InstallInSanitizerDir() bool InstallInRamdisk() bool InstallInVendorRamdisk() bool InstallInDebugRamdisk() bool InstallInRecovery() bool InstallInRoot() bool InstallBypassMake() bool Loading Loading @@ -1849,6 +1850,16 @@ func modulePartition(ctx ModuleInstallPathContext, os OsType) string { if !ctx.InstallInRoot() { partition += "/system" } } else if ctx.InstallInDebugRamdisk() { // The module is only available after switching root into // /first_stage_ramdisk. To expose the module before switching root // on a device without a dedicated recovery partition, install the // recovery variant. if ctx.DeviceConfig().BoardUsesRecoveryAsBoot() { partition = "debug_ramdisk/first_stage_ramdisk" } else { partition = "debug_ramdisk" } } else if ctx.InstallInRecovery() { if ctx.InstallInRoot() { partition = "recovery/root" Loading Loading @@ -2019,6 +2030,7 @@ type testModuleInstallPathContext struct { inSanitizerDir bool inRamdisk bool inVendorRamdisk bool inDebugRamdisk bool inRecovery bool inRoot bool forceOS *OsType Loading Loading @@ -2051,6 +2063,10 @@ func (m testModuleInstallPathContext) InstallInVendorRamdisk() bool { return m.inVendorRamdisk } func (m testModuleInstallPathContext) InstallInDebugRamdisk() bool { return m.inDebugRamdisk } func (m testModuleInstallPathContext) InstallInRecovery() bool { return m.inRecovery } Loading
android/paths_test.go +143 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import ( "strconv" "strings" "testing" "github.com/google/blueprint/proptools" ) type strsTestCase struct { Loading Loading @@ -338,6 +340,73 @@ func TestPathForModuleInstall(t *testing.T) { partitionDir: "target/product/test_device/recovery/root", }, { name: "ramdisk binary", ctx: &testModuleInstallPathContext{ baseModuleContext: baseModuleContext{ os: deviceTarget.Os, target: deviceTarget, }, inRamdisk: true, }, in: []string{"my_test"}, out: "target/product/test_device/ramdisk/system/my_test", partitionDir: "target/product/test_device/ramdisk/system", }, { name: "ramdisk root binary", ctx: &testModuleInstallPathContext{ baseModuleContext: baseModuleContext{ os: deviceTarget.Os, target: deviceTarget, }, inRamdisk: true, inRoot: true, }, in: []string{"my_test"}, out: "target/product/test_device/ramdisk/my_test", partitionDir: "target/product/test_device/ramdisk", }, { name: "vendor_ramdisk binary", ctx: &testModuleInstallPathContext{ baseModuleContext: baseModuleContext{ os: deviceTarget.Os, target: deviceTarget, }, inVendorRamdisk: true, }, in: []string{"my_test"}, out: "target/product/test_device/vendor_ramdisk/system/my_test", partitionDir: "target/product/test_device/vendor_ramdisk/system", }, { name: "vendor_ramdisk root binary", ctx: &testModuleInstallPathContext{ baseModuleContext: baseModuleContext{ os: deviceTarget.Os, target: deviceTarget, }, inVendorRamdisk: true, inRoot: true, }, in: []string{"my_test"}, out: "target/product/test_device/vendor_ramdisk/my_test", partitionDir: "target/product/test_device/vendor_ramdisk", }, { name: "debug_ramdisk binary", ctx: &testModuleInstallPathContext{ baseModuleContext: baseModuleContext{ os: deviceTarget.Os, target: deviceTarget, }, inDebugRamdisk: true, }, in: []string{"my_test"}, out: "target/product/test_device/debug_ramdisk/my_test", partitionDir: "target/product/test_device/debug_ramdisk", }, { name: "system native test binary", ctx: &testModuleInstallPathContext{ Loading Loading @@ -635,6 +704,80 @@ func TestPathForModuleInstall(t *testing.T) { } } func TestPathForModuleInstallRecoveryAsBoot(t *testing.T) { testConfig := pathTestConfig("") testConfig.TestProductVariables.BoardUsesRecoveryAsBoot = proptools.BoolPtr(true) testConfig.TestProductVariables.BoardMoveRecoveryResourcesToVendorBoot = proptools.BoolPtr(true) deviceTarget := Target{Os: Android, Arch: Arch{ArchType: Arm64}} testCases := []struct { name string ctx *testModuleInstallPathContext in []string out string partitionDir string }{ { name: "ramdisk binary", ctx: &testModuleInstallPathContext{ baseModuleContext: baseModuleContext{ os: deviceTarget.Os, target: deviceTarget, }, inRamdisk: true, inRoot: true, }, in: []string{"my_test"}, out: "target/product/test_device/recovery/root/first_stage_ramdisk/my_test", partitionDir: "target/product/test_device/recovery/root/first_stage_ramdisk", }, { name: "vendor_ramdisk binary", ctx: &testModuleInstallPathContext{ baseModuleContext: baseModuleContext{ os: deviceTarget.Os, target: deviceTarget, }, inVendorRamdisk: true, inRoot: true, }, in: []string{"my_test"}, out: "target/product/test_device/vendor_ramdisk/first_stage_ramdisk/my_test", partitionDir: "target/product/test_device/vendor_ramdisk/first_stage_ramdisk", }, { name: "debug_ramdisk binary", ctx: &testModuleInstallPathContext{ baseModuleContext: baseModuleContext{ os: deviceTarget.Os, target: deviceTarget, }, inDebugRamdisk: true, }, in: []string{"my_test"}, out: "target/product/test_device/debug_ramdisk/first_stage_ramdisk/my_test", partitionDir: "target/product/test_device/debug_ramdisk/first_stage_ramdisk", }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { tc.ctx.baseModuleContext.config = testConfig output := PathForModuleInstall(tc.ctx, tc.in...) if output.basePath.path != tc.out { t.Errorf("unexpected path:\n got: %q\nwant: %q\n", output.basePath.path, tc.out) } if output.partitionDir != tc.partitionDir { t.Errorf("unexpected partitionDir:\n got: %q\nwant: %q\n", output.partitionDir, tc.partitionDir) } }) } } func TestBaseDirForInstallPath(t *testing.T) { testConfig := pathTestConfig("") deviceTarget := Target{Os: Android, Arch: Arch{ArchType: Arm64}} Loading