Merge "Revert "Remove compilation actions from java sdk library"" into main
This commit is contained in:
@@ -1122,7 +1122,7 @@ func AndroidMkEntriesForTest(t *testing.T, ctx *TestContext, mod blueprint.Modul
|
|||||||
|
|
||||||
entriesList := p.AndroidMkEntries()
|
entriesList := p.AndroidMkEntries()
|
||||||
aconfigUpdateAndroidMkEntries(ctx, mod.(Module), &entriesList)
|
aconfigUpdateAndroidMkEntries(ctx, mod.(Module), &entriesList)
|
||||||
for i := range entriesList {
|
for i, _ := range entriesList {
|
||||||
entriesList[i].fillInEntries(ctx, mod)
|
entriesList[i].fillInEntries(ctx, mod)
|
||||||
}
|
}
|
||||||
return entriesList
|
return entriesList
|
||||||
|
@@ -1677,13 +1677,7 @@ func apexFileForJavaModuleWithFile(ctx android.BaseModuleContext, module javaMod
|
|||||||
af.jacocoReportClassesFile = module.JacocoReportClassesFile()
|
af.jacocoReportClassesFile = module.JacocoReportClassesFile()
|
||||||
af.lintDepSets = module.LintDepSets()
|
af.lintDepSets = module.LintDepSets()
|
||||||
af.customStem = module.Stem() + ".jar"
|
af.customStem = module.Stem() + ".jar"
|
||||||
// TODO: b/338641779 - Remove special casing of sdkLibrary once bcpf and sscpf depends
|
if dexpreopter, ok := module.(java.DexpreopterInterface); ok {
|
||||||
// on the implementation library
|
|
||||||
if sdkLib, ok := module.(*java.SdkLibrary); ok {
|
|
||||||
for _, install := range sdkLib.BuiltInstalledForApex() {
|
|
||||||
af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
|
|
||||||
}
|
|
||||||
} else if dexpreopter, ok := module.(java.DexpreopterInterface); ok {
|
|
||||||
for _, install := range dexpreopter.DexpreoptBuiltInstalledForApex() {
|
for _, install := range dexpreopter.DexpreoptBuiltInstalledForApex() {
|
||||||
af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
|
af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
|
||||||
}
|
}
|
||||||
|
@@ -7146,7 +7146,7 @@ func TestJavaSDKLibrary_WithinApex(t *testing.T) {
|
|||||||
|
|
||||||
// The bar library should depend on the implementation jar.
|
// The bar library should depend on the implementation jar.
|
||||||
barLibrary := ctx.ModuleForTests("bar", "android_common_myapex").Rule("javac")
|
barLibrary := ctx.ModuleForTests("bar", "android_common_myapex").Rule("javac")
|
||||||
if expected, actual := `^-classpath [^:]*/turbine-combined/foo\.jar$`, barLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
|
if expected, actual := `^-classpath [^:]*/turbine-combined/foo\.impl\.jar$`, barLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
|
||||||
t.Errorf("expected %q, found %#q", expected, actual)
|
t.Errorf("expected %q, found %#q", expected, actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7287,7 +7287,7 @@ func TestJavaSDKLibrary_ImportPreferred(t *testing.T) {
|
|||||||
|
|
||||||
// The bar library should depend on the implementation jar.
|
// The bar library should depend on the implementation jar.
|
||||||
barLibrary := ctx.ModuleForTests("bar", "android_common_myapex").Rule("javac")
|
barLibrary := ctx.ModuleForTests("bar", "android_common_myapex").Rule("javac")
|
||||||
if expected, actual := `^-classpath [^:]*/turbine-combined/foo\.jar$`, barLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
|
if expected, actual := `^-classpath [^:]*/turbine-combined/foo\.impl\.jar$`, barLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
|
||||||
t.Errorf("expected %q, found %#q", expected, actual)
|
t.Errorf("expected %q, found %#q", expected, actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -161,8 +161,8 @@ func TestJavaSdkLibrary_RequireXmlPermissionFile(t *testing.T) {
|
|||||||
moduleName string
|
moduleName string
|
||||||
expected []string
|
expected []string
|
||||||
}{
|
}{
|
||||||
{"foo-shared_library", []string{"foo-shared_library.impl", "foo-shared_library.xml"}},
|
{"foo-shared_library", []string{"foo-shared_library.xml"}},
|
||||||
{"foo-no_shared_library", []string{"foo-no_shared_library.impl"}},
|
{"foo-no_shared_library", nil},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
mod := result.ModuleForTests(tc.moduleName, "android_common").Module()
|
mod := result.ModuleForTests(tc.moduleName, "android_common").Module()
|
||||||
|
@@ -1682,11 +1682,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
|||||||
j.dexJarFile = makeDexJarPathFromPath(dexOutputFile)
|
j.dexJarFile = makeDexJarPathFromPath(dexOutputFile)
|
||||||
|
|
||||||
// Dexpreopting
|
// Dexpreopting
|
||||||
libName := android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName())
|
j.dexpreopt(ctx, android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName()), dexOutputFile)
|
||||||
if j.SdkLibraryName() != nil && strings.HasSuffix(ctx.ModuleName(), ".impl") {
|
|
||||||
libName = strings.TrimSuffix(libName, ".impl")
|
|
||||||
}
|
|
||||||
j.dexpreopt(ctx, libName, dexOutputFile)
|
|
||||||
|
|
||||||
outputFile = dexOutputFile
|
outputFile = dexOutputFile
|
||||||
} else {
|
} else {
|
||||||
|
@@ -7,7 +7,6 @@ import (
|
|||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
soongTesting "android/soong/testing"
|
soongTesting "android/soong/testing"
|
||||||
"android/soong/testing/code_metadata_internal_proto"
|
"android/soong/testing/code_metadata_internal_proto"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -150,10 +150,6 @@ func isModuleInConfiguredList(ctx android.BaseModuleContext, module android.Modu
|
|||||||
// Strip a prebuilt_ prefix so that this can match a prebuilt module that has not been renamed.
|
// Strip a prebuilt_ prefix so that this can match a prebuilt module that has not been renamed.
|
||||||
name = android.RemoveOptionalPrebuiltPrefix(name)
|
name = android.RemoveOptionalPrebuiltPrefix(name)
|
||||||
|
|
||||||
// Strip the ".impl" suffix, so that the implementation library of the java_sdk_library is
|
|
||||||
// treated identical to the top level java_sdk_library.
|
|
||||||
name = strings.TrimSuffix(name, ".impl")
|
|
||||||
|
|
||||||
// Ignore any module that is not listed in the boot image configuration.
|
// Ignore any module that is not listed in the boot image configuration.
|
||||||
index := configuredBootJars.IndexOfJar(name)
|
index := configuredBootJars.IndexOfJar(name)
|
||||||
if index == -1 {
|
if index == -1 {
|
||||||
|
@@ -303,7 +303,7 @@ func TestHiddenAPIEncoding_JavaSdkLibrary(t *testing.T) {
|
|||||||
`)
|
`)
|
||||||
|
|
||||||
checkDexEncoded := func(t *testing.T, name, unencodedDexJar, encodedDexJar string) {
|
checkDexEncoded := func(t *testing.T, name, unencodedDexJar, encodedDexJar string) {
|
||||||
moduleForTests := result.ModuleForTests(name+".impl", "android_common")
|
moduleForTests := result.ModuleForTests(name, "android_common")
|
||||||
|
|
||||||
encodeDexRule := moduleForTests.Rule("hiddenAPIEncodeDex")
|
encodeDexRule := moduleForTests.Rule("hiddenAPIEncodeDex")
|
||||||
actualUnencodedDexJar := encodeDexRule.Input
|
actualUnencodedDexJar := encodeDexRule.Input
|
||||||
@@ -319,8 +319,18 @@ func TestHiddenAPIEncoding_JavaSdkLibrary(t *testing.T) {
|
|||||||
|
|
||||||
// The java_library embedded with the java_sdk_library must be dex encoded.
|
// The java_library embedded with the java_sdk_library must be dex encoded.
|
||||||
t.Run("foo", func(t *testing.T) {
|
t.Run("foo", func(t *testing.T) {
|
||||||
expectedUnencodedDexJar := "out/soong/.intermediates/foo.impl/android_common/aligned/foo.jar"
|
expectedUnencodedDexJar := "out/soong/.intermediates/foo/android_common/aligned/foo.jar"
|
||||||
expectedEncodedDexJar := "out/soong/.intermediates/foo.impl/android_common/hiddenapi/foo.jar"
|
expectedEncodedDexJar := "out/soong/.intermediates/foo/android_common/hiddenapi/foo.jar"
|
||||||
checkDexEncoded(t, "foo", expectedUnencodedDexJar, expectedEncodedDexJar)
|
checkDexEncoded(t, "foo", expectedUnencodedDexJar, expectedEncodedDexJar)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// The dex jar of the child implementation java_library of the java_sdk_library is not currently
|
||||||
|
// dex encoded.
|
||||||
|
t.Run("foo.impl", func(t *testing.T) {
|
||||||
|
fooImpl := result.ModuleForTests("foo.impl", "android_common")
|
||||||
|
encodeDexRule := fooImpl.MaybeRule("hiddenAPIEncodeDex")
|
||||||
|
if encodeDexRule.Rule != nil {
|
||||||
|
t.Errorf("foo.impl is not expected to be encoded")
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
49
java/java.go
49
java/java.go
@@ -674,10 +674,6 @@ type Library struct {
|
|||||||
|
|
||||||
var _ android.ApexModule = (*Library)(nil)
|
var _ android.ApexModule = (*Library)(nil)
|
||||||
|
|
||||||
func (j *Library) CheckDepsMinSdkVersion(ctx android.ModuleContext) {
|
|
||||||
CheckMinSdkVersion(ctx, j)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Provides access to the list of permitted packages from apex boot jars.
|
// Provides access to the list of permitted packages from apex boot jars.
|
||||||
type PermittedPackagesForUpdatableBootJars interface {
|
type PermittedPackagesForUpdatableBootJars interface {
|
||||||
PermittedPackagesForUpdatableBootJars() []string
|
PermittedPackagesForUpdatableBootJars() []string
|
||||||
@@ -906,12 +902,6 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
j.minSdkVersion = j.MinSdkVersion(ctx)
|
j.minSdkVersion = j.MinSdkVersion(ctx)
|
||||||
j.maxSdkVersion = j.MaxSdkVersion(ctx)
|
j.maxSdkVersion = j.MaxSdkVersion(ctx)
|
||||||
|
|
||||||
// Check min_sdk_version of the transitive dependencies if this module is created from
|
|
||||||
// java_sdk_library.
|
|
||||||
if j.deviceProperties.Min_sdk_version != nil && j.SdkLibraryName() != nil {
|
|
||||||
j.CheckDepsMinSdkVersion(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SdkLibrary.GenerateAndroidBuildActions(ctx) sets the stubsLinkType to Unknown.
|
// SdkLibrary.GenerateAndroidBuildActions(ctx) sets the stubsLinkType to Unknown.
|
||||||
// If the stubsLinkType has already been set to Unknown, the stubsLinkType should
|
// If the stubsLinkType has already been set to Unknown, the stubsLinkType should
|
||||||
// not be overridden.
|
// not be overridden.
|
||||||
@@ -942,12 +932,8 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
j.checkSdkVersions(ctx)
|
j.checkSdkVersions(ctx)
|
||||||
j.checkHeadersOnly(ctx)
|
j.checkHeadersOnly(ctx)
|
||||||
if ctx.Device() {
|
if ctx.Device() {
|
||||||
libName := j.Name()
|
|
||||||
if j.SdkLibraryName() != nil && strings.HasSuffix(libName, ".impl") {
|
|
||||||
libName = proptools.String(j.SdkLibraryName())
|
|
||||||
}
|
|
||||||
j.dexpreopter.installPath = j.dexpreopter.getInstallPath(
|
j.dexpreopter.installPath = j.dexpreopter.getInstallPath(
|
||||||
ctx, libName, android.PathForModuleInstall(ctx, "framework", j.Stem()+".jar"))
|
ctx, j.Name(), android.PathForModuleInstall(ctx, "framework", j.Stem()+".jar"))
|
||||||
j.dexpreopter.isSDKLibrary = j.deviceProperties.IsSDKLibrary
|
j.dexpreopter.isSDKLibrary = j.deviceProperties.IsSDKLibrary
|
||||||
setUncompressDex(ctx, &j.dexpreopter, &j.dexer)
|
setUncompressDex(ctx, &j.dexpreopter, &j.dexer)
|
||||||
j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
|
j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
|
||||||
@@ -958,24 +944,8 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
j.compile(ctx, nil, nil, nil)
|
j.compile(ctx, nil, nil, nil)
|
||||||
|
|
||||||
// If this module is an impl library created from java_sdk_library,
|
exclusivelyForApex := !apexInfo.IsForPlatform()
|
||||||
// install the files under the java_sdk_library module outdir instead of this module outdir.
|
if (Bool(j.properties.Installable) || ctx.Host()) && !exclusivelyForApex {
|
||||||
if j.SdkLibraryName() != nil && strings.HasSuffix(j.Name(), ".impl") {
|
|
||||||
j.setInstallRules(ctx, proptools.String(j.SdkLibraryName()))
|
|
||||||
} else {
|
|
||||||
j.setInstallRules(ctx, ctx.ModuleName())
|
|
||||||
}
|
|
||||||
|
|
||||||
android.SetProvider(ctx, android.TestOnlyProviderKey, android.TestModuleInformation{
|
|
||||||
TestOnly: Bool(j.sourceProperties.Test_only),
|
|
||||||
TopLevelTarget: j.sourceProperties.Top_level_test_target,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (j *Library) setInstallRules(ctx android.ModuleContext, installModuleName string) {
|
|
||||||
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
|
|
||||||
|
|
||||||
if (Bool(j.properties.Installable) || ctx.Host()) && apexInfo.IsForPlatform() {
|
|
||||||
var extraInstallDeps android.InstallPaths
|
var extraInstallDeps android.InstallPaths
|
||||||
if j.InstallMixin != nil {
|
if j.InstallMixin != nil {
|
||||||
extraInstallDeps = j.InstallMixin(ctx, j.outputFile)
|
extraInstallDeps = j.InstallMixin(ctx, j.outputFile)
|
||||||
@@ -992,23 +962,22 @@ func (j *Library) setInstallRules(ctx android.ModuleContext, installModuleName s
|
|||||||
if !ctx.Host() {
|
if !ctx.Host() {
|
||||||
archDir = ctx.DeviceConfig().DeviceArch()
|
archDir = ctx.DeviceConfig().DeviceArch()
|
||||||
}
|
}
|
||||||
installDir = android.PathForModuleInstall(ctx, installModuleName, archDir)
|
installDir = android.PathForModuleInstall(ctx, ctx.ModuleName(), archDir)
|
||||||
} else {
|
} else {
|
||||||
installDir = android.PathForModuleInstall(ctx, "framework")
|
installDir = android.PathForModuleInstall(ctx, "framework")
|
||||||
}
|
}
|
||||||
j.installFile = ctx.InstallFile(installDir, j.Stem()+".jar", j.outputFile, extraInstallDeps...)
|
j.installFile = ctx.InstallFile(installDir, j.Stem()+".jar", j.outputFile, extraInstallDeps...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
android.SetProvider(ctx, android.TestOnlyProviderKey, android.TestModuleInformation{
|
||||||
|
TestOnly: Bool(j.sourceProperties.Test_only),
|
||||||
|
TopLevelTarget: j.sourceProperties.Top_level_test_target,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
j.usesLibrary.deps(ctx, false)
|
j.usesLibrary.deps(ctx, false)
|
||||||
j.deps(ctx)
|
j.deps(ctx)
|
||||||
|
|
||||||
if j.SdkLibraryName() != nil && strings.HasSuffix(j.Name(), ".impl") {
|
|
||||||
if dexpreopt.IsDex2oatNeeded(ctx) {
|
|
||||||
dexpreopt.RegisterToolDeps(ctx)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@@ -353,7 +353,7 @@ func TestPlatformBootclasspath_HiddenAPIMonolithicFiles(t *testing.T) {
|
|||||||
|
|
||||||
// All the intermediate rules use the same inputs.
|
// All the intermediate rules use the same inputs.
|
||||||
expectedIntermediateInputs := `
|
expectedIntermediateInputs := `
|
||||||
out/soong/.intermediates/bar.impl/android_common/javac/bar.jar
|
out/soong/.intermediates/bar/android_common/javac/bar.jar
|
||||||
out/soong/.intermediates/foo-hiddenapi-annotations/android_common/javac/foo-hiddenapi-annotations.jar
|
out/soong/.intermediates/foo-hiddenapi-annotations/android_common/javac/foo-hiddenapi-annotations.jar
|
||||||
out/soong/.intermediates/foo/android_common/javac/foo.jar
|
out/soong/.intermediates/foo/android_common/javac/foo.jar
|
||||||
`
|
`
|
||||||
|
@@ -950,10 +950,6 @@ type commonToSdkLibraryAndImport struct {
|
|||||||
// Path to the header jars of the implementation library
|
// Path to the header jars of the implementation library
|
||||||
// This is non-empty only when api_only is false.
|
// This is non-empty only when api_only is false.
|
||||||
implLibraryHeaderJars android.Paths
|
implLibraryHeaderJars android.Paths
|
||||||
|
|
||||||
// The reference to the implementation library created by the source module.
|
|
||||||
// Is nil if the source module does not exist.
|
|
||||||
implLibraryModule *Library
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *commonToSdkLibraryAndImport) initCommon(module commonSdkLibraryAndImportModule) {
|
func (c *commonToSdkLibraryAndImport) initCommon(module commonSdkLibraryAndImportModule) {
|
||||||
@@ -1000,10 +996,6 @@ func (c *commonToSdkLibraryAndImport) generateCommonBuildActions(ctx android.Mod
|
|||||||
c.doctagPaths = android.PathsForModuleSrc(ctx, c.commonSdkLibraryProperties.Doctag_files)
|
c.doctagPaths = android.PathsForModuleSrc(ctx, c.commonSdkLibraryProperties.Doctag_files)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *commonToSdkLibraryAndImport) getImplLibraryModule() *Library {
|
|
||||||
return c.implLibraryModule
|
|
||||||
}
|
|
||||||
|
|
||||||
// Module name of the runtime implementation library
|
// Module name of the runtime implementation library
|
||||||
func (c *commonToSdkLibraryAndImport) implLibraryModuleName() string {
|
func (c *commonToSdkLibraryAndImport) implLibraryModuleName() string {
|
||||||
return c.module.RootLibraryName() + ".impl"
|
return c.module.RootLibraryName() + ".impl"
|
||||||
@@ -1380,8 +1372,6 @@ type SdkLibraryDependency interface {
|
|||||||
|
|
||||||
// sharedLibrary returns true if this can be used as a shared library.
|
// sharedLibrary returns true if this can be used as a shared library.
|
||||||
sharedLibrary() bool
|
sharedLibrary() bool
|
||||||
|
|
||||||
getImplLibraryModule() *Library
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SdkLibrary struct {
|
type SdkLibrary struct {
|
||||||
@@ -1393,8 +1383,6 @@ type SdkLibrary struct {
|
|||||||
scopeToProperties map[*apiScope]*ApiScopeProperties
|
scopeToProperties map[*apiScope]*ApiScopeProperties
|
||||||
|
|
||||||
commonToSdkLibraryAndImport
|
commonToSdkLibraryAndImport
|
||||||
|
|
||||||
builtInstalledForApex []dexpreopterInstall
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ SdkLibraryDependency = (*SdkLibrary)(nil)
|
var _ SdkLibraryDependency = (*SdkLibrary)(nil)
|
||||||
@@ -1403,20 +1391,6 @@ func (module *SdkLibrary) generateTestAndSystemScopesByDefault() bool {
|
|||||||
return module.sdkLibraryProperties.Generate_system_and_test_apis
|
return module.sdkLibraryProperties.Generate_system_and_test_apis
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath {
|
|
||||||
if module.implLibraryModule != nil {
|
|
||||||
return module.implLibraryModule.DexJarBuildPath(ctx)
|
|
||||||
}
|
|
||||||
return makeUnsetDexJarPath()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (module *SdkLibrary) DexJarInstallPath() android.Path {
|
|
||||||
if module.implLibraryModule != nil {
|
|
||||||
return module.implLibraryModule.DexJarInstallPath()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (module *SdkLibrary) getGeneratedApiScopes(ctx android.EarlyModuleContext) apiScopes {
|
func (module *SdkLibrary) getGeneratedApiScopes(ctx android.EarlyModuleContext) apiScopes {
|
||||||
// Check to see if any scopes have been explicitly enabled. If any have then all
|
// Check to see if any scopes have been explicitly enabled. If any have then all
|
||||||
// must be.
|
// must be.
|
||||||
@@ -1468,10 +1442,6 @@ func (module *SdkLibrary) getGeneratedApiScopes(ctx android.EarlyModuleContext)
|
|||||||
var _ android.ModuleWithMinSdkVersionCheck = (*SdkLibrary)(nil)
|
var _ android.ModuleWithMinSdkVersionCheck = (*SdkLibrary)(nil)
|
||||||
|
|
||||||
func (module *SdkLibrary) CheckMinSdkVersion(ctx android.ModuleContext) {
|
func (module *SdkLibrary) CheckMinSdkVersion(ctx android.ModuleContext) {
|
||||||
CheckMinSdkVersion(ctx, &module.Library)
|
|
||||||
}
|
|
||||||
|
|
||||||
func CheckMinSdkVersion(ctx android.ModuleContext, module *Library) {
|
|
||||||
android.CheckMinSdkVersion(ctx, module.MinSdkVersion(ctx), func(c android.ModuleContext, do android.PayloadDepsCallback) {
|
android.CheckMinSdkVersion(ctx, module.MinSdkVersion(ctx), func(c android.ModuleContext, do android.PayloadDepsCallback) {
|
||||||
ctx.WalkDeps(func(child android.Module, parent android.Module) bool {
|
ctx.WalkDeps(func(child android.Module, parent android.Module) bool {
|
||||||
isExternal := !module.depIsInSameApex(ctx, child)
|
isExternal := !module.depIsInSameApex(ctx, child)
|
||||||
@@ -1568,6 +1538,10 @@ func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
m += "Please see the documentation of the prebuilt_apis module type (and a usage example in prebuilts/sdk) for a convenient way to generate these."
|
m += "Please see the documentation of the prebuilt_apis module type (and a usage example in prebuilts/sdk) for a convenient way to generate these."
|
||||||
ctx.ModuleErrorf(m)
|
ctx.ModuleErrorf(m)
|
||||||
}
|
}
|
||||||
|
if module.requiresRuntimeImplementationLibrary() {
|
||||||
|
// Only add the deps for the library if it is actually going to be built.
|
||||||
|
module.Library.deps(ctx)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) OutputFiles(tag string) (android.Paths, error) {
|
func (module *SdkLibrary) OutputFiles(tag string) (android.Paths, error) {
|
||||||
@@ -1576,7 +1550,7 @@ func (module *SdkLibrary) OutputFiles(tag string) (android.Paths, error) {
|
|||||||
return paths, err
|
return paths, err
|
||||||
}
|
}
|
||||||
if module.requiresRuntimeImplementationLibrary() {
|
if module.requiresRuntimeImplementationLibrary() {
|
||||||
return module.implLibraryModule.OutputFiles(tag)
|
return module.Library.OutputFiles(tag)
|
||||||
}
|
}
|
||||||
if tag == "" {
|
if tag == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@@ -1591,12 +1565,18 @@ func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
|||||||
// TODO (b/331665856): Implement a principled solution for this.
|
// TODO (b/331665856): Implement a principled solution for this.
|
||||||
module.HideFromMake()
|
module.HideFromMake()
|
||||||
}
|
}
|
||||||
|
if proptools.String(module.deviceProperties.Min_sdk_version) != "" {
|
||||||
|
module.CheckMinSdkVersion(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
module.generateCommonBuildActions(ctx)
|
module.generateCommonBuildActions(ctx)
|
||||||
|
|
||||||
module.stem = proptools.StringDefault(module.overridableProperties.Stem, ctx.ModuleName())
|
// Only build an implementation library if required.
|
||||||
|
if module.requiresRuntimeImplementationLibrary() {
|
||||||
module.provideHiddenAPIPropertyInfo(ctx)
|
// stubsLinkType must be set before calling Library.GenerateAndroidBuildActions
|
||||||
|
module.Library.stubsLinkType = Unknown
|
||||||
|
module.Library.GenerateAndroidBuildActions(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
// Collate the components exported by this module. All scope specific modules are exported but
|
// Collate the components exported by this module. All scope specific modules are exported but
|
||||||
// the impl and xml component modules are not.
|
// the impl and xml component modules are not.
|
||||||
@@ -1623,40 +1603,10 @@ func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
|||||||
if tag == implLibraryTag {
|
if tag == implLibraryTag {
|
||||||
if dep, ok := android.OtherModuleProvider(ctx, to, JavaInfoProvider); ok {
|
if dep, ok := android.OtherModuleProvider(ctx, to, JavaInfoProvider); ok {
|
||||||
module.implLibraryHeaderJars = append(module.implLibraryHeaderJars, dep.HeaderJars...)
|
module.implLibraryHeaderJars = append(module.implLibraryHeaderJars, dep.HeaderJars...)
|
||||||
module.implLibraryModule = to.(*Library)
|
|
||||||
android.SetProvider(ctx, JavaInfoProvider, dep)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
|
|
||||||
if !apexInfo.IsForPlatform() {
|
|
||||||
module.hideApexVariantFromMake = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if module.implLibraryModule != nil {
|
|
||||||
if ctx.Device() {
|
|
||||||
module.classesJarPaths = android.Paths{module.implLibraryModule.implementationJarFile}
|
|
||||||
module.bootDexJarPath = module.implLibraryModule.bootDexJarPath
|
|
||||||
module.uncompressDexState = module.implLibraryModule.uncompressDexState
|
|
||||||
module.active = module.implLibraryModule.active
|
|
||||||
}
|
|
||||||
|
|
||||||
module.outputFile = module.implLibraryModule.outputFile
|
|
||||||
module.dexJarFile = makeDexJarPathFromPath(module.implLibraryModule.dexJarFile.Path())
|
|
||||||
module.headerJarFile = module.implLibraryModule.headerJarFile
|
|
||||||
module.implementationAndResourcesJar = module.implLibraryModule.implementationAndResourcesJar
|
|
||||||
module.builtInstalledForApex = module.implLibraryModule.builtInstalledForApex
|
|
||||||
module.dexpreopter.configPath = module.implLibraryModule.dexpreopter.configPath
|
|
||||||
module.dexpreopter.outputProfilePathOnHost = module.implLibraryModule.dexpreopter.outputProfilePathOnHost
|
|
||||||
|
|
||||||
if !module.Host() {
|
|
||||||
module.hostdexInstallFile = module.implLibraryModule.hostdexInstallFile
|
|
||||||
}
|
|
||||||
|
|
||||||
android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: module.implLibraryModule.uniqueSrcFiles.Strings()})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make the set of components exported by this module available for use elsewhere.
|
// Make the set of components exported by this module available for use elsewhere.
|
||||||
exportedComponentInfo := android.ExportedComponentsInfo{Components: android.SortedKeys(exportedComponents)}
|
exportedComponentInfo := android.ExportedComponentsInfo{Components: android.SortedKeys(exportedComponents)}
|
||||||
android.SetProvider(ctx, android.ExportedComponentsInfoProvider, exportedComponentInfo)
|
android.SetProvider(ctx, android.ExportedComponentsInfoProvider, exportedComponentInfo)
|
||||||
@@ -1686,18 +1636,13 @@ func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
|||||||
android.SetProvider(ctx, android.AdditionalSdkInfoProvider, android.AdditionalSdkInfo{additionalSdkInfo})
|
android.SetProvider(ctx, android.AdditionalSdkInfoProvider, android.AdditionalSdkInfo{additionalSdkInfo})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) BuiltInstalledForApex() []dexpreopterInstall {
|
|
||||||
return module.builtInstalledForApex
|
|
||||||
}
|
|
||||||
|
|
||||||
func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {
|
func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {
|
||||||
if !module.requiresRuntimeImplementationLibrary() {
|
if !module.requiresRuntimeImplementationLibrary() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
entriesList := module.Library.AndroidMkEntries()
|
entriesList := module.Library.AndroidMkEntries()
|
||||||
entries := &entriesList[0]
|
|
||||||
entries.Required = append(entries.Required, module.implLibraryModuleName())
|
|
||||||
if module.sharedLibrary() {
|
if module.sharedLibrary() {
|
||||||
|
entries := &entriesList[0]
|
||||||
entries.Required = append(entries.Required, module.xmlPermissionsModuleName())
|
entries.Required = append(entries.Required, module.xmlPermissionsModuleName())
|
||||||
}
|
}
|
||||||
return entriesList
|
return entriesList
|
||||||
@@ -1818,21 +1763,20 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext)
|
|||||||
Libs []string
|
Libs []string
|
||||||
Static_libs []string
|
Static_libs []string
|
||||||
Apex_available []string
|
Apex_available []string
|
||||||
Stem *string
|
|
||||||
}{
|
}{
|
||||||
Name: proptools.StringPtr(module.implLibraryModuleName()),
|
Name: proptools.StringPtr(module.implLibraryModuleName()),
|
||||||
Visibility: visibility,
|
Visibility: visibility,
|
||||||
// Set the instrument property to ensure it is instrumented when instrumentation is required.
|
// Set the instrument property to ensure it is instrumented when instrumentation is required.
|
||||||
Instrument: true,
|
Instrument: true,
|
||||||
|
// Set the impl_only libs. Note that the module's "Libs" get appended as well, via the
|
||||||
Libs: append(module.properties.Libs, module.sdkLibraryProperties.Impl_only_libs...),
|
// addition of &module.properties below.
|
||||||
|
Libs: module.sdkLibraryProperties.Impl_only_libs,
|
||||||
Static_libs: append(module.properties.Static_libs, module.sdkLibraryProperties.Impl_only_static_libs...),
|
// Set the impl_only static libs. Note that the module's "static_libs" get appended as well, via the
|
||||||
|
// addition of &module.properties below.
|
||||||
|
Static_libs: module.sdkLibraryProperties.Impl_only_static_libs,
|
||||||
// Pass the apex_available settings down so that the impl library can be statically
|
// Pass the apex_available settings down so that the impl library can be statically
|
||||||
// embedded within a library that is added to an APEX. Needed for updatable-media.
|
// embedded within a library that is added to an APEX. Needed for updatable-media.
|
||||||
Apex_available: module.ApexAvailable(),
|
Apex_available: module.ApexAvailable(),
|
||||||
|
|
||||||
Stem: proptools.StringPtr(module.Name()),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
properties := []interface{}{
|
properties := []interface{}{
|
||||||
@@ -2223,9 +2167,6 @@ func (module *SdkLibrary) DepIsInSameApex(mctx android.BaseModuleContext, dep an
|
|||||||
if depTag == xmlPermissionsFileTag {
|
if depTag == xmlPermissionsFileTag {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if dep.Name() == module.implLibraryModuleName() {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return module.Library.DepIsInSameApex(mctx, dep)
|
return module.Library.DepIsInSameApex(mctx, dep)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2651,6 +2592,10 @@ type SdkLibraryImport struct {
|
|||||||
|
|
||||||
commonToSdkLibraryAndImport
|
commonToSdkLibraryAndImport
|
||||||
|
|
||||||
|
// The reference to the implementation library created by the source module.
|
||||||
|
// Is nil if the source module does not exist.
|
||||||
|
implLibraryModule *Library
|
||||||
|
|
||||||
// The reference to the xml permissions module created by the source module.
|
// The reference to the xml permissions module created by the source module.
|
||||||
// Is nil if the source module does not exist.
|
// Is nil if the source module does not exist.
|
||||||
xmlPermissionsFileModule *sdkLibraryXml
|
xmlPermissionsFileModule *sdkLibraryXml
|
||||||
@@ -3615,8 +3560,7 @@ func (s *sdkLibrarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMembe
|
|||||||
s.Min_device_sdk = sdk.commonSdkLibraryProperties.Min_device_sdk
|
s.Min_device_sdk = sdk.commonSdkLibraryProperties.Min_device_sdk
|
||||||
s.Max_device_sdk = sdk.commonSdkLibraryProperties.Max_device_sdk
|
s.Max_device_sdk = sdk.commonSdkLibraryProperties.Max_device_sdk
|
||||||
|
|
||||||
implLibrary := sdk.getImplLibraryModule()
|
if sdk.dexpreopter.dexpreoptProperties.Dex_preopt_result.Profile_guided {
|
||||||
if implLibrary != nil && implLibrary.dexpreopter.dexpreoptProperties.Dex_preopt_result.Profile_guided {
|
|
||||||
s.DexPreoptProfileGuided = proptools.BoolPtr(true)
|
s.DexPreoptProfileGuided = proptools.BoolPtr(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -186,13 +186,13 @@ func TestJavaSdkLibrary(t *testing.T) {
|
|||||||
// test if quuz have created the api_contribution module
|
// test if quuz have created the api_contribution module
|
||||||
result.ModuleForTests(apiScopePublic.stubsSourceModuleName("quuz")+".api.contribution", "")
|
result.ModuleForTests(apiScopePublic.stubsSourceModuleName("quuz")+".api.contribution", "")
|
||||||
|
|
||||||
fooImplDexJar := result.ModuleForTests("foo.impl", "android_common").Rule("d8")
|
fooDexJar := result.ModuleForTests("foo", "android_common").Rule("d8")
|
||||||
// tests if kotlinc generated files are NOT excluded from output of foo.impl.
|
// tests if kotlinc generated files are NOT excluded from output of foo.
|
||||||
android.AssertStringDoesNotContain(t, "foo.impl dex", fooImplDexJar.BuildParams.Args["mergeZipsFlags"], "-stripFile META-INF/*.kotlin_module")
|
android.AssertStringDoesNotContain(t, "foo dex", fooDexJar.BuildParams.Args["mergeZipsFlags"], "-stripFile META-INF/*.kotlin_module")
|
||||||
|
|
||||||
barImplDexJar := result.ModuleForTests("bar.impl", "android_common").Rule("d8")
|
barDexJar := result.ModuleForTests("bar", "android_common").Rule("d8")
|
||||||
// tests if kotlinc generated files are excluded from output of bar.impl.
|
// tests if kotlinc generated files are excluded from output of bar.
|
||||||
android.AssertStringDoesContain(t, "bar.impl dex", barImplDexJar.BuildParams.Args["mergeZipsFlags"], "-stripFile META-INF/*.kotlin_module")
|
android.AssertStringDoesContain(t, "bar dex", barDexJar.BuildParams.Args["mergeZipsFlags"], "-stripFile META-INF/*.kotlin_module")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestJavaSdkLibrary_UpdatableLibrary(t *testing.T) {
|
func TestJavaSdkLibrary_UpdatableLibrary(t *testing.T) {
|
||||||
@@ -1457,11 +1457,11 @@ func TestSdkLibrary_CheckMinSdkVersion(t *testing.T) {
|
|||||||
preparer.RunTestWithBp(t, `
|
preparer.RunTestWithBp(t, `
|
||||||
java_sdk_library {
|
java_sdk_library {
|
||||||
name: "sdklib",
|
name: "sdklib",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
static_libs: ["util"],
|
static_libs: ["util"],
|
||||||
min_sdk_version: "30",
|
min_sdk_version: "30",
|
||||||
unsafe_ignore_missing_latest_api: true,
|
unsafe_ignore_missing_latest_api: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
java_library {
|
java_library {
|
||||||
name: "util",
|
name: "util",
|
||||||
|
@@ -1095,7 +1095,7 @@ func testSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T, targetBui
|
|||||||
|
|
||||||
bcpf := result.ModuleForTests("mybootclasspathfragment", "android_common")
|
bcpf := result.ModuleForTests("mybootclasspathfragment", "android_common")
|
||||||
rule := bcpf.Output("out/soong/.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi" + suffix + "/stub-flags.csv")
|
rule := bcpf.Output("out/soong/.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi" + suffix + "/stub-flags.csv")
|
||||||
android.AssertPathsRelativeToTopEquals(t, "stub flags inputs", android.SortedUniqueStrings(expectedStubFlagsInputs), android.SortedUniquePaths(rule.Implicits))
|
android.AssertPathsRelativeToTopEquals(t, "stub flags inputs", expectedStubFlagsInputs, rule.Implicits)
|
||||||
|
|
||||||
CheckSnapshot(t, result, "mysdk", "",
|
CheckSnapshot(t, result, "mysdk", "",
|
||||||
checkAndroidBpContents(expectedSdkSnapshot),
|
checkAndroidBpContents(expectedSdkSnapshot),
|
||||||
@@ -1153,7 +1153,7 @@ java_sdk_library_import {
|
|||||||
// of the snapshot.
|
// of the snapshot.
|
||||||
expectedStubFlagsInputs := []string{
|
expectedStubFlagsInputs := []string{
|
||||||
"out/soong/.intermediates/mysdklibrary.stubs.exportable/android_common/dex/mysdklibrary.stubs.exportable.jar",
|
"out/soong/.intermediates/mysdklibrary.stubs.exportable/android_common/dex/mysdklibrary.stubs.exportable.jar",
|
||||||
"out/soong/.intermediates/mysdklibrary.impl/android_common/aligned/mysdklibrary.jar",
|
"out/soong/.intermediates/mysdklibrary/android_common/aligned/mysdklibrary.jar",
|
||||||
}
|
}
|
||||||
|
|
||||||
testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "S",
|
testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "S",
|
||||||
@@ -1234,9 +1234,9 @@ java_sdk_library_import {
|
|||||||
// they are both part of the snapshot.
|
// they are both part of the snapshot.
|
||||||
expectedStubFlagsInputs := []string{
|
expectedStubFlagsInputs := []string{
|
||||||
"out/soong/.intermediates/mynewsdklibrary.stubs.exportable/android_common/dex/mynewsdklibrary.stubs.exportable.jar",
|
"out/soong/.intermediates/mynewsdklibrary.stubs.exportable/android_common/dex/mynewsdklibrary.stubs.exportable.jar",
|
||||||
"out/soong/.intermediates/mynewsdklibrary.impl/android_common/aligned/mynewsdklibrary.jar",
|
"out/soong/.intermediates/mynewsdklibrary/android_common/aligned/mynewsdklibrary.jar",
|
||||||
"out/soong/.intermediates/mysdklibrary.stubs.exportable/android_common/dex/mysdklibrary.stubs.exportable.jar",
|
"out/soong/.intermediates/mysdklibrary.stubs.exportable/android_common/dex/mysdklibrary.stubs.exportable.jar",
|
||||||
"out/soong/.intermediates/mysdklibrary.impl/android_common/aligned/mysdklibrary.jar",
|
"out/soong/.intermediates/mysdklibrary/android_common/aligned/mysdklibrary.jar",
|
||||||
}
|
}
|
||||||
|
|
||||||
testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "Tiramisu",
|
testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "Tiramisu",
|
||||||
|
Reference in New Issue
Block a user