From a97c5d3f08c1df08c73cee4808feb3c1e015bdc8 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 28 Mar 2018 14:58:31 -0700 Subject: Add support for android_library modules Add support for compiling android_library modules into AARs, and refactor app support on top of it. Bug: 73724997 Test: app_test.go Change-Id: I1dfac5fffe577c6680bc4709147b2061eb7d819c --- java/app_builder.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'java/app_builder.go') diff --git a/java/app_builder.go b/java/app_builder.go index 945d7bdb3..954ca4464 100644 --- a/java/app_builder.go +++ b/java/app_builder.go @@ -96,3 +96,39 @@ func CreateAppPackage(ctx android.ModuleContext, outputFile android.WritablePath }, }) } + +var buildAAR = pctx.AndroidStaticRule("buildAAR", + blueprint.RuleParams{ + Command: `rm -rf ${outDir} && mkdir -p ${outDir} && ` + + `cp ${manifest} ${outDir}/AndroidManifest.xml && ` + + `cp ${classesJar} ${outDir}/classes.jar && ` + + `cp ${rTxt} ${outDir}/R.txt && ` + + `${config.SoongZipCmd} -jar -o $out -C ${outDir} -D ${outDir} ${resArgs}`, + CommandDeps: []string{"${config.SoongZipCmd}"}, + }, + "manifest", "classesJar", "rTxt", "resArgs", "outDir") + +func BuildAAR(ctx android.ModuleContext, outputFile android.WritablePath, + classesJar, manifest, rTxt android.Path, res android.Paths) { + + // TODO(ccross): uniquify and copy resources with dependencies + + deps := android.Paths{manifest, rTxt} + classesJarPath := "" + if classesJar != nil { + deps = append(deps, classesJar) + classesJarPath = classesJar.String() + } + + ctx.Build(pctx, android.BuildParams{ + Rule: buildAAR, + Implicits: deps, + Output: outputFile, + Args: map[string]string{ + "manifest": manifest.String(), + "classesJar": classesJarPath, + "rTxt": rTxt.String(), + "outDir": android.PathForModuleOut(ctx, "aar").String(), + }, + }) +} -- cgit v1.2.3-59-g8ed1b