Skip to content

Commit

Permalink
macOS: Improve compatibility with JDK builds
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelbl committed Jan 3, 2024
1 parent d7b1da8 commit 149c69d
Show file tree
Hide file tree
Showing 19 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ If you are using Maven, add the below dependency to your pom.xml:
<dependency>
<groupId>net.codecrete.usb</groupId>
<artifactId>java-does-usb</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>
</dependency>
```

If you are using Gradle, add the below dependency to your build.gradle file:

```groovy
compile group: 'net.codecrete.usb', name: 'java-does-usb', version: '0.7.0'
compile group: 'net.codecrete.usb', name: 'java-does-usb', version: '0.7.1'
```

```java
Expand Down
2 changes: 1 addition & 1 deletion examples/bulk_transfer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ $ mvn compile exec:exec
[INFO] Scanning for projects...
[INFO]
[INFO] --------------< net.codecrete.usb.examples:bulk-transfer >--------------
[INFO] Building bulk-transfer 0.7.0
[INFO] Building bulk-transfer 0.7.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ bulk-transfer ---
Expand Down
4 changes: 2 additions & 2 deletions examples/bulk_transfer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.codecrete.usb.examples</groupId>
<artifactId>bulk-transfer</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>

<name>bulk-transfer</name>
<url>https://github.com/manuelbl/JavaDoesUSB/examples/bulk_transfer</url>
Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>net.codecrete.usb</groupId>
<artifactId>java-does-usb</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion examples/enumerate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $ mvn compile exec:exec
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< net.codecrete.usb.examples:enumerate >----------------
[INFO] Building enumerate 0.7.0
[INFO] Building enumerate 0.7.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ enumerate ---
Expand Down
4 changes: 2 additions & 2 deletions examples/enumerate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.codecrete.usb.examples</groupId>
<artifactId>enumerate</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>

<name>enumerate</name>
<url>https://github.com/manuelbl/JavaDoesUSB/examples/enumerate</url>
Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>net.codecrete.usb</groupId>
<artifactId>java-does-usb</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>
</dependency>
<dependency>
<groupId>org.tinylog</groupId>
Expand Down
2 changes: 1 addition & 1 deletion examples/enumerate_kotlin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ $ mvn clean package
### Run the jar

```shell
$ java --enable-preview --enable-native-access=ALL-UNNAMED -jar target/enumerate-0.7.0-jar-with-dependencies.jar
$ java --enable-preview --enable-native-access=ALL-UNNAMED -jar target/enumerate-0.7.1-jar-with-dependencies.jar
Device:
VID: 0xcafe
PID: 0xceaf
Expand Down
4 changes: 2 additions & 2 deletions examples/enumerate_kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>net.codecrete.usb.examples</groupId>
<artifactId>enumerate</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>
<packaging>jar</packaging>

<name>enumerate</name>
Expand Down Expand Up @@ -64,7 +64,7 @@
<dependency>
<groupId>net.codecrete.usb</groupId>
<artifactId>java-does-usb</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>
</dependency>
<dependency>
<groupId>org.tinylog</groupId>
Expand Down
4 changes: 2 additions & 2 deletions examples/epaper_display/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ $ mvn compile exec:exec
[INFO] Scanning for projects...
[INFO]
[INFO] -------------< net.codecrete.usb.examples:epaper-display >--------------
[INFO] Building epaper-display 0.7.0
[INFO] Building epaper-display 0.7.1
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
Expand Down Expand Up @@ -81,6 +81,6 @@ $ sudo -i
Password:
$ cd /Users/me/Documents/JavaDoesUSB/examples/epaper_display
$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-20.jdk/Contents/Home
$ $JAVA_HOME/bin/java --enable-preview --enable-native-access=ALL-UNNAMED -cp target/classes:/Users/me/.m2/repository/net/codecrete/usb/java-does-usb/0.7.0/java-does-usb-0.7.0.jar net.codecrete.usb.examples.EPaperDisplay
$ $JAVA_HOME/bin/java --enable-preview --enable-native-access=ALL-UNNAMED -cp target/classes:/Users/me/.m2/repository/net/codecrete/usb/java-does-usb/0.7.1/java-does-usb-0.7.1.jar net.codecrete.usb.examples.EPaperDisplay
Display size: 1200 x 825
```
4 changes: 2 additions & 2 deletions examples/epaper_display/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.codecrete.usb.examples</groupId>
<artifactId>epaper-display</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>

<name>epaper-display</name>
<url>https://github.com/manuelbl/JavaDoesUSB/examples/epaper_display</url>
Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>net.codecrete.usb</groupId>
<artifactId>java-does-usb</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion examples/monitor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $ mvn compile exec:exec
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< net.codecrete.usb.examples:monitor >-----------------
[INFO] Building monitor 0.7.0
[INFO] Building monitor 0.7.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ monitor ---
Expand Down
4 changes: 2 additions & 2 deletions examples/monitor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.codecrete.usb.examples</groupId>
<artifactId>monitor</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>

