Skip to content

Commit ea0e9e4

Browse files
authored
Add aarch64 linux build (#2785)
1 parent dff663b commit ea0e9e4

File tree

14 files changed

+267
-36
lines changed

14 files changed

+267
-36
lines changed

.github/workflows/nightly.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,41 @@ jobs:
8181
tag_name: "nightly"
8282
overwrite: true
8383

84+
build-linux-aarch64:
85+
if: github.repository_owner == 'winder'
86+
needs: build-and-test
87+
runs-on: ubuntu-24.04
88+
89+
steps:
90+
- uses: actions/checkout@v3
91+
- name: Set up JDK
92+
uses: actions/setup-java@v3
93+
with:
94+
java-version: '17'
95+
distribution: 'temurin'
96+
97+
- name: Cache the Maven packages to speed up build
98+
uses: actions/cache@v3
99+
with:
100+
path: ~/.m2
101+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
102+
restore-keys: ${{ runner.os }}-m2
103+
104+
- name: Build
105+
run: mvn clean install -DskipTests
106+
107+
- name: Package Linux
108+
run: mvn package -pl ugs-fx -P fx-build-linux-aarch64
109+
110+
- name: Upload DEB binaries to snapshot release
111+
uses: xresloader/upload-to-github-release@v1
112+
env:
113+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
with:
115+
file: "ugs-fx/target/installer/ugs-*.deb;ugs-fx/target/installer/ugs-*.rpm"
116+
prerelease: true
117+
tag_name: "nightly"
118+
overwrite: true
84119

85120
build-macosx-x64:
86121
if: github.repository_owner == 'winder'

ugs-fx/build-linux-aarch64.sh

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
#!/bin/bash
2+
3+
# ------ ENVIRONMENT --------------------------------------------------------
4+
# The script depends on various environment variables to exist in order to
5+
# run properly. The java version we want to use, the location of the java
6+
# binaries (java home), and the project version as defined inside the pom.xml
7+
# file, e.g. 1.0-SNAPSHOT.
8+
#
9+
# PROJECT_VERSION: version used in pom.xml, e.g. 1.0-SNAPSHOT
10+
# APP_VERSION: the application version, e.g. 1.0.0, shown in "about" dialog
11+
12+
if [ -z ${PROJECT_VERSION} ]; then echo "Missing PROJECT_VERSION"; exit 1; fi
13+
if [ -z ${APP_VERSION} ]; then echo "Missing APP_VERSION"; exit 1; fi
14+
15+
# Download JVM
16+
JVM=zulu21.42.19-ca-fx-jdk21.0.7-linux_aarch64
17+
set -e
18+
ZIP=$JVM.tar.gz
19+
export JAVA_HOME=.jdks/$JVM
20+
if test -d $JAVA_HOME/$JVM/; then
21+
echo "Using existing JDK from $JAVA_HOME"
22+
else
23+
rm -rf $JAVA_HOME
24+
mkdir -p $JAVA_HOME
25+
curl -o $ZIP https://cdn.azul.com/zulu/bin/$ZIP
26+
tar -xvzf $ZIP -C $JAVA_HOME
27+
mv $JAVA_HOME/$JVM/* $JAVA_HOME/
28+
fi
29+
30+
JAVA_VERSION=17
31+
MAIN_JAR="ugs-fx-$PROJECT_VERSION.jar"
32+
33+
echo "Java home: $JAVA_HOME"
34+
echo "Project version: $PROJECT_VERSION"
35+
echo "App version: $APP_VERSION"
36+
echo "Main JAR file: $MAIN_JAR"
37+
38+
# ------ SETUP DIRECTORIES AND FILES ----------------------------------------
39+
# Remove previously generated java runtime and installers. Copy all required
40+
# jar files into the input/libs folder.
41+
42+
rm -rfd ./target/java-runtime/
43+
rm -rfd target/installer/
44+
45+
mkdir -p target/installer/input/libs/
46+
cp target/libs/* target/installer/input/libs/
47+
cp target/${MAIN_JAR} target/installer/input/libs/
48+
cp installer/ugs.svg target/installer/input/libs/
49+
50+
# ------ REQUIRED MODULES ---------------------------------------------------
51+
# Use jlink to detect all modules that are required to run the application.
52+
# Starting point for the jdep analysis is the set of jars being used by the
53+
# application.
54+
55+
echo "Detecting required modules"
56+
detected_modules=`$JAVA_HOME/bin/jdeps \
57+
-q \
58+
--multi-release ${JAVA_VERSION} \
59+
--ignore-missing-deps \
60+
--print-module-deps \
61+
--class-path "target/installer/input/libs/*" \
62+
target/classes/com/willwinder/universalgcodesender/fx/Main.class`
63+
64+
# ------ MANUAL MODULES -----------------------------------------------------
65+
# jdk.crypto.ec has to be added manually bound via --bind-services or
66+
# otherwise HTTPS does not work.
67+
#
68+
# See: https://bugs.openjdk.java.net/browse/JDK-8221674
69+
#
70+
# In addition we need jdk.localedata if the application is localized.
71+
# This can be reduced to the actually needed locales via a jlink parameter,
72+
# e.g., --include-locales=en,de.
73+
#
74+
# Don't forget the leading ','!
75+
76+
extra_modules=,jdk.crypto.ec,jdk.localedata,jdk.dynalink,jdk.zipfs
77+
echo "Using modules: ${detected_modules}${extra_modules}"
78+
79+
# ------ RUNTIME IMAGE ------------------------------------------------------
80+
# Use the jlink tool to create a runtime image for our application. We are
81+
# doing this in a separate step instead of letting jlink do the work as part
82+
# of the jpackage tool. This approach allows for finer configuration and also
83+
# works with dependencies that are not fully modularized, yet.
84+
85+
echo "Creating Java runtime image"
86+
$JAVA_HOME/bin/jlink \
87+
--strip-native-commands \
88+
--no-header-files \
89+
--no-man-pages \
90+
--strip-debug \
91+
--add-modules "${detected_modules}${extra_modules}" \
92+
--include-locales=en,de \
93+
--output target/java-runtime
94+
95+
# ------ PACKAGING ----------------------------------------------------------
96+
# In the end we will find the package inside the target/installer directory.
97+
98+
$JAVA_HOME/bin/jpackage \
99+
--type deb \
100+
--dest target/installer \
101+
--input target/installer/input/libs \
102+
--name ugs \
103+
--linux-deb-maintainer "[email protected]" \
104+
--main-class com.willwinder.universalgcodesender.fx.Main \
105+
--main-jar ${MAIN_JAR} \
106+
--resource-dir installer \
107+
--java-options "-XX:MaxRAMPercentage=85.0 -Dprism.forceGPU=true" \
108+
--runtime-image target/java-runtime \
109+
--app-version ${APP_VERSION} \
110+
--copyright "Joacim Breiler" \
111+
--license-file ../COPYING \
112+
--about-url https://universalgcodesender.com/
113+
114+
mv target/installer/ugs_*.deb "target/installer/ugs-${APP_VERSION}-aarch64.deb"
115+
116+
117+
$JAVA_HOME/bin/jpackage \
118+
--type rpm \
119+
--dest target/installer \
120+
--input target/installer/input/libs \
121+
--name ugs \
122+
--linux-deb-maintainer "[email protected]" \
123+
--main-class com.willwinder.universalgcodesender.fx.Main \
124+
--main-jar ${MAIN_JAR} \
125+
--resource-dir installer \
126+
--java-options "-XX:MaxRAMPercentage=85.0 -Dprism.forceGPU=true" \
127+
--runtime-image target/java-runtime \
128+
--app-version ${APP_VERSION} \
129+
--vendor "Universal G-code Sender" \
130+
--copyright "Joacim Breiler" \
131+
--license-file ../COPYING \
132+
--about-url https://universalgcodesender.com/
133+
134+
mv target/installer/ugs-*.rpm "target/installer/ugs-${APP_VERSION}-aarch64.rpm"

ugs-fx/build-macosx-aarch64.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ $JAVA_HOME/bin/jlink \
8787
--strip-native-commands \
8888
--no-header-files \
8989
--no-man-pages \
90-
--compress=2 \
9190
--strip-debug \
9291
--add-modules "${detected_modules}${extra_modules}" \
9392
--include-locales=en,de \

ugs-fx/build-macosx-x64.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ $JAVA_HOME/bin/jlink \
8787
--strip-native-commands \
8888
--no-header-files \
8989
--no-man-pages \
90-
--compress=2 \
9190
--strip-debug \
9291
--add-modules "${detected_modules}${extra_modules}" \
9392
--include-locales=en,de \

ugs-fx/build-windows-x64.bat

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ echo Creating Java runtime image...
6262
--strip-native-commands ^
6363
--no-header-files ^
6464
--no-man-pages ^
65-
--compress=2 ^
6665
--strip-debug ^
6766
--add-modules "%detected_modules%%extra_modules%" ^
6867
--include-locales=en,de ^

ugs-fx/pom.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,43 @@
182182
</build>
183183
</profile>
184184

185+
<profile>
186+
<id>fx-build-linux-aarch64</id>
187+
<activation>
188+
<activeByDefault>false</activeByDefault>
189+
</activation>
190+
<build>
191+
<plugins>
192+
<plugin>
193+
<artifactId>exec-maven-plugin</artifactId>
194+
<groupId>org.codehaus.mojo</groupId>
195+
<version>${exec.maven.plugin.version}</version>
196+
<executions>
197+
<execution>
198+
<id>Build Native aarch64 App</id>
199+
<phase>package</phase>
200+
<goals>
201+
<goal>exec</goal>
202+
</goals>
203+
</execution>
204+
</executions>
205+
<configuration>
206+
<workingDirectory>${project.basedir}</workingDirectory>
207+
<executable>./build-linux-aarch64.sh</executable>
208+
<environmentVariables>
209+
<APP_VERSION>
210+
${revision}
211+
</APP_VERSION>
212+
<PROJECT_VERSION>
213+
${project.version}
214+
</PROJECT_VERSION>
215+
</environmentVariables>
216+
</configuration>
217+
</plugin>
218+
</plugins>
219+
</build>
220+
</profile>
221+
185222
<profile>
186223
<id>fx-build-macosx-aarch64</id>
187224
<activation>

ugs-fx/src/main/java/com/willwinder/universalgcodesender/fx/component/visualizer/OrientationCube.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ private Box createFace(double size, OrientationCubeFace faceEnum, double transla
5353
face.setOnMouseClicked(event -> onFaceClicked.accept(faceEnum));
5454
PhongMaterial material = new PhongMaterial();
5555
material.setDiffuseMap(createLabeledFace(faceEnum.name(), Colors.BLACKISH));
56+
material.setSpecularColor(Color.BLACK);
57+
material.setSpecularPower(1);
5658
face.setMaterial(material);
5759
return face;
5860
}
@@ -117,4 +119,4 @@ private WritableImage createLabeledFace(String label, Color background) {
117119
public void setRotations(Rotate rotateX, Rotate rotateY, Rotate rotateZ) {
118120
cubeRoot.getTransforms().addAll(rotateX, rotateY, rotateZ);
119121
}
120-
}
122+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.willwinder.universalgcodesender.fx.component.visualizer.machine.common;
2+
3+
import eu.mihosoft.vrl.v3d.CSG;
4+
import eu.mihosoft.vrl.v3d.STL;
5+
6+
import java.io.FileNotFoundException;
7+
import java.io.IOException;
8+
import java.io.InputStream;
9+
import java.net.URISyntaxException;
10+
import java.nio.file.Files;
11+
import java.nio.file.Path;
12+
import java.nio.file.StandardCopyOption;
13+
14+
public class STLModel {
15+
/**
16+
* Reads an STL file from the class path
17+
*
18+
* @param resource the resource to read
19+
* @return a CSG with the read STL
20+
* @throws IOException if the resource couldn't be read
21+
* @throws URISyntaxException if the URI to the resource was wrong
22+
*/
23+
public static CSG readSTL(String resource) throws IOException, URISyntaxException {
24+
25+
// This is a workaround for reading STL:s from class path since the Path.of doesn't
26+
// handle jdk.zipfs very well
27+
try (InputStream in = STLModel.class.getResourceAsStream(resource)) {
28+
if (in == null) {
29+
throw new FileNotFoundException("Resource not found: " + resource);
30+
}
31+
32+
Path tempFile = Files.createTempFile("temp", "stl");
33+
Files.copy(in, tempFile, StandardCopyOption.REPLACE_EXISTING);
34+
tempFile.toFile().deleteOnExit();
35+
return STL.file(Path.of(tempFile.toUri()));
36+
}
37+
}
38+
}

