diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 79e236364..eff626d93 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -148,43 +148,6 @@ jobs: ./gradlew spotlessCheck - photon-release: - if: startsWith(github.ref, 'refs/tags/v') - needs: [photon-build-package] - runs-on: ubuntu-latest - steps: - - uses: actions/download-artifact@v2 - with: - name: jar - - - run: | - NEW_JAR=$(realpath $(find . -name photonvision\*.jar)) - sudo apt install unzip zip - curl -sk https://api.github.com/repos/photonvision/photon-pi-gen/releases/tags/v2021.1.4 | grep "browser_download_url.*zip" | cut -d : -f 2,3 | tr -d '"' | wget -qi - - FILE_NAME=$(ls | grep image_*.zip) - unzip $FILE_NAME - IMAGE_FILE=$(ls | grep *.img) - TMP=$(mktemp -d) - LOOP=$(sudo losetup --show -fP "${IMAGE_FILE}") - sudo mount ${LOOP}p2 $TMP - pushd . - cd $TMP/opt/photonvision - ls - sudo cp $NEW_JAR photonvision.jar - popd - sudo umount ${TMP} - sudo rmdir ${TMP} - rm $FILE_NAME - NEW_IMAGE=$(basename "${NEW_JAR/jar/img}") - mv $IMAGE_FILE $NEW_IMAGE - zip -r $(basename "${NEW_JAR/.jar/-image.zip}") $NEW_IMAGE - rm $NEW_IMAGE - - - uses: softprops/action-gh-release@v1 - with: - files: '**/*' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Building photonlib photonlib-build-host: @@ -316,35 +279,18 @@ jobs: name: built-docs path: photon-server/src/main/resources/web/docs - # Build fat jar. + # Build fat jar for both pi and everything - run: | chmod +x gradlew ./gradlew photon-server:shadowJar --max-workers 1 + ./gradlew photon-server:shadowJar --max-workers 1 -Ppionly + # The image will only pull the Pi JAR in - name: Generate image if: github.event_name != 'pull_request' run: | - NEW_JAR=$(realpath $(find . -name photonvision\*.jar)) - sudo apt install unzip zip - curl -sk https://api.github.com/repos/photonvision/photon-pi-gen/releases/tags/v2021.1.4 | grep "browser_download_url.*zip" | cut -d : -f 2,3 | tr -d '"' | wget -qi - - FILE_NAME=$(ls | grep image_*.zip) - unzip $FILE_NAME - IMAGE_FILE=$(ls | grep *.img) - TMP=$(mktemp -d) - LOOP=$(sudo losetup --show -fP "${IMAGE_FILE}") - sudo mount ${LOOP}p2 $TMP - pushd . - cd $TMP/opt/photonvision - ls - sudo cp $NEW_JAR photonvision.jar - popd - sudo umount ${TMP} - sudo rmdir ${TMP} - rm $FILE_NAME - NEW_IMAGE=$(basename "${NEW_JAR/jar/img}") - mv $IMAGE_FILE $NEW_IMAGE - zip -r $(basename "${NEW_JAR/.jar/-image.zip}") $NEW_IMAGE - rm $NEW_IMAGE + chmod +x scripts/generatePiImage.sh + ./scripts/generatePiImage.sh # Upload final fat jar as artifact. - uses: actions/upload-artifact@master @@ -365,3 +311,24 @@ jobs: photon-server/build/libs/*.jar photonvision*.zip if: github.event_name == 'push' + + photon-release: + if: startsWith(github.ref, 'refs/tags/v') + needs: [photon-build-package] + runs-on: ubuntu-latest + steps: + # This *should* pull in fat and pi-only jars + - uses: actions/download-artifact@v2 + with: + name: jar + + - run: | + chmod +x scripts/generatePiImage.sh + ./scripts/generatePiImage.sh + + # All we've downloaded (ideally) is the fat jar, pi jar, and image. So just upload it all + - uses: softprops/action-gh-release@v1 + with: + files: '**/*' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 7bfedc17e..7f8cd6787 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,13 @@ If you are interested in contributing code or documentation to the project, plea +## Gradle Arguments + +Note that these are case sensitive! + +* `-Ppionly`: only builds for `linuxraspbian`, which reduces JAR size. The JAR name will have "-raspi" appended. +- `-PtgtIp`: deploys (builds and copies the JAR) to the coprocessor at the specified IP +- `-Pprofile`: enables JVM profiling ## Acknowledgments PhotonVision was forked from [Chameleon Vision](https://github.com/Chameleon-Vision/chameleon-vision/). Thank you to everyone who worked on the original project. diff --git a/build.gradle b/build.gradle index 625eeb173..37201985c 100644 --- a/build.gradle +++ b/build.gradle @@ -27,6 +27,12 @@ ext { joglVersion = "2.4.0-rc-20200307" pubVersion = versionString isDev = pubVersion.startsWith("dev") + + + jniPlatforms = project.hasProperty('pionly') ? ['linuxraspbian'] + : ['linuxaarch64bionic', 'linuxraspbian', 'linuxx86-64', 'osxx86-64', 'windowsx86-64'] + + println("Building for archs " + jniPlatforms) } spotless { diff --git a/photon-core/build.gradle b/photon-core/build.gradle index 1e6550b1b..7f43dbdc0 100644 --- a/photon-core/build.gradle +++ b/photon-core/build.gradle @@ -11,11 +11,7 @@ dependencies { implementation 'org.msgpack:jackson-dataformat-msgpack:0.8.20' // wpiutil - implementation "edu.wpi.first.wpiutil:wpiutil-jni:$wpilibVersion:linuxaarch64bionic" - implementation "edu.wpi.first.wpiutil:wpiutil-jni:$wpilibVersion:linuxraspbian" - implementation "edu.wpi.first.wpiutil:wpiutil-jni:$wpilibVersion:linuxx86-64" - implementation "edu.wpi.first.wpiutil:wpiutil-jni:$wpilibVersion:osxx86-64" - implementation "edu.wpi.first.wpiutil:wpiutil-jni:$wpilibVersion:windowsx86-64" + jniPlatforms.each { implementation "edu.wpi.first.wpiutil:wpiutil-jni:$wpilibVersion:$it" } // JOGL stuff (currently we only distribute for aarch64, which is Pi 4) implementation "org.jogamp.gluegen:gluegen-rt:$joglVersion" diff --git a/photon-lib/build.gradle b/photon-lib/build.gradle index 8bd671ce6..0e52fc039 100644 --- a/photon-lib/build.gradle +++ b/photon-lib/build.gradle @@ -12,8 +12,6 @@ test { useJUnitPlatform() } -def jniPlatforms = ['linuxaarch64bionic', 'linuxraspbian', 'linuxx86-64', 'osxx86-64', 'windowsx86-64'] - // Apply Java configuration dependencies { implementation project(":photon-targeting") diff --git a/photon-server/build.gradle b/photon-server/build.gradle index 08dbd4f24..2570ecad3 100644 --- a/photon-server/build.gradle +++ b/photon-server/build.gradle @@ -24,7 +24,9 @@ dependencies { shadowJar { configurations = [project.configurations.runtimeClasspath] - archiveFileName.set("photonvision-${project.version}.jar") + String name = "photonvision-${project.version}" + if(project.hasProperty('pionly')) name += "-raspi" + archiveFileName.set("${name}.jar") } task runNpmOnClient(type: Exec) { diff --git a/scripts/generatePiImage.sh b/scripts/generatePiImage.sh new file mode 100755 index 000000000..9ee2ddea3 --- /dev/null +++ b/scripts/generatePiImage.sh @@ -0,0 +1,23 @@ +# We need to look for a JAR with the "-raspi" suffix so we don't accidentally bundle the big jar +# Not that it really matters, but it'll save us 50 megs or so +NEW_JAR=$(realpath $(find . -name photonvision\*-raspi.jar)) +sudo apt install unzip zip +curl -sk https://api.github.com/repos/photonvision/photon-pi-gen/releases/tags/v2021.1.4 | grep "browser_download_url.*zip" | cut -d : -f 2,3 | tr -d '"' | wget -qi - +FILE_NAME=$(ls | grep image_*.zip) +unzip $FILE_NAME +IMAGE_FILE=$(ls | grep *.img) +TMP=$(mktemp -d) +LOOP=$(sudo losetup --show -fP "${IMAGE_FILE}") +sudo mount ${LOOP}p2 $TMP +pushd . +cd $TMP/opt/photonvision +ls +sudo cp $NEW_JAR photonvision.jar +popd +sudo umount ${TMP} +sudo rmdir ${TMP} +rm $FILE_NAME +NEW_IMAGE=$(basename "${NEW_JAR/jar/img}") +mv $IMAGE_FILE $NEW_IMAGE +zip -r $(basename "${NEW_JAR/.jar/-image.zip}") $NEW_IMAGE +rm $NEW_IMAGE diff --git a/shared/common.gradle b/shared/common.gradle index 09a5dfeb1..fbfe5e4a9 100644 --- a/shared/common.gradle +++ b/shared/common.gradle @@ -26,25 +26,13 @@ dependencies { implementation "edu.wpi.first.cameraserver:cameraserver-java:$wpilibVersion" implementation "edu.wpi.first.cscore:cscore-java:$wpilibVersion" - implementation "edu.wpi.first.cscore:cscore-jni:$wpilibVersion:linuxaarch64bionic" - implementation "edu.wpi.first.cscore:cscore-jni:$wpilibVersion:linuxraspbian" - implementation "edu.wpi.first.cscore:cscore-jni:$wpilibVersion:linuxx86-64" - implementation "edu.wpi.first.cscore:cscore-jni:$wpilibVersion:osxx86-64" - implementation "edu.wpi.first.cscore:cscore-jni:$wpilibVersion:windowsx86-64" + jniPlatforms.each { implementation "edu.wpi.first.cscore:cscore-jni:$wpilibVersion:$it" } implementation "edu.wpi.first.ntcore:ntcore-java:$wpilibVersion" - implementation "edu.wpi.first.ntcore:ntcore-jni:$wpilibVersion:linuxaarch64bionic" - implementation "edu.wpi.first.ntcore:ntcore-jni:$wpilibVersion:linuxraspbian" - implementation "edu.wpi.first.ntcore:ntcore-jni:$wpilibVersion:linuxx86-64" - implementation "edu.wpi.first.ntcore:ntcore-jni:$wpilibVersion:osxx86-64" - implementation "edu.wpi.first.ntcore:ntcore-jni:$wpilibVersion:windowsx86-64" + jniPlatforms.each { implementation "edu.wpi.first.ntcore:ntcore-jni:$wpilibVersion:$it" } implementation "edu.wpi.first.thirdparty.frc2022.opencv:opencv-java:$opencvVersion" - implementation "edu.wpi.first.thirdparty.frc2022.opencv:opencv-jni:$opencvVersion:linuxaarch64bionic" - implementation "edu.wpi.first.thirdparty.frc2022.opencv:opencv-jni:$opencvVersion:linuxraspbian" - implementation "edu.wpi.first.thirdparty.frc2022.opencv:opencv-jni:$opencvVersion:linuxx86-64" - implementation "edu.wpi.first.thirdparty.frc2022.opencv:opencv-jni:$opencvVersion:osxx86-64" - implementation "edu.wpi.first.thirdparty.frc2022.opencv:opencv-jni:$opencvVersion:windowsx86-64" + jniPlatforms.each { implementation "edu.wpi.first.thirdparty.frc2022.opencv:opencv-jni:$opencvVersion:$it" } implementation "edu.wpi.first.wpimath:wpimath-java:2022.1.1-beta-2" implementation "org.ejml:ejml-simple:0.41"