diff --git a/com.ibm.wala.cast.test/build.gradle b/com.ibm.wala.cast.test/build.gradle index 1bf3aaa56..b570fb2d0 100644 --- a/com.ibm.wala.cast.test/build.gradle +++ b/com.ibm.wala.cast.test/build.gradle @@ -2,6 +2,7 @@ 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' @@ -20,30 +21,6 @@ dependencies { 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" }) - outputs.dir headerDir - outputs.cacheIf { true } - - // 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) } - def classpath = classesDirs.asPath - def javah = currentJvm.getExecutable('javah') - commandLine(javah, '-d', "$headerDir", '-classpath', classpath) - args(qualifiedClasses) -} - def addCastRpath(currentJvm, targetPlatform, linker) { switch (targetPlatform.operatingSystem.name) { case 'linux': @@ -59,19 +36,22 @@ def addCastRpath(currentJvm, targetPlatform, linker) { } def addCastEnvironment(task, xlatorLibrary) { - def castLibrary = xlatorLibrary.libs[0].linkFiles.singleFile + 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(NativeLibrarySpec) { + xlator_test(JniNativeLibrarySpec) { + javaCompileTasks << compileTestJava + sources.cpp { source { srcDirs = ['harness-src/c'] include 'smoke.cpp' } - generatedBy generateJniHeaders ['cast', 'jdk'].each { lib project: ':com.ibm.wala.cast', library: it } @@ -117,10 +97,12 @@ model { // 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