Fork of the T.J. Watson Libraries for Analysis used by DASCA.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

129 lines
3.3 KiB

plugins {
id 'com.github.hauner.jarTest'
id 'cpp'
id 'eclipse'
id 'edu.wpi.first.GradleJni' version '0.2.1'
}
eclipse.project.natures 'org.eclipse.pde.PluginNature'
prepareIntelliJIDEA.dependsOn jarTest
sourceSets.test.java.srcDirs = ['harness-src/java']
dependencies {
testCompile(
'junit:junit:4.12',
project(':com.ibm.wala.cast'),
project(':com.ibm.wala.core'),
project(':com.ibm.wala.util'),
project(configuration: 'testArchives', path: ':com.ibm.wala.core.tests'),
)
}
def currentJvm = org.gradle.internal.jvm.Jvm.current()
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) {
def castLibrary = xlatorLibrary.libs[2].linkFiles.singleFile
def castLibraryDirectory = castLibrary.parent
assert castLibraryDirectory.endsWith('/com.ibm.wala.cast/build/libs/cast/shared')
task.environment 'DYLD_LIBRARY_PATH', castLibrary.parent
}
model {
components {
xlator_test(JniNativeLibrarySpec) {
javaCompileTasks << compileTestJava
sources.cpp {
source {
srcDirs = ['harness-src/c']
include 'smoke.cpp'
}
['cast', 'jdk'].each {
lib project: ':com.ibm.wala.cast', library: it
}
}
binaries {
withType(StaticLibraryBinarySpec) {
buildable = false
}
withType(SharedLibraryBinarySpec) {
addCastRpath(currentJvm, targetPlatform, linker)
}
}
}
smoke_main(NativeExecutableSpec) {
sources.cpp {
source {
srcDirs = ['harness-src/c']
include 'smoke_main.cpp'
}
['cast', 'jdk'].each {
lib project: ':com.ibm.wala.cast', library: it
}
}
binaries.all {
addCastRpath(currentJvm, targetPlatform, linker)
}
}
}
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
dependsOn executableBinary
def pathElements = [$.binaries.test.getClassesDir()]
// implementations of native methods
def library = $.binaries.xlator_testSharedLibrary
dependsOn library
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)
}
check.dependsOn checkSmoke_main
}
}