diff options
-rw-r--r-- | build.gradle | 9 | ||||
-rw-r--r-- | buildSrc/src/main/groovy/org/gradle/frege/FregeTask.groovy | 43 | ||||
-rw-r--r-- | buildSrc/src/main/resources/META-INF/gradle-plugins/frege.properties | 1 | ||||
-rw-r--r-- | src/main/frege/HelloWorld.fr | 2 |
4 files changed, 51 insertions, 4 deletions
diff --git a/build.gradle b/build.gradle index c995453..f426383 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,10 @@ -import org.gradle.frege.FregePlugin - buildscript { repositories { flatDir name:"frege-lib", dirs:"buildSrc/lib" } } -apply plugin: FregePlugin +apply plugin: "frege" apply plugin: "idea" apply plugin: "java" @@ -17,4 +15,9 @@ repositories { dependencies { compile ":frege:3.21.232-g7b05453" +} + +compileFrege { + outputDir = project.file("$buildDir/frege") + verbose = true }
\ No newline at end of file diff --git a/buildSrc/src/main/groovy/org/gradle/frege/FregeTask.groovy b/buildSrc/src/main/groovy/org/gradle/frege/FregeTask.groovy index 9938c46..26598b9 100644 --- a/buildSrc/src/main/groovy/org/gradle/frege/FregeTask.groovy +++ b/buildSrc/src/main/groovy/org/gradle/frege/FregeTask.groovy @@ -10,6 +10,8 @@ import org.gradle.api.internal.file.FileResolver class FregeTask extends DefaultTask { + private static final FREGE_FILE_EXTENSION_PATTERN = ~/.*\.fr?$/ + @Input boolean hints @Input boolean verbose @@ -22,15 +24,54 @@ class FregeTask extends DefaultTask { @Input boolean includeStale + // TODO: Find default + @OutputDirectory File outputDir = new File("build/classes") + @TaskAction void executeCompile() { - println "Compiling Frege" + println "Compiling Frege to " + outputDir FileResolver fileResolver = getServices().get(FileResolver.class) JavaExecAction action = new DefaultJavaExecAction(fileResolver) action.setMain("frege.compiler.Main") action.setClasspath(project.files(project.configurations.compile)) + + List args = [] + if (hints) + args << "-hints" + if (inline) + args << "-inline" + if (make) + args << "-make" + if (verbose) + args << "-v" + if (skipCompile) + args << "-j" + + args << "-d" + args << outputDir + + + eachFileRecurse(new File("src/main/frege")) { File file -> + if (file.name =~ FREGE_FILE_EXTENSION_PATTERN) { + args << file + } + + } + + action.args(args) + action.execute() } + private static void eachFileRecurse(File dir, Closure fileProcessor) { + dir.eachFile { File file -> + if (file.directory) { + eachFileRecurse(file, fileProcessor) + } else { + fileProcessor(file) + } + } + } + }
\ No newline at end of file diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/frege.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/frege.properties new file mode 100644 index 0000000..cc3210c --- /dev/null +++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/frege.properties @@ -0,0 +1 @@ +implementation-class=org.gradle.frege.FregePlugin diff --git a/src/main/frege/HelloWorld.fr b/src/main/frege/HelloWorld.fr new file mode 100644 index 0000000..c47a6f2 --- /dev/null +++ b/src/main/frege/HelloWorld.fr @@ -0,0 +1,2 @@ +module HelloWorld where +main _ = println "Hello World"
\ No newline at end of file |