Merge changes from topic "carry_required"
* changes: APEX carries required properties of its dependencies *RequiredModuleNames functions are available via Module interface
This commit is contained in:
commit
64d5ccef7a
|
@ -231,6 +231,10 @@ type Module interface {
|
||||||
|
|
||||||
// Get the visibility rules that control the visibility of this module.
|
// Get the visibility rules that control the visibility of this module.
|
||||||
visibility() []string
|
visibility() []string
|
||||||
|
|
||||||
|
RequiredModuleNames() []string
|
||||||
|
HostRequiredModuleNames() []string
|
||||||
|
TargetRequiredModuleNames() []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Qualified id for a module
|
// Qualified id for a module
|
||||||
|
@ -897,6 +901,18 @@ func (m *ModuleBase) InRecovery() bool {
|
||||||
return m.base().commonProperties.ImageVariation == RecoveryVariation
|
return m.base().commonProperties.ImageVariation == RecoveryVariation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *ModuleBase) RequiredModuleNames() []string {
|
||||||
|
return m.base().commonProperties.Required
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ModuleBase) HostRequiredModuleNames() []string {
|
||||||
|
return m.base().commonProperties.Host_required
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ModuleBase) TargetRequiredModuleNames() []string {
|
||||||
|
return m.base().commonProperties.Target_required
|
||||||
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) {
|
func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) {
|
||||||
allInstalledFiles := Paths{}
|
allInstalledFiles := Paths{}
|
||||||
allCheckbuildFiles := Paths{}
|
allCheckbuildFiles := Paths{}
|
||||||
|
@ -1930,15 +1946,15 @@ func (m *moduleContext) ExpandOptionalSource(srcFile *string, prop string) Optio
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) RequiredModuleNames() []string {
|
func (m *moduleContext) RequiredModuleNames() []string {
|
||||||
return m.module.base().commonProperties.Required
|
return m.module.RequiredModuleNames()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) HostRequiredModuleNames() []string {
|
func (m *moduleContext) HostRequiredModuleNames() []string {
|
||||||
return m.module.base().commonProperties.Host_required
|
return m.module.HostRequiredModuleNames()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) TargetRequiredModuleNames() []string {
|
func (m *moduleContext) TargetRequiredModuleNames() []string {
|
||||||
return m.module.base().commonProperties.Target_required
|
return m.module.TargetRequiredModuleNames()
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -152,6 +152,27 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexName, moduleDir string)
|
||||||
return moduleNames
|
return moduleNames
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *apexBundle) writeRequiredModules(w io.Writer) {
|
||||||
|
var required []string
|
||||||
|
var targetRequired []string
|
||||||
|
var hostRequired []string
|
||||||
|
for _, fi := range a.filesInfo {
|
||||||
|
required = append(required, fi.requiredModuleNames...)
|
||||||
|
targetRequired = append(targetRequired, fi.targetRequiredModuleNames...)
|
||||||
|
hostRequired = append(hostRequired, fi.hostRequiredModuleNames...)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(required) > 0 {
|
||||||
|
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(required, " "))
|
||||||
|
}
|
||||||
|
if len(targetRequired) > 0 {
|
||||||
|
fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES +=", strings.Join(targetRequired, " "))
|
||||||
|
}
|
||||||
|
if len(hostRequired) > 0 {
|
||||||
|
fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES +=", strings.Join(hostRequired, " "))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (a *apexBundle) androidMkForType() android.AndroidMkData {
|
func (a *apexBundle) androidMkForType() android.AndroidMkData {
|
||||||
return android.AndroidMkData{
|
return android.AndroidMkData{
|
||||||
Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
|
Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
|
||||||
|
@ -170,6 +191,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData {
|
||||||
if len(moduleNames) > 0 {
|
if len(moduleNames) > 0 {
|
||||||
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(moduleNames, " "))
|
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(moduleNames, " "))
|
||||||
}
|
}
|
||||||
|
a.writeRequiredModules(w)
|
||||||
fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
|
fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -188,6 +210,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData {
|
||||||
if len(a.externalDeps) > 0 {
|
if len(a.externalDeps) > 0 {
|
||||||
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(a.externalDeps, " "))
|
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(a.externalDeps, " "))
|
||||||
}
|
}
|
||||||
|
a.writeRequiredModules(w)
|
||||||
var postInstallCommands []string
|
var postInstallCommands []string
|
||||||
if a.prebuiltFileToDelete != "" {
|
if a.prebuiltFileToDelete != "" {
|
||||||
postInstallCommands = append(postInstallCommands, "rm -rf "+
|
postInstallCommands = append(postInstallCommands, "rm -rf "+
|
||||||
|
|
|
@ -461,6 +461,10 @@ type apexFile struct {
|
||||||
symlinks []string
|
symlinks []string
|
||||||
transitiveDep bool
|
transitiveDep bool
|
||||||
moduleDir string
|
moduleDir string
|
||||||
|
|
||||||
|
requiredModuleNames []string
|
||||||
|
targetRequiredModuleNames []string
|
||||||
|
hostRequiredModuleNames []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, moduleName string, installDir string, class apexFileClass, module android.Module) apexFile {
|
func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, moduleName string, installDir string, class apexFileClass, module android.Module) apexFile {
|
||||||
|
@ -473,6 +477,9 @@ func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, moduleNa
|
||||||
}
|
}
|
||||||
if module != nil {
|
if module != nil {
|
||||||
ret.moduleDir = ctx.OtherModuleDir(module)
|
ret.moduleDir = ctx.OtherModuleDir(module)
|
||||||
|
ret.requiredModuleNames = module.RequiredModuleNames()
|
||||||
|
ret.targetRequiredModuleNames = module.TargetRequiredModuleNames()
|
||||||
|
ret.hostRequiredModuleNames = module.HostRequiredModuleNames()
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
|
@ -3328,6 +3328,43 @@ func TestRejectNonInstallableJavaLibrary(t *testing.T) {
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCarryRequiredModuleNames(t *testing.T) {
|
||||||
|
ctx, config := testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
native_shared_libs: ["mylib"],
|
||||||
|
}
|
||||||
|
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "mylib",
|
||||||
|
srcs: ["mylib.cpp"],
|
||||||
|
system_shared_libs: [],
|
||||||
|
stl: "none",
|
||||||
|
required: ["a", "b"],
|
||||||
|
host_required: ["c", "d"],
|
||||||
|
target_required: ["e", "f"],
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
||||||
|
data := android.AndroidMkDataForTest(t, config, "", apexBundle)
|
||||||
|
name := apexBundle.BaseModuleName()
|
||||||
|
prefix := "TARGET_"
|
||||||
|
var builder strings.Builder
|
||||||
|
data.Custom(&builder, name, prefix, "", data)
|
||||||
|
androidMk := builder.String()
|
||||||
|
ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += a b\n")
|
||||||
|
ensureContains(t, androidMk, "LOCAL_HOST_REQUIRED_MODULES += c d\n")
|
||||||
|
ensureContains(t, androidMk, "LOCAL_TARGET_REQUIRED_MODULES += e f\n")
|
||||||
|
}
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
run := func() int {
|
run := func() int {
|
||||||
setUp()
|
setUp()
|
||||||
|
|
Loading…
Reference in New Issue