Skip to content

Commit dd2b2d0

Browse files
committed
Add support for specifying compiler options.
1 parent d231b07 commit dd2b2d0

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ compileClojure {
2020
// If projectOnly is true, only warnings from your project are errors.
2121
}
2222
23+
// Compiler options for AOT
24+
disableLocalsClearing = true // Defaults to false
25+
elideMeta = ['doc', 'file', 'line', 'added'] // Defaults to []
26+
directLinking = true // Defaults to false
27+
2328
// compileClojure implements the standard JavaForkOptions interface, and thus supports the
2429
// standard Gradle mechanisms for configuring a Java process:
2530
// systemProperty systemProperties minHeapSize maxHeapSize
@@ -41,6 +46,7 @@ compileTestClojure {
4146
testClojure {
4247
// Standard JVM execution options here for test process
4348
systemProperty 'java.awt.headless', true
49+
4450
// Specifying junitReport will trigger JUnit XML report generation
4551
// in addition to standard console output (turned off by default)
4652
junitReport = file("$buildDir/reports/junit-report.xml")

src/main/kotlin/cursive/ClojurePlugin.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ open class ClojureCompiler @Inject constructor(val fileResolver: FileResolver) :
193193
var copySourceToOutput: Boolean? = null
194194
var reflectionWarnings = ReflectionWarnings(false, false, false)
195195

196+
var disableLocalsClearing: Boolean = false
197+
var elideMeta: Collection<String> = emptyList()
198+
var directLinking: Boolean = false
199+
196200
var namespaces: Collection<String> = emptyList()
197201

198202
fun reflectionWarnings(configureClosure: Closure<Any?>?): ReflectionWarnings {
@@ -225,7 +229,10 @@ open class ClojureCompiler @Inject constructor(val fileResolver: FileResolver) :
225229

226230
val script = listOf("(try",
227231
" (binding [*compile-path* \"${destinationDir.canonicalPath}\"",
228-
" *warn-on-reflection* ${reflectionWarnings.enabled}]",
232+
" *warn-on-reflection* ${reflectionWarnings.enabled}",
233+
" *compiler-options* {:disable-locals-clearing $disableLocalsClearing",
234+
" :elide-meta [${elideMeta.map { ":$it" }.joinToString(" ")}]",
235+
" :direct-linking $directLinking}]",
229236
" " + namespaces.map { "(compile '$it)" }.joinToString("\n ") + ")",
230237
" (catch Throwable e",
231238
" (.printStackTrace e)",

0 commit comments

Comments
 (0)