diff --git a/.blaze/blaze.java b/.blaze/blaze.java index 5e3dad2..3faaa46 100644 --- a/.blaze/blaze.java +++ b/.blaze/blaze.java @@ -28,41 +28,35 @@ public void build_natives() throws Exception { final String targetStr = Contexts.config().value("target").orNull(); final NativeTarget nativeTarget = targetStr != null ? NativeTarget.fromJneTarget(targetStr) : NativeTarget.detect(); - if (nativeTarget.getOperatingSystem() == OperatingSystem.WINDOWS) { - this.build_natives_on_windows(nativeTarget); - } else { - this.build_natives_on_unix(nativeTarget); - } - } + log.info("Copying native code to (cleaned) {} directory...", targetDir); + rm(targetDir).recursive().force().run(); + mkdir(targetDir).parents().run(); + cp(globber(nativeDir, "*")).target(targetDir).recursive().debug().run(); - private void build_natives_on_unix(NativeTarget nativeTarget) throws Exception { final Path targetJcatDir = targetDir.resolve("jcat"); final Path targetLibHelloJDir = targetDir.resolve("libhelloj"); final Path javaOutputDir = withBaseDir("../src/test/resources/jne/" + nativeTarget.toJneOsAbi() + "/" + nativeTarget.toJneArch()); + final String exename = nativeTarget.resolveExecutableFileName("jcat"); final String libname = nativeTarget.resolveLibraryFileName("helloj"); - log.info("Copying native code to (cleaned) {} directory...", targetDir); - rm(targetDir).recursive().force().run(); - mkdir(targetDir).parents().run(); - cp(globber(nativeDir, "*")).target(targetDir).recursive().debug().run(); - - log.info("Building jcat executable..."); - exec("make").workingDir(targetJcatDir).env("DUDE", "yo").verbose().run(); + if (nativeTarget.getOperatingSystem() == OperatingSystem.WINDOWS) { + // unfortunately its easiest to delegate this to helper script + exec("setup/build-native-lib-windows-action.bat", nativeTarget.toJneOsAbi(), nativeTarget.toJneArch()) + .workingDir(this.projectDir) + .verbose() + .run(); + } else { + log.info("Building jcat executable..."); + exec("make").workingDir(targetJcatDir).debug().run(); - log.info("Building helloj library..."); - exec("make").workingDir(targetLibHelloJDir).debug().run(); + log.info("Building helloj library..."); + exec("make").workingDir(targetLibHelloJDir).debug().run(); + } - cp(targetJcatDir.resolve("jcat")).target(javaOutputDir).force().verbose().run(); + cp(targetJcatDir.resolve(exename)).target(javaOutputDir).force().verbose().run(); cp(targetLibHelloJDir.resolve(libname)).target(javaOutputDir).force().verbose().run(); } - private void build_natives_on_windows(NativeTarget nativeTarget) throws Exception { - exec("setup/build-native-lib-windows-action.bat", nativeTarget.toJneOsAbi(), nativeTarget.toJneArch()) - .workingDir(this.projectDir) - .verbose() - .run(); - } - @Task(order = 2) public void test() throws Exception { exec("mvn", "test") diff --git a/setup/build-native-lib-linux-action.sh b/setup/build-native-lib-linux-action.sh deleted file mode 100755 index bf1dbe1..0000000 --- a/setup/build-native-lib-linux-action.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -BASEDIR=$(dirname "$0") -cd "$BASEDIR/.." -PROJECT_DIR=$PWD - -BUILDOS=$1 -BUILDARCH=$2 - -mkdir -p target -rsync -avrt --delete ./native/ ./target/ - -cd target/jcat -make - -export CXXFLAGS="-z noexecstack" - -cd ../libhelloj -make - -cd .. -OUTPUT_DIR="../src/test/resources/jne/${BUILDOS}/${BUILDARCH}" -mkdir -p "$OUTPUT_DIR" -cp jcat/jcat "$OUTPUT_DIR" -cp libhelloj/libhelloj.so "$OUTPUT_DIR" \ No newline at end of file diff --git a/setup/build-native-lib-macos-action.sh b/setup/build-native-lib-macos-action.sh deleted file mode 100755 index dadeaf4..0000000 --- a/setup/build-native-lib-macos-action.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -liex -# shell w/ login & interactive, exit if any command fails, log each command - -BASEDIR=$(dirname "$0") -cd "$BASEDIR/.." -PROJECT_DIR=$PWD - -BUILDOS=$1 -BUILDARCH=$2 - -mkdir -p target -rsync -avrt --delete ./native/ ./target/ - -cd target/jcat -make - -export SHAREDFILEEXT="dylib" - -cd ../libhelloj -make - -cd .. -OUTPUT_DIR="../src/test/resources/jne/${BUILDOS}/${BUILDARCH}" -cp jcat/jcat "$OUTPUT_DIR" -cp libhelloj/libhelloj.dylib "$OUTPUT_DIR" \ No newline at end of file diff --git a/setup/build-native-lib-windows-action.bat b/setup/build-native-lib-windows-action.bat index bb70770..59c62ef 100755 --- a/setup/build-native-lib-windows-action.bat +++ b/setup/build-native-lib-windows-action.bat @@ -41,9 +41,4 @@ cd .\target\jcat nmake -f VCMakefile cd ..\libhelloj -nmake -f VCMakefile - -cd .. -set OUTPUT_DIR="..\src\test\resources\jne\%BUILDOS%\%BUILDARCH%" -copy jcat\jcat.exe "%OUTPUT_DIR%" -copy libhelloj\helloj.dll "%OUTPUT_DIR%" \ No newline at end of file +nmake -f VCMakefile \ No newline at end of file diff --git a/src/test/resources/jne/windows/arm64/helloj.dll b/src/test/resources/jne/windows/arm64/helloj.dll index c927797..2eb6417 100755 Binary files a/src/test/resources/jne/windows/arm64/helloj.dll and b/src/test/resources/jne/windows/arm64/helloj.dll differ diff --git a/src/test/resources/jne/windows/arm64/jcat.exe b/src/test/resources/jne/windows/arm64/jcat.exe index ae7b6ce..2d711c1 100755 Binary files a/src/test/resources/jne/windows/arm64/jcat.exe and b/src/test/resources/jne/windows/arm64/jcat.exe differ diff --git a/src/test/resources/jne/windows/x32 b/src/test/resources/jne/windows/x32 new file mode 100644 index 0000000..9cb980e Binary files /dev/null and b/src/test/resources/jne/windows/x32 differ diff --git a/src/test/resources/jne/windows/x64/helloj.dll b/src/test/resources/jne/windows/x64/helloj.dll index 1129482..9c78690 100755 Binary files a/src/test/resources/jne/windows/x64/helloj.dll and b/src/test/resources/jne/windows/x64/helloj.dll differ diff --git a/src/test/resources/jne/windows/x64/jcat.exe b/src/test/resources/jne/windows/x64/jcat.exe index c085001..130ddaf 100755 Binary files a/src/test/resources/jne/windows/x64/jcat.exe and b/src/test/resources/jne/windows/x64/jcat.exe differ