Skip to content

Commit 9d99fb6

Browse files
authored
Windows ARM Support (#120)
1 parent 397cf0e commit 9d99fb6

File tree

10 files changed

+248
-0
lines changed

10 files changed

+248
-0
lines changed

.github/workflows/maven.yml

+16
Original file line numberDiff line numberDiff line change
@@ -753,3 +753,19 @@ jobs:
753753
uses: ilammy/[email protected]
754754
- name: Build with Maven
755755
run: mvn -B --show-version -ntp --file pom.xml clean package
756+
757+
Windows-ARM-Build-JDK11:
758+
runs-on: self-hosted
759+
steps:
760+
- uses: actions/checkout@v3
761+
- name: Enable Developer Command Prompt
762+
uses: ilammy/[email protected]
763+
with:
764+
arch: arm64
765+
- name: Build with Maven
766+
run: .\mvnw -B --show-version -ntp --file pom.xml clean package
767+
- name: Upload the build
768+
uses: actions/upload-artifact@v3
769+
with:
770+
name: Windows-ARM-Build-JDK8
771+
path: C:\Users\HyperXPro\Desktop\actions-runner\_work\Brotli4j\

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Brotli4j provides Brotli compression and decompression for Java.
99
| Module | Architecture | Tested On |
1010
|:------------------------------|:------------:|--------------------------------:|
1111
| Windows (Windows Server 2022) | x64 | JDK 1.8, JDK 11, JDK 17, JDK 21 |
12+
| Windows 11 | Aarch64 | JDK 11 |
1213
| Linux (CentOS 6) | x64 | JDK 1.8, JDK 11, JDK 17, JDK 21 |
1314
| Linux (Ubuntu 18.04) | Aarch64 | JDK 1.8, JDK 11, JDK 17, JDK 21 |
1415
| Linux (Ubuntu 18.04) | ARMv7 | JDK 1.8, JDK 11, JDK 17 |
@@ -208,6 +209,10 @@ public class Example {
208209

209210
### Additional Notes
210211

212+
* Windows-AArch64: Brotli4j is compiled with JDK 11 with JDK 8 as target because JDK 8 Windows Aarch64 builds are not available at the moment.
213+
However, it should not cause any problem on running it on JDK 8 or plus.
214+
__________________________________________________________________
215+
211216
* 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
212217
with JDK 8, we're cross-compiling RISC-V64 native module bytecode with JDK 8. This should not break existing application using
213218
Broti4j. However, you should use JDK 11+ for using Brotli4j on RISC-V64 platform.

all/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@
8989
<artifactId>native-windows-x86_64</artifactId>
9090
<version>${project.version}</version>
9191
</dependency>
92+
<dependency>
93+
<groupId>com.aayushatharva.brotli4j</groupId>
94+
<artifactId>native-windows-aarch64</artifactId>
95+
<version>${project.version}</version>
96+
</dependency>
9297
</dependencies>
9398
</dependencyManagement>
9499

brotli4j/pom.xml

+17
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,23 @@
161161
</dependencies>
162162
</profile>
163163

164+
<profile>
165+
<id>windows-aarch64</id>
166+
<activation>
167+
<os>
168+
<family>Windows</family>
169+
<arch>aarch64</arch>
170+
</os>
171+
</activation>
172+
<dependencies>
173+
<dependency>
174+
<groupId>com.aayushatharva.brotli4j</groupId>
175+
<artifactId>native-windows-aarch64</artifactId>
176+
<version>${project.parent.version}</version>
177+
</dependency>
178+
</dependencies>
179+
</profile>
180+
164181
<profile>
165182
<id>osx-x86_64</id>
166183
<activation>

brotli4j/src/main/java/com/aayushatharva/brotli4j/Brotli4jLoader.java

+2
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ private static String getPlatform() {
136136
} else if (osName.startsWith("Windows")) {
137137
if ("amd64".equalsIgnoreCase(archName)) {
138138
return "windows-x86_64";
139+
} else if ("aarch64".equalsIgnoreCase(archName)) {
140+
return "windows-aarch64";
139141
}
140142
} else if (osName.startsWith("Mac")) {
141143
if ("x86_64".equalsIgnoreCase(archName)) {

natives/pom.xml

+15
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<module>linux-ppc64le</module>
3636
<module>linux-riscv64</module>
3737
<module>windows-x86_64</module>
38+
<module>windows-aarch64</module>
3839
<module>osx-x86_64</module>
3940
<module>osx-aarch64</module>
4041
</modules>
@@ -140,6 +141,19 @@
140141
</modules>
141142
</profile>
142143

144+
<profile>
145+
<id>windows-aarch64</id>
146+
<activation>
147+
<os>
148+
<family>Windows</family>
149+
<arch>aarch64</arch>
150+
</os>
151+
</activation>
152+
<modules>
153+
<module>windows-aarch64</module>
154+
</modules>
155+
</profile>
156+
143157
<profile>
144158
<id>osx-x86_64</id>
145159
<activation>
@@ -176,6 +190,7 @@
176190
<module>linux-ppc64le</module>
177191
<module>linux-riscv64</module>
178192
<module>windows-x86_64</module>
193+
<module>windows-aarch64</module>
179194
<module>osx-x86_64</module>
180195
<module>osx-aarch64</module>
181196
</modules>

natives/windows-aarch64/build.bat

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@ECHO OFF
2+
3+
REM
4+
REM Minimal script to compile the native resources
5+
REM
6+
REM Requirements
7+
REM --------------
8+
REM o Java 1.8 JDK installed, needs JAVA_HOME set
9+
REM o cmake 3.0 + installed and available via PATH
10+
REM o nmake installed (comes e.g. with Visual Studio), call "vcvarsall.bat x64" before to activate 64bit tools
11+
REM
12+
13+
:ENSURE_WORKING_DIRECTORY
14+
cd "%~dp0"
15+
16+
:PREPARE_FOLDERS
17+
if not exist "%~dp0target" mkdir "%~dp0target"
18+
if not exist "%~dp0target\classes" mkdir "%~dp0target\classes"
19+
if not exist "%~dp0target\classes\lib" mkdir "%~dp0target\classes\lib"
20+
SET TARGET_CLASSES_PATH=%~dp0target\classes\lib\windows-aarch64
21+
if not exist "%TARGET_CLASSES_PATH%" mkdir "%TARGET_CLASSES_PATH%"
22+
23+
:PREPARE_MAKEFILES
24+
cd "%~dp0target"
25+
cmake -DCMAKE_BUILD_TYPE=RELEASE -G "NMake Makefiles" ..\..\..\ || goto ERROR
26+
27+
:MAKE_ALL
28+
cd "%~dp0target"
29+
nmake || goto ERROR
30+
31+
:COPY_DLL_FOR_MAVEN_PACKAGING
32+
copy /Y "%~dp0target\brotli.dll" "%TARGET_CLASSES_PATH%" || goto ERROR
33+
34+
:ENSURE_WORKING_DIRECTORY
35+
cd %~dp0
36+
goto :EOF
37+
38+
:ERROR
39+
cd %~dp0
40+
echo "*** An error occurred. Please check log messages. ***"
41+
exit /b -1

natives/windows-aarch64/pom.xml

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright (c) 2020-2023, Aayush Atharva
4+
5+
Brotli4j licenses this file to you under the
6+
Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
-->
19+
<project xmlns="http://maven.apache.org/POM/4.0.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22+
<parent>
23+
<artifactId>natives</artifactId>
24+
<groupId>com.aayushatharva.brotli4j</groupId>
25+
<version>1.13.0</version>
26+
</parent>
27+
<modelVersion>4.0.0</modelVersion>
28+
29+
<artifactId>native-windows-aarch64</artifactId>
30+
<packaging>jar</packaging>
31+
32+
<properties>
33+
<javaModuleName>com.aayushatharva.brotli4j.windows.aarch64</javaModuleName>
34+
</properties>
35+
36+
<build>
37+
<plugins>
38+
<plugin>
39+
<groupId>org.moditect</groupId>
40+
<artifactId>moditect-maven-plugin</artifactId>
41+
<version>1.0.0.RC2</version>
42+
<executions>
43+
<execution>
44+
<id>add-module-infos</id>
45+
<phase>package</phase>
46+
<goals>
47+
<goal>add-module-info</goal>
48+
</goals>
49+
<configuration>
50+
<jvmVersion>9</jvmVersion>
51+
<module>
52+
<moduleInfoSource>
53+
module ${javaModuleName} {
54+
requires com.aayushatharva.brotli4j.service;
55+
exports ${javaModuleName} to com.aayushatharva.brotli4j;
56+
provides com.aayushatharva.brotli4j.service.BrotliNativeProvider with
57+
${javaModuleName}.NativeLoader;
58+
}
59+
</moduleInfoSource>
60+
</module>
61+
<jdepsExtraArgs>
62+
<arg>--multi-release</arg>
63+
<arg>9</arg>
64+
</jdepsExtraArgs>
65+
</configuration>
66+
</execution>
67+
</executions>
68+
</plugin>
69+
</plugins>
70+
</build>
71+
72+
<profiles>
73+
<profile>
74+
<id>windows-aarch64</id>
75+
<activation>
76+
<os>
77+
<family>Windows</family>
78+
<arch>aarch64</arch>
79+
</os>
80+
</activation>
81+
<build>
82+
<plugins>
83+
<plugin>
84+
<groupId>org.codehaus.mojo</groupId>
85+
<artifactId>exec-maven-plugin</artifactId>
86+
<version>3.0.0</version>
87+
<executions>
88+
<execution>
89+
<id>Execute-Native-Compile</id>
90+
<phase>process-classes</phase>
91+
<goals>
92+
<goal>exec</goal>
93+
</goals>
94+
<configuration>
95+
<executable>${project.basedir}/build.bat</executable>
96+
</configuration>
97+
</execution>
98+
</executions>
99+
</plugin>
100+
</plugins>
101+
</build>
102+
</profile>
103+
104+
<profile>
105+
<id>release</id>
106+
<build>
107+
<resources>
108+
<resource>
109+
<directory>resources</directory>
110+
</resource>
111+
</resources>
112+
</build>
113+
</profile>
114+
</profiles>
115+
116+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2020-2023, Aayush Atharva
3+
*
4+
* Brotli4j licenses this file to you under the
5+
* Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package com.aayushatharva.brotli4j.windows.aarch64;
18+
19+
import com.aayushatharva.brotli4j.service.BrotliNativeProvider;
20+
21+
/**
22+
* Service class to access the native lib in a JPMS context
23+
*/
24+
public class NativeLoader implements BrotliNativeProvider {
25+
26+
@Override
27+
public String platformName() {
28+
return "windows-aarch64";
29+
}
30+
}

pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<java.version>1.8</java.version>
6666
<maven.compiler.source>1.8</maven.compiler.source>
6767
<maven.compiler.target>1.8</maven.compiler.target>
68+
<overwriteExistingFiles>true</overwriteExistingFiles>
6869
</properties>
6970

7071
<profiles>

0 commit comments

Comments
 (0)