Merge pull request #9 from JetBrains/download-deps

Download some deps from the JFrog repo
This commit is contained in:
SvyatoslavScherbina
2016-10-17 18:30:45 +03:00
committed by GitHub
12 changed files with 128 additions and 26 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
.DS_Store .DS_Store
.idea/shelf .idea/shelf
dependencies /dependencies/all
dist dist
translator/src/test/kotlin/tests/*/linked translator/src/test/kotlin/tests/*/linked
out out
+2 -2
View File
@@ -24,11 +24,11 @@ model {
binaries.all { binaries.all {
cCompiler.args compilerArgsForJniIncludes cCompiler.args compilerArgsForJniIncludes
cCompiler.args "-I$llvmInstallPath/include" cCompiler.args "-I$llvmDir/include"
} }
binaries.withType(SharedLibraryBinarySpec) { binaries.withType(SharedLibraryBinarySpec) {
linker.args "-L$llvmInstallPath/lib", "-lclang" linker.args "-L$llvmDir/lib", "-lclang"
} }
} }
} }
+2 -3
View File
@@ -23,10 +23,9 @@ model {
} }
binaries.all { binaries.all {
cCompiler.args compilerArgsForJniIncludes cCompiler.args compilerArgsForJniIncludes
cCompiler.args "-I$ffiIncludePath" cCompiler.args "-I$libffiDir/include"
String libffiPicPath = "$ffiLibPath/libffi_pic.a" linker.args "$libffiDir/lib/libffi.a"
linker.args file(libffiPicPath).exists() ? libffiPicPath : "$ffiLibPath/libffi.a"
} }
} }
} }
+6 -2
View File
@@ -19,8 +19,8 @@ repositories {
kotlinNativeInterop { kotlinNativeInterop {
llvm { llvm {
defFile '../backend.native/llvm.def' defFile '../backend.native/llvm.def'
compilerOpts "-I$llvmInstallPath/include" compilerOpts "-I$llvmDir/include"
linkerOpts "-L$llvmInstallPath/lib" linkerOpts "-L$llvmDir/lib"
} }
} }
@@ -31,3 +31,7 @@ dependencies {
} }
mainClassName = 'MainKt' mainClassName = 'MainKt'
run {
environment 'LD_LIBRARY_PATH' : "$llvmDir/lib"
}
+4 -2
View File
@@ -36,8 +36,8 @@ sourceSets {
kotlinNativeInterop { kotlinNativeInterop {
llvm { llvm {
defFile 'llvm.def' defFile 'llvm.def'
compilerOpts "-I$llvmInstallPath/include" compilerOpts "-I$llvmDir/include"
linkerOpts "-L$llvmInstallPath/lib" linkerOpts "-L$llvmDir/lib"
} }
hash { // TODO: copy-pasted from ':common:compileHash' hash { // TODO: copy-pasted from ':common:compileHash'
@@ -86,6 +86,8 @@ task run(type: JavaExec) {
doFirst { doFirst {
args '-runtime', project(':runtime').build.outputs.files.singleFile args '-runtime', project(':runtime').build.outputs.files.singleFile
} }
environment 'LD_LIBRARY_PATH' : "$llvmDir/lib"
} }
+6
View File
@@ -5,3 +5,9 @@ if (new File("$project.rootDir/local.properties").exists()) {
props.load(new FileInputStream("$project.rootDir/local.properties")) props.load(new FileInputStream("$project.rootDir/local.properties"))
props.each {prop -> project.ext.set(prop.key, prop.value)} 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 { project.exec {
workingDir objDir workingDir objDir
executable "$project.llvmInstallPath/bin/clang++" executable "$project.llvmDir/bin/clang++"
args '-std=c++11' args '-std=c++11'
args compilerArgs args compilerArgs
@@ -82,7 +82,7 @@ class CompileCppToBitcode extends DefaultTask {
} }
project.exec { project.exec {
executable "$project.llvmInstallPath/bin/llvm-link" executable "$project.llvmDir/bin/llvm-link"
args project.fileTree(objDir).include('**/*.bc') args project.fileTree(objDir).include('**/*.bc')
args linkerArgs 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:Indexer").buildDir, "nativelibs"),
new File(project.findProject(":Interop:Runtime").buildDir, "nativelibs") new File(project.findProject(":Interop:Runtime").buildDir, "nativelibs")
).asPath ).asPath
systemProperties "llvmInstallPath" : project.llvmInstallPath systemProperties "llvmInstallPath" : project.llvmDir
environment "LIBCLANG_DISABLE_CRASH_RECOVERY": "1" environment "LIBCLANG_DISABLE_CRASH_RECOVERY": "1"
environment "DYLD_LIBRARY_PATH": "${project.llvmInstallPath}/lib" environment "DYLD_LIBRARY_PATH": "${project.llvmDir}/lib"
environment "LD_LIBRARY_PATH": "${project.llvmInstallPath}/lib" environment "LD_LIBRARY_PATH": "${project.llvmDir}/lib"
outputs.dir generatedSrcDir outputs.dir generatedSrcDir
outputs.dir nativeLibsDir outputs.dir nativeLibsDir
+93
View File
@@ -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)
}
-3
View File
@@ -1,4 +1 @@
kotlin_version=1.0.4 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
+8 -8
View File
@@ -17,15 +17,15 @@ task test {
doLast { doLast {
exec { 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 { exec {
commandLine "$llvmInstallPath/bin/clang++", build.outFile, "$buildDir/main.bc", '-o', "$buildDir/main" commandLine "$llvmDir/bin/clang++", build.outFile, "$buildDir/main.bc", '-o', "$buildDir/main"
} }
exec { exec {
workingDir buildDir workingDir buildDir
commandLine './main' commandLine './main'
} }
} }
} }
+1
View File
@@ -1,3 +1,4 @@
include ':dependencies'
include ':Interop:Indexer' include ':Interop:Indexer'
include ':Interop:StubGenerator' include ':Interop:StubGenerator'
include ':Interop:Runtime' include ':Interop:Runtime'