Merge "java_sdk_library - Allow it to be replaced by prebuilt" am: 9be2556d90
am: e1c279f889
Change-Id: I4cbfd1d1cd84c529e0a89334042e9eafbf0bb4bf
This commit is contained in:
@@ -2094,12 +2094,12 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
filesInfo = append(filesInfo, af)
|
filesInfo = append(filesInfo, af)
|
||||||
|
|
||||||
pf, _ := sdkLib.OutputFiles(".xml")
|
pf := sdkLib.XmlPermissionsFile()
|
||||||
if len(pf) != 1 {
|
if pf == nil {
|
||||||
ctx.PropertyErrorf("java_libs", "%q failed to generate permission XML", depName)
|
ctx.PropertyErrorf("java_libs", "%q failed to generate permission XML", depName)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
filesInfo = append(filesInfo, newApexFile(ctx, pf[0], pf[0].Base(), "etc/permissions", etc, nil))
|
filesInfo = append(filesInfo, newApexFile(ctx, pf, pf.Base(), "etc/permissions", etc, nil))
|
||||||
return true // track transitive dependencies
|
return true // track transitive dependencies
|
||||||
} else {
|
} else {
|
||||||
ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
|
ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
|
||||||
|
@@ -3488,8 +3488,9 @@ func TestJavaSDKLibrary(t *testing.T) {
|
|||||||
"etc/permissions/foo.xml",
|
"etc/permissions/foo.xml",
|
||||||
})
|
})
|
||||||
// Permission XML should point to the activated path of impl jar of java_sdk_library
|
// Permission XML should point to the activated path of impl jar of java_sdk_library
|
||||||
xml := ctx.ModuleForTests("foo", "android_common_myapex").Output("foo.xml")
|
sdkLibrary := ctx.ModuleForTests("foo", "android_common_myapex").Module().(*java.SdkLibrary)
|
||||||
ensureContains(t, xml.Args["content"], `<library name="foo" file="/apex/myapex/javalib/foo.jar"`)
|
xml := sdkLibrary.XmlPermissionsFileContent()
|
||||||
|
ensureContains(t, xml, `<library name="foo" file="/apex/myapex/javalib/foo.jar"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCompatConfig(t *testing.T) {
|
func TestCompatConfig(t *testing.T) {
|
||||||
|
@@ -16,6 +16,7 @@ package java
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
"android/soong/genrule"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@@ -264,6 +265,8 @@ func (module *SdkLibrary) getActiveApiScopes() apiScopes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var xmlPermissionsFileTag = dependencyTag{name: "xml-permissions-file"}
|
||||||
|
|
||||||
func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
for _, apiScope := range module.getActiveApiScopes() {
|
for _, apiScope := range module.getActiveApiScopes() {
|
||||||
// Add dependencies to the stubs library
|
// Add dependencies to the stubs library
|
||||||
@@ -273,6 +276,11 @@ func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
ctx.AddVariationDependencies(nil, apiScope.apiFileTag, module.docsName(apiScope))
|
ctx.AddVariationDependencies(nil, apiScope.apiFileTag, module.docsName(apiScope))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !proptools.Bool(module.sdkLibraryProperties.Api_only) {
|
||||||
|
// Add dependency to the rule for generating the xml permissions file
|
||||||
|
ctx.AddDependency(module, xmlPermissionsFileTag, module.genXmlPermissionsFileName())
|
||||||
|
}
|
||||||
|
|
||||||
module.Library.deps(ctx)
|
module.Library.deps(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,8 +290,6 @@ func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
|||||||
module.Library.GenerateAndroidBuildActions(ctx)
|
module.Library.GenerateAndroidBuildActions(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.buildPermissionsFile(ctx)
|
|
||||||
|
|
||||||
// Record the paths to the header jars of the library (stubs and impl).
|
// Record the paths to the header jars of the library (stubs and impl).
|
||||||
// When this java_sdk_library is depended upon from others via "libs" property,
|
// When this java_sdk_library is depended upon from others via "libs" property,
|
||||||
// the recorded paths will be returned depending on the link type of the caller.
|
// the recorded paths will be returned depending on the link type of the caller.
|
||||||
@@ -308,31 +314,19 @@ func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
|||||||
ctx.ModuleErrorf("depends on module %q of unknown tag %q", otherName, tag)
|
ctx.ModuleErrorf("depends on module %q of unknown tag %q", otherName, tag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
if tag == xmlPermissionsFileTag {
|
||||||
}
|
if genRule, ok := to.(genrule.SourceFileGenerator); ok {
|
||||||
|
pf := genRule.GeneratedSourceFiles()
|
||||||
func (module *SdkLibrary) buildPermissionsFile(ctx android.ModuleContext) {
|
if len(pf) != 1 {
|
||||||
xmlContent := fmt.Sprintf(permissionsTemplate, module.BaseModuleName(), module.implPath())
|
ctx.ModuleErrorf("%q failed to generate permission XML", otherName)
|
||||||
permissionsFile := android.PathForModuleOut(ctx, module.xmlFileName())
|
} else {
|
||||||
|
module.permissionsFile = pf[0]
|
||||||
ctx.Build(pctx, android.BuildParams{
|
|
||||||
Rule: android.WriteFile,
|
|
||||||
Output: permissionsFile,
|
|
||||||
Description: "Generating " + module.BaseModuleName() + " permissions",
|
|
||||||
Args: map[string]string{
|
|
||||||
"content": xmlContent,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
module.permissionsFile = permissionsFile
|
|
||||||
}
|
|
||||||
|
|
||||||
func (module *SdkLibrary) OutputFiles(tag string) (android.Paths, error) {
|
|
||||||
switch tag {
|
|
||||||
case ".xml":
|
|
||||||
return android.Paths{module.permissionsFile}, nil
|
|
||||||
}
|
}
|
||||||
return module.Library.OutputFiles(tag)
|
} else {
|
||||||
|
ctx.ModuleErrorf("depends on module %q to generate xml permissions file but it does not provide any outputs", otherName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {
|
func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {
|
||||||
@@ -421,6 +415,11 @@ func (module *SdkLibrary) xmlFileName() string {
|
|||||||
return module.BaseModuleName() + sdkXmlFileSuffix
|
return module.BaseModuleName() + sdkXmlFileSuffix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Module name of the rule for generating the XML permissions file
|
||||||
|
func (module *SdkLibrary) genXmlPermissionsFileName() string {
|
||||||
|
return "gen-" + module.BaseModuleName() + sdkXmlFileSuffix
|
||||||
|
}
|
||||||
|
|
||||||
// Get the sdk version for use when compiling the stubs library.
|
// Get the sdk version for use when compiling the stubs library.
|
||||||
func (module *SdkLibrary) sdkVersionForStubsLibrary(mctx android.LoadHookContext, apiScope *apiScope) string {
|
func (module *SdkLibrary) sdkVersionForStubsLibrary(mctx android.LoadHookContext, apiScope *apiScope) string {
|
||||||
sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
|
sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
|
||||||
@@ -614,8 +613,34 @@ func (module *SdkLibrary) createStubsSources(mctx android.LoadHookContext, apiSc
|
|||||||
mctx.CreateModule(DroidstubsFactory, &props)
|
mctx.CreateModule(DroidstubsFactory, &props)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (module *SdkLibrary) XmlPermissionsFile() android.Path {
|
||||||
|
return module.permissionsFile
|
||||||
|
}
|
||||||
|
|
||||||
|
func (module *SdkLibrary) XmlPermissionsFileContent() string {
|
||||||
|
return fmt.Sprintf(permissionsTemplate, module.BaseModuleName(), module.implPath())
|
||||||
|
}
|
||||||
|
|
||||||
// Creates the xml file that publicizes the runtime library
|
// Creates the xml file that publicizes the runtime library
|
||||||
func (module *SdkLibrary) createXmlFile(mctx android.LoadHookContext) {
|
func (module *SdkLibrary) createXmlFile(mctx android.LoadHookContext) {
|
||||||
|
|
||||||
|
xmlContent := module.XmlPermissionsFileContent()
|
||||||
|
|
||||||
|
genRuleName := module.genXmlPermissionsFileName()
|
||||||
|
|
||||||
|
// Create a genrule module to create the XML permissions file.
|
||||||
|
genRuleProps := struct {
|
||||||
|
Name *string
|
||||||
|
Cmd *string
|
||||||
|
Out []string
|
||||||
|
}{
|
||||||
|
Name: proptools.StringPtr(genRuleName),
|
||||||
|
Cmd: proptools.StringPtr("echo -e '" + xmlContent + "' > '$(out)'"),
|
||||||
|
Out: []string{module.xmlFileName()},
|
||||||
|
}
|
||||||
|
|
||||||
|
mctx.CreateModule(genrule.GenRuleFactory, &genRuleProps)
|
||||||
|
|
||||||
// creates a prebuilt_etc module to actually place the xml file under
|
// creates a prebuilt_etc module to actually place the xml file under
|
||||||
// <partition>/etc/permissions
|
// <partition>/etc/permissions
|
||||||
etcProps := struct {
|
etcProps := struct {
|
||||||
@@ -628,7 +653,7 @@ func (module *SdkLibrary) createXmlFile(mctx android.LoadHookContext) {
|
|||||||
System_ext_specific *bool
|
System_ext_specific *bool
|
||||||
}{}
|
}{}
|
||||||
etcProps.Name = proptools.StringPtr(module.xmlFileName())
|
etcProps.Name = proptools.StringPtr(module.xmlFileName())
|
||||||
etcProps.Src = proptools.StringPtr(":" + module.BaseModuleName() + "{.xml}")
|
etcProps.Src = proptools.StringPtr(":" + genRuleName)
|
||||||
etcProps.Sub_dir = proptools.StringPtr("permissions")
|
etcProps.Sub_dir = proptools.StringPtr("permissions")
|
||||||
if module.SocSpecific() {
|
if module.SocSpecific() {
|
||||||
etcProps.Soc_specific = proptools.BoolPtr(true)
|
etcProps.Soc_specific = proptools.BoolPtr(true)
|
||||||
|
Reference in New Issue
Block a user