66bd698270
also fix Mac build failure related to 'ar'
81 lines
2.2 KiB
Groovy
81 lines
2.2 KiB
Groovy
//ant.importBuild 'backend.native/kotlin-ir/build.xml'
|
|
|
|
if (new File("$project.rootDir/local.properties").exists()) {
|
|
Properties props = new Properties()
|
|
props.load(new FileInputStream("$project.rootDir/local.properties"))
|
|
props.each {prop -> project.ext.set(prop.key, prop.value)}
|
|
}
|
|
|
|
convention.plugins.platformInfo = new PlatformInfo()
|
|
|
|
allprojects {
|
|
if (path != ":dependencies") {
|
|
evaluationDependsOn(":dependencies")
|
|
}
|
|
|
|
ext.clangPath = ["$llvmDir/bin"]
|
|
ext.clangArgs = []
|
|
final String binDir
|
|
if (isLinux()) {
|
|
binDir = "$gccToolchainDir/$gnuTriplet/bin"
|
|
ext.clangArgs.addAll([
|
|
"--sysroot=$gccToolchainDir/$gnuTriplet/sysroot",
|
|
"--gcc-toolchain=$gccToolchainDir"
|
|
])
|
|
} else {
|
|
binDir = "$sysrootDir/usr/bin"
|
|
ext.clangArgs << "--sysroot=$sysrootDir"
|
|
}
|
|
ext.clangArgs << "-B$binDir"
|
|
ext.clangPath << binDir
|
|
|
|
convention.plugins.execClang = new org.jetbrains.kotlin.ExecClang(project)
|
|
|
|
plugins.withType(NativeComponentPlugin) {
|
|
model {
|
|
toolChains {
|
|
clang(Clang) {
|
|
clangPath.each {
|
|
path it
|
|
}
|
|
|
|
eachPlatform { // TODO: will not work when cross-compiling
|
|
[cCompiler, cppCompiler, linker].each {
|
|
it.withArguments { it.addAll(clangArgs) }
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class PlatformInfo {
|
|
private final String osName = System.properties['os.name']
|
|
private final String osArch = System.properties['os.arch']
|
|
|
|
boolean isMac() {
|
|
return osName == 'Mac OS X'
|
|
}
|
|
|
|
boolean isLinux() {
|
|
return osName == 'Linux'
|
|
}
|
|
|
|
boolean isAmd64() {
|
|
return osArch in ['x86_64', 'amd64']
|
|
}
|
|
|
|
String getGnuTriplet() {
|
|
if (isLinux() && isAmd64()) {
|
|
return "x86_64-unknown-linux-gnu"
|
|
} else {
|
|
throw unsupportedPlatformException()
|
|
}
|
|
}
|
|
|
|
Throwable unsupportedPlatformException() {
|
|
return new Error("unsupported platform: $osName/$osArch")
|
|
}
|
|
} |