From b51e96015519d17f5c57d93b6314161d11282822 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 25 Oct 2023 19:18:27 +0200 Subject: [PATCH 1/4] Add native-linux-riscv64 package (#111) Motivation: This patch adds support for linux-riscv64. There was no code change other than adding support for linux-riscv64. Modification: It requires updating uraimo/run-on-arch-action to v2.4.0 for support for riscv64. It also uses JDK 21 for riscv64 as it's the first LTS version with support for riscv64 (backports to JDK 17 done and JDK 11 in progress). Result: Support for riscv64 architecture. --- .github/workflows/maven.yml | 193 ++++++++++++++++-- all/pom.xml | 5 + brotli4j/pom.xml | 17 ++ .../brotli4j/Brotli4jLoader.java | 2 + docker/docker-compose11.yml | 2 +- docker/docker-compose17.yml | 2 +- natives/linux-riscv64/build.sh | 21 ++ natives/linux-riscv64/pom.xml | 120 +++++++++++ .../brotli4j/linux/riscv64/NativeLoader.java | 30 +++ natives/pom.xml | 15 ++ pom.xml | 18 ++ 11 files changed, 403 insertions(+), 22 deletions(-) create mode 100644 natives/linux-riscv64/build.sh create mode 100644 natives/linux-riscv64/pom.xml create mode 100644 natives/linux-riscv64/src/main/java/com/aayushatharva/brotli4j/linux/riscv64/NativeLoader.java diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 7f57cb0c..c3c473d1 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -26,7 +26,7 @@ jobs: java-version: 8 architecture: x64 - name: Build with Maven - run: mvn -B -ntp clean package --file pom.xml + run: mvn -B --show-version -ntp clean package --file pom.xml - name: Upload the build uses: actions/upload-artifact@v3 with: @@ -44,7 +44,7 @@ jobs: java-version: 11 architecture: x64 - name: Build with Maven - run: mvn -B -ntp clean package --file pom.xml + run: mvn -B --show-version -ntp --file pom.xml clean package MacOS-x86_64-Build-JDK17: runs-on: macos-latest @@ -57,7 +57,7 @@ jobs: java-version: 17 architecture: x64 - name: Build with Maven - run: mvn -B -ntp clean package --file pom.xml + run: mvn -B --show-version -ntp --file pom.xml clean package Linux-x86_64-Build-JDK8: runs-on: ubuntu-latest @@ -98,7 +98,7 @@ jobs: restore-keys: | ${{ runner.os }}-pr-${{ env.cache-name }}- ${{ runner.os }}-pr- - - uses: uraimo/run-on-arch-action@v2.3.0 + - uses: uraimo/run-on-arch-action@v2.4.0 name: Run commands id: runcmd with: @@ -125,7 +125,7 @@ jobs: run: | export JAVA_HOME="/jdk" chmod +x ./mvnw - ./mvnw -B -ntp clean package + ./mvnw -B --show-version -ntp clean package - name: Upload the build uses: actions/upload-artifact@v3 @@ -145,7 +145,7 @@ jobs: key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- - - uses: uraimo/run-on-arch-action@v2.3.0 + - uses: uraimo/run-on-arch-action@v2.4.0 name: Run commands id: runcmd with: @@ -172,7 +172,7 @@ jobs: run: | export JAVA_HOME="/jdk" chmod +x ./mvnw - ./mvnw -B -ntp clean package + ./mvnw -B --show-version -ntp clean package Linux-Aarch64-Build-JDK17: runs-on: ubuntu-latest @@ -186,7 +186,7 @@ jobs: key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- - - uses: uraimo/run-on-arch-action@v2.3.0 + - uses: uraimo/run-on-arch-action@v2.4.0 name: Run commands id: runcmd with: @@ -214,7 +214,7 @@ jobs: export MAVEN_OPTS="-Djdk.lang.Process.launchMechanism=vfork" export JAVA_HOME="/jdk" chmod +x ./mvnw - ./mvnw -B -ntp clean package + ./mvnw -B --show-version -ntp clean package Linux-ArmV7-Build-JDK8: runs-on: ubuntu-latest @@ -228,7 +228,7 @@ jobs: key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- - - uses: uraimo/run-on-arch-action@v2.3.0 + - uses: uraimo/run-on-arch-action@v2.4.0 name: Run commands id: runcmd with: @@ -255,7 +255,7 @@ jobs: run: | export JAVA_HOME="/jdk" chmod +x ./mvnw - ./mvnw -B -ntp clean package + ./mvnw -B --show-version -ntp clean package - name: Upload the build uses: actions/upload-artifact@v3 @@ -275,7 +275,7 @@ jobs: key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- - - uses: uraimo/run-on-arch-action@v2.3.0 + - uses: uraimo/run-on-arch-action@v2.4.0 name: Run commands id: runcmd with: @@ -302,7 +302,7 @@ jobs: run: | export JAVA_HOME="/jdk" chmod +x ./mvnw - ./mvnw -B -ntp clean package + ./mvnw -B --show-version -ntp clean package Linux-s390x-Build-JDK8: runs-on: ubuntu-latest @@ -316,7 +316,7 @@ jobs: key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- - - uses: uraimo/run-on-arch-action@v2.3.0 + - uses: uraimo/run-on-arch-action@v2.4.0 name: Run commands id: runcmd with: @@ -339,7 +339,7 @@ jobs: run: | chmod +x ./mvnw - ./mvnw -B -ntp clean package + ./mvnw -B --show-version -ntp clean package - name: Upload the build uses: actions/upload-artifact@v3 @@ -359,7 +359,7 @@ jobs: key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- - - uses: uraimo/run-on-arch-action@v2.3.0 + - uses: uraimo/run-on-arch-action@v2.4.0 name: Run commands id: runcmd with: @@ -382,7 +382,160 @@ jobs: run: | chmod +x ./mvnw - ./mvnw -B -ntp clean package + ./mvnw -B --show-version -ntp clean package + + Linux-riscv64-Build-JDK11: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + env: + cache-name: cache-m2-repository-${{ runner.os }}-jdk11-riscv64 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- + + - uses: uraimo/run-on-arch-action@v2.4.0 + name: Run commands + id: runcmd + with: + arch: riscv64 + distro: ubuntu20.04 + + # Not required, but speeds up builds by storing container images in + # a GitHub package registry. + githubToken: ${{ github.token }} + + # Mount the .m2/repository + dockerRunArgs: | + --platform linux/riscv64 + --volume "/home/runner/.m2/repository/:/root/.m2/repository" + # Install dependencies + install: | + apt-get update + apt-get install -q -y curl gnupg2 autoconf automake libtool make tar git cmake build-essential openjdk-11-jdk + + run: | + export MAVEN_OPTS="-Djdk.lang.Process.launchMechanism=vfork" + chmod +x ./mvnw + ./mvnw -B --show-version -ntp clean package + + - uses: uraimo/run-on-arch-action@v2.4.0 + name: Test on JDK 8 + id: test + with: + arch: aarch64 + distro: ubuntu20.04 + + # Not required, but speeds up builds by storing container images in + # a GitHub package registry. + githubToken: ${{ github.token }} + + # Mount the .m2/repository + dockerRunArgs: | + --platform linux/aarch64 + --volume "/home/runner/.m2/repository/:/root/.m2/repository" + + # Install dependencies + install: | + apt-get update + apt-get install -q -y curl gnupg2 autoconf automake libtool make tar git cmake build-essential openjdk-8-jdk + + run: | + export MAVEN_OPTS="-Djdk.lang.Process.launchMechanism=vfork" + chmod +x ./mvnw + # Build native-linux-aarch64 only + ./mvnw -B --show-version -ntp clean package -pl :native-linux-aarch64 -DskipTests + # Test with JDK 8 + ./mvnw -B --show-version -ntp surefire:test + + # RISC-V doesn't upload the JDK 8 build because JDK 8 doesn't exist on RISC-V. Instead, we upload + # the JDK 11 build. It should work on JDK 8 as well, as we are testing it on all other platforms. + - name: Upload the build + uses: actions/upload-artifact@v3 + with: + name: Linux-riscv64-Build-JDK11 + path: /home/runner/work/Brotli4j/ + + Linux-riscv64-Build-JDK17: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + env: + cache-name: cache-m2-repository-${{ runner.os }}-jdk17-riscv64 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- + - uses: uraimo/run-on-arch-action@v2.4.0 + name: Run commands + id: runcmd + with: + arch: riscv64 + distro: ubuntu20.04 + + # Not required, but speeds up builds by storing container images in + # a GitHub package registry. + githubToken: ${{ github.token }} + + # Mount the .m2/repository + dockerRunArgs: | + --platform linux/riscv64 + --volume "/home/runner/.m2/repository/:/root/.m2/repository" + # Install dependencies + install: | + apt-get update + apt-get install -q -y curl gnupg2 autoconf automake libtool make tar git cmake build-essential openjdk-17-jdk + + run: | + export MAVEN_OPTS="-Djdk.lang.Process.launchMechanism=vfork" + chmod +x ./mvnw + ./mvnw -B --show-version -ntp clean package + + Linux-riscv64-Build-JDK21: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + env: + cache-name: cache-m2-repository-${{ runner.os }}-jdk21-riscv64 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- + - uses: uraimo/run-on-arch-action@v2.4.0 + name: Run commands + id: runcmd + with: + arch: riscv64 + distro: ubuntu22.04 + + # Not required, but speeds up builds by storing container images in + # a GitHub package registry. + githubToken: ${{ github.token }} + + # Mount the .m2/repository + dockerRunArgs: | + --platform linux/riscv64 + --volume "/home/runner/.m2/repository/:/root/.m2/repository" + + # Install dependencies + install: | + apt-get update + apt-get install -q -y curl gnupg2 autoconf automake libtool make tar git cmake build-essential + + curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | bash && . ~/.jabba/jabba.sh + jabba install 21-custom=tgz+https://api.adoptium.net/v3/binary/latest/21/ea/linux/riscv64/jdk/hotspot/normal/eclipse?project=jdk -o /jdk + + run: | + export JAVA_HOME="/jdk" + chmod +x ./mvnw + ./mvnw -B --show-version -ntp clean package Windows-x86_64-Build-JDK8: runs-on: windows-latest @@ -397,7 +550,7 @@ jobs: - name: Enable Developer Command Prompt uses: ilammy/msvc-dev-cmd@v1.12.0 - name: Build with Maven - run: mvn -B -ntp clean package --file pom.xml + run: mvn -B --show-version -ntp clean package --file pom.xml - name: Upload the build uses: actions/upload-artifact@v3 with: @@ -418,7 +571,7 @@ jobs: - name: Enable Developer Command Prompt uses: ilammy/msvc-dev-cmd@v1.12.0 - name: Build with Maven - run: mvn -B -ntp clean package --file pom.xml + run: mvn -B --show-version -ntp --file pom.xml clean package Windows-x86_64-Build-JDK17: runs-on: windows-latest @@ -433,4 +586,4 @@ jobs: - name: Enable Developer Command Prompt uses: ilammy/msvc-dev-cmd@v1.12.0 - name: Build with Maven - run: mvn -B -ntp clean package --file pom.xml + run: mvn -B --show-version -ntp --file pom.xml clean package diff --git a/all/pom.xml b/all/pom.xml index e52e122c..ec2d50f7 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -64,6 +64,11 @@ native-linux-s390x ${project.version} + + com.aayushatharva.brotli4j + native-linux-riscv64 + ${project.version} + com.aayushatharva.brotli4j native-osx-aarch64 diff --git a/brotli4j/pom.xml b/brotli4j/pom.xml index 4c18b596..6f95e5af 100644 --- a/brotli4j/pom.xml +++ b/brotli4j/pom.xml @@ -110,6 +110,23 @@ + + linux-riscv64 + + + Linux + riscv64 + + + + + com.aayushatharva.brotli4j + native-linux-riscv64 + ${project.parent.version} + + + + windows-x86_64 diff --git a/brotli4j/src/main/java/com/aayushatharva/brotli4j/Brotli4jLoader.java b/brotli4j/src/main/java/com/aayushatharva/brotli4j/Brotli4jLoader.java index 5d21f807..19ba205f 100644 --- a/brotli4j/src/main/java/com/aayushatharva/brotli4j/Brotli4jLoader.java +++ b/brotli4j/src/main/java/com/aayushatharva/brotli4j/Brotli4jLoader.java @@ -128,6 +128,8 @@ private static String getPlatform() { return "linux-armv7"; } else if ("s390x".equalsIgnoreCase(archName)) { return "linux-s390x"; + } else if ("riscv64".equalsIgnoreCase(archName)) { + return "linux-riscv64"; } } else if (osName.startsWith("Windows")) { if ("amd64".equalsIgnoreCase(archName)) { diff --git a/docker/docker-compose11.yml b/docker/docker-compose11.yml index 5de3cf1e..bd59fc3b 100644 --- a/docker/docker-compose11.yml +++ b/docker/docker-compose11.yml @@ -18,7 +18,7 @@ services: build: <<: *common - command: /bin/bash -cl "mvn -B -ntp clean package --file pom.xml" + command: /bin/bash -cl "mvn -B --show-version -ntp --file pom.xml clean package" shell: <<: *common diff --git a/docker/docker-compose17.yml b/docker/docker-compose17.yml index fc3e8be9..80aec39f 100644 --- a/docker/docker-compose17.yml +++ b/docker/docker-compose17.yml @@ -18,7 +18,7 @@ services: build: <<: *common - command: /bin/bash -cl "mvn -B -ntp clean package --file pom.xml" + command: /bin/bash -cl "mvn -B --show-version -ntp --file pom.xml clean package" shell: <<: *common diff --git a/natives/linux-riscv64/build.sh b/natives/linux-riscv64/build.sh new file mode 100644 index 00000000..84deba17 --- /dev/null +++ b/natives/linux-riscv64/build.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +CURPATH=$(pwd) +TARGET_CLASSES_PATH="target/classes/lib/linux-riscv64" +TARGET_PATH="target" + +exitWithError() { + cd ${CURPATH} + echo "*** An error occurred. Please check log messages. ***" + exit $1 +} + +mkdir -p "$TARGET_CLASSES_PATH" + +cd "$TARGET_PATH" +cmake ../../../ || exitWithError $? +make || exitWithError $? +rm -f "$CURPATH/${TARGET_CLASSES_PATH}/libbrotli.so" +cp "./libbrotli.so" "$CURPATH/${TARGET_CLASSES_PATH}" || exitWithError $? + +cd "${CURPATH}" diff --git a/natives/linux-riscv64/pom.xml b/natives/linux-riscv64/pom.xml new file mode 100644 index 00000000..e94a9771 --- /dev/null +++ b/natives/linux-riscv64/pom.xml @@ -0,0 +1,120 @@ + + + + + natives + com.aayushatharva.brotli4j + 1.12.0 + + 4.0.0 + + native-linux-riscv64 + jar + + + com.aayushatharva.brotli4j.linux.riscv64 + + + + + + org.moditect + moditect-maven-plugin + 1.0.0.RC2 + + + add-module-infos + package + + add-module-info + + + 9 + + + module ${javaModuleName} { + requires com.aayushatharva.brotli4j.service; + exports ${javaModuleName} to com.aayushatharva.brotli4j; + provides com.aayushatharva.brotli4j.service.BrotliNativeProvider with + ${javaModuleName}.NativeLoader; + } + + + + --multi-release + 9 + + + + + + + + + + + linux-riscv64 + + + Linux + riscv64 + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.0 + + + build-native + process-classes + + exec + + + /bin/bash + + build.sh + + ${project.basedir} + + + + + + + + + + release + + + + resources + + + + + + + diff --git a/natives/linux-riscv64/src/main/java/com/aayushatharva/brotli4j/linux/riscv64/NativeLoader.java b/natives/linux-riscv64/src/main/java/com/aayushatharva/brotli4j/linux/riscv64/NativeLoader.java new file mode 100644 index 00000000..5ca26f97 --- /dev/null +++ b/natives/linux-riscv64/src/main/java/com/aayushatharva/brotli4j/linux/riscv64/NativeLoader.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2020-2023, Aayush Atharva + * + * Brotli4j licenses this file to you under the + * Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aayushatharva.brotli4j.linux.riscv64; + +import com.aayushatharva.brotli4j.service.BrotliNativeProvider; + +/** + * Service class to access the native lib in a JPMS context + */ +public class NativeLoader implements BrotliNativeProvider { + + @Override + public String platformName() { + return "linux-riscv64"; + } +} diff --git a/natives/pom.xml b/natives/pom.xml index 0238b9e2..5c8d8076 100644 --- a/natives/pom.xml +++ b/natives/pom.xml @@ -32,6 +32,7 @@ linux-aarch64 linux-armv7 linux-s390x + linux-riscv64 windows-x86_64 osx-x86_64 osx-aarch64 @@ -99,6 +100,19 @@ + + linux-riscv64 + + + Linux + riscv64 + + + + linux-riscv64 + + + windows-x86_64 @@ -145,6 +159,7 @@ linux-aarch64 linux-armv7 linux-s390x + linux-riscv64 windows-x86_64 osx-x86_64 osx-aarch64 diff --git a/pom.xml b/pom.xml index 2d788bb5..322ecdd4 100644 --- a/pom.xml +++ b/pom.xml @@ -67,6 +67,18 @@ 1.8 + + + jdk9+ + + [9,) + + + 8 + + + + ossrh @@ -107,6 +119,12 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.0 + + org.apache.maven.plugins maven-jar-plugin From ba01471761627e9d8df37aab6e543b3ad846a313 Mon Sep 17 00:00:00 2001 From: Aayush Atharva Date: Thu, 26 Oct 2023 11:38:40 +0530 Subject: [PATCH 2/4] Remove extra JDK8 RISC-V build --- .github/workflows/maven.yml | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index c3c473d1..c989983f 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -422,37 +422,6 @@ jobs: chmod +x ./mvnw ./mvnw -B --show-version -ntp clean package - - uses: uraimo/run-on-arch-action@v2.4.0 - name: Test on JDK 8 - id: test - with: - arch: aarch64 - distro: ubuntu20.04 - - # Not required, but speeds up builds by storing container images in - # a GitHub package registry. - githubToken: ${{ github.token }} - - # Mount the .m2/repository - dockerRunArgs: | - --platform linux/aarch64 - --volume "/home/runner/.m2/repository/:/root/.m2/repository" - - # Install dependencies - install: | - apt-get update - apt-get install -q -y curl gnupg2 autoconf automake libtool make tar git cmake build-essential openjdk-8-jdk - - run: | - export MAVEN_OPTS="-Djdk.lang.Process.launchMechanism=vfork" - chmod +x ./mvnw - # Build native-linux-aarch64 only - ./mvnw -B --show-version -ntp clean package -pl :native-linux-aarch64 -DskipTests - # Test with JDK 8 - ./mvnw -B --show-version -ntp surefire:test - - # RISC-V doesn't upload the JDK 8 build because JDK 8 doesn't exist on RISC-V. Instead, we upload - # the JDK 11 build. It should work on JDK 8 as well, as we are testing it on all other platforms. - name: Upload the build uses: actions/upload-artifact@v3 with: From 26b1df93009ee10747f01d1de3229a93c2e0095f Mon Sep 17 00:00:00 2001 From: Aayush Atharva Date: Thu, 26 Oct 2023 12:10:07 +0530 Subject: [PATCH 3/4] Update README.md --- README.md | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3e4bbe4d..9bdd5df9 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,16 @@ Brotli4j provides Brotli compression and decompression for Java. ## Supported Platforms: -| Module | Architecture | Tested On | -|:------------------------------|:------------:|------------------------:| -| Windows (Windows Server 2022) | x64 | JDK 1.8, JDK 11, JDK 17 | -| Linux (CentOS 6) | x64 | JDK 1.8, JDK 11, JDK 17 | -| Linux (Ubuntu 18.04) | Aarch64 | JDK 1.8, JDK 11, JDK 17 | -| Linux (Ubuntu 18.04) | ARMv7 | JDK 1.8, JDK 11 | -| Linux (Ubuntu 18.04) | s390x | JDK 1.8, JDK 11 | -| macOS (Catalina) | x64 | JDK 1.8, JDK 11, JDK 17 | -| macOS (Catalina) | Aarch64 | JDK 1.8, JDK 11, JDK 17 | +| Module | Architecture | Tested On | +|:------------------------------|:------------:|--------------------------------:| +| Windows (Windows Server 2022) | x64 | JDK 1.8, JDK 11, JDK 17 | +| Linux (CentOS 6) | x64 | JDK 1.8, JDK 11, JDK 17 | +| Linux (Ubuntu 18.04) | Aarch64 | JDK 1.8, JDK 11, JDK 17 | +| Linux (Ubuntu 18.04) | ARMv7 | JDK 1.8, JDK 11 | +| Linux (Ubuntu 18.04) | s390x | JDK 1.8, JDK 11 | +| Linux (Ubuntu 20.04) | RISC-V64 | JDK 1.8, JDK 11, JDK 17, JDK 21 | +| macOS (Catalina) | x64 | JDK 1.8, JDK 11, JDK 17 | +| macOS (Catalina) | Aarch64 | JDK 1.8, JDK 11, JDK 17 | #### *Install [Microsoft Visual C++ Redistributable](https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170) before running this library on Windows @@ -189,6 +190,11 @@ public class Example { } ``` +### Additional Notes + +* RISC-V64: This platform is only supported by JDK 11+ (i.e. JDK 11, JDK 17, JDK 21, atm.). However, Since Brotli4j was always compiled +with JDK 8, we're cross-compiling RISC-V64 native module bytecode with JDK 8. This should not break existing application using +Broti4j. However, you should use JDK 11+ for using Brotli4j on RISC-V64 platform. __________________________________________________________________ ## Sponsors From 616d9e031c6f44fdee3c0eadcc66d75f05cce037 Mon Sep 17 00:00:00 2001 From: Aayush Atharva Date: Thu, 26 Oct 2023 12:16:36 +0530 Subject: [PATCH 4/4] Update README.md --- README.md | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 9bdd5df9..15a2ffbe 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Of course, you can add native(s) as dependency manually also. ```kotlin import org.gradle.nativeplatform.platform.internal.Architectures import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform +import org.gradle.nativeplatform.operatingsystem.OperatingSystem val brotliVersion = "1.12.0" val operatingSystem: OperatingSystem = DefaultNativePlatform.getCurrentOperatingSystem() @@ -55,20 +56,32 @@ repositories { dependencies { implementation("com.aayushatharva.brotli4j:brotli4j:$brotliVersion") runtimeOnly( - "com.aayushatharva.brotli4j:native-${ - if (operatingSystem.isWindows) "windows-x86_64" - else if (operatingSystem.isMacOsX) - if (DefaultNativePlatform.getCurrentArchitecture().isArm()) "osx-aarch64" - else "osx-x86_64" - else if (operatingSystem.isLinux) - if (Architectures.ARM_V7.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) "linux-armv7" - else if (Architectures.AARCH64.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) "linux-aarch64" - else if (Architectures.X86_64.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) "linux-x86_64" - else - throw IllegalStateException("Unsupported architecture: ${DefaultNativePlatform.getCurrentArchitecture().name}") - else - throw IllegalStateException("Unsupported operating system: $operatingSystem") - }:$brotliVersion" + "com.aayushatharva.brotli4j:native-" + + if (operatingSystem.isWindows) { + "windows-x86_64" + } else if (operatingSystem.isMacOsX) { + if (DefaultNativePlatform.getCurrentArchitecture().isArm()) { + "osx-aarch64" + } else { + "osx-x86_64" + } + } else if (operatingSystem.isLinux) { + if (Architectures.ARM_V7.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) { + "linux-armv7" + } else if (Architectures.AARCH64.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) { + "linux-aarch64" + } else if (Architectures.X86_64.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) { + "linux-x86_64" + } else if (Architectures.S390X.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) { + "linux-s390x" + } else if (Architectures.RISCV_64.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) { + "linux-riscv64" + } else { + throw IllegalStateException("Unsupported architecture: ${DefaultNativePlatform.getCurrentArchitecture().name}") + } + } else { + throw IllegalStateException("Unsupported operating system: $operatingSystem") + } + ":$brotliVersion" ) } ``` @@ -97,9 +110,11 @@ dependencies { if (Architectures.ARM_V7.isAlias(DefaultNativePlatform.getCurrentArchitecture().getName())) "linux-armv7" else if (Architectures.AARCH64.isAlias(DefaultNativePlatform.getCurrentArchitecture().getName())) "linux-aarch64" else if (Architectures.X86_64.isAlias(DefaultNativePlatform.getCurrentArchitecture().getName())) "linux-x86_64" + else if (Architectures.S390X.isAlias(DefaultNativePlatform.getCurrentArchitecture().getName())) "linux-s390x" + else if (Architectures.RISCV_64.isAlias(DefaultNativePlatform.getCurrentArchitecture().getName())) "linux-riscv64" else throw new IllegalStateException("Unsupported architecture: ${DefaultNativePlatform.getCurrentArchitecture().getName()}"); - else + else throw new IllegalStateException("Unsupported operating system: $operatingSystem"); }:$brotliVersion""") }