Merge pull request #9 from JetBrains/download-deps
Download some deps from the JFrog repo
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
.DS_Store
|
||||
.idea/shelf
|
||||
dependencies
|
||||
/dependencies/all
|
||||
dist
|
||||
translator/src/test/kotlin/tests/*/linked
|
||||
out
|
||||
|
||||
@@ -24,11 +24,11 @@ model {
|
||||
|
||||
binaries.all {
|
||||
cCompiler.args compilerArgsForJniIncludes
|
||||
cCompiler.args "-I$llvmInstallPath/include"
|
||||
cCompiler.args "-I$llvmDir/include"
|
||||
}
|
||||
|
||||
binaries.withType(SharedLibraryBinarySpec) {
|
||||
linker.args "-L$llvmInstallPath/lib", "-lclang"
|
||||
linker.args "-L$llvmDir/lib", "-lclang"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,9 @@ model {
|
||||
}
|
||||
binaries.all {
|
||||
cCompiler.args compilerArgsForJniIncludes
|
||||
cCompiler.args "-I$ffiIncludePath"
|
||||
cCompiler.args "-I$libffiDir/include"
|
||||
|
||||
String libffiPicPath = "$ffiLibPath/libffi_pic.a"
|
||||
linker.args file(libffiPicPath).exists() ? libffiPicPath : "$ffiLibPath/libffi.a"
|
||||
linker.args "$libffiDir/lib/libffi.a"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ repositories {
|
||||
kotlinNativeInterop {
|
||||
llvm {
|
||||
defFile '../backend.native/llvm.def'
|
||||
compilerOpts "-I$llvmInstallPath/include"
|
||||
linkerOpts "-L$llvmInstallPath/lib"
|
||||
compilerOpts "-I$llvmDir/include"
|
||||
linkerOpts "-L$llvmDir/lib"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,3 +31,7 @@ dependencies {
|
||||
}
|
||||
|
||||
mainClassName = 'MainKt'
|
||||
|
||||
run {
|
||||
environment 'LD_LIBRARY_PATH' : "$llvmDir/lib"
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ sourceSets {
|
||||
kotlinNativeInterop {
|
||||
llvm {
|
||||
defFile 'llvm.def'
|
||||
compilerOpts "-I$llvmInstallPath/include"
|
||||
linkerOpts "-L$llvmInstallPath/lib"
|
||||
compilerOpts "-I$llvmDir/include"
|
||||
linkerOpts "-L$llvmDir/lib"
|
||||
}
|
||||
|
||||
hash { // TODO: copy-pasted from ':common:compileHash'
|
||||
@@ -86,6 +86,8 @@ task run(type: JavaExec) {
|
||||
doFirst {
|
||||
args '-runtime', project(':runtime').build.outputs.files.singleFile
|
||||
}
|
||||
|
||||
environment 'LD_LIBRARY_PATH' : "$llvmDir/lib"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,4 +4,10 @@ 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)}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
if (path != ":dependencies") {
|
||||
evaluationDependsOn(":dependencies")
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class CompileCppToBitcode extends DefaultTask {
|
||||
|
||||
project.exec {
|
||||
workingDir objDir
|
||||
executable "$project.llvmInstallPath/bin/clang++"
|
||||
executable "$project.llvmDir/bin/clang++"
|
||||
args '-std=c++11'
|
||||
|
||||
args compilerArgs
|
||||
@@ -82,7 +82,7 @@ class CompileCppToBitcode extends DefaultTask {
|
||||
}
|
||||
|
||||
project.exec {
|
||||
executable "$project.llvmInstallPath/bin/llvm-link"
|
||||
executable "$project.llvmDir/bin/llvm-link"
|
||||
args project.fileTree(objDir).include('**/*.bc')
|
||||
|
||||
args linkerArgs
|
||||
|
||||
@@ -141,10 +141,10 @@ class NamedNativeInteropConfig extends AbstractFileCollection implements Named {
|
||||
new File(project.findProject(":Interop:Indexer").buildDir, "nativelibs"),
|
||||
new File(project.findProject(":Interop:Runtime").buildDir, "nativelibs")
|
||||
).asPath
|
||||
systemProperties "llvmInstallPath" : project.llvmInstallPath
|
||||
systemProperties "llvmInstallPath" : project.llvmDir
|
||||
environment "LIBCLANG_DISABLE_CRASH_RECOVERY": "1"
|
||||
environment "DYLD_LIBRARY_PATH": "${project.llvmInstallPath}/lib"
|
||||
environment "LD_LIBRARY_PATH": "${project.llvmInstallPath}/lib"
|
||||
environment "DYLD_LIBRARY_PATH": "${project.llvmDir}/lib"
|
||||
environment "LD_LIBRARY_PATH": "${project.llvmDir}/lib"
|
||||
|
||||
outputs.dir generatedSrcDir
|
||||
outputs.dir nativeLibsDir
|
||||
|
||||
Vendored
+93
@@ -0,0 +1,93 @@
|
||||
abstract class NativeDep extends DefaultTask {
|
||||
|
||||
private static String getCurrentHostTarget() {
|
||||
String osName = System.properties['os.name']
|
||||
String osArch = System.properties['os.arch']
|
||||
|
||||
// TODO: implement more generally
|
||||
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 {
|
||||
throw new Error("Unsupported arch: $osArch")
|
||||
}
|
||||
}
|
||||
|
||||
protected final String target = getCurrentHostTarget();
|
||||
|
||||
@Input
|
||||
abstract String getFileName()
|
||||
|
||||
protected String getUrl() {
|
||||
return "http://repo.labs.intellij.net/kotlin-native/$fileName"
|
||||
}
|
||||
|
||||
protected File getBaseOutDir() {
|
||||
final File res = project.file("all")
|
||||
res.mkdirs()
|
||||
return res
|
||||
}
|
||||
|
||||
protected File download() {
|
||||
File result = new File(baseOutDir, fileName)
|
||||
ant.get(src: url, dest: result, usetimestamp: true)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
class TgzNativeDep extends NativeDep {
|
||||
String baseName
|
||||
|
||||
@Override
|
||||
String getFileName() {
|
||||
return "${baseName}.tar.gz"
|
||||
}
|
||||
|
||||
@OutputDirectory
|
||||
File getOutputDir() {
|
||||
return new File(baseOutDir, baseName)
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
public void downloadAndExtract() {
|
||||
File archived = this.download()
|
||||
|
||||
try {
|
||||
// Builtin Gradle unpacking tools seem to unable to handle symlinks;
|
||||
// Use external "tar" executable as workaround:
|
||||
project.exec {
|
||||
executable "tar"
|
||||
workingDir baseOutDir
|
||||
args "xf", archived
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
project.delete(outputDir)
|
||||
throw e
|
||||
}
|
||||
|
||||
// TODO: do not extract if already extracted
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
task libffi(type: TgzNativeDep) {
|
||||
baseName = "libffi-3.2.1-2-$target"
|
||||
}
|
||||
|
||||
task llvm(type: TgzNativeDep) {
|
||||
baseName = "clang+llvm-3.8.0-$target"
|
||||
}
|
||||
|
||||
|
||||
task update {
|
||||
dependsOn tasks.withType(NativeDep)
|
||||
}
|
||||
|
||||
tasks.withType(TgzNativeDep) {
|
||||
rootProject.ext.set("${name}Dir", outputDir.path)
|
||||
}
|
||||
@@ -1,4 +1 @@
|
||||
kotlin_version=1.0.4
|
||||
llvmInstallPath=/opt/local/libexec/llvm-3.8
|
||||
ffiIncludePath=/opt/local/lib/libffi-3.2.1/include
|
||||
ffiLibPath=/opt/local/lib
|
||||
|
||||
@@ -17,15 +17,15 @@ task test {
|
||||
|
||||
doLast {
|
||||
exec {
|
||||
commandLine "$llvmInstallPath/bin/clang", 'src/test/c/main.c', '-c', '-emit-llvm', '-o', "$buildDir/main.bc"
|
||||
}
|
||||
commandLine "$llvmDir/bin/clang", 'src/test/c/main.c', '-c', '-emit-llvm', '-o', "$buildDir/main.bc"
|
||||
}
|
||||
exec {
|
||||
commandLine "$llvmInstallPath/bin/clang++", build.outFile, "$buildDir/main.bc", '-o', "$buildDir/main"
|
||||
}
|
||||
exec {
|
||||
workingDir buildDir
|
||||
commandLine './main'
|
||||
}
|
||||
commandLine "$llvmDir/bin/clang++", build.outFile, "$buildDir/main.bc", '-o', "$buildDir/main"
|
||||
}
|
||||
exec {
|
||||
workingDir buildDir
|
||||
commandLine './main'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
include ':dependencies'
|
||||
include ':Interop:Indexer'
|
||||
include ':Interop:StubGenerator'
|
||||
include ':Interop:Runtime'
|
||||
|
||||
Reference in New Issue
Block a user