-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (44 loc) · 1.52 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
# this is from /usr/libexec/java_home -v 1.8
#JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_72.jdk/Contents/Home
JAVA_HOME=`/usr/libexec/java_home -v 1.8`
JAVA_OS=darwin
endif
ifeq ($(UNAME_S),Linux)
JAVA_HOME=/usr/java/default
JAVA_OS=linux
LINUX_ADD=amd64/
endif
# include rules that can change the locations
-include custom.rules
JAVA_LIBRARY_PATH=$(JAVA_HOME)/jre/lib/$(LINUX_ADD)server/
JAVA_INCLUDES=-I$(JAVA_HOME)/include/ -I$(JAVA_HOME)/include/$(JAVA_OS)/ -L$(JAVA_LIBRARY_PATH)
#JAVA_APP_ARGS=1 2 3
JAVA_ARGS=-XX:NativeMemoryTracking=detail $(A) TestMain
CPP_ARGS=
CPP_ARGS+=-Dsun.java.launcher.diag=true
CPP_ARGS+=-Djava.class.path=.
CPP_ARGS+=-XX:NativeMemoryTracking=detail
all: compile
verify_args: bin
g++ -g -O0 args.cc verify_args.cc $(JAVA_INCLUDES) -o bin/verify_args
jnivm: bin
g++ -g -O0 args.cc jnivm.cc $(JAVA_INCLUDES) -ldl -o bin/jnivm
bin:
-mkdir bin
clean:
rm -rf bin
compile: clean verify_args jnivm
run_jni: compile
echo ./bin/jnivm $(CPP_ARGS) TestMain
_JAVA_LAUNCHER_DEBUG=1 LD_LIBRARY_PATH=$(JAVA_LIBRARY_PATH) ./bin/jnivm $(CPP_ARGS) TestMain $(JAVA_APP_ARGS)
debug_jni: compile
_JAVA_LAUNCHER_DEBUG=1 LD_LIBRARY_PATH=$(JAVA_LIBRARY_PATH) gdb --args ./bin/jnivm $(CPP_ARGS) TestMain $(JAVA_APP_ARGS)
run_java:
_JAVA_LAUNCHER_DEBUG=1 java $(JAVA_ARGS)
test_jni:
export LD_LIBRARY_PATH=$(JAVA_LIBRARY_PATH) && ./test_jni.sh $(CPP_ARGS) TestMain $(JAVA_APP_ARGS)
unit_test: verify_args
./bin/verify_args
run_tests: unit_test test_jni