apply plugin: 'cpp' apply plugin: 'google-test-test-suite' apply plugin: 'visual-studio' apply plugin: 'edu.wpi.first.NativeUtils' apply plugin: 'edu.wpi.first.GradleJni' apply plugin: SingleNativeBuild apply plugin: ExtraTasks apply from: "${rootDir}/shared/config.gradle" ext { baseId = nativeName groupId = "edu.wpi.first.${nativeName}" } apply from: "${rootDir}/shared/java/javacommon.gradle" dependencies { compile project(':wpiutil') devCompile project(':wpiutil') } project(':').libraryBuild.dependsOn build model { components { "${nativeName}Base"(JniNativeLibrarySpec) { if (project.hasProperty('setBaseName')) { baseName = setBaseName } javaCompileTasks << compileJava jniCrossCompileOptions << JniCrossCompileOptions('linux', 'athena', ["${rootDir}/shared/arm-linux-jni".toString(), "${rootDir}/shared/arm-linux-jni/linux".toString()]) sources { cpp { source { srcDirs 'src/main/native/cpp' include '**/*.cpp' } exportedHeaders { srcDirs 'src/main/native/include' } } } binaries.all { if (it instanceof SharedLibraryBinarySpec) { it.buildable = false return } lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' if (project.hasProperty('splitSetup')) { splitSetup(it) } if (project.hasProperty('niLibraries')) { project(':ni-libraries').addNiLibrariesToLinker(it) } } } "${nativeName}"(JniNativeLibrarySpec) { if (project.hasProperty('setBaseName')) { baseName = setBaseName } enableCheckTask true javaCompileTasks << compileJava jniCrossCompileOptions << JniCrossCompileOptions('linux', 'athena', ["${rootDir}/shared/arm-linux-jni".toString(), "${rootDir}/shared/arm-linux-jni/linux".toString()]) sources { cpp { source { srcDirs "${rootDir}/shared/singlelib" include '**/*.cpp' } exportedHeaders { srcDirs 'src/main/native/include' } } } binaries.all { lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' if (project.hasProperty('niLibraries')) { project(':ni-libraries').addNiLibrariesToLinker(it) } } } "${nativeName}JNI"(JniNativeLibrarySpec) { if (project.hasProperty('setBaseName')) { baseName = setBaseName } else { baseName = nativeName } enableCheckTask true javaCompileTasks << compileJava jniCrossCompileOptions << JniCrossCompileOptions('linux', 'athena', ["${rootDir}/shared/arm-linux-jni".toString(), "${rootDir}/shared/arm-linux-jni/linux".toString()]) sources { cpp { source { srcDirs "${rootDir}/shared/singlelib" include '**/*.cpp' } exportedHeaders { srcDirs 'src/main/native/include' } } } binaries.all { if (it instanceof StaticLibraryBinarySpec) { it.buildable = false return } lib project: ':wpiutil', library: 'wpiutil', linkage: 'static' } } // By default, a development executable will be generated. This is to help the case of // testing specific functionality of the library. "${nativeName}Dev"(NativeExecutableSpec) { sources { cpp { source { srcDirs 'src/dev/native/cpp' include '**/*.cpp' } exportedHeaders { srcDirs 'src/dev/native/include' } } } binaries.all { if (project.hasProperty('niLibraries')) { project(':ni-libraries').addNiLibrariesToLinker(it) } lib library: nativeName, linkage: 'shared' lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' } } } testSuites { "${nativeName}Test"(GoogleTestTestSuiteSpec) { for(NativeComponentSpec c : $.components) { if (c.name == nativeName) { testing c break } } sources { cpp { source { srcDirs 'src/test/native/cpp' include '**/*.cpp' } exportedHeaders { srcDirs 'src/test/native/include', 'src/main/native/cpp' } } } } } binaries { withType(GoogleTestTestSuiteBinarySpec) { if (!project.hasProperty('onlyAthena')) { lib project: ':gtest', library: 'gtest', linkage: 'static' lib library: nativeName, linkage: 'shared' lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' } else { it.buildable = false } } } tasks { def c = $.components project.tasks.create('runCpp', Exec) { group = 'WPILib' description = "Run the ${nativeName}Dev executable" def found = false def systemArch = getCurrentArch() c.each { if (it in NativeExecutableSpec && it.name == "${nativeName}Dev") { it.binaries.each { if (!found) { def arch = it.targetPlatform.architecture.name if (arch == systemArch) { dependsOn it.tasks.install commandLine it.tasks.install.runScriptFile.get().asFile.toString() def filePath = it.tasks.install.installDirectory.get().toString() + File.separatorChar + 'lib' test.dependsOn it.tasks.install test.systemProperty 'java.library.path', filePath test.environment 'LD_LIBRARY_PATH', filePath test.workingDir filePath run.dependsOn it.tasks.install run.systemProperty 'java.library.path', filePath run.environment 'LD_LIBRARY_PATH', filePath run.workingDir filePath found = true } } } } } } } } ext.getJniSpecClass = { return JniNativeLibrarySpec } tasks.withType(RunTestExecutable) { args "--gtest_output=xml:test_detail.xml" outputs.dir outputDir } apply from: "${rootDir}/shared/jni/publish.gradle"