Adding ability to compile for Raspberry Pi. #45

This commit is contained in:
Rob Greene 2020-10-07 16:13:13 -05:00
parent 33492f949f
commit 3cf8c4a9b5
4 changed files with 67 additions and 5 deletions

View File

@ -13,7 +13,7 @@ $ ./gradlew test
## Building ## Building
``` ```
$ ./gradlew assemble $ ./gradlew clean assemble
BUILD SUCCESSFUL in 2s BUILD SUCCESSFUL in 2s
6 actionable tasks: 6 executed 6 actionable tasks: 6 executed
@ -44,3 +44,42 @@ To launch the GUI version of AppleCommander, use the following:
* Mac OS X: * Mac OS X:
`java -XstartOnFirstThread -jar build/libs/AppleCommander-macosx-VERSION.jar` `java -XstartOnFirstThread -jar build/libs/AppleCommander-macosx-VERSION.jar`
## Raspberry Pi Notes
Available versions found are: `3.8` and `4.6`. `4.6` failed with a JNI issue.
Retrieve libraries:
```
$ sudo apt install libswt-gtk-3-java libswt-gtk-3-jni
```
Combine into one JAR (`-j` drops the directories from `*.so` files in the zip file):
```
$ cp /usr/lib/java/swt-gtk-3.8.2.jar org.eclipse.swt.gtk.linux.arm-3.8.2.jar
$ zip -j org.eclipse.swt.gtk.linux.arm-3.8.2.jar /usr/lib/jni/libswt-*3836*.so
```
Preserve JAR file in `rpi-lib`! If the file name is incorrect, the build process will show the expected filename in the error message...
Error for 4.6:
```
** (SWT:12220): CRITICAL **: 15:12:55.506: JNI method ID pointer is NULL for method atkObject_get_role
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.webcodepro.applecommander.ui.AppleCommander.launchSwtAppleCommander(AppleCommander.java:103)
at com.webcodepro.applecommander.ui.AppleCommander.main(AppleCommander.java:57)
Caused by: java.lang.NoSuchMethodError: atkObject_get_role
at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:1581)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4470)
at com.webcodepro.applecommander.ui.swt.SwtAppleCommander.launch(SwtAppleCommander.java:93)
at com.webcodepro.applecommander.ui.swt.SwtAppleCommander.launch(SwtAppleCommander.java:79)
... 6 more
```

View File

@ -8,9 +8,13 @@ plugins {
repositories { repositories {
mavenCentral() mavenCentral()
maven { maven {
// SWT libraries // SWT libraries (historical, need a better site)
url "http://maven-eclipse.github.io/maven" url "http://maven-eclipse.github.io/maven"
} }
flatDir {
// SWT libraries (hand-generated SWT for Pi)
dirs "./rpi-lib"
}
} }
mainClassName = 'com.webcodepro.applecommander.ui.AppleCommander' mainClassName = 'com.webcodepro.applecommander.ui.AppleCommander'
@ -22,13 +26,18 @@ compileJava {
} }
test { test {
String osName = System.getProperty('os.name').toLowerCase().split()[0]
String osArch = System.getProperty('os.arch').toLowerCase().split()[0]
String swtDependency String swtDependency
switch (System.getProperty('os.name').toLowerCase().split()[0]) { switch (osName) {
case 'windows': case 'windows':
swtDependency = "org.eclipse.swt:org.eclipse.swt.win32.win32.x86_64:$swtVersion" swtDependency = "org.eclipse.swt:org.eclipse.swt.win32.win32.x86_64:$swtVersion"
break break
case 'linux': case 'linux':
swtDependency = "org.eclipse.swt:org.eclipse.swt.gtk.linux.x86_64:$swtVersion" swtDependency = "org.eclipse.swt:org.eclipse.swt.gtk.linux.x86_64:$swtVersion"
if (osArch == 'arm') {
swtDependency = "org.eclipse.swt:org.eclipse.swt.gtk.linux.arm:$piswtVersion"
}
break break
case 'mac': case 'mac':
swtDependency = "org.eclipse.swt:org.eclipse.swt.cocoa.macosx.x86_64:$swtVersion" swtDependency = "org.eclipse.swt:org.eclipse.swt.cocoa.macosx.x86_64:$swtVersion"
@ -116,7 +125,20 @@ task linuxJar(type: Jar) {
} }
doFirst { doFirst {
// Pick and include just the Linux JAR contents // Pick and include just the Linux JAR contents
from { configurations.runtime.collect { it.name.contains('.linux.') ? zipTree(it) : 'fake' } } from { configurations.runtime.collect { it.name.contains('.linux.x86_64-') ? zipTree(it) : 'fake' } }
}
}
task piJar(type: Jar) {
dependencies {
compile "org.eclipse.swt:org.eclipse.swt.gtk.linux.arm:$piswtVersion"
}
appendix 'linuxarm-gtk'
from(sourceSets.main.output) {
include 'com/webcodepro/**'
}
doFirst {
// Pick and include just the Linux JAR contents
from { configurations.runtime.collect { it.name.contains('.linux.arm-') ? zipTree(it) : 'fake' } }
} }
} }
task macosxJar(type: Jar) { task macosxJar(type: Jar) {
@ -162,7 +184,7 @@ javadoc {
artifacts { artifacts {
archives mavenJar, acJar archives mavenJar, acJar
archives linuxJar, macosxJar, windowsJar archives linuxJar, piJar, macosxJar, windowsJar
archives javadocJar, sourcesJar archives javadocJar, sourcesJar
} }

View File

@ -8,6 +8,7 @@ shkVersion=1.2.2
asVersion=1.2.1 asVersion=1.2.1
btVersion=0.3.1 btVersion=0.3.1
swtVersion=4.6.1 swtVersion=4.6.1
piswtVersion=3.8.2
junitVersion=4.12 junitVersion=4.12
antVersion=1.8.2 antVersion=1.8.2
commonsLang3Version=3.7 commonsLang3Version=3.7

Binary file not shown.