2018-05-23 21:44:29 +00:00
|
|
|
plugins {
|
|
|
|
id 'com.github.hauner.jarTest'
|
|
|
|
id 'cpp'
|
|
|
|
id 'eclipse'
|
2018-05-28 18:07:54 +00:00
|
|
|
id 'edu.wpi.first.GradleJni' version '0.2.1'
|
2018-05-23 21:44:29 +00:00
|
|
|
}
|
2018-01-15 04:50:52 +00:00
|
|
|
|
|
|
|
eclipse.project.natures 'org.eclipse.pde.PluginNature'
|
2018-07-12 18:53:37 +00:00
|
|
|
prepareIntelliJIDEA.dependsOn jarTest
|
2017-12-24 20:20:37 +00:00
|
|
|
|
2017-12-26 21:54:35 +00:00
|
|
|
sourceSets.test.java.srcDirs = ['harness-src/java']
|
2017-11-27 08:34:48 +00:00
|
|
|
|
|
|
|
dependencies {
|
2018-01-11 03:56:27 +00:00
|
|
|
testCompile(
|
2018-05-21 21:37:54 +00:00
|
|
|
'junit:junit:4.12',
|
2018-01-11 03:56:27 +00:00
|
|
|
project(':com.ibm.wala.cast'),
|
|
|
|
project(':com.ibm.wala.core'),
|
|
|
|
project(':com.ibm.wala.util'),
|
|
|
|
project(configuration: 'testArchives', path: ':com.ibm.wala.core.tests'),
|
|
|
|
)
|
2017-11-28 01:45:05 +00:00
|
|
|
}
|
2017-12-24 20:20:37 +00:00
|
|
|
|
|
|
|
def currentJvm = org.gradle.internal.jvm.Jvm.current()
|
|
|
|
|
2018-05-28 15:37:51 +00:00
|
|
|
def addCastRpath(currentJvm, targetPlatform, linker) {
|
|
|
|
switch (targetPlatform.operatingSystem.name) {
|
|
|
|
case 'linux':
|
|
|
|
case 'osx':
|
|
|
|
[
|
|
|
|
// TODO: compute path on following line from 'cast' library properties somehow
|
|
|
|
"${project(':com.ibm.wala.cast').buildDir}/libs/cast/shared",
|
|
|
|
// TODO: compute paths on following lines from 'jdk' library properties somehow
|
|
|
|
"${currentJvm.javaHome}/jre/lib/amd64/server",
|
|
|
|
"${currentJvm.javaHome}/jre/lib/server",
|
|
|
|
].each { linker.args "-Wl,-rpath,$it" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def addCastEnvironment(task, xlatorLibrary) {
|
2018-05-28 18:07:54 +00:00
|
|
|
def castLibrary = xlatorLibrary.libs[2].linkFiles.singleFile
|
|
|
|
def castLibraryDirectory = castLibrary.parent
|
|
|
|
assert castLibraryDirectory.endsWith('/com.ibm.wala.cast/build/libs/cast/shared')
|
2018-05-28 15:37:51 +00:00
|
|
|
task.environment 'DYLD_LIBRARY_PATH', castLibrary.parent
|
|
|
|
}
|
|
|
|
|
2017-12-24 20:20:37 +00:00
|
|
|
model {
|
|
|
|
components {
|
2018-05-28 18:07:54 +00:00
|
|
|
xlator_test(JniNativeLibrarySpec) {
|
|
|
|
javaCompileTasks << compileTestJava
|
|
|
|
|
2017-12-24 20:20:37 +00:00
|
|
|
sources.cpp {
|
|
|
|
source {
|
2017-12-26 21:54:35 +00:00
|
|
|
srcDirs = ['harness-src/c']
|
2017-12-24 20:20:37 +00:00
|
|
|
include 'smoke.cpp'
|
|
|
|
}
|
2017-12-24 23:43:31 +00:00
|
|
|
['cast', 'jdk'].each {
|
|
|
|
lib project: ':com.ibm.wala.cast', library: it
|
|
|
|
}
|
2017-12-24 20:20:37 +00:00
|
|
|
}
|
2018-05-27 23:47:33 +00:00
|
|
|
|
2017-12-24 20:20:37 +00:00
|
|
|
binaries {
|
|
|
|
withType(StaticLibraryBinarySpec) {
|
|
|
|
buildable = false
|
|
|
|
}
|
2018-01-21 22:15:31 +00:00
|
|
|
withType(SharedLibraryBinarySpec) {
|
2018-05-28 15:37:51 +00:00
|
|
|
addCastRpath(currentJvm, targetPlatform, linker)
|
2017-12-24 20:20:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-27 23:47:33 +00:00
|
|
|
|
2017-12-24 20:20:37 +00:00
|
|
|
smoke_main(NativeExecutableSpec) {
|
2017-12-24 23:43:31 +00:00
|
|
|
sources.cpp {
|
|
|
|
source {
|
2017-12-26 21:54:35 +00:00
|
|
|
srcDirs = ['harness-src/c']
|
2017-12-24 23:43:31 +00:00
|
|
|
include 'smoke_main.cpp'
|
|
|
|
}
|
2017-12-24 20:20:37 +00:00
|
|
|
['cast', 'jdk'].each {
|
|
|
|
lib project: ':com.ibm.wala.cast', library: it
|
|
|
|
}
|
2017-12-24 23:43:31 +00:00
|
|
|
}
|
2018-05-27 23:47:33 +00:00
|
|
|
|
2017-12-24 23:43:31 +00:00
|
|
|
binaries.all {
|
2018-05-28 15:37:51 +00:00
|
|
|
addCastRpath(currentJvm, targetPlatform, linker)
|
2017-12-24 20:20:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-12-26 22:58:29 +00:00
|
|
|
|
2018-05-28 15:37:51 +00:00
|
|
|
tasks {
|
|
|
|
test {
|
|
|
|
def lib = linkXlator_testSharedLibrary
|
|
|
|
dependsOn lib
|
|
|
|
systemProperty 'java.library.path', lib.destinationDirectory.get().asFile
|
|
|
|
|
|
|
|
addCastEnvironment(it, $.binaries.xlator_testSharedLibrary)
|
|
|
|
}
|
|
|
|
|
|
|
|
checkSmoke_main(Exec) {
|
|
|
|
// main executable to run for test
|
|
|
|
def executableBinary = $.binaries.smoke_mainExecutable
|
|
|
|
executable executableBinary.executableFile
|
2018-05-28 18:07:54 +00:00
|
|
|
dependsOn executableBinary
|
2018-05-28 15:37:51 +00:00
|
|
|
def pathElements = [$.binaries.test.getClassesDir()]
|
|
|
|
|
|
|
|
// implementations of native methods
|
|
|
|
def library = $.binaries.xlator_testSharedLibrary
|
2018-05-28 18:07:54 +00:00
|
|
|
dependsOn library
|
2018-05-28 15:37:51 +00:00
|
|
|
pathElements << library.sharedLibraryFile.parent
|
|
|
|
|
|
|
|
// "primorial.txt" resource loaded during test
|
|
|
|
def coreResources = project(':com.ibm.wala.core').processResources
|
|
|
|
dependsOn coreResources
|
|
|
|
pathElements << coreResources.destinationDir
|
|
|
|
|
|
|
|
// additional supporting Java class files
|
|
|
|
['cast', 'core', 'util'].each {
|
|
|
|
def compileJava = project(":com.ibm.wala.$it").compileJava
|
|
|
|
dependsOn compileJava
|
|
|
|
pathElements << compileJava.destinationDir
|
|
|
|
}
|
|
|
|
|
|
|
|
// all combined as a colon-delimited path list
|
|
|
|
args pathElements.join(':')
|
|
|
|
|
|
|
|
addCastEnvironment(it, $.binaries.xlator_testSharedLibrary)
|
|
|
|
}
|
2018-02-27 03:55:27 +00:00
|
|
|
|
2018-05-28 15:37:51 +00:00
|
|
|
check.dependsOn checkSmoke_main
|
2018-01-21 00:20:56 +00:00
|
|
|
}
|
2017-12-26 22:58:29 +00:00
|
|
|
}
|