diff --git a/.blaze/blaze.java b/.blaze/blaze.java index 3faaa46..1f2fca2 100644 --- a/.blaze/blaze.java +++ b/.blaze/blaze.java @@ -28,6 +28,7 @@ public void build_natives() throws Exception { final String targetStr = Contexts.config().value("target").orNull(); final NativeTarget nativeTarget = targetStr != null ? NativeTarget.fromJneTarget(targetStr) : NativeTarget.detect(); + log.info("Building natives for target {}", nativeTarget.toJneTarget()); log.info("Copying native code to (cleaned) {} directory...", targetDir); rm(targetDir).recursive().force().run(); mkdir(targetDir).parents().run(); @@ -46,11 +47,17 @@ public void build_natives() throws Exception { .verbose() .run(); } else { + String cmd = "make"; + // freebsd and openbsd, we need to use gmake + if (nativeTarget.getOperatingSystem() == OperatingSystem.FREEBSD || nativeTarget.getOperatingSystem() == OperatingSystem.OPENBSD) { + cmd = "gmake"; + } + log.info("Building jcat executable..."); - exec("make").workingDir(targetJcatDir).debug().run(); + exec(cmd).workingDir(targetJcatDir).debug().run(); log.info("Building helloj library..."); - exec("make").workingDir(targetLibHelloJDir).debug().run(); + exec(cmd).workingDir(targetLibHelloJDir).debug().run(); } cp(targetJcatDir.resolve(exename)).target(javaOutputDir).force().verbose().run(); @@ -258,14 +265,16 @@ public void cross_build_natives() throws Exception { new Buildx(crossTargets) .tags("build") .execute((target, project) -> { - String buildScript = "setup/build-native-lib-linux-action.sh"; + /*String buildScript = "setup/build-native-lib-linux-action.sh"; if (target.getOs().equals("macos")) { buildScript = "setup/build-native-lib-macos-action.sh"; } else if (target.getOs().equals("windows")) { buildScript = "setup/build-native-lib-windows-action.bat"; } - project.action(buildScript, target.getOs(), target.getArch()).run(); + project.action(buildScript, target.getOs(), target.getArch()).run();*/ + + project.action("java", "-jar", "blaze.jar", "build_natives", "--target", target.getOsArch()).run(); // we know that the only modified file will be in the artifact dir final String artifactRelPath = "src/test/resources/jne/" + target.getOs() + "/" + target.getArch() + "/"; diff --git a/native/jcat/Makefile b/native/jcat/Makefile index 97153dc..0d19a1a 100644 --- a/native/jcat/Makefile +++ b/native/jcat/Makefile @@ -1,11 +1,3 @@ -# -# To run this in your own shell -# CC=gcc make -# - -#CC = gcc -#CPP = g++ - all: $(CC) -Wall -pedantic -O2 -o jcat jcat.c diff --git a/native/libhelloj/Makefile b/native/libhelloj/Makefile index 22f0d72..0f32767 100644 --- a/native/libhelloj/Makefile +++ b/native/libhelloj/Makefile @@ -10,13 +10,29 @@ JAVA ?= java SHAREDFILEEXT ?= so UNAME_S := $(shell uname -s) EXTRA_CXXFLAGS := -z noexecstack +CXXFLAGS := +CFLAGS := +JAVA_INCLUDE := -I${JAVA_HOME}/include ifeq ($(UNAME_S),Darwin) + JAVA_INCLUDE := ${JAVA_INCLUDE} -I${JAVA_HOME}/include/darwin SHAREDFILEEXT = dylib EXTRA_CXXFLAGS = endif +ifeq ($(UNAME_S),Linux) + JAVA_INCLUDE := ${JAVA_INCLUDE} -I${JAVA_HOME}/include/linux +endif +ifeq ($(UNAME_S),FreeBSD) + JAVA_INCLUDE := ${JAVA_INCLUDE} -I${JAVA_HOME}/include/freebsd + CXX = clang++ +endif +ifeq ($(UNAME_S),OpenBSD) + JAVA_INCLUDE := ${JAVA_INCLUDE} -I${JAVA_HOME}/include/openbsd + EXTRA_CXXFLAGS = + CXX = clang++ +endif all: - $(CXX) -shared -fPIC -Wall -pedantic -O3 $(CXXFLAGS) $(EXTRA_CXXFLAGS) -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux -I${JAVA_HOME}/include/darwin -I${JAVA_HOME}/include/freebsd -I${JAVA_HOME}/include/openbsd -o libhelloj.$(SHAREDFILEEXT) -lc helloj_HelloLib.cpp + $(CXX) -shared -fPIC -Wall -pedantic -O3 $(CXXFLAGS) $(EXTRA_CXXFLAGS) $(JAVA_INCLUDE) -o libhelloj.$(SHAREDFILEEXT) -lc helloj_HelloLib.cpp jniheaders: $(JAVAC) -h . helloj/HelloLib.java diff --git a/src/test/resources/jne/linux/x64/jcat b/src/test/resources/jne/linux/x64/jcat index 668f16e..80b0b75 100755 Binary files a/src/test/resources/jne/linux/x64/jcat and b/src/test/resources/jne/linux/x64/jcat differ diff --git a/src/test/resources/jne/linux/x64/libhelloj.so b/src/test/resources/jne/linux/x64/libhelloj.so index 1e2ce37..7d3cd2f 100755 Binary files a/src/test/resources/jne/linux/x64/libhelloj.so and b/src/test/resources/jne/linux/x64/libhelloj.so differ