Limit the number of the Java source files in a single compilation unit
KYTHE_JAVA_SOURCE_BATCH_SIZE environment variable controls this setting.
The limit is 1000 if this variable is not set.
Fixes: 179932118
Test: run prebuilts/build-tools/build-prebuilts.sh, use it to build kzips, check
Change-Id: I9ad57dfd1d2c2dce5cff755b1bd61cf933420bd3
diff --git a/android/config.go b/android/config.go
index 50e39d7..6170f34 100644
--- a/android/config.go
+++ b/android/config.go
@@ -24,6 +24,7 @@
"os"
"path/filepath"
"runtime"
+ "strconv"
"strings"
"sync"
@@ -911,6 +912,25 @@
return "json"
}
+// XrefCuJavaSourceMax returns the maximum number of the Java source files
+// in a single compilation unit
+const xrefJavaSourceFileMaxDefault = "1000"
+
+func (c Config) XrefCuJavaSourceMax() string {
+ v := c.Getenv("KYTHE_JAVA_SOURCE_BATCH_SIZE")
+ if v == "" {
+ return xrefJavaSourceFileMaxDefault
+ }
+ if _, err := strconv.ParseUint(v, 0, 0); err != nil {
+ fmt.Fprintf(os.Stderr,
+ "bad KYTHE_JAVA_SOURCE_BATCH_SIZE value: %s, will use %s",
+ err, xrefJavaSourceFileMaxDefault)
+ return xrefJavaSourceFileMaxDefault
+ }
+ return v
+
+}
+
func (c *config) EmitXrefRules() bool {
return c.XrefCorpusName() != ""
}