2018-01-11 04:36:57 +00:00
|
|
|
apply plugin: 'com.github.hauner.jarTest'
|
2017-12-24 20:20:37 +00:00
|
|
|
apply plugin: 'cpp'
|
2018-01-15 04:50:52 +00:00
|
|
|
apply plugin: 'eclipse'
|
|
|
|
|
|
|
|
eclipse.project.natures 'org.eclipse.pde.PluginNature'
|
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
|
|
|
|
|
|
|
// TODO: build following targets for "test"-only, not "main"
|
|
|
|
|
|
|
|
def currentJvm = org.gradle.internal.jvm.Jvm.current()
|
|
|
|
|
|
|
|
task generateJniHeaders(type: Exec, dependsOn: [testClasses, ':com.ibm.wala.cast:classes']) {
|
|
|
|
// classes for which we need headers
|
|
|
|
def nativePackage = 'com.ibm.wala.cast.test'
|
|
|
|
def nativeClasses = ['TestNativeTranslator']
|
|
|
|
def qualifiedClasses = nativeClasses.collect { "$nativePackage.$it" }
|
|
|
|
|
|
|
|
// inputs and outputs, suitable for use with rule-based model configuration
|
|
|
|
ext {
|
|
|
|
sourceDir = null
|
|
|
|
headerDir = "$buildDir/include"
|
|
|
|
}
|
|
|
|
inputs.files files(qualifiedClasses.collect { "$buildDir/${it.replace('.', '/')}.class" })
|
2018-03-31 23:04:00 +00:00
|
|
|
outputs.dir headerDir
|
2018-03-31 23:02:04 +00:00
|
|
|
outputs.cacheIf { true }
|
2017-12-24 20:20:37 +00:00
|
|
|
|
|
|
|
// javah command to generate headers
|
|
|
|
def sourceSets = [sourceSets.test, project(':com.ibm.wala.cast').sourceSets.main]
|
|
|
|
def classesDirs = sourceSets.inject(files()) { acc, val -> acc.plus(val.output.classesDirs) }
|
2017-12-26 20:55:21 +00:00
|
|
|
def classpath = classesDirs.asPath
|
2017-12-24 20:20:37 +00:00
|
|
|
def javah = currentJvm.getExecutable('javah')
|
|
|
|
commandLine(javah, '-d', "$headerDir", '-classpath', classpath)
|
|
|
|
args(qualifiedClasses)
|
|
|
|
}
|
|
|
|
|
|
|
|
model {
|
|
|
|
components {
|
|
|
|
xlator_test(NativeLibrarySpec) {
|
|
|
|
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'
|
|
|
|
}
|
2018-01-17 03:23:36 +00:00
|
|
|
generatedBy generateJniHeaders
|
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
|
|
|
}
|
|
|
|
binaries {
|
|
|
|
withType(StaticLibraryBinarySpec) {
|
|
|
|
buildable = false
|
|
|
|
}
|
2018-01-21 22:15:31 +00:00
|
|
|
withType(SharedLibraryBinarySpec) {
|
2018-01-16 22:40:59 +00:00
|
|
|
switch ("$targetPlatform.operatingSystem.name/$targetPlatform.architecture.name") {
|
|
|
|
case 'linux/x86-64':
|
|
|
|
// TODO: compute path on following line from 'cast' library properties somehow
|
|
|
|
linker.args '-Wl,-rpath', "${project(':com.ibm.wala.cast').buildDir}/libs/cast/shared"
|
|
|
|
// TODO: compute path on following line from 'jdk' library properties somehow
|
|
|
|
linker.args '-Wl,-rpath', "${currentJvm.javaHome}/jre/lib/amd64/server"
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
binaries.all {
|
2018-02-27 04:08:36 +00:00
|
|
|
switch ("$targetPlatform.operatingSystem.name/$targetPlatform.architecture.name") {
|
|
|
|
case 'linux/x86-64':
|
|
|
|
// TODO: compute path on following line from 'cast' library properties somehow
|
|
|
|
linker.args '-Wl,-rpath', "${project(':com.ibm.wala.cast').buildDir}/libs/cast/shared"
|
|
|
|
// TODO: compute path on following line from 'jdk' library properties somehow
|
|
|
|
linker.args '-Wl,-rpath', "${currentJvm.javaHome}/jre/lib/amd64/server"
|
|
|
|
}
|
2017-12-24 20:20:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-12-26 22:58:29 +00:00
|
|
|
|
2018-01-21 00:20:56 +00:00
|
|
|
tasks.test {
|
2018-01-21 22:16:01 +00:00
|
|
|
def lib = linkXlator_testSharedLibrary
|
|
|
|
dependsOn lib
|
2018-04-18 23:49:58 +00:00
|
|
|
systemProperty 'java.library.path', lib.destinationDirectory.orNull.asFile
|
2018-02-27 03:55:27 +00:00
|
|
|
|
|
|
|
// TODO: compute path on following line from 'cast' library properties somehow
|
|
|
|
def castLibDir = "${project(':com.ibm.wala.cast').buildDir}/libs/cast/shared"
|
|
|
|
environment 'DYLD_LIBRARY_PATH', castLibDir
|
2018-01-21 00:20:56 +00:00
|
|
|
}
|
2017-12-26 22:58:29 +00:00
|
|
|
}
|