ugs-fx/src/main/java/com/willwinder/universalgcodesender/fx/component/visualizer/machine/longmill/parts/MGN12Block.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
package com.willwinder.universalgcodesender.fx.component.visualizer.machine.longmill.parts;
22

33
import static com.willwinder.universalgcodesender.fx.component.visualizer.machine.Colors.COLOR_STEEL;
4-
import com.willwinder.universalgcodesender.fx.component.visualizer.machine.longmill.LongMillModel;
4+
5+
import com.willwinder.universalgcodesender.fx.component.visualizer.machine.common.STLModel;
56
import eu.mihosoft.vrl.v3d.CSG;
6-
import eu.mihosoft.vrl.v3d.STL;
77
import javafx.scene.Group;
88
import javafx.scene.paint.Color;
99
import javafx.scene.paint.PhongMaterial;
1010
import javafx.scene.shape.MeshView;
1111

1212
import java.io.IOException;
1313
import java.net.URISyntaxException;
14-
import java.nio.file.Path;
15-
import java.util.Objects;
1614
import java.util.logging.Level;
1715
import java.util.logging.Logger;
1816

@@ -21,7 +19,7 @@ public class MGN12Block extends Group {
2119

2220
public MGN12Block() {
2321
try {
24-
CSG csg = STL.file(Path.of(Objects.requireNonNull(LongMillModel.class.getResource("/model/longmill/mgn12-block.stl")).toURI()))
22+
CSG csg = STLModel.readSTL("/model/longmill/mgn12-block.stl")
2523
.scale(1000);
2624
PhongMaterial material = new PhongMaterial();
2725
material.setDiffuseColor(COLOR_STEEL);

ugs-fx/src/main/java/com/willwinder/universalgcodesender/fx/component/visualizer/machine/longmill/parts/VWheel.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.willwinder.universalgcodesender.fx.component.visualizer.machine.longmill.parts;
22

33
import static com.willwinder.universalgcodesender.fx.component.visualizer.machine.Colors.COLOR_DARK_GREY;
4-
import com.willwinder.universalgcodesender.fx.component.visualizer.machine.longmill.LongMillModel;
4+
5+
import com.willwinder.universalgcodesender.fx.component.visualizer.machine.common.STLModel;
56
import eu.mihosoft.vrl.v3d.CSG;
6-
import eu.mihosoft.vrl.v3d.STL;
77
import javafx.scene.Group;
88
import javafx.scene.paint.Color;
99
import javafx.scene.paint.PhongMaterial;
@@ -14,8 +14,6 @@
1414

1515
import java.io.IOException;
1616
import java.net.URISyntaxException;
17-
import java.nio.file.Path;
18-
import java.util.Objects;
1917
import java.util.logging.Level;
2018
import java.util.logging.Logger;
2119

@@ -24,7 +22,7 @@ public class VWheel extends Group {
2422

2523
public VWheel() {
2624
try {
27-
CSG csg = STL.file(Path.of(Objects.requireNonNull(LongMillModel.class.getResource("/model/longmill/vwheel.stl")).toURI()))
25+
CSG csg = STLModel.readSTL("/model/longmill/vwheel.stl")
2826
.scale(1000);
2927
PhongMaterial material = new PhongMaterial();
3028
material.setDiffuseColor(COLOR_DARK_GREY);
@@ -36,15 +34,15 @@ public VWheel() {
3634
getChildren().add(meshView);
3735

3836
Cylinder cylinder = new Cylinder(7, 10);
37+
cylinder.setMaterial(material);
3938
cylinder.getTransforms().add(new Rotate(90, Rotate.Z_AXIS));
4039
getChildren().add(cylinder);
4140

4241
Cylinder bolt = new Cylinder(3, 10);
42+
bolt.setMaterial(material);
4343
bolt.getTransforms().add(new Rotate(90, Rotate.Z_AXIS));
4444
bolt.getTransforms().add(new Translate(0, -10, 0));
4545
getChildren().add(bolt);
46-
47-
4846
} catch (IOException | URISyntaxException | NullPointerException e) {
4947
LOGGER.log(Level.INFO, "Could not load model", e);
5048
}

0 commit comments

Comments
 (0)