aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTing-Yuan Huang <laszio@google.com>2022-01-13 13:30:05 -0800
committerlaszio <ting-yuan@users.noreply.github.com>2022-02-02 13:45:47 -0800
commitb5867e6af5e30193d7a11c6ee39262c0cba193ab (patch)
tree671acd2bdcdb4ec7932882458aa21837de917fd3
parent35e1556f6f329714a9d730ea4a7743317535ce1a (diff)
downloadksp-b5867e6af5e30193d7a11c6ee39262c0cba193ab.tar.gz
Unconditionally disable FIR in KSP Gradle tasks
KSP for FIR is still under development. This change allows KSP to be used with compiler tasks where FIR is enabled.
-rw-r--r--gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt3
-rw-r--r--integration-tests/src/test/kotlin/com/google/devtools/ksp/test/PlaygroundIT.kt13
2 files changed, 16 insertions, 0 deletions
diff --git a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt
index 73eb242a..1e664f3c 100644
--- a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt
+++ b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt
@@ -577,6 +577,7 @@ abstract class KspTaskJvm @Inject constructor(
args.addPluginOptions(options.get())
args.destinationAsFile = destination
args.allowNoSourceFiles = true
+ args.useFir = false
}
// Overrding an internal function is hacky.
@@ -671,6 +672,7 @@ abstract class KspTaskJS @Inject constructor(
args.addPluginOptions(options.get())
args.outputFile = File(destination, "dummyOutput.js").canonicalPath
kotlinOptions.copyFreeCompilerArgsToArgs(args)
+ args.useFir = false
}
// Overrding an internal function is hacky.
@@ -750,6 +752,7 @@ abstract class KspTaskMetadata @Inject constructor(
args.friendPaths = friendPaths.files.map { it.absolutePath }.toTypedArray()
args.refinesPaths = refinesMetadataPaths.map { it.absolutePath }.toTypedArray()
args.expectActualLinker = true
+ args.useFir = false
}
// Overrding an internal function is hacky.
diff --git a/integration-tests/src/test/kotlin/com/google/devtools/ksp/test/PlaygroundIT.kt b/integration-tests/src/test/kotlin/com/google/devtools/ksp/test/PlaygroundIT.kt
index 2e746a21..c5f56898 100644
--- a/integration-tests/src/test/kotlin/com/google/devtools/ksp/test/PlaygroundIT.kt
+++ b/integration-tests/src/test/kotlin/com/google/devtools/ksp/test/PlaygroundIT.kt
@@ -131,4 +131,17 @@ class PlaygroundIT {
Assert.assertTrue(result.output.contains("kotlin.io.FileAlreadyExistsException"))
}
}
+
+ // Test -Xuse-fir for compilation; KSP still uses FE1.0
+ @Test
+ fun testFirPreview() {
+ val gradleProperties = File(project.root, "gradle.properties")
+ gradleProperties.appendText("\nkotlin.useFir=true")
+ val gradleRunner = GradleRunner.create().withProjectDir(project.root)
+ gradleRunner.buildAndCheck("clean", "build") { result ->
+ Assert.assertTrue(result.output.contains("This build uses in-dev FIR"))
+ Assert.assertTrue(result.output.contains("-Xuse-fir"))
+ }
+ project.restore(gradleProperties.path)
+ }
}