Skip to content

Commit

Permalink
Cleanup of native build on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jjlauer committed Oct 27, 2023
1 parent 3f4daae commit 67aa492
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 80 deletions.
42 changes: 18 additions & 24 deletions .blaze/blaze.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
25 changes: 0 additions & 25 deletions setup/build-native-lib-linux-action.sh

This file was deleted.

25 changes: 0 additions & 25 deletions setup/build-native-lib-macos-action.sh

This file was deleted.

7 changes: 1 addition & 6 deletions setup/build-native-lib-windows-action.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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%"
nmake -f VCMakefile
Binary file modified src/test/resources/jne/windows/arm64/helloj.dll
Binary file not shown.
Binary file modified src/test/resources/jne/windows/arm64/jcat.exe
Binary file not shown.
Binary file added src/test/resources/jne/windows/x32
Binary file not shown.
Binary file modified src/test/resources/jne/windows/x64/helloj.dll
Binary file not shown.
Binary file modified src/test/resources/jne/windows/x64/jcat.exe
Binary file not shown.

0 comments on commit 67aa492

Please sign in to comment.