Merge "Add static_libs property in java_api_library soong module" am: 61e09756c2
am: f2deb3cb1f
am: 41ea80e148
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2436213 Change-Id: I29b765c90496313973f3744885f7bd48253f3052 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
21
java/java.go
21
java/java.go
@@ -1632,6 +1632,10 @@ type JavaApiLibraryProperties struct {
|
||||
// List of shared java libs that this module has dependencies to and
|
||||
// should be passed as classpath in javac invocation
|
||||
Libs []string
|
||||
|
||||
// List of java libs that this module has static dependencies to and will be
|
||||
// passed in metalava invocation
|
||||
Static_libs []string
|
||||
}
|
||||
|
||||
func ApiLibraryFactory() android.Module {
|
||||
@@ -1704,6 +1708,7 @@ func (al *ApiLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
ctx.AddDependency(ctx.Module(), javaApiContributionTag, apiContributionName)
|
||||
}
|
||||
ctx.AddVariationDependencies(nil, libTag, al.properties.Libs...)
|
||||
ctx.AddVariationDependencies(nil, staticLibTag, al.properties.Static_libs...)
|
||||
}
|
||||
|
||||
func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
@@ -1723,6 +1728,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
|
||||
var srcFiles android.Paths
|
||||
var classPaths android.Paths
|
||||
var staticLibs android.Paths
|
||||
ctx.VisitDirectDeps(func(dep android.Module) {
|
||||
tag := ctx.OtherModuleDependencyTag(dep)
|
||||
switch tag {
|
||||
@@ -1736,6 +1742,9 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
case libTag:
|
||||
provider := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
|
||||
classPaths = append(classPaths, provider.HeaderJars...)
|
||||
case staticLibTag:
|
||||
provider := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
|
||||
staticLibs = append(staticLibs, provider.HeaderJars...)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1760,7 +1769,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
FlagWithArg("-D ", stubsDir.String())
|
||||
|
||||
rule.Build("metalava", "metalava merged")
|
||||
|
||||
compiledStubs := android.PathForModuleOut(ctx, ctx.ModuleName(), "stubs.jar")
|
||||
al.stubsJar = android.PathForModuleOut(ctx, ctx.ModuleName(), "android.jar")
|
||||
|
||||
var flags javaBuilderFlags
|
||||
@@ -1768,9 +1777,17 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
flags.javacFlags = strings.Join(al.properties.Javacflags, " ")
|
||||
flags.classpath = classpath(classPaths)
|
||||
|
||||
TransformJavaToClasses(ctx, al.stubsJar, 0, android.Paths{},
|
||||
TransformJavaToClasses(ctx, compiledStubs, 0, android.Paths{},
|
||||
android.Paths{al.stubsSrcJar}, flags, android.Paths{})
|
||||
|
||||
builder := android.NewRuleBuilder(pctx, ctx)
|
||||
builder.Command().
|
||||
BuiltTool("merge_zips").
|
||||
Output(al.stubsJar).
|
||||
Inputs(android.Paths{compiledStubs}).
|
||||
Inputs(staticLibs)
|
||||
builder.Build("merge_zips", "merge jar files")
|
||||
|
||||
ctx.Phony(ctx.ModuleName(), al.stubsJar)
|
||||
|
||||
ctx.SetProvider(JavaInfoProvider, JavaInfo{
|
||||
|
Reference in New Issue
Block a user