From af05017b7533f6f84b04fcce1b85cb1a1d2efe51 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 15 Nov 2017 23:01:59 -0800 Subject: [PATCH] Add support for .srcjar files from genrules and srcs Allow srcs to contain .srcjar files, which will be extracted just before javac. Also allow genrules and generated sources to directly return .srcjar files. Test: m checkbuild Change-Id: Ie4cf60ecb9d2ec63a4c2275221544203b1383597 --- java/config/config.go | 2 +- java/gen.go | 10 ++++------ java/java.go | 5 +++-- scripts/{extract-src-jars.sh => extract-srcjars.sh} | 0 4 files changed, 8 insertions(+), 9 deletions(-) rename scripts/{extract-src-jars.sh => extract-srcjars.sh} (100%) diff --git a/java/config/config.go b/java/config/config.go index d4994a1c9..3cd284157 100644 --- a/java/config/config.go +++ b/java/config/config.go @@ -70,7 +70,7 @@ func init() { pctx.SourcePathVariable("JrtFsJar", "${JavaHome}/lib/jrt-fs.jar") pctx.SourcePathVariable("Ziptime", "prebuilts/build-tools/${hostPrebuiltTag}/bin/ziptime") - pctx.SourcePathVariable("ExtractSrcJarsCmd", "build/soong/scripts/extract-src-jars.sh") + pctx.SourcePathVariable("ExtractSrcJarsCmd", "build/soong/scripts/extract-srcjars.sh") pctx.SourcePathVariable("JarArgsCmd", "build/soong/scripts/jar-args.sh") pctx.HostBinToolVariable("SoongZipCmd", "soong_zip") pctx.HostBinToolVariable("MergeZipsCmd", "merge_zips") diff --git a/java/gen.go b/java/gen.go index 8fa199e14..c73a446ce 100644 --- a/java/gen.go +++ b/java/gen.go @@ -85,7 +85,7 @@ func genLogtags(ctx android.ModuleContext, logtagsFile android.Path) android.Pat } func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths, - flags javaBuilderFlags) (android.Paths, android.Paths) { + flags javaBuilderFlags) android.Paths { var protoFiles android.Paths outSrcFiles := make(android.Paths, 0, len(srcFiles)) @@ -106,17 +106,15 @@ func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths, } } - var outSrcJars android.Paths - if len(protoFiles) > 0 { - protoSrcJar := android.PathForModuleGen(ctx, "proto.src.jar") + protoSrcJar := android.PathForModuleGen(ctx, "proto.srcjar") genProto(ctx, protoSrcJar, protoFiles, flags.protoFlags, flags.protoOutFlag, "") - outSrcJars = append(outSrcJars, protoSrcJar) + outSrcFiles = append(outSrcFiles, protoSrcJar) } - return outSrcFiles, outSrcJars + return outSrcFiles } func LogtagsSingleton() blueprint.Singleton { diff --git a/java/java.go b/java/java.go index 8a9b31f75..b2bd2b0a4 100644 --- a/java/java.go +++ b/java/java.go @@ -550,8 +550,9 @@ func (j *Module) compile(ctx android.ModuleContext) { flags = protoFlags(ctx, &j.protoProperties, flags) } - var srcJars android.Paths - srcFiles, srcJars = j.genSources(ctx, srcFiles, flags) + srcFiles = j.genSources(ctx, srcFiles, flags) + + srcJars := srcFiles.FilterByExt(".srcjar") srcJars = append(srcJars, deps.srcJars...) srcJars = append(srcJars, j.ExtraSrcJars...) diff --git a/scripts/extract-src-jars.sh b/scripts/extract-srcjars.sh similarity index 100% rename from scripts/extract-src-jars.sh rename to scripts/extract-srcjars.sh