Create .kzip files for kotlin translation units
This CL creates the build rules to invoke the standalone kotlin
extractor and create .kzip files for each kotlin translation unit. These
will be indexed by the internal g3 kotlin indexers
Implementation details
- Create a `kotlinKytheExtract` static rule. Its inputs will be source
.kt/.srcjar files and other verbatim args passed to kotlinc. The
extrator will serialize this information into a .kzip file. The .kzip
file should contain the necessary information to "replay" the
compilation
- Create a xref_kotlin phony rule to build all .kzip files corresponding
to kotlin translation units.
This implementation has one limitation. Since the kotlin indexers
"replay" the compilation using its own version of kotlinc-jvm, there
might be indexing issues caused by kotlinc version skew between android
builds and indexing builds. `-kotlin-home` can likely solve that, but
this CL defers that for now.
Bug: 265428637
Test: Built the phony `xref_kotlin`, and ran the indexer locally using go/kythe-git-local-run#indexing-to-local-xrefs-server
Change-Id: Ifb370f2df8aa46f71df3fe1ae7d7aa5da773cc8b
diff --git a/java/java.go b/java/java.go
index 797a90d..99f4437 100644
--- a/java/java.go
+++ b/java/java.go
@@ -356,12 +356,17 @@
// TODO(jungjw): Move this to kythe.go once it's created.
type xref interface {
XrefJavaFiles() android.Paths
+ XrefKotlinFiles() android.Paths
}
func (j *Module) XrefJavaFiles() android.Paths {
return j.kytheFiles
}
+func (j *Module) XrefKotlinFiles() android.Paths {
+ return j.kytheKotlinFiles
+}
+
func (d dependencyTag) PropagateAconfigValidation() bool {
return d.static
}
@@ -3304,15 +3309,20 @@
func (ks *kytheExtractJavaSingleton) GenerateBuildActions(ctx android.SingletonContext) {
var xrefTargets android.Paths
+ var xrefKotlinTargets android.Paths
ctx.VisitAllModules(func(module android.Module) {
if javaModule, ok := module.(xref); ok {
xrefTargets = append(xrefTargets, javaModule.XrefJavaFiles()...)
+ xrefKotlinTargets = append(xrefKotlinTargets, javaModule.XrefKotlinFiles()...)
}
})
// TODO(asmundak): perhaps emit a rule to output a warning if there were no xrefTargets
if len(xrefTargets) > 0 {
ctx.Phony("xref_java", xrefTargets...)
}
+ if len(xrefKotlinTargets) > 0 {
+ ctx.Phony("xref_kotlin", xrefKotlinTargets...)
+ }
}
var Bool = proptools.Bool