Merge "Add package module to sdk snapshot that contains licenses" am: c8aeb00a9c
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1702370 Change-Id: I07ce0f2f6984c1d7c03caea1a1207c36c0c5cfe2
This commit is contained in:
@@ -63,6 +63,12 @@ func TestSnapshotWithPackageDefaultLicense(t *testing.T) {
|
|||||||
checkUnversionedAndroidBpContents(`
|
checkUnversionedAndroidBpContents(`
|
||||||
// This is auto-generated. DO NOT EDIT.
|
// This is auto-generated. DO NOT EDIT.
|
||||||
|
|
||||||
|
package {
|
||||||
|
// A default list here prevents the license LSC from adding its own list which would
|
||||||
|
// be unnecessary as every module in the sdk already has its own licenses property.
|
||||||
|
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||||
|
}
|
||||||
|
|
||||||
java_import {
|
java_import {
|
||||||
name: "myjavalib",
|
name: "myjavalib",
|
||||||
prefer: false,
|
prefer: false,
|
||||||
@@ -88,6 +94,12 @@ license {
|
|||||||
checkVersionedAndroidBpContents(`
|
checkVersionedAndroidBpContents(`
|
||||||
// This is auto-generated. DO NOT EDIT.
|
// This is auto-generated. DO NOT EDIT.
|
||||||
|
|
||||||
|
package {
|
||||||
|
// A default list here prevents the license LSC from adding its own list which would
|
||||||
|
// be unnecessary as every module in the sdk already has its own licenses property.
|
||||||
|
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||||
|
}
|
||||||
|
|
||||||
java_import {
|
java_import {
|
||||||
name: "mysdk_myjavalib@current",
|
name: "mysdk_myjavalib@current",
|
||||||
sdk_member_name: "myjavalib",
|
sdk_member_name: "myjavalib",
|
||||||
|
@@ -228,6 +228,7 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) andro
|
|||||||
|
|
||||||
allMembersByName := make(map[string]struct{})
|
allMembersByName := make(map[string]struct{})
|
||||||
exportedMembersByName := make(map[string]struct{})
|
exportedMembersByName := make(map[string]struct{})
|
||||||
|
hasLicenses := false
|
||||||
var memberVariantDeps []sdkMemberVariantDep
|
var memberVariantDeps []sdkMemberVariantDep
|
||||||
for _, sdkVariant := range sdkVariants {
|
for _, sdkVariant := range sdkVariants {
|
||||||
memberVariantDeps = append(memberVariantDeps, sdkVariant.memberVariantDeps...)
|
memberVariantDeps = append(memberVariantDeps, sdkVariant.memberVariantDeps...)
|
||||||
@@ -241,6 +242,10 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) andro
|
|||||||
if memberVariantDep.export {
|
if memberVariantDep.export {
|
||||||
exportedMembersByName[name] = struct{}{}
|
exportedMembersByName[name] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if memberVariantDep.memberType == android.LicenseModuleSdkMemberType {
|
||||||
|
hasLicenses = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,6 +271,22 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) andro
|
|||||||
}
|
}
|
||||||
s.builderForTests = builder
|
s.builderForTests = builder
|
||||||
|
|
||||||
|
// If the sdk snapshot includes any license modules then add a package module which has a
|
||||||
|
// default_applicable_licenses property. That will prevent the LSC license process from updating
|
||||||
|
// the generated Android.bp file to add a package module that includes all licenses used by all
|
||||||
|
// the modules in that package. That would be unnecessary as every module in the sdk should have
|
||||||
|
// their own licenses property specified.
|
||||||
|
if hasLicenses {
|
||||||
|
pkg := bpFile.newModule("package")
|
||||||
|
property := "default_applicable_licenses"
|
||||||
|
pkg.AddCommentForProperty(property, `
|
||||||
|
A default list here prevents the license LSC from adding its own list which would
|
||||||
|
be unnecessary as every module in the sdk already has its own licenses property.
|
||||||
|
`)
|
||||||
|
pkg.AddProperty(property, []string{"Android-Apache-2.0"})
|
||||||
|
bpFile.AddModule(pkg)
|
||||||
|
}
|
||||||
|
|
||||||
// Group the variants for each member module together and then group the members of each member
|
// Group the variants for each member module together and then group the members of each member
|
||||||
// type together.
|
// type together.
|
||||||
members := s.groupMemberVariantsByMemberThenType(ctx, memberVariantDeps)
|
members := s.groupMemberVariantsByMemberThenType(ctx, memberVariantDeps)
|
||||||
|
Reference in New Issue
Block a user