build: refactor platform checks
also improve verbosity when downloading dependencies fails
This commit is contained in:
committed by
SvyatoslavScherbina
parent
720947facb
commit
bee2a76008
@@ -92,7 +92,7 @@ String[] linkerOpts1() {
|
|||||||
'-lLLVMCore',
|
'-lLLVMCore',
|
||||||
'-lLLVMSupport']
|
'-lLLVMSupport']
|
||||||
List<String> ldflags = new ArrayList<>()
|
List<String> ldflags = new ArrayList<>()
|
||||||
if (System.properties['os.name'].startsWith("Linux"))
|
if (isLinux())
|
||||||
ldflags.addAll(["-L$llvmDir/lib",
|
ldflags.addAll(["-L$llvmDir/lib",
|
||||||
"-Wl,-Bstatic", "-Wl,--whole-archive"]
|
"-Wl,-Bstatic", "-Wl,--whole-archive"]
|
||||||
+ libs
|
+ libs
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ abstract class KonanTest extends DefaultTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private linux() {
|
private linux() {
|
||||||
return System.properties['os.name'].startsWith('Linux')
|
return project.isLinux()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String linkDl() {
|
protected String linkDl() {
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ if (new File("$project.rootDir/local.properties").exists()) {
|
|||||||
props.each {prop -> project.ext.set(prop.key, prop.value)}
|
props.each {prop -> project.ext.set(prop.key, prop.value)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
convention.plugins.platformInfo = new PlatformInfo()
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
if (path != ":dependencies") {
|
if (path != ":dependencies") {
|
||||||
evaluationDependsOn(":dependencies")
|
evaluationDependsOn(":dependencies")
|
||||||
@@ -34,4 +36,33 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Vendored
+7
-14
@@ -1,20 +1,12 @@
|
|||||||
abstract class NativeDep extends DefaultTask {
|
abstract class NativeDep extends DefaultTask {
|
||||||
|
|
||||||
private static String getCurrentHostTarget() {
|
private String getCurrentHostTarget() {
|
||||||
String osName = System.properties['os.name']
|
if (project.isMac() && project.isAmd64()) {
|
||||||
String osArch = System.properties['os.arch']
|
return 'darwin-macos'
|
||||||
|
} else if (project.isLinux() && project.isAmd64()) {
|
||||||
// TODO: implement more generally
|
return 'linux-x86-64'
|
||||||
if (osArch in ['x86_64', 'amd64']) {
|
|
||||||
if (osName == 'Mac OS X') {
|
|
||||||
return 'darwin-macos'
|
|
||||||
} else if (osName == 'Linux') {
|
|
||||||
return 'linux-x86-64'
|
|
||||||
} else {
|
|
||||||
throw new Error("Unsupported OS: $osName")
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Unsupported arch: $osArch")
|
throw project.unsupportedPlatformException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +59,7 @@ class TgzNativeDep extends NativeDep {
|
|||||||
args "xf", archived
|
args "xf", archived
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace()
|
||||||
project.delete(outputDir)
|
project.delete(outputDir)
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user