From ebe1a51c81f9ab300e55126a8a7e3028c64efcd7 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 14 Nov 2017 13:12:14 -0800 Subject: Fix java AIDL properties to match C/C++ The C/C++ aidl properties use: aidl: { local_include_dirs: [], include_dirs: [], } But the Android.bp file was expecting: aidl_include_dirs: [], export_aidl_include_dirs: [], Update java AIDL support to match the C support, which is also what the androidmk conversion tool is creating. Test: m checkbuild Change-Id: I3df763d0b203b1b6556798a21b0553e7d35ad7d5 --- java/java.go | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'java/java.go') diff --git a/java/java.go b/java/java.go index 432e816e5..8a9b31f75 100644 --- a/java/java.go +++ b/java/java.go @@ -136,12 +136,17 @@ type CompilerDeviceProperties struct { // if not blank, set to the version of the sdk to compile against Sdk_version *string - // directories to pass to aidl tool - Aidl_includes []string + Aidl struct { + // Top level directories to pass to aidl tool + Include_dirs []string - // directories that should be added as include directories - // for any aidl sources of modules that depend on this module - Export_aidl_include_dirs []string + // Directories rooted at the Android.bp file to pass to aidl tool + Local_include_dirs []string + + // directories that should be added as include directories for any aidl sources of modules + // that depend on this module, as well as to aidl for this module. + Export_include_dirs []string + } // If true, export a copy of the module as a -hostdex module for host testing. Hostdex *bool @@ -377,7 +382,11 @@ func (j *Module) hasSrcExt(ext string) bool { func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath, aidlIncludeDirs android.Paths) []string { - localAidlIncludes := android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl_includes) + aidlIncludes := android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Local_include_dirs) + aidlIncludes = append(aidlIncludes, + android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs)...) + aidlIncludes = append(aidlIncludes, + android.PathsForSource(ctx, j.deviceProperties.Aidl.Include_dirs)...) var flags []string if aidlPreprocess.Valid() { @@ -387,7 +396,7 @@ func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.Opt } flags = append(flags, android.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I")) - flags = append(flags, android.JoinWithPrefix(localAidlIncludes.Strings(), "-I")) + flags = append(flags, android.JoinWithPrefix(aidlIncludes.Strings(), "-I")) flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String()) if src := android.ExistentPathForSource(ctx, "", ctx.ModuleDir(), "src"); src.Valid() { flags = append(flags, "-I"+src.String()) @@ -528,7 +537,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB func (j *Module) compile(ctx android.ModuleContext) { - j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Export_aidl_include_dirs) + j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs) deps := j.collectDeps(ctx) flags := j.collectBuilderFlags(ctx, deps) -- cgit v1.2.3-59-g8ed1b From af05017b7533f6f84b04fcce1b85cb1a1d2efe51 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 15 Nov 2017 23:01:59 -0800 Subject: 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 | 30 ------------------------------ scripts/extract-srcjars.sh | 30 ++++++++++++++++++++++++++++++ 5 files changed, 38 insertions(+), 39 deletions(-) delete mode 100755 scripts/extract-src-jars.sh create mode 100755 scripts/extract-srcjars.sh (limited to 'java/java.go') 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-src-jars.sh deleted file mode 100755 index 918cf8a53..000000000 --- a/scripts/extract-src-jars.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -e - -# Extracts .java files from source jars in a specified directory and writes out a list of the files - -if [ -z "$1" -o -z "$2" ]; then - echo "usage: $0 [ ...]" >&2 - exit 1 -fi - -output_dir=$1 -shift -output_file=$1 -shift - -rm -f $output_file -touch $output_file - -for j in "$@"; do - for f in $(zipinfo -1 $j '*.java'); do - echo $output_dir/$f >> $output_file - done - unzip -qn -d $output_dir $j '*.java' -done - -duplicates=$(cat $output_file | sort | uniq -d | uniq) -if [ -n "$duplicates" ]; then - echo Duplicate source files: - echo $duplicates - exit 1 -fi diff --git a/scripts/extract-srcjars.sh b/scripts/extract-srcjars.sh new file mode 100755 index 000000000..918cf8a53 --- /dev/null +++ b/scripts/extract-srcjars.sh @@ -0,0 +1,30 @@ +#!/bin/bash -e + +# Extracts .java files from source jars in a specified directory and writes out a list of the files + +if [ -z "$1" -o -z "$2" ]; then + echo "usage: $0 [ ...]" >&2 + exit 1 +fi + +output_dir=$1 +shift +output_file=$1 +shift + +rm -f $output_file +touch $output_file + +for j in "$@"; do + for f in $(zipinfo -1 $j '*.java'); do + echo $output_dir/$f >> $output_file + done + unzip -qn -d $output_dir $j '*.java' +done + +duplicates=$(cat $output_file | sort | uniq -d | uniq) +if [ -n "$duplicates" ]; then + echo Duplicate source files: + echo $duplicates + exit 1 +fi -- cgit v1.2.3-59-g8ed1b