aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreehugger Robot2019-05-13 15:21:47 -0500
committerGerrit Code Review2019-05-13 15:21:47 -0500
commitf3e802bf0df27a7af9da285439108d5eff1e9a84 (patch)
treef4fd77cc0a4efff970bc524efaca0504042cfa4d
parent95aabdad9cda7decb78acba66723803435eb7062 (diff)
parent6c6e6cd64d7754a988c2a4172010dce4e39cadd0 (diff)
downloadplatform-build-soong-f3e802bf0df27a7af9da285439108d5eff1e9a84.tar.gz
platform-build-soong-f3e802bf0df27a7af9da285439108d5eff1e9a84.tar.xz
platform-build-soong-f3e802bf0df27a7af9da285439108d5eff1e9a84.zip
Merge "Don't hide *.kotlin_module in turbine dependencies"
-rw-r--r--java/device_host_converter.go2
-rw-r--r--java/java.go2
-rw-r--r--java/kotlin.go18
-rwxr-xr-xscripts/gen-kotlin-build-file.sh9
4 files changed, 21 insertions, 10 deletions
diff --git a/java/device_host_converter.go b/java/device_host_converter.go
index b92f4d73..3804c376 100644
--- a/java/device_host_converter.go
+++ b/java/device_host_converter.go
@@ -126,7 +126,7 @@ func (d *DeviceHostConverter) GenerateAndroidBuildActions(ctx android.ModuleCont
126 if len(d.headerJars) > 1 { 126 if len(d.headerJars) > 1 {
127 outputFile := android.PathForModuleOut(ctx, "turbine-combined", jarName) 127 outputFile := android.PathForModuleOut(ctx, "turbine-combined", jarName)
128 TransformJarsToJar(ctx, outputFile, "turbine combine", d.headerJars, 128 TransformJarsToJar(ctx, outputFile, "turbine combine", d.headerJars,
129 android.OptionalPath{}, false, nil, nil) 129 android.OptionalPath{}, false, nil, []string{"META-INF/TRANSITIVE"})
130 d.combinedHeaderJar = outputFile 130 d.combinedHeaderJar = outputFile
131 } else { 131 } else {
132 d.combinedHeaderJar = d.headerJars[0] 132 d.combinedHeaderJar = d.headerJars[0]
diff --git a/java/java.go b/java/java.go
index 01e7dc40..866b33c0 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1380,7 +1380,7 @@ func (j *Module) compileJavaHeader(ctx android.ModuleContext, srcFiles, srcJars
1380 // since we have to strip META-INF/TRANSITIVE dir from turbine.jar 1380 // since we have to strip META-INF/TRANSITIVE dir from turbine.jar
1381 combinedJar := android.PathForModuleOut(ctx, "turbine-combined", jarName) 1381 combinedJar := android.PathForModuleOut(ctx, "turbine-combined", jarName)
1382 TransformJarsToJar(ctx, combinedJar, "for turbine", jars, android.OptionalPath{}, 1382 TransformJarsToJar(ctx, combinedJar, "for turbine", jars, android.OptionalPath{},
1383 false, nil, []string{"META-INF"}) 1383 false, nil, []string{"META-INF/TRANSITIVE"})
1384 headerJar = combinedJar 1384 headerJar = combinedJar
1385 1385
1386 if j.expandJarjarRules != nil { 1386 if j.expandJarjarRules != nil {
diff --git a/java/kotlin.go b/java/kotlin.go
index 54c6b0ee..33167baf 100644
--- a/java/kotlin.go
+++ b/java/kotlin.go
@@ -18,6 +18,7 @@ import (
18 "bytes" 18 "bytes"
19 "encoding/base64" 19 "encoding/base64"
20 "encoding/binary" 20 "encoding/binary"
21 "path/filepath"
21 "strings" 22 "strings"
22 23
23 "android/soong/android" 24 "android/soong/android"
@@ -30,7 +31,7 @@ var kotlinc = pctx.AndroidGomaStaticRule("kotlinc",
30 Command: `rm -rf "$classesDir" "$srcJarDir" "$kotlinBuildFile" "$emptyDir" && ` + 31 Command: `rm -rf "$classesDir" "$srcJarDir" "$kotlinBuildFile" "$emptyDir" && ` +
31 `mkdir -p "$classesDir" "$srcJarDir" "$emptyDir" && ` + 32 `mkdir -p "$classesDir" "$srcJarDir" "$emptyDir" && ` +
32 `${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` + 33 `${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
33 `${config.GenKotlinBuildFileCmd} $classpath $classesDir $out.rsp $srcJarDir/list > $kotlinBuildFile &&` + 34 `${config.GenKotlinBuildFileCmd} $classpath "$name" $classesDir $out.rsp $srcJarDir/list > $kotlinBuildFile &&` +
34 `${config.KotlincCmd} ${config.JavacHeapFlags} $kotlincFlags ` + 35 `${config.KotlincCmd} ${config.JavacHeapFlags} $kotlincFlags ` +
35 `-jvm-target $kotlinJvmTarget -Xbuild-file=$kotlinBuildFile -kotlin-home $emptyDir && ` + 36 `-jvm-target $kotlinJvmTarget -Xbuild-file=$kotlinBuildFile -kotlin-home $emptyDir && ` +
36 `${config.SoongZipCmd} -jar -o $out -C $classesDir -D $classesDir && ` + 37 `${config.SoongZipCmd} -jar -o $out -C $classesDir -D $classesDir && ` +
@@ -50,7 +51,8 @@ var kotlinc = pctx.AndroidGomaStaticRule("kotlinc",
50 Rspfile: "$out.rsp", 51 Rspfile: "$out.rsp",
51 RspfileContent: `$in`, 52 RspfileContent: `$in`,
52 }, 53 },
53 "kotlincFlags", "classpath", "srcJars", "srcJarDir", "classesDir", "kotlinJvmTarget", "kotlinBuildFile", "emptyDir") 54 "kotlincFlags", "classpath", "srcJars", "srcJarDir", "classesDir", "kotlinJvmTarget", "kotlinBuildFile",
55 "emptyDir", "name")
54 56
55// kotlinCompile takes .java and .kt sources and srcJars, and compiles the .kt sources into a classes jar in outputFile. 57// kotlinCompile takes .java and .kt sources and srcJars, and compiles the .kt sources into a classes jar in outputFile.
56func kotlinCompile(ctx android.ModuleContext, outputFile android.WritablePath, 58func kotlinCompile(ctx android.ModuleContext, outputFile android.WritablePath,
@@ -61,6 +63,9 @@ func kotlinCompile(ctx android.ModuleContext, outputFile android.WritablePath,
61 deps = append(deps, flags.kotlincClasspath...) 63 deps = append(deps, flags.kotlincClasspath...)
62 deps = append(deps, srcJars...) 64 deps = append(deps, srcJars...)
63 65
66 kotlinName := filepath.Join(ctx.ModuleDir(), ctx.ModuleSubDir(), ctx.ModuleName())
67 kotlinName = strings.ReplaceAll(kotlinName, "/", "__")
68
64 ctx.Build(pctx, android.BuildParams{ 69 ctx.Build(pctx, android.BuildParams{
65 Rule: kotlinc, 70 Rule: kotlinc,
66 Description: "kotlinc", 71 Description: "kotlinc",
@@ -77,6 +82,7 @@ func kotlinCompile(ctx android.ModuleContext, outputFile android.WritablePath,
77 "emptyDir": android.PathForModuleOut(ctx, "kotlinc", "empty").String(), 82 "emptyDir": android.PathForModuleOut(ctx, "kotlinc", "empty").String(),
78 // http://b/69160377 kotlinc only supports -jvm-target 1.6 and 1.8 83 // http://b/69160377 kotlinc only supports -jvm-target 1.6 and 1.8
79 "kotlinJvmTarget": "1.8", 84 "kotlinJvmTarget": "1.8",
85 "name": kotlinName,
80 }, 86 },
81 }) 87 })
82} 88}
@@ -85,7 +91,7 @@ var kapt = pctx.AndroidGomaStaticRule("kapt",
85 blueprint.RuleParams{ 91 blueprint.RuleParams{
86 Command: `rm -rf "$srcJarDir" "$kotlinBuildFile" "$kaptDir" && mkdir -p "$srcJarDir" "$kaptDir" && ` + 92 Command: `rm -rf "$srcJarDir" "$kotlinBuildFile" "$kaptDir" && mkdir -p "$srcJarDir" "$kaptDir" && ` +
87 `${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` + 93 `${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
88 `${config.GenKotlinBuildFileCmd} $classpath "" $out.rsp $srcJarDir/list > $kotlinBuildFile &&` + 94 `${config.GenKotlinBuildFileCmd} $classpath "$name" "" $out.rsp $srcJarDir/list > $kotlinBuildFile &&` +
89 `${config.KotlincCmd} ${config.KotlincSuppressJDK9Warnings} ${config.JavacHeapFlags} $kotlincFlags ` + 95 `${config.KotlincCmd} ${config.KotlincSuppressJDK9Warnings} ${config.JavacHeapFlags} $kotlincFlags ` +
90 `-Xplugin=${config.KotlinKaptJar} ` + 96 `-Xplugin=${config.KotlinKaptJar} ` +
91 `-P plugin:org.jetbrains.kotlin.kapt3:sources=$kaptDir/sources ` + 97 `-P plugin:org.jetbrains.kotlin.kapt3:sources=$kaptDir/sources ` +
@@ -111,7 +117,7 @@ var kapt = pctx.AndroidGomaStaticRule("kapt",
111 RspfileContent: `$in`, 117 RspfileContent: `$in`,
112 }, 118 },
113 "kotlincFlags", "encodedJavacFlags", "kaptProcessorPath", "kaptProcessor", 119 "kotlincFlags", "encodedJavacFlags", "kaptProcessorPath", "kaptProcessor",
114 "classpath", "srcJars", "srcJarDir", "kaptDir", "kotlinJvmTarget", "kotlinBuildFile") 120 "classpath", "srcJars", "srcJarDir", "kaptDir", "kotlinJvmTarget", "kotlinBuildFile", "name")
115 121
116// kotlinKapt performs Kotlin-compatible annotation processing. It takes .kt and .java sources and srcjars, and runs 122// kotlinKapt performs Kotlin-compatible annotation processing. It takes .kt and .java sources and srcjars, and runs
117// annotation processors over all of them, producing a srcjar of generated code in outputFile. The srcjar should be 123// annotation processors over all of them, producing a srcjar of generated code in outputFile. The srcjar should be
@@ -138,6 +144,9 @@ func kotlinKapt(ctx android.ModuleContext, outputFile android.WritablePath,
138 {"-target", flags.javaVersion}, 144 {"-target", flags.javaVersion},
139 }) 145 })
140 146
147 kotlinName := filepath.Join(ctx.ModuleDir(), ctx.ModuleSubDir(), ctx.ModuleName())
148 kotlinName = strings.ReplaceAll(kotlinName, "/", "__")
149
141 ctx.Build(pctx, android.BuildParams{ 150 ctx.Build(pctx, android.BuildParams{
142 Rule: kapt, 151 Rule: kapt,
143 Description: "kapt", 152 Description: "kapt",
@@ -154,6 +163,7 @@ func kotlinKapt(ctx android.ModuleContext, outputFile android.WritablePath,
154 "kaptProcessor": kaptProcessor, 163 "kaptProcessor": kaptProcessor,
155 "kaptDir": android.PathForModuleOut(ctx, "kapt/gen").String(), 164 "kaptDir": android.PathForModuleOut(ctx, "kapt/gen").String(),
156 "encodedJavacFlags": encodedJavacFlags, 165 "encodedJavacFlags": encodedJavacFlags,
166 "name": kotlinName,
157 }, 167 },
158 }) 168 })
159} 169}
diff --git a/scripts/gen-kotlin-build-file.sh b/scripts/gen-kotlin-build-file.sh
index 1e03f72e..177ca1b0 100755
--- a/scripts/gen-kotlin-build-file.sh
+++ b/scripts/gen-kotlin-build-file.sh
@@ -17,7 +17,7 @@
17# Generates kotlinc module xml file to standard output based on rsp files 17# Generates kotlinc module xml file to standard output based on rsp files
18 18
19if [[ -z "$1" ]]; then 19if [[ -z "$1" ]]; then
20 echo "usage: $0 <classpath> <outDir> <rspFiles>..." >&2 20 echo "usage: $0 <classpath> <name> <outDir> <rspFiles>..." >&2
21 exit 1 21 exit 1
22fi 22fi
23 23
@@ -27,8 +27,9 @@ if [[ $1 == "-classpath" ]]; then
27fi; 27fi;
28 28
29classpath=$1 29classpath=$1
30out_dir=$2 30name=$2
31shift 2 31out_dir=$3
32shift 3
32 33
33# Path in the build file may be relative to the build file, we need to make them 34# Path in the build file may be relative to the build file, we need to make them
34# absolute 35# absolute
@@ -44,7 +45,7 @@ get_abs_path () {
44} 45}
45 46
46# Print preamble 47# Print preamble
47echo "<modules><module name=\"name\" type=\"java-production\" outputDir=\"${out_dir}\">" 48echo "<modules><module name=\"${name}\" type=\"java-production\" outputDir=\"${out_dir}\">"
48 49
49# Print classpath entries 50# Print classpath entries
50for file in $(echo "$classpath" | tr ":" "\n"); do 51for file in $(echo "$classpath" | tr ":" "\n"); do