Merge changes I4c8cd544,I62d4d43d,I0ae667d4,Id357adc0,I1ff87134
* changes: Don't create version variations of sdk modules Create fewer empty version variants Don't make SplitPerApiLevel imply UseSdk Remove vendor crt special case Fix apex_test.go and add it to Android.bp
This commit is contained in:
commit
ac0cd89283
|
@ -63,6 +63,7 @@ bootstrap_go_package {
|
|||
testSrcs: [
|
||||
"android_test.go",
|
||||
"androidmk_test.go",
|
||||
"apex_test.go",
|
||||
"arch_test.go",
|
||||
"config_test.go",
|
||||
"csuite_config_test.go",
|
||||
|
|
|
@ -42,7 +42,7 @@ type ApexInfo struct {
|
|||
InApexes []string
|
||||
}
|
||||
|
||||
func (i ApexInfo) mergedName(ctx EarlyModuleContext) string {
|
||||
func (i ApexInfo) mergedName(ctx PathContext) string {
|
||||
name := "apex" + strconv.Itoa(i.MinSdkVersion(ctx).FinalOrFutureInt())
|
||||
for _, sdk := range i.RequiredSdks {
|
||||
name += "_" + sdk.Name + "_" + sdk.Version
|
||||
|
@ -50,7 +50,7 @@ func (i ApexInfo) mergedName(ctx EarlyModuleContext) string {
|
|||
return name
|
||||
}
|
||||
|
||||
func (this *ApexInfo) MinSdkVersion(ctx EarlyModuleContext) ApiLevel {
|
||||
func (this *ApexInfo) MinSdkVersion(ctx PathContext) ApiLevel {
|
||||
return ApiLevelOrPanic(ctx, this.MinSdkVersionStr)
|
||||
}
|
||||
|
||||
|
@ -358,7 +358,7 @@ func (a byApexName) Less(i, j int) bool { return a[i].ApexVariationName < a[j].A
|
|||
// mergeApexVariations deduplicates APEX variations that would build identically into a common
|
||||
// variation. It returns the reduced list of variations and a list of aliases from the original
|
||||
// variation names to the new variation names.
|
||||
func mergeApexVariations(ctx EarlyModuleContext, apexVariations []ApexInfo) (merged []ApexInfo, aliases [][2]string) {
|
||||
func mergeApexVariations(ctx PathContext, apexVariations []ApexInfo) (merged []ApexInfo, aliases [][2]string) {
|
||||
sort.Sort(byApexName(apexVariations))
|
||||
seen := make(map[string]int)
|
||||
for _, apexInfo := range apexVariations {
|
||||
|
|
|
@ -29,10 +29,10 @@ func Test_mergeApexVariations(t *testing.T) {
|
|||
{
|
||||
name: "single",
|
||||
in: []ApexInfo{
|
||||
{"foo", 10000, false, nil, []string{"foo"}},
|
||||
{"foo", "current", false, nil, []string{"foo"}},
|
||||
},
|
||||
wantMerged: []ApexInfo{
|
||||
{"apex10000", 10000, false, nil, []string{"foo"}},
|
||||
{"apex10000", "current", false, nil, []string{"foo"}},
|
||||
},
|
||||
wantAliases: [][2]string{
|
||||
{"foo", "apex10000"},
|
||||
|
@ -41,11 +41,11 @@ func Test_mergeApexVariations(t *testing.T) {
|
|||
{
|
||||
name: "merge",
|
||||
in: []ApexInfo{
|
||||
{"foo", 10000, false, SdkRefs{{"baz", "1"}}, []string{"foo"}},
|
||||
{"bar", 10000, false, SdkRefs{{"baz", "1"}}, []string{"bar"}},
|
||||
{"foo", "current", false, SdkRefs{{"baz", "1"}}, []string{"foo"}},
|
||||
{"bar", "current", false, SdkRefs{{"baz", "1"}}, []string{"bar"}},
|
||||
},
|
||||
wantMerged: []ApexInfo{
|
||||
{"apex10000_baz_1", 10000, false, SdkRefs{{"baz", "1"}}, []string{"bar", "foo"}},
|
||||
{"apex10000_baz_1", "current", false, SdkRefs{{"baz", "1"}}, []string{"bar", "foo"}},
|
||||
},
|
||||
wantAliases: [][2]string{
|
||||
{"bar", "apex10000_baz_1"},
|
||||
|
@ -55,12 +55,12 @@ func Test_mergeApexVariations(t *testing.T) {
|
|||
{
|
||||
name: "don't merge version",
|
||||
in: []ApexInfo{
|
||||
{"foo", 10000, false, nil, []string{"foo"}},
|
||||
{"bar", 30, false, nil, []string{"bar"}},
|
||||
{"foo", "current", false, nil, []string{"foo"}},
|
||||
{"bar", "30", false, nil, []string{"bar"}},
|
||||
},
|
||||
wantMerged: []ApexInfo{
|
||||
{"apex30", 30, false, nil, []string{"bar"}},
|
||||
{"apex10000", 10000, false, nil, []string{"foo"}},
|
||||
{"apex30", "30", false, nil, []string{"bar"}},
|
||||
{"apex10000", "current", false, nil, []string{"foo"}},
|
||||
},
|
||||
wantAliases: [][2]string{
|
||||
{"bar", "apex30"},
|
||||
|
@ -70,11 +70,11 @@ func Test_mergeApexVariations(t *testing.T) {
|
|||
{
|
||||
name: "merge updatable",
|
||||
in: []ApexInfo{
|
||||
{"foo", 10000, false, nil, []string{"foo"}},
|
||||
{"bar", 10000, true, nil, []string{"bar"}},
|
||||
{"foo", "current", false, nil, []string{"foo"}},
|
||||
{"bar", "current", true, nil, []string{"bar"}},
|
||||
},
|
||||
wantMerged: []ApexInfo{
|
||||
{"apex10000", 10000, true, nil, []string{"bar", "foo"}},
|
||||
{"apex10000", "current", true, nil, []string{"bar", "foo"}},
|
||||
},
|
||||
wantAliases: [][2]string{
|
||||
{"bar", "apex10000"},
|
||||
|
@ -84,12 +84,12 @@ func Test_mergeApexVariations(t *testing.T) {
|
|||
{
|
||||
name: "don't merge sdks",
|
||||
in: []ApexInfo{
|
||||
{"foo", 10000, false, SdkRefs{{"baz", "1"}}, []string{"foo"}},
|
||||
{"bar", 10000, false, SdkRefs{{"baz", "2"}}, []string{"bar"}},
|
||||
{"foo", "current", false, SdkRefs{{"baz", "1"}}, []string{"foo"}},
|
||||
{"bar", "current", false, SdkRefs{{"baz", "2"}}, []string{"bar"}},
|
||||
},
|
||||
wantMerged: []ApexInfo{
|
||||
{"apex10000_baz_2", 10000, false, SdkRefs{{"baz", "2"}}, []string{"bar"}},
|
||||
{"apex10000_baz_1", 10000, false, SdkRefs{{"baz", "1"}}, []string{"foo"}},
|
||||
{"apex10000_baz_2", "current", false, SdkRefs{{"baz", "2"}}, []string{"bar"}},
|
||||
{"apex10000_baz_1", "current", false, SdkRefs{{"baz", "1"}}, []string{"foo"}},
|
||||
},
|
||||
wantAliases: [][2]string{
|
||||
{"bar", "apex10000_baz_2"},
|
||||
|
@ -99,7 +99,9 @@ func Test_mergeApexVariations(t *testing.T) {
|
|||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
gotMerged, gotAliases := mergeApexVariations(tt.in)
|
||||
config := TestConfig(buildDir, nil, "", nil)
|
||||
ctx := &configErrorWrapper{config: config}
|
||||
gotMerged, gotAliases := mergeApexVariations(ctx, tt.in)
|
||||
if !reflect.DeepEqual(gotMerged, tt.wantMerged) {
|
||||
t.Errorf("mergeApexVariations() gotMerged = %v, want %v", gotMerged, tt.wantMerged)
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ var FirstNonLibAndroidSupportVersion = uncheckedFinalApiLevel(21)
|
|||
// * "30" -> "30"
|
||||
// * "R" -> "30"
|
||||
// * "S" -> "S"
|
||||
func ReplaceFinalizedCodenames(ctx EarlyModuleContext, raw string) string {
|
||||
func ReplaceFinalizedCodenames(ctx PathContext, raw string) string {
|
||||
num, ok := getFinalCodenamesMap(ctx.Config())[raw]
|
||||
if !ok {
|
||||
return raw
|
||||
|
@ -175,7 +175,7 @@ func ReplaceFinalizedCodenames(ctx EarlyModuleContext, raw string) string {
|
|||
//
|
||||
// Inputs that are not "current", known previews, or convertible to an integer
|
||||
// will return an error.
|
||||
func ApiLevelFromUser(ctx EarlyModuleContext, raw string) (ApiLevel, error) {
|
||||
func ApiLevelFromUser(ctx PathContext, raw string) (ApiLevel, error) {
|
||||
if raw == "" {
|
||||
panic("API level string must be non-empty")
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ func ApiLevelFromUser(ctx EarlyModuleContext, raw string) (ApiLevel, error) {
|
|||
// Converts an API level string `raw` into an ApiLevel in the same method as
|
||||
// `ApiLevelFromUser`, but the input is assumed to have no errors and any errors
|
||||
// will panic instead of returning an error.
|
||||
func ApiLevelOrPanic(ctx EarlyModuleContext, raw string) ApiLevel {
|
||||
func ApiLevelOrPanic(ctx PathContext, raw string) ApiLevel {
|
||||
value, err := ApiLevelFromUser(ctx, raw)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
|
|
|
@ -40,19 +40,14 @@ type binarySdkMemberType struct {
|
|||
|
||||
func (mt *binarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
targets := mctx.MultiTargets()
|
||||
for _, lib := range names {
|
||||
for _, bin := range names {
|
||||
for _, target := range targets {
|
||||
name, version := StubsLibNameAndVersion(lib)
|
||||
if version == "" {
|
||||
version = "latest"
|
||||
}
|
||||
variations := target.Variations()
|
||||
if mctx.Device() {
|
||||
variations = append(variations,
|
||||
blueprint.Variation{Mutator: "image", Variation: android.CoreVariation},
|
||||
blueprint.Variation{Mutator: "version", Variation: version})
|
||||
blueprint.Variation{Mutator: "image", Variation: android.CoreVariation})
|
||||
}
|
||||
mctx.AddFarVariationDependencies(variations, dependencyTag, name)
|
||||
mctx.AddFarVariationDependencies(variations, dependencyTag, bin)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
11
cc/cc.go
11
cc/cc.go
|
@ -697,6 +697,9 @@ func (c *Module) MinSdkVersion() string {
|
|||
}
|
||||
|
||||
func (c *Module) SplitPerApiLevel() bool {
|
||||
if !c.canUseSdk() {
|
||||
return false
|
||||
}
|
||||
if linker, ok := c.linker.(*objectLinker); ok {
|
||||
return linker.isCrt()
|
||||
}
|
||||
|
@ -1026,7 +1029,7 @@ func (c *Module) canUseSdk() bool {
|
|||
|
||||
func (c *Module) UseSdk() bool {
|
||||
if c.canUseSdk() {
|
||||
return String(c.Properties.Sdk_version) != "" || c.SplitPerApiLevel()
|
||||
return String(c.Properties.Sdk_version) != ""
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -1868,7 +1871,7 @@ func (c *Module) addSharedLibDependenciesWithVersions(ctx android.BottomUpMutato
|
|||
|
||||
variations = append([]blueprint.Variation(nil), variations...)
|
||||
|
||||
if version != "" && VersionVariantAvailable(c) {
|
||||
if version != "" && CanBeOrLinkAgainstVersionVariants(c) {
|
||||
// Version is explicitly specified. i.e. libFoo#30
|
||||
variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
|
||||
depTag.explicitlyVersioned = true
|
||||
|
@ -1883,7 +1886,7 @@ func (c *Module) addSharedLibDependenciesWithVersions(ctx android.BottomUpMutato
|
|||
// If the version is not specified, add dependency to all stubs libraries.
|
||||
// The stubs library will be used when the depending module is built for APEX and
|
||||
// the dependent module is not in the same APEX.
|
||||
if version == "" && VersionVariantAvailable(c) {
|
||||
if version == "" && CanBeOrLinkAgainstVersionVariants(c) {
|
||||
if dep, ok := deps[0].(*Module); ok {
|
||||
for _, ver := range dep.AllStubsVersions() {
|
||||
// Note that depTag.ExplicitlyVersioned is false in this case.
|
||||
|
@ -2489,7 +2492,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||
|
||||
if ccDep.CcLibrary() && !libDepTag.static() {
|
||||
depIsStubs := ccDep.BuildStubs()
|
||||
depHasStubs := VersionVariantAvailable(c) && ccDep.HasStubsVariants()
|
||||
depHasStubs := CanBeOrLinkAgainstVersionVariants(c) && ccDep.HasStubsVariants()
|
||||
depInSameApexes := android.DirectlyInAllApexes(c.InApexes(), depName)
|
||||
depInPlatform := !android.DirectlyInAnyApex(ctx, depName)
|
||||
|
||||
|
|
|
@ -1541,18 +1541,33 @@ func createVersionVariations(mctx android.BottomUpMutatorContext, versions []str
|
|||
mctx.CreateAliasVariation("latest", latestVersion)
|
||||
}
|
||||
|
||||
func VersionVariantAvailable(module interface {
|
||||
func CanBeOrLinkAgainstVersionVariants(module interface {
|
||||
Host() bool
|
||||
InRamdisk() bool
|
||||
InRecovery() bool
|
||||
UseSdk() bool
|
||||
}) bool {
|
||||
return !module.Host() && !module.InRamdisk() && !module.InRecovery()
|
||||
return !module.Host() && !module.InRamdisk() && !module.InRecovery() && !module.UseSdk()
|
||||
}
|
||||
|
||||
func CanBeVersionVariant(module interface {
|
||||
Host() bool
|
||||
InRamdisk() bool
|
||||
InRecovery() bool
|
||||
UseSdk() bool
|
||||
CcLibraryInterface() bool
|
||||
Shared() bool
|
||||
Static() bool
|
||||
}) bool {
|
||||
return CanBeOrLinkAgainstVersionVariants(module) &&
|
||||
module.CcLibraryInterface() && (module.Shared() || module.Static())
|
||||
}
|
||||
|
||||
// versionSelector normalizes the versions in the Stubs.Versions property into MutatedProperties.AllStubsVersions,
|
||||
// and propagates the value from implementation libraries to llndk libraries with the same name.
|
||||
func versionSelectorMutator(mctx android.BottomUpMutatorContext) {
|
||||
if library, ok := mctx.Module().(LinkableInterface); ok && VersionVariantAvailable(library) {
|
||||
if library, ok := mctx.Module().(LinkableInterface); ok && CanBeVersionVariant(library) {
|
||||
|
||||
if library.CcLibrary() && library.BuildSharedVariant() && len(library.StubsVersions()) > 0 &&
|
||||
!library.IsSdkVariant() {
|
||||
|
||||
|
@ -1582,7 +1597,7 @@ func versionSelectorMutator(mctx android.BottomUpMutatorContext) {
|
|||
// versionMutator splits a module into the mandatory non-stubs variant
|
||||
// (which is unnamed) and zero or more stubs variants.
|
||||
func versionMutator(mctx android.BottomUpMutatorContext) {
|
||||
if library, ok := mctx.Module().(LinkableInterface); ok && VersionVariantAvailable(library) {
|
||||
if library, ok := mctx.Module().(LinkableInterface); ok && CanBeVersionVariant(library) {
|
||||
createVersionVariations(mctx, library.AllStubsVersions())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,8 +85,11 @@ func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorCont
|
|||
variations := target.Variations()
|
||||
if mctx.Device() {
|
||||
variations = append(variations,
|
||||
blueprint.Variation{Mutator: "image", Variation: android.CoreVariation},
|
||||
blueprint.Variation{Mutator: "version", Variation: version})
|
||||
blueprint.Variation{Mutator: "image", Variation: android.CoreVariation})
|
||||
if mt.linkTypes != nil {
|
||||
variations = append(variations,
|
||||
blueprint.Variation{Mutator: "version", Variation: version})
|
||||
}
|
||||
}
|
||||
if mt.linkTypes == nil {
|
||||
mctx.AddFarVariationDependencies(variations, dependencyTag, name)
|
||||
|
|
|
@ -63,6 +63,8 @@ type LinkableInterface interface {
|
|||
ToolchainLibrary() bool
|
||||
NdkPrebuiltStl() bool
|
||||
StubDecorator() bool
|
||||
|
||||
SplitPerApiLevel() bool
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
@ -96,11 +96,6 @@ func (object *objectLinker) linkerProps() []interface{} {
|
|||
func (*objectLinker) linkerInit(ctx BaseModuleContext) {}
|
||||
|
||||
func (object *objectLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
||||
if ctx.useVndk() && ctx.toolchain().Bionic() {
|
||||
// Needed for VNDK builds where bionic headers aren't automatically added.
|
||||
deps.LateSharedLibs = append(deps.LateSharedLibs, "libc")
|
||||
}
|
||||
|
||||
deps.HeaderLibs = append(deps.HeaderLibs, object.Properties.Header_libs...)
|
||||
deps.ObjFiles = append(deps.ObjFiles, object.Properties.Objs...)
|
||||
return deps
|
||||
|
|
|
@ -32,11 +32,11 @@ func sdkMutator(ctx android.BottomUpMutatorContext) {
|
|||
switch m := ctx.Module().(type) {
|
||||
case LinkableInterface:
|
||||
if m.AlwaysSdk() {
|
||||
if !m.UseSdk() {
|
||||
if !m.UseSdk() && !m.SplitPerApiLevel() {
|
||||
ctx.ModuleErrorf("UseSdk() must return true when AlwaysSdk is set, did the factory forget to set Sdk_version?")
|
||||
}
|
||||
ctx.CreateVariations("sdk")
|
||||
} else if m.UseSdk() {
|
||||
} else if m.UseSdk() || m.SplitPerApiLevel() {
|
||||
modules := ctx.CreateVariations("", "sdk")
|
||||
modules[0].(*Module).Properties.Sdk_version = nil
|
||||
modules[1].(*Module).Properties.IsSdkVariant = true
|
||||
|
|
12
rust/rust.go
12
rust/rust.go
|
@ -221,6 +221,10 @@ func (mod *Module) IsSdkVariant() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (mod *Module) SplitPerApiLevel() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (mod *Module) ToolchainLibrary() bool {
|
||||
return false
|
||||
}
|
||||
|
@ -995,11 +999,7 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||
}
|
||||
|
||||
deps := mod.deps(ctx)
|
||||
commonDepVariations := []blueprint.Variation{}
|
||||
if cc.VersionVariantAvailable(mod) {
|
||||
commonDepVariations = append(commonDepVariations,
|
||||
blueprint.Variation{Mutator: "version", Variation: ""})
|
||||
}
|
||||
var commonDepVariations []blueprint.Variation
|
||||
if !mod.Host() {
|
||||
commonDepVariations = append(commonDepVariations,
|
||||
blueprint.Variation{Mutator: "image", Variation: android.CoreVariation})
|
||||
|
@ -1055,7 +1055,7 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||
blueprint.Variation{Mutator: "link", Variation: "static"}),
|
||||
cc.StaticDepTag(), deps.StaticLibs...)
|
||||
|
||||
crtVariations := append(cc.GetCrtVariations(ctx, mod), commonDepVariations...)
|
||||
crtVariations := cc.GetCrtVariations(ctx, mod)
|
||||
if deps.CrtBegin != "" {
|
||||
actx.AddVariationDependencies(crtVariations, cc.CrtBeginDepTag, deps.CrtBegin)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue