From dd8b65034664aa45e951f2046bbd7fd557848d68 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 23 Dec 2023 16:15:53 -0800 Subject: [PATCH] gih --- build.gradle | 1 + photon-core/build.gradle | 52 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/build.gradle b/build.gradle index c6c9ca2915..b571df5302 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ plugins { id "edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin" version "2020.2" id "edu.wpi.first.GradleRIO" version "2024.1.1-beta-4" id 'edu.wpi.first.WpilibTools' version '1.3.0' + id 'edu.wpi.first.GradleJni' version '1.1.0' } allprojects { diff --git a/photon-core/build.gradle b/photon-core/build.gradle index 48bc192dc7..a93e094586 100644 --- a/photon-core/build.gradle +++ b/photon-core/build.gradle @@ -48,3 +48,55 @@ task writeCurrentVersion { build.dependsOn writeCurrentVersion apply from: "${rootDir}/shared/javacpp/setupBuild.gradle" + +apply plugin: 'edu.wpi.first.GradleJni' +model { + components { + "${nativeName}JNI"(JniNativeLibrarySpec) { + baseName = nativeName + 'jni' + + enableCheckTask !project.hasProperty('skipJniCheck') + javaCompileTasks << compileJava + jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.roborio) + jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.linuxarm32) + jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.linuxarm64) + + sources { + cpp { + source { + srcDirs 'src/main/native/cpp' + if (project.hasProperty('generatedSources')) { + srcDir generatedSources + } + include '**/jni/**/*.cpp' + } + exportedHeaders { + srcDir 'src/main/native/include' + if (project.hasProperty('generatedHeaders')) { + srcDir generatedHeaders + } + include '**/*.h' + } + } + } + + binaries.all { + if (it instanceof StaticLibraryBinarySpec) { + it.buildable = false + return + } + lib library: "${nativeName}", linkage: 'shared' + if (!project.hasProperty('noWpiutil')) { + lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' + } + if (project.hasProperty('jniSplitSetup')) { + jniSplitSetup(it) + } + } + + if(project.hasProperty("jni_native_libs")) jni_native_libs.each { name -> + nativeUtils.useRequiredLibrary(it, name) + } + } + } +}