Skip to content

Commit

Permalink
Fix jni build
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Dec 27, 2024
1 parent 7a9e668 commit 8c145ec
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
4 changes: 3 additions & 1 deletion java/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ include config.mk

all:
$(JAVAC) $(JAVACFLAGS) $(JAVASRC)/*.java examples/Test.java
cd src/main/java && jar cvf ../../../r2pipe.jar org
$(MAKE) mvn
# cd src/main/java && jar cvf ../../../r2pipe.jar org
# $(MAKE) -C jni
$(MAKE) -C examples

m mvn maven:
mvn clean compile
mvn install
cp target/*.jar .

run:
$(MAKE) -C examples run
Expand Down
26 changes: 21 additions & 5 deletions java/jni/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
OUT=libr2pipe-jni.jnilib
EXT_SO=$(shell r2 -H R2_LIBEXT)
OUT=libr2pipe-jni.$(EXT_SO)
JVH=org_radare_r2pipe_R2PipeJNI.h

JNIFLAGS+=-I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/JavaVM.framework/Headers/
JNIFLAGS+=-I /System/Library/Frameworks/JavaVM.framework/Headers/
JAVA_HOME?=$(shell /usr/libexec/java_home)
ifeq ($(JAVA_HOME),)
JAVA_HOME ?= $(shell dirname $(shell dirname $(shell readlink -f $(shell which javac))))
endif
JNI_INCLUDE = -I$(JAVA_HOME)/include
ifeq ($(shell uname),Darwin)
JNI_INCLUDE+= -I$(JAVA_HOME)/include/darwin
else
JNI_INCLUDE+= -I$(JAVA_HOME)/include/linux
endif

JNIFLAGS+=$(JNI_INCLUDE)
# /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/JavaVM.framework/Headers/
# JNIFLAGS+=-I /System/Library/Frameworks/JavaVM.framework/Headers/

all: $(JVH)
$(CC) -o $(OUT) -dynamiclib -fPIC $(JNIFLAGS) r2pipe-jni.c -framework JavaVM
$(CC) -o $(OUT) -dynamiclib -fPIC $(JNIFLAGS) r2pipe-jni.c
# -framework JavaVM

$(JVH): ../src/main/java/org/radare/r2pipe/R2PipeJNI.class
javah -cp ../r2pipe.jar -d . org.radare.r2pipe.R2PipeJNI
javac -h . -d . ../src/main/java/org/radare/r2pipe/R2PipeJNI.java
#javac -h . org.radare.r2pipe.R2PipeJNI
# javah -cp ../r2pipe.jar -d . org.radare.r2pipe.R2PipeJNI

clean:
rm -f $(JVH) $(OUT)
2 changes: 1 addition & 1 deletion java/jni/r2pipe-jni.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* jni interface for r2pipe -- pancake 2016 */
/* jni interface for r2pipe -- pancake 2016-2024 */

#include "org_radare_r2pipe_R2PipeJNI.h"
#include <string.h>
Expand Down

0 comments on commit 8c145ec

Please sign in to comment.