Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add native-linux-riscv64 package #111

Merged
merged 10 commits into from
Oct 25, 2023
56 changes: 49 additions & 7 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
luhenry marked this conversation as resolved.
Show resolved Hide resolved

# 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"
luhenry marked this conversation as resolved.
Show resolved Hide resolved
chmod +x ./mvnw
./mvnw -B -ntp clean package

Windows-x86_64-Build-JDK8:
runs-on: windows-latest
steps:
Expand Down
5 changes: 5 additions & 0 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@
<artifactId>native-linux-s390x</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.aayushatharva.brotli4j</groupId>
<artifactId>native-linux-riscv64</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.aayushatharva.brotli4j</groupId>
<artifactId>native-osx-aarch64</artifactId>
Expand Down
17 changes: 17 additions & 0 deletions brotli4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,23 @@
</dependencies>
</profile>

<profile>
<id>linux-riscv64</id>
<activation>
<os>
<family>Linux</family>
<arch>riscv64</arch>
</os>
</activation>
<dependencies>
<dependency>
<groupId>com.aayushatharva.brotli4j</groupId>
<artifactId>native-linux-riscv64</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
</profile>

<profile>
<id>windows-x86_64</id>
<activation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
21 changes: 21 additions & 0 deletions natives/linux-riscv64/build.sh
Original file line number Diff line number Diff line change
@@ -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}"
120 changes: 120 additions & 0 deletions natives/linux-riscv64/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>natives</artifactId>
<groupId>com.aayushatharva.brotli4j</groupId>
<version>1.12.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>native-linux-riscv64</artifactId>
<packaging>jar</packaging>

<properties>
<javaModuleName>com.aayushatharva.brotli4j.linux.riscv64</javaModuleName>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<version>1.0.0.RC2</version>
<executions>
<execution>
<id>add-module-infos</id>
<phase>package</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<jvmVersion>9</jvmVersion>
<module>
<moduleInfoSource>
module ${javaModuleName} {
requires com.aayushatharva.brotli4j.service;
exports ${javaModuleName} to com.aayushatharva.brotli4j;
provides com.aayushatharva.brotli4j.service.BrotliNativeProvider with
${javaModuleName}.NativeLoader;
}
</moduleInfoSource>
</module>
<jdepsExtraArgs>
<arg>--multi-release</arg>
<arg>9</arg>
</jdepsExtraArgs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>linux-riscv64</id>
<activation>
<os>
<family>Linux</family>
<arch>riscv64</arch>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>build-native</id>
<phase>process-classes</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>/bin/bash</executable>
<arguments>
<argument>build.sh</argument>
</arguments>
<workingDirectory>${project.basedir}</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>release</id>
<build>
<resources>
<resource>
<directory>resources</directory>
</resource>
</resources>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -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";
}
}
15 changes: 15 additions & 0 deletions natives/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<module>linux-aarch64</module>
<module>linux-armv7</module>
<module>linux-s390x</module>
<module>linux-riscv64</module>
<module>windows-x86_64</module>
<module>osx-x86_64</module>
<module>osx-aarch64</module>
Expand Down Expand Up @@ -99,6 +100,19 @@
</modules>
</profile>

<profile>
<id>linux-riscv64</id>
<activation>
<os>
<family>Linux</family>
<arch>riscv64</arch>
</os>
</activation>
<modules>
<module>linux-riscv64</module>
</modules>
</profile>

<profile>
<id>windows-x86_64</id>
<activation>
Expand Down Expand Up @@ -145,6 +159,7 @@
<module>linux-aarch64</module>
<module>linux-armv7</module>
<module>linux-s390x</module>
<module>linux-riscv64</module>
<module>windows-x86_64</module>
<module>osx-x86_64</module>
<module>osx-aarch64</module>
Expand Down