Add pi-only JAR createion (#362)

This commit is contained in:
Matt
2021-12-18 12:53:08 -05:00
committed by GitHub
parent 1522adaa0e
commit 8b079d9b20
8 changed files with 69 additions and 82 deletions

View File

@@ -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 }}

View File

@@ -14,6 +14,13 @@ If you are interested in contributing code or documentation to the project, plea
<img src="https://contrib.rocks/image?repo=PhotonVision/photonvision" />
</a>
## 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.

View File

@@ -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 {

View File

@@ -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"

View File

@@ -12,8 +12,6 @@ test {
useJUnitPlatform()
}
def jniPlatforms = ['linuxaarch64bionic', 'linuxraspbian', 'linuxx86-64', 'osxx86-64', 'windowsx86-64']
// Apply Java configuration
dependencies {
implementation project(":photon-targeting")

View File

@@ -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) {

23
scripts/generatePiImage.sh Executable file
View File

@@ -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

View File

@@ -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"