Skip to content

Commit

Permalink
Dial it back, and test a linux run
Browse files Browse the repository at this point in the history
  • Loading branch information
Rongmario committed Feb 10, 2024
1 parent a22673e commit 14a8ec6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
23 changes: 9 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,25 @@ on: push

env:
LIB_NAME: libImagineBreaker
INCLUDE: $JAVA_HOME/include
PATH_TO_CODE: natives/src/main/c/zone_rong_imaginebreaker_ImagineBreaker

jobs:
compile:
linux_compile:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Java 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17

- name: Compile
run: |
x86_64-w64-mingw32-gcc -I"$INCLUDE" -I"$INCLUDE/win32" $PATH_TO_CODE.c -o $PATH_TO_CODE_x64.o
aarch64-w64-mingw32-gcc -I"$INCLUDE" -I"$INCLUDE/win32" $PATH_TO_CODE.c -o $PATH_TO_CODE_arm64.o
i686-w64-mingw32-gcc -m32 -I"$INCLUDE" -I"$INCLUDE/win32" $PATH_TO_CODE.c -o $PATH_TO_CODE_x32.o
gcc -c -fPIC -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux $PATH_TO_CODE.c -o $PATH_TO_CODE_x64.o
- name: Link
run: |
x86_64-w64-mingw32-gcc -shared -o /lib/win/$LIB_NAME_x64.dll $PATH_TO_CODE_x64.o -Wl,--add-stdcall-alias
aarch64-w64-mingw32-gcc -shared -o /lib/win/$LIB_NAME_arm64.dll $PATH_TO_CODE_arm64.o -Wl,--add-stdcall-alias
i686-w64-mingw32-gcc -shared -o /lib/win/$LIB_NAME_x32.dll $PATH_TO_CODE_x32.o -Wl,--add-stdcall-alias
gcc -shared -fPIC -o /lib/linux/$LIB_NAME_x64.so $PATH_TO_CODE_x64.o -lc
- name: Upload Natives
uses: actions/upload-artifact@v3
with:
name: native
path: /lib/linux/
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ targetVendors.each { spec, info ->
toolchain.vendor = spec
}
test.useJUnitPlatform()
test.systemProperty "java.library.path", file("${project(":natives").buildDir}/output/").absolutePath
test.systemProperty "java.library.path", file("${project(":natives").buildDir}/lib/main/debug/").absolutePath
}
testVendorsAndVersions.configure {
dependsOn testTask
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/zone/rong/imaginebreaker/NativeLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ enum OperatingSystem {

public static void load() {
try {
System.loadLibrary(getLibraryNameWithoutExt());
System.loadLibrary(getRawLibraryName());
} catch (Throwable t) {
loadFromJar(getLibraryName());
}
Expand Down Expand Up @@ -97,10 +97,8 @@ private static void loadFromJar(final String libraryResourcePath) {
}
}

private static String getLibraryNameWithoutExt() {
var name = "libImagineBreaker_";
var arch = "x" + ARCH_BITS;
return name + arch;
private static String getRawLibraryName() {
return "libImagineBreaker";
}

private static String getLibraryName() {
Expand Down

0 comments on commit 14a8ec6

Please sign in to comment.