Loading android/config.go +24 −0 Original line number Diff line number Diff line Loading @@ -288,6 +288,10 @@ func TestArchConfig(buildDir string, env map[string]string) Config { config.BuildOsVariant = config.Targets[BuildOs][0].String() config.BuildOsCommonVariant = getCommonTargets(config.Targets[BuildOs])[0].String() config.TestProductVariables.DeviceArch = proptools.StringPtr("arm64") config.TestProductVariables.DeviceArchVariant = proptools.StringPtr("armv8-a") config.TestProductVariables.DeviceSecondaryArch = proptools.StringPtr("arm") config.TestProductVariables.DeviceSecondaryArchVariant = proptools.StringPtr("armv7-a-neon") return testConfig } Loading Loading @@ -1100,3 +1104,23 @@ func (c *config) ProductPrivateSepolicyDirs() []string { func (c *config) ProductCompatibleProperty() bool { return Bool(c.productVariables.ProductCompatibleProperty) } func (c *deviceConfig) BoardVndkRuntimeDisable() bool { return Bool(c.config.productVariables.BoardVndkRuntimeDisable) } func (c *deviceConfig) DeviceArch() string { return String(c.config.productVariables.DeviceArch) } func (c *deviceConfig) DeviceArchVariant() string { return String(c.config.productVariables.DeviceArchVariant) } func (c *deviceConfig) DeviceSecondaryArch() string { return String(c.config.productVariables.DeviceSecondaryArch) } func (c *deviceConfig) DeviceSecondaryArchVariant() string { return String(c.config.productVariables.DeviceSecondaryArchVariant) } android/util.go +25 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,31 @@ func JoinWithPrefix(strs []string, prefix string) string { return string(ret) } func JoinWithSuffix(strs []string, suffix string, separator string) string { if len(strs) == 0 { return "" } if len(strs) == 1 { return strs[0] + suffix } n := len(" ") * (len(strs) - 1) for _, s := range strs { n += len(suffix) + len(s) } ret := make([]byte, 0, n) for i, s := range strs { if i != 0 { ret = append(ret, separator...) } ret = append(ret, s...) ret = append(ret, suffix...) } return string(ret) } func sortedKeys(m map[string][]string) []string { s := make([]string, 0, len(m)) for k := range m { Loading android/variable.go +2 −0 Original line number Diff line number Diff line Loading @@ -279,6 +279,8 @@ type productVariables struct { BoardPlatPrivateSepolicyDirs []string `json:",omitempty"` BoardSepolicyM4Defs []string `json:",omitempty"` BoardVndkRuntimeDisable *bool `json:",omitempty"` VendorVars map[string]map[string]string `json:",omitempty"` Ndk_abis *bool `json:",omitempty"` Loading cc/cc.go +5 −1 Original line number Diff line number Diff line Loading @@ -1011,7 +1011,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { } } if c.installer != nil && !c.Properties.PreventInstall && c.IsForPlatform() && c.outputFile.Valid() { if c.installable() { c.installer.install(ctx, c.outputFile.Path()) if ctx.Failed() { return Loading Loading @@ -1968,6 +1968,10 @@ func (c *Module) IsInstallableToApex() bool { return false } func (c *Module) installable() bool { return c.installer != nil && !c.Properties.PreventInstall && c.IsForPlatform() && c.outputFile.Valid() } func (c *Module) imageVariation() string { variation := "core" if c.useVndk() { Loading cc/cc_test.go +47 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import ( "fmt" "io/ioutil" "os" "path/filepath" "reflect" "sort" "strings" Loading Loading @@ -75,6 +76,7 @@ func createTestContext(t *testing.T, config android.Config, bp string, os androi ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) { ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel() }) ctx.RegisterSingletonType("vndk-snapshot", android.SingletonFactoryAdaptor(VndkSnapshotSingleton)) ctx.Register() // add some modules that are required by the compiler and/or linker Loading Loading @@ -286,8 +288,28 @@ func checkVndkModule(t *testing.T, ctx *android.TestContext, name, subDir string } } func checkVndkSnapshot(t *testing.T, ctx *android.TestContext, name, subDir, variant string) { vndkSnapshot := ctx.SingletonForTests("vndk-snapshot") snapshotPath := filepath.Join(subDir, name+".so") mod := ctx.ModuleForTests(name, variant).Module().(*Module) if !mod.outputFile.Valid() { t.Errorf("%q must have output\n", name) return } out := vndkSnapshot.Output(snapshotPath) if out.Input != mod.outputFile.Path() { t.Errorf("The input of VNDK snapshot must be %q, but %q", out.Input.String(), mod.outputFile.String()) } } func TestVndk(t *testing.T) { ctx := testCc(t, ` config := android.TestArchConfig(buildDir, nil) config.TestProductVariables.DeviceVndkVersion = StringPtr("current") config.TestProductVariables.Platform_vndk_version = StringPtr("VER") ctx := testCcWithConfig(t, ` cc_library { name: "libvndk", vendor_available: true, Loading Loading @@ -325,12 +347,35 @@ func TestVndk(t *testing.T) { }, nocrt: true, } `) `, config) checkVndkModule(t, ctx, "libvndk", "vndk-VER", false, "") checkVndkModule(t, ctx, "libvndk_private", "vndk-VER", false, "") checkVndkModule(t, ctx, "libvndk_sp", "vndk-sp-VER", true, "") checkVndkModule(t, ctx, "libvndk_sp_private", "vndk-sp-VER", true, "") // Check VNDK snapshot output. snapshotDir := "vndk-snapshot" snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64") vndkLibPath := filepath.Join(snapshotVariantPath, fmt.Sprintf("arch-%s-%s", "arm64", "armv8-a")) vndkLib2ndPath := filepath.Join(snapshotVariantPath, fmt.Sprintf("arch-%s-%s", "arm", "armv7-a-neon")) vndkCoreLibPath := filepath.Join(vndkLibPath, "shared", "vndk-core") vndkSpLibPath := filepath.Join(vndkLibPath, "shared", "vndk-sp") vndkCoreLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-core") vndkSpLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-sp") variant := "android_arm64_armv8-a_vendor_shared" variant2nd := "android_arm_armv7-a-neon_vendor_shared" checkVndkSnapshot(t, ctx, "libvndk", vndkCoreLibPath, variant) checkVndkSnapshot(t, ctx, "libvndk", vndkCoreLib2ndPath, variant2nd) checkVndkSnapshot(t, ctx, "libvndk_sp", vndkSpLibPath, variant) checkVndkSnapshot(t, ctx, "libvndk_sp", vndkSpLib2ndPath, variant2nd) } func TestVndkDepError(t *testing.T) { Loading Loading
android/config.go +24 −0 Original line number Diff line number Diff line Loading @@ -288,6 +288,10 @@ func TestArchConfig(buildDir string, env map[string]string) Config { config.BuildOsVariant = config.Targets[BuildOs][0].String() config.BuildOsCommonVariant = getCommonTargets(config.Targets[BuildOs])[0].String() config.TestProductVariables.DeviceArch = proptools.StringPtr("arm64") config.TestProductVariables.DeviceArchVariant = proptools.StringPtr("armv8-a") config.TestProductVariables.DeviceSecondaryArch = proptools.StringPtr("arm") config.TestProductVariables.DeviceSecondaryArchVariant = proptools.StringPtr("armv7-a-neon") return testConfig } Loading Loading @@ -1100,3 +1104,23 @@ func (c *config) ProductPrivateSepolicyDirs() []string { func (c *config) ProductCompatibleProperty() bool { return Bool(c.productVariables.ProductCompatibleProperty) } func (c *deviceConfig) BoardVndkRuntimeDisable() bool { return Bool(c.config.productVariables.BoardVndkRuntimeDisable) } func (c *deviceConfig) DeviceArch() string { return String(c.config.productVariables.DeviceArch) } func (c *deviceConfig) DeviceArchVariant() string { return String(c.config.productVariables.DeviceArchVariant) } func (c *deviceConfig) DeviceSecondaryArch() string { return String(c.config.productVariables.DeviceSecondaryArch) } func (c *deviceConfig) DeviceSecondaryArchVariant() string { return String(c.config.productVariables.DeviceSecondaryArchVariant) }
android/util.go +25 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,31 @@ func JoinWithPrefix(strs []string, prefix string) string { return string(ret) } func JoinWithSuffix(strs []string, suffix string, separator string) string { if len(strs) == 0 { return "" } if len(strs) == 1 { return strs[0] + suffix } n := len(" ") * (len(strs) - 1) for _, s := range strs { n += len(suffix) + len(s) } ret := make([]byte, 0, n) for i, s := range strs { if i != 0 { ret = append(ret, separator...) } ret = append(ret, s...) ret = append(ret, suffix...) } return string(ret) } func sortedKeys(m map[string][]string) []string { s := make([]string, 0, len(m)) for k := range m { Loading
android/variable.go +2 −0 Original line number Diff line number Diff line Loading @@ -279,6 +279,8 @@ type productVariables struct { BoardPlatPrivateSepolicyDirs []string `json:",omitempty"` BoardSepolicyM4Defs []string `json:",omitempty"` BoardVndkRuntimeDisable *bool `json:",omitempty"` VendorVars map[string]map[string]string `json:",omitempty"` Ndk_abis *bool `json:",omitempty"` Loading
cc/cc.go +5 −1 Original line number Diff line number Diff line Loading @@ -1011,7 +1011,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { } } if c.installer != nil && !c.Properties.PreventInstall && c.IsForPlatform() && c.outputFile.Valid() { if c.installable() { c.installer.install(ctx, c.outputFile.Path()) if ctx.Failed() { return Loading Loading @@ -1968,6 +1968,10 @@ func (c *Module) IsInstallableToApex() bool { return false } func (c *Module) installable() bool { return c.installer != nil && !c.Properties.PreventInstall && c.IsForPlatform() && c.outputFile.Valid() } func (c *Module) imageVariation() string { variation := "core" if c.useVndk() { Loading
cc/cc_test.go +47 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import ( "fmt" "io/ioutil" "os" "path/filepath" "reflect" "sort" "strings" Loading Loading @@ -75,6 +76,7 @@ func createTestContext(t *testing.T, config android.Config, bp string, os androi ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) { ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel() }) ctx.RegisterSingletonType("vndk-snapshot", android.SingletonFactoryAdaptor(VndkSnapshotSingleton)) ctx.Register() // add some modules that are required by the compiler and/or linker Loading Loading @@ -286,8 +288,28 @@ func checkVndkModule(t *testing.T, ctx *android.TestContext, name, subDir string } } func checkVndkSnapshot(t *testing.T, ctx *android.TestContext, name, subDir, variant string) { vndkSnapshot := ctx.SingletonForTests("vndk-snapshot") snapshotPath := filepath.Join(subDir, name+".so") mod := ctx.ModuleForTests(name, variant).Module().(*Module) if !mod.outputFile.Valid() { t.Errorf("%q must have output\n", name) return } out := vndkSnapshot.Output(snapshotPath) if out.Input != mod.outputFile.Path() { t.Errorf("The input of VNDK snapshot must be %q, but %q", out.Input.String(), mod.outputFile.String()) } } func TestVndk(t *testing.T) { ctx := testCc(t, ` config := android.TestArchConfig(buildDir, nil) config.TestProductVariables.DeviceVndkVersion = StringPtr("current") config.TestProductVariables.Platform_vndk_version = StringPtr("VER") ctx := testCcWithConfig(t, ` cc_library { name: "libvndk", vendor_available: true, Loading Loading @@ -325,12 +347,35 @@ func TestVndk(t *testing.T) { }, nocrt: true, } `) `, config) checkVndkModule(t, ctx, "libvndk", "vndk-VER", false, "") checkVndkModule(t, ctx, "libvndk_private", "vndk-VER", false, "") checkVndkModule(t, ctx, "libvndk_sp", "vndk-sp-VER", true, "") checkVndkModule(t, ctx, "libvndk_sp_private", "vndk-sp-VER", true, "") // Check VNDK snapshot output. snapshotDir := "vndk-snapshot" snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64") vndkLibPath := filepath.Join(snapshotVariantPath, fmt.Sprintf("arch-%s-%s", "arm64", "armv8-a")) vndkLib2ndPath := filepath.Join(snapshotVariantPath, fmt.Sprintf("arch-%s-%s", "arm", "armv7-a-neon")) vndkCoreLibPath := filepath.Join(vndkLibPath, "shared", "vndk-core") vndkSpLibPath := filepath.Join(vndkLibPath, "shared", "vndk-sp") vndkCoreLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-core") vndkSpLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-sp") variant := "android_arm64_armv8-a_vendor_shared" variant2nd := "android_arm_armv7-a-neon_vendor_shared" checkVndkSnapshot(t, ctx, "libvndk", vndkCoreLibPath, variant) checkVndkSnapshot(t, ctx, "libvndk", vndkCoreLib2ndPath, variant2nd) checkVndkSnapshot(t, ctx, "libvndk_sp", vndkSpLibPath, variant) checkVndkSnapshot(t, ctx, "libvndk_sp", vndkSpLib2ndPath, variant2nd) } func TestVndkDepError(t *testing.T) { Loading