<name>monitor</name>
<url>https://github.com/manuelbl/JavaDoesUSB/examples/monitor</url>
Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>net.codecrete.usb</groupId>
<artifactId>java-does-usb</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>
</dependency>
<dependency>
<groupId>org.tinylog</groupId>
Expand Down
2 changes: 1 addition & 1 deletion examples/monitor_kotlin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ $ mvn clean package
### Run the jar

```shell
$ java --enable-preview --enable-native-access=ALL-UNNAMED -jar target/monitor-0.7.0-jar-with-dependencies.jar
$ java --enable-preview --enable-native-access=ALL-UNNAMED -jar target/monitor-0.7.1-jar-with-dependencies.jar
WARNING: "public static final void net.codecrete.usb.examples.MonitorKt.main()" chosen over "public static void net.codecrete.usb.examples.MonitorKt.main(java.lang.String[])"
Present: VID: 0xcafe, PID: 0xceaf, manufacturer: JavaDoesUSB, product: Loopback, serial: 35A737883336, ID: 4295265643
Present: VID: 0x1a40, PID: 0x0801, manufacturer: null, product: USB 2.0 Hub, serial: null, ID: 4295259660
Expand Down
4 changes: 2 additions & 2 deletions examples/monitor_kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>net.codecrete.usb.examples</groupId>
<artifactId>monitor</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>
<packaging>jar</packaging>

<name>monitor</name>
Expand Down Expand Up @@ -64,7 +64,7 @@
<dependency>
<groupId>net.codecrete.usb</groupId>
<artifactId>java-does-usb</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>
</dependency>
<dependency>
<groupId>org.tinylog</groupId>
Expand Down
2 changes: 1 addition & 1 deletion examples/stm_dfu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Run the command below (adapting the file path depending on your specific board):

```shell
$ mvn package
$ java --enable-preview --enable-native-access=ALL-UNNAMED -jar target/stm_dfu-0.7.0.jar ../../test-devices/loopback-stm32/bin/blackpill-f401cc.bin
$ java --enable-preview --enable-native-access=ALL-UNNAMED -jar target/stm_dfu-0.7.1.jar ../../test-devices/loopback-stm32/bin/blackpill-f401cc.bin
DFU device found with serial 35A737883336.
Target memory segment: Internal Flash
Erasing page at 0x8000000 (size 0x4000)
Expand Down
4 changes: 2 additions & 2 deletions examples/stm_dfu/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>net.codecrete.usb.examples</groupId>
<artifactId>stm_dfu</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>

<name>stm_dfu</name>
<url>https://github.com/manuelbl/JavaDoesUSB/examples/stm_dfu</url>
Expand All @@ -19,7 +19,7 @@
<dependency>
<groupId>net.codecrete.usb</groupId>
<artifactId>java-does-usb</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion java-does-usb/jextract/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ SymbolLookup loaderLookup = SymbolLookup.libraryLookup("libudev.so", MemorySessi

Most of the required native functions on macOS are part of a framework. Frameworks internally have a more complex file organization of header and binary files than appears from the outside. Thus, they require a special logic to locate framework header files. *clang* supports it with the `-F`. *jextract* allows to specify the options via `compiler_flags.txt` file. Since the file must be in the local directory and since it does not apply to Linux and Windows, separate directories must be used for the operating systems.

The generated code has the same problem as the Linux code for *udev*. It must be manually changed to use `SymbolLookup.libraryLookup()` for the libraries `CoreFoundation.framework/CoreFoundation` and `IOKit.framework/IOKit` respectively.
The generated code has the same problem as the Linux code for *udev*. It must be manually changed to use `SymbolLookup.libraryLookup()` for the frameworks `CoreFoundation` and `IOKit` respectively, and use an absolute path starting with `/System/Library/Frameworks/`.


## Windows
Expand Down
2 changes: 1 addition & 1 deletion java-does-usb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.codecrete.usb</groupId>
<artifactId>java-does-usb</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>

<properties>
<maven.compiler.source>21</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class RuntimeHelper {
static {
// System.loadLibrary("CoreFoundation.framework");
// SymbolLookup loaderLookup = SymbolLookup.loaderLookup();
SymbolLookup loaderLookup = SymbolLookup.libraryLookup("CoreFoundation.framework/CoreFoundation", Arena.global());
SymbolLookup loaderLookup = SymbolLookup.libraryLookup("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation", Arena.global());
SYMBOL_LOOKUP = name -> loaderLookup.find(name).or(() -> LINKER.defaultLookup().find(name));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class RuntimeHelper {
static {
// System.loadLibrary("IOKit.framework");
// SymbolLookup loaderLookup = SymbolLookup.loaderLookup();
SymbolLookup loaderLookup = SymbolLookup.libraryLookup("IOKit.framework/IOKit", Arena.global());
SymbolLookup loaderLookup = SymbolLookup.libraryLookup("/System/Library/Frameworks/IOKit.framework/IOKit", Arena.global());
SYMBOL_LOOKUP = name -> loaderLookup.find(name).or(() -> LINKER.defaultLookup().find(name));
}

Expand Down

0 comments on commit 149c69d

Please sign in to comment.