diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 7f57cb0c..1064a86e 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -384,6 +384,48 @@ jobs: chmod +x ./mvnw ./mvnw -B -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.0.0-custom=tgz+https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.1%2B12-ea-beta/OpenJDK21U-jdk_riscv64_linux_hotspot_ea_21-0-1-12.tar.gz -o /jdk + + run: | + export MAVEN_OPTS="-Djdk.lang.Process.launchMechanism=vfork" + export JAVA_HOME="/jdk" + chmod +x ./mvnw + ./mvnw -B -ntp clean package + Windows-x86_64-Build-JDK8: runs-on: windows-latest steps: 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/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