build: add target native SDK as downloadable dependency
also improve Gradle native toolchains configuration
This commit is contained in:
committed by
SvyatoslavScherbina
parent
db1853f627
commit
e7558f9ddc
@@ -16,13 +16,6 @@ def javaHome = System.getProperty('java.home')
|
|||||||
def compilerArgsForJniIncludes = ["", "linux", "darwin"].collect { "-I$javaHome/../include/$it" } as String[]
|
def compilerArgsForJniIncludes = ["", "linux", "darwin"].collect { "-I$javaHome/../include/$it" } as String[]
|
||||||
|
|
||||||
model {
|
model {
|
||||||
//TODO: it's better to find some way share this configuration
|
|
||||||
toolChains {
|
|
||||||
clang(Clang) {
|
|
||||||
path "${llvmDir}/bin/clang"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
components {
|
components {
|
||||||
clangbridge(NativeLibrarySpec) {
|
clangbridge(NativeLibrarySpec) {
|
||||||
sources {
|
sources {
|
||||||
|
|||||||
@@ -15,13 +15,6 @@ def javaHome = System.getProperty('java.home')
|
|||||||
def compilerArgsForJniIncludes = ["", "linux", "darwin"].collect { "-I$javaHome/../include/$it" } as String[]
|
def compilerArgsForJniIncludes = ["", "linux", "darwin"].collect { "-I$javaHome/../include/$it" } as String[]
|
||||||
|
|
||||||
model {
|
model {
|
||||||
//TODO: it's better to find some way share this configuration
|
|
||||||
toolChains {
|
|
||||||
clang(Clang) {
|
|
||||||
path "${llvmDir}/bin/clang"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
components {
|
components {
|
||||||
callbacks(NativeLibrarySpec) {
|
callbacks(NativeLibrarySpec) {
|
||||||
sources.c.source {
|
sources.c.source {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ abstract class KonanTest extends DefaultTask {
|
|||||||
def runtimeProject = project.project(":runtime")
|
def runtimeProject = project.project(":runtime")
|
||||||
def llvmLlc = llvmTool("llc")
|
def llvmLlc = llvmTool("llc")
|
||||||
def llvmC = llvmTool("clang")
|
def llvmC = llvmTool("clang")
|
||||||
|
def llvmCAdditionalArgs = ["--sysroot=$project.sysrootDir"]
|
||||||
def runtimeBc = new File("${runtimeProject.buildDir.canonicalPath}/runtime.bc")
|
def runtimeBc = new File("${runtimeProject.buildDir.canonicalPath}/runtime.bc")
|
||||||
def mainC = 'main.c'
|
def mainC = 'main.c'
|
||||||
String goldValue = null
|
String goldValue = null
|
||||||
@@ -88,6 +89,8 @@ class UnitKonanTest extends KonanTest {
|
|||||||
project.exec {
|
project.exec {
|
||||||
commandLine "${llvmC}", "${testC}", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}",
|
commandLine "${llvmC}", "${testC}", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}",
|
||||||
"-o", "${exe.absolutePath}"
|
"-o", "${exe.absolutePath}"
|
||||||
|
|
||||||
|
args llvmCAdditionalArgs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,6 +100,8 @@ class RunKonanTest extends KonanTest {
|
|||||||
project.exec {
|
project.exec {
|
||||||
commandLine "${llvmC}", "-DRUN_TEST", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}",
|
commandLine "${llvmC}", "-DRUN_TEST", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}",
|
||||||
"-o", "${exe.absolutePath}"
|
"-o", "${exe.absolutePath}"
|
||||||
|
|
||||||
|
args llvmCAdditionalArgs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-9
@@ -11,16 +11,16 @@ allprojects {
|
|||||||
evaluationDependsOn(":dependencies")
|
evaluationDependsOn(":dependencies")
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEvaluate {
|
plugins.withType(NativeComponentPlugin) {
|
||||||
if (plugins.hasPlugin('c')) {
|
model {
|
||||||
model {
|
toolChains {
|
||||||
toolChains {
|
clang(Clang) {
|
||||||
clang(Clang) {
|
path "$llvmDir/bin"
|
||||||
path "$llvmDir/bin"
|
|
||||||
|
|
||||||
// The system PATH should be appended automatically according to Gradle docs,
|
eachPlatform { // TODO: will not work when cross-compiling
|
||||||
// but this doesn't seem to happen
|
[cCompiler, cppCompiler, linker].each {
|
||||||
path System.env.PATH.split(File.pathSeparator)
|
it.withArguments { it << "--sysroot=$sysrootDir" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ class CompileCppToBitcode extends DefaultTask {
|
|||||||
executable "$project.llvmDir/bin/clang++"
|
executable "$project.llvmDir/bin/clang++"
|
||||||
args '-std=c++11'
|
args '-std=c++11'
|
||||||
|
|
||||||
|
args "--sysroot=$project.sysrootDir"
|
||||||
|
|
||||||
args compilerArgs
|
args compilerArgs
|
||||||
|
|
||||||
args "-I$headersDir"
|
args "-I$headersDir"
|
||||||
|
|||||||
@@ -174,6 +174,10 @@ class NamedNativeInteropConfig implements Named {
|
|||||||
args "-linker:" + linker
|
args "-linker:" + linker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String sysrootArg = "--sysroot=$project.sysrootDir"
|
||||||
|
compilerOpts += sysrootArg
|
||||||
|
linkerOpts += sysrootArg
|
||||||
|
|
||||||
args compilerOpts.collect { "-copt:$it" }
|
args compilerOpts.collect { "-copt:$it" }
|
||||||
args linkerOpts.collect { "-lopt:$it" }
|
args linkerOpts.collect { "-lopt:$it" }
|
||||||
|
|
||||||
|
|||||||
Vendored
+4
@@ -85,6 +85,10 @@ task llvm(type: TgzNativeDep) {
|
|||||||
baseName = "clang+llvm-3.8.0-$target"
|
baseName = "clang+llvm-3.8.0-$target"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task sysroot(type: TgzNativeDep) {
|
||||||
|
baseName = "target-sysroot-1-$target"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
task update {
|
task update {
|
||||||
dependsOn tasks.withType(NativeDep)
|
dependsOn tasks.withType(NativeDep)
|
||||||
|
|||||||
Reference in New Issue
Block a user