Use rsp for kotlin classpath
Support long classpaths by passing the classpath in a file to the script that generates build.xml. Bug: 308016794 Test: builds Flag: EXEMPT refactor Change-Id: Ib238a83a26acba7ede8e55298397dbeb9a57a866
This commit is contained in:
@@ -101,6 +101,10 @@ func kotlinCompile(ctx android.ModuleContext, outputFile, headerOutputFile andro
|
||||
commonSrcFilesArg = "--common_srcs " + commonSrcsList.String()
|
||||
}
|
||||
|
||||
classpathRspFile := android.PathForModuleOut(ctx, "kotlinc", "classpath.rsp")
|
||||
android.WriteFileRule(ctx, classpathRspFile, strings.Join(flags.kotlincClasspath.Strings(), " "))
|
||||
deps = append(deps, classpathRspFile)
|
||||
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: kotlinc,
|
||||
Description: "kotlinc",
|
||||
@@ -109,7 +113,7 @@ func kotlinCompile(ctx android.ModuleContext, outputFile, headerOutputFile andro
|
||||
Inputs: srcFiles,
|
||||
Implicits: deps,
|
||||
Args: map[string]string{
|
||||
"classpath": flags.kotlincClasspath.FormJavaClassPath(""),
|
||||
"classpath": classpathRspFile.String(),
|
||||
"kotlincFlags": flags.kotlincFlags,
|
||||
"commonSrcFilesArg": commonSrcFilesArg,
|
||||
"srcJars": strings.Join(srcJars.Strings(), " "),
|
||||
@@ -205,6 +209,10 @@ func kotlinKapt(ctx android.ModuleContext, srcJarOutputFile, resJarOutputFile an
|
||||
kotlinName := filepath.Join(ctx.ModuleDir(), ctx.ModuleSubDir(), ctx.ModuleName())
|
||||
kotlinName = strings.ReplaceAll(kotlinName, "/", "__")
|
||||
|
||||
classpathRspFile := android.PathForModuleOut(ctx, "kapt", "classpath.rsp")
|
||||
android.WriteFileRule(ctx, classpathRspFile, strings.Join(flags.kotlincClasspath.Strings(), "\n"))
|
||||
deps = append(deps, classpathRspFile)
|
||||
|
||||
// First run kapt to generate .java stubs from .kt files
|
||||
kaptStubsJar := android.PathForModuleOut(ctx, "kapt", "stubs.jar")
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
@@ -214,7 +222,7 @@ func kotlinKapt(ctx android.ModuleContext, srcJarOutputFile, resJarOutputFile an
|
||||
Inputs: srcFiles,
|
||||
Implicits: deps,
|
||||
Args: map[string]string{
|
||||
"classpath": flags.kotlincClasspath.FormJavaClassPath(""),
|
||||
"classpath": classpathRspFile.String(),
|
||||
"kotlincFlags": flags.kotlincFlags,
|
||||
"commonSrcFilesArg": commonSrcFilesArg,
|
||||
"srcJars": strings.Join(srcJars.Strings(), " "),
|
||||
|
@@ -37,7 +37,7 @@ def parse_args():
|
||||
parser.add_argument('--out', dest='out',
|
||||
help='file to which the module.xml contents will be written.')
|
||||
parser.add_argument('--classpath', dest='classpath', action='append', default=[],
|
||||
help='classpath to pass to kotlinc.')
|
||||
help='file containing classpath to pass to kotlinc.')
|
||||
parser.add_argument('--name', dest='name',
|
||||
help='name of the module.')
|
||||
parser.add_argument('--out_dir', dest='out_dir',
|
||||
@@ -65,8 +65,8 @@ def main():
|
||||
f.write(' <module name="%s" type="java-production" outputDir="%s">\n' % (args.name, args.out_dir or ''))
|
||||
|
||||
# Print classpath entries
|
||||
for c in args.classpath:
|
||||
for entry in c.split(':'):
|
||||
for classpath_rsp_file in args.classpath:
|
||||
for entry in NinjaRspFileReader(classpath_rsp_file):
|
||||
path = os.path.abspath(entry)
|
||||
f.write(' <classpath path="%s"/>\n' % path)
|
||||
|
||||
|
Reference in New Issue
Block a user