diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a6de08e..6b7395a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,10 +8,6 @@ on: pull_request: branches: [ "main" ] -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release - jobs: build-host: strategy: @@ -20,9 +16,15 @@ jobs: include: - os: ubuntu-22.04 arch-name: linuxx86-64 + BUILD_TYPE: Release + publish-type: "" + - os: ubuntu-22.04 + arch-name: linuxx86-64 + BUILD_TYPE: Debug + publish-type: "debug" runs-on: ${{ matrix.os }} - name: "mrcal-jni - Build - ${{ matrix.arch-name }}" + name: "mrcal-jni - Build - ${{ matrix.arch-name }}/${{matrix.publish-type}}" steps: - uses: actions/checkout@v3 @@ -52,17 +54,17 @@ jobs: - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/cmake_build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DOPENCV_ARCH=${{ matrix.arch-name }} + run: cmake -B ${{github.workspace}}/cmake_build -DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} -DOPENCV_ARCH=${{ matrix.arch-name }} - name: Build shared mrcal_jni # Build your program with the given configuration - run: cmake --build ${{github.workspace}}/cmake_build --config ${{env.BUILD_TYPE}} ${{ (startsWith(matrix.arch-name, 'windowx86-64') && '--config Release') || '' }} -j --target mrcal_jni + run: cmake --build ${{github.workspace}}/cmake_build --config ${{matrix.BUILD_TYPE}} ${{ (startsWith(matrix.arch-name, 'windowx86-64') && '--config Release') || '' }} -j --target mrcal_jni - name: Gradle build # Build your program with the given configuration run: ./gradlew build - - run: ./gradlew publish + - run: ./gradlew publish -PPublishType=${{ matrix.publish-type }} name: Publish env: ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }} @@ -70,12 +72,24 @@ jobs: - uses: actions/upload-artifact@master with: - name: libmrcal-jar-${{ matrix.arch-name }} + name: libmrcal-jar-${{ matrix.arch-name }}-${{matrix.BUILD_TYPE}} path: | ${{ github.workspace }}/build/libs/*.jar build-raspi: runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - BUILD_TYPE: Release + publish-type: "" + - BUILD_TYPE: Debug + publish-type: "debug" + + name: "mrcal-jni - Build - ${{ matrix.BUILD_TYPE }}/${{ matrix.publish-type }}" + steps: - uses: actions/checkout@v3 @@ -95,27 +109,34 @@ jobs: sudo bash -c "echo 'deb [trusted=yes] http://mrcal.secretsauce.net/packages/jammy/public/ jammy main' >> /etc/apt/sources.list" sudo apt update sudo apt install cmake default-jdk default-jre git gcc g++ libmrcal-dev mrbuild libsuitesparse-dev liblist-moreutils-perl -y - cmake -B cmake_build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DOPENCV_ARCH=linuxarm64 - cmake --build cmake_build --config ${{env.BUILD_TYPE}} -j --target mrcal_jni + cmake -B cmake_build -DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} -DOPENCV_ARCH=linuxarm64 + cmake --build cmake_build --config ${{matrix.BUILD_TYPE}} -j --target mrcal_jni - run: | - ./gradlew build ${{ (startsWith(github.event_name, 'push') && 'publish') || '' }} -PArchOverride=linuxarm64 + ./gradlew build ${{ (startsWith(github.event_name, 'push') && 'publish') || '' }} -PArchOverride=linuxarm64 -PPublishType=${{ matrix.publish-type }} env: ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }} - uses: actions/upload-artifact@v3 name: Upload jar with: - name: libmrcal-jar-pi + name: libmrcal-jar-pi-${{matrix.BUILD_TYPE}} path: ${{ github.workspace }}/build/libs/*.jar build-windows: - runs-on: windows-latest - name: "mrcal-jni - Build - Windows" + strategy: + fail-fast: false + matrix: + include: + - BUILD_TYPE: Release + publish-type: "" + - BUILD_TYPE: Debug + publish-type: "debug" + + name: "mrcal-jni - Build Windows - ${{ matrix.BUILD_TYPE }}/${{matrix.publish-type}}" - env: - BUILD_TYPE: "Release" + runs-on: windows-latest steps: - uses: actions/checkout@v3 @@ -144,17 +165,17 @@ jobs: runVcpkgInstall: true - name: Configure CMake - run: cmake -B ${{github.workspace}}/cmake_build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DOPENCV_ARCH=windowsx86-64 -T ClangCl -A x64 -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE="vcpkg/scripts/buildsystems/vcpkg.cmake" + run: cmake -B ${{github.workspace}}/cmake_build -DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} -DOPENCV_ARCH=windowsx86-64 -T ClangCl -A x64 -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE="vcpkg/scripts/buildsystems/vcpkg.cmake" - name: Build shared mrcal_jni # Build your program with the given configuration - run: cmake --build ${{github.workspace}}/cmake_build --config ${{env.BUILD_TYPE}} -j --target mrcal_jni + run: cmake --build ${{github.workspace}}/cmake_build --config ${{matrix.BUILD_TYPE}} -j --target mrcal_jni - name: Gradle build # Build your program with the given configuration run: ./gradlew build - - run: ./gradlew publish + - run: ./gradlew publish -PPublishType=${{ matrix.publish-type }} name: Publish env: ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }} @@ -162,7 +183,7 @@ jobs: - uses: actions/upload-artifact@master with: - name: libmrcal-jar-windowsx64 + name: libmrcal-jar-windowsx64-${{matrix.BUILD_TYPE}} path: ${{ github.workspace }}/build/libs/*.jar release: diff --git a/publish.gradle b/publish.gradle index 94042f0..0d84487 100644 --- a/publish.gradle +++ b/publish.gradle @@ -4,8 +4,11 @@ def nativeName = wpilibTools.platformMapper.currentPlatform.platformName; def artifactGroupId = 'org.photonvision' def baseArtifactId = "photon-mrcal" +def jniType = project.findProperty("PublishType") ?: ""; +println("Building with JNI publish type: " + jniType); + task nativeLibraryJar(type: Jar, dependsOn: copyNativeLibrary) { - archiveClassifier = nativeName + archiveClassifier = nativeName + jniType from outputsFolder } build.dependsOn nativeLibraryJar