build: simplify clang(++) configuration

also introduce 'execClang' block
This commit is contained in:
Svyatoslav Scherbina
2016-11-08 11:34:30 +07:00
committed by SvyatoslavScherbina
parent 4e5e7d37ee
commit 55f8257f92
7 changed files with 75 additions and 24 deletions
+2 -3
View File
@@ -105,20 +105,19 @@ String[] linkerOpts1() {
+ ["-L$libffiDir/lib", "-lffi"])
ArrayList<String> strldflags = new ArrayList<>()
ldflags.forEach{strldflags.add(it.toString())}
strldflags.add("-B$sysrootDir/usr/bin".toString())
return strldflags.toArray(new String[0])
}
kotlinNativeInterop {
llvm {
defFile 'llvm.def'
compilerOpts "-fPIC", "-I$llvmDir/include", "-B$sysrootDir/usr/bin"
compilerOpts "-fPIC", "-I$llvmDir/include"
linkerOpts linkerOpts1()
}
hash { // TODO: copy-pasted from ':common:compileHash'
compilerOpts '-fPIC'
linkerOpts '-fPIC', "-B$sysrootDir/usr/bin"
linkerOpts '-fPIC'
linker 'clang++'
linkOutputs ':common:compileHash'
+4 -10
View File
@@ -11,8 +11,6 @@ abstract class KonanTest extends DefaultTask {
def backendNative = project.project(":backend.native")
def runtimeProject = project.project(":runtime")
def llvmLlc = llvmTool("llc")
def llvmC = llvmTool("clang")
def llvmCAdditionalArgs = ["--sysroot=$project.sysrootDir"]
def runtimeBc = new File("${runtimeProject.buildDir.canonicalPath}/runtime.bc")
def mainC = 'main.c'
String goldValue = null
@@ -100,22 +98,18 @@ abstract class KonanTest extends DefaultTask {
class UnitKonanTest extends KonanTest {
void compileTest(File sourceS, File runtimeS, File exe) {
def testC = sourceS.absolutePath.replace(".kt.S", "-test.c")
project.exec {
commandLine "${llvmC}", "-B${project.sysrootDir}/usr/bin", "${testC}", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}", linkDl(),
project.execClang {
commandLine "clang", "${testC}", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}", linkDl(),
"-o", "${exe.absolutePath}"
args llvmCAdditionalArgs
}
}
}
class RunKonanTest extends KonanTest {
void compileTest(File sourceS, File runtimeS, File exe) {
project.exec {
commandLine "${llvmC}", "-DRUN_TEST", "-B${project.sysrootDir}/usr/bin", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}", linkDl(),
project.execClang {
commandLine "clang", "-DRUN_TEST", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}", linkDl(),
"-o", "${exe.absolutePath}"
args llvmCAdditionalArgs
}
}
}