runtime/build.gradle: extract bitcode compilation to custom task class

This commit is contained in:
Svyatoslav Scherbina
2016-10-13 16:46:27 +03:00
parent abc98983e1
commit d800e193e8
2 changed files with 99 additions and 33 deletions
+6 -33
View File
@@ -1,39 +1,12 @@
import org.jetbrains.kotlin.CompileCppToBitcode
// TODO: consider using some Gradle plugins to build and test
def srcDir = 'src/main/cpp'
def objDir = "$buildDir/bitcode"
def outFile = "$buildDir/runtime.bc"
task compile(type: Exec) {
doFirst {
new File(objDir).mkdirs()
}
task build(type: CompileCppToBitcode) {
name 'runtime'
srcRoot file('src/main')
inputs.dir srcDir
outputs.dir objDir
workingDir objDir
executable "$llvmInstallPath/bin/clang"
args '-std=c++11'
args '-c', '-emit-llvm'
args fileTree(srcDir).include('**/*.cpp')
}
task build(type: Exec) {
dependsOn compile
inputs.dir objDir
outputs.file outFile
executable "$llvmInstallPath/bin/llvm-link"
args '-o', outFile
doFirst {
args fileTree(objDir).include('**/*.bc')
}
}
task test {
@@ -44,7 +17,7 @@ task test {
commandLine "$llvmInstallPath/bin/clang", 'src/test/c/main.c', '-c', '-emit-llvm', '-o', "$buildDir/main.bc"
}
exec {
commandLine "$llvmInstallPath/bin/clang++", outFile, "$buildDir/main.bc", '-o', "$buildDir/main"
commandLine "$llvmInstallPath/bin/clang++", build.outFile, "$buildDir/main.bc", '-o', "$buildDir/main"
}
exec {
workingDir buildDir