Move SDK prebuilts to new prebuilt_sdk module type

SDK prebuilts need to be treated differently than other prebuilts.
They are used like a normal Java prebuilts when compiling java files,
but they are also used as aapt includes when compiling apps, and they
provide prebuilt aidl files when compiling aidl sources.  Create a
new module type so dependers can determine what kind of dependency
they are.

Change-Id: If426da63cfadcb4b14abda58c7b346554912a07a
This commit is contained in:
Colin Cross 2015-04-13 13:52:22 -07:00
parent f05fe97df6
commit aa8630ba09
2 changed files with 51 additions and 22 deletions

View file

@ -67,6 +67,7 @@ func main() {
ctx.RegisterModuleType("java_binary", java.JavaBinaryFactory)
ctx.RegisterModuleType("java_binary_host", java.JavaBinaryHostFactory)
ctx.RegisterModuleType("prebuilt_java_library", java.JavaPrebuiltFactory)
ctx.RegisterModuleType("prebuilt_sdk", java.SdkPrebuiltFactory)
// Mutators
ctx.RegisterEarlyMutator("arch", common.ArchMutator)

View file

@ -121,7 +121,6 @@ type JavaDependency interface {
ClassJarSpecs() []jarSpec
ResourceJarSpecs() []jarSpec
AidlIncludeDirs() []string
AidlPreprocessed() string
}
func NewJavaBase(base *javaBase, module JavaModuleType, hod common.HostOrDeviceSupported,
@ -209,13 +208,15 @@ func (j *javaBase) collectDeps(ctx common.AndroidModuleContext) (classpath []str
} else {
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
}
aidlIncludeDirs = append(aidlIncludeDirs, j.AidlIncludeDirs()...)
if j.AidlPreprocessed() != "" {
if aidlPreprocess != "" {
ctx.ModuleErrorf("multiple dependencies with preprocessed aidls:\n %q\n %q",
aidlPreprocess, j.AidlPreprocessed())
} else {
aidlPreprocess = j.AidlPreprocessed()
aidlIncludeDirs = append(aidlIncludeDirs, javaDep.AidlIncludeDirs()...)
if sdkDep, ok := module.(sdkDependency); ok {
if sdkDep.AidlPreprocessed() != "" {
if aidlPreprocess != "" {
ctx.ModuleErrorf("multiple dependencies with preprocessed aidls:\n %q\n %q",
aidlPreprocess, sdkDep.AidlPreprocessed())
} else {
aidlPreprocess = sdkDep.AidlPreprocessed()
}
}
}
} else {
@ -358,10 +359,6 @@ func (j *javaBase) AidlIncludeDirs() []string {
return j.exportAidlIncludeDirs
}
func (j *javaBase) AidlPreprocessed() string {
return ""
}
var _ logtagsProducer = (*javaBase)(nil)
func (j *javaBase) logtags() []string {
@ -434,11 +431,9 @@ type JavaPrebuilt struct {
common.AndroidModuleBase
properties struct {
Srcs []string
Aidl_preprocessed string
Srcs []string
}
aidlPreprocessed string
classpathFile string
classJarSpecs, resourceJarSpecs []jarSpec
}
@ -455,9 +450,6 @@ func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx common.AndroidModuleConte
j.classpathFile = prebuilt
j.classJarSpecs = []jarSpec{classJarSpec}
j.resourceJarSpecs = []jarSpec{resourceJarSpec}
if j.properties.Aidl_preprocessed != "" {
j.aidlPreprocessed = filepath.Join(common.ModuleSrcDir(ctx), j.properties.Aidl_preprocessed)
}
ctx.InstallFileName("framework", ctx.ModuleName()+".jar", j.classpathFile)
}
@ -479,10 +471,6 @@ func (j *JavaPrebuilt) AidlIncludeDirs() []string {
return nil
}
func (j *JavaPrebuilt) AidlPreprocessed() string {
return j.aidlPreprocessed
}
func JavaPrebuiltFactory() (blueprint.Module, []interface{}) {
module := &JavaPrebuilt{}
@ -490,6 +478,46 @@ func JavaPrebuiltFactory() (blueprint.Module, []interface{}) {
common.MultilibCommon, &module.properties)
}
//
// SDK java prebuilts (.jar containing resources plus framework.aidl)
//
type sdkDependency interface {
JavaDependency
AidlPreprocessed() string
}
var _ sdkDependency = (*sdkPrebuilt)(nil)
type sdkPrebuilt struct {
JavaPrebuilt
sdkProperties struct {
Aidl_preprocessed string
}
aidlPreprocessed string
}
func (j *sdkPrebuilt) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
j.JavaPrebuilt.GenerateAndroidBuildActions(ctx)
if j.sdkProperties.Aidl_preprocessed != "" {
j.aidlPreprocessed = filepath.Join(common.ModuleSrcDir(ctx), j.sdkProperties.Aidl_preprocessed)
}
}
func (j *sdkPrebuilt) AidlPreprocessed() string {
return j.aidlPreprocessed
}
func SdkPrebuiltFactory() (blueprint.Module, []interface{}) {
module := &sdkPrebuilt{}
return common.InitAndroidArchModule(module, common.HostAndDeviceSupported,
common.MultilibCommon, &module.properties, &module.sdkProperties)
}
func inList(s string, l []string) bool {
for _, e := range l {
if e == s {