Skip to content

Commit 0bf7f8f

Browse files
committed
[build] Fix the invocation-overhead build.
The `tests/invocation-overhead` build had regressed, largely becuase it's rarely executed. Breakage was due to the fact that the JNI headers could no longer be found, and that when running `make run`, the "wrong" mono was being used wrt the JVM that was used (e.g. trying to use a 32-bit mono with a 64-bit JVM). Refactor some Makefile logic and cleanup for consistency.
1 parent 40b75e9 commit 0bf7f8f

File tree

4 files changed

+43
-10
lines changed

4 files changed

+43
-10
lines changed

Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ ifeq ($(OS),Linux)
99
NATIVE_EXT = .so
1010
endif
1111

12-
RUNTIME := $(shell if [ -f "`which mono64`" ] ; then echo mono64 ; else echo mono; fi) --debug=casts
13-
1412
XA_CONFIGURATION = XAIntegrationDebug
1513

1614
GENDARME_URL = https://cloud.github.com/downloads/spouliot/gendarme/gendarme-2.10-bin.zip
@@ -58,8 +56,8 @@ clean:
5856
-rm -Rf bin/$(CONFIGURATION) bin/Build$(CONFIGURATION) bin/Test$(CONFIGURATION) bin/XAIntegration$(CONFIGURATION)
5957
-rm src/Java.Runtime.Environment/Java.Runtime.Environment.dll.config
6058

61-
include build-tools/scripts/jdk.mk
6259
include build-tools/scripts/mono.mk
60+
include build-tools/scripts/jdk.mk
6361

6462
$(PACKAGES) $(NUNIT_CONSOLE):
6563
nuget restore

build-tools/scripts/jdk.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
#
44
# Inputs:
55
#
6-
# $(OS): `uname` value of the host operating system
6+
# $(OS): Optional; **uname**(1) value of the host operating system
77
# $(CONFIGURATION): Build configuration name, e.g. Debug or Release
8+
# $(RUNTIME): `mono` executable for the host operating system
89
#
910
# Outputs:
1011
#
@@ -19,7 +20,7 @@
1920
# $(JI_JVM_PATH):
2021
# Location of the Java native library that contains e.g. JNI_CreateJavaVM().
2122

22-
23+
OS ?= $(shell uname)
2324

2425
ifeq ($(OS),Darwin)
2526

build-tools/scripts/mono.mk

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
#
2+
# JDK Path Probing
3+
#
4+
# Inputs:
5+
#
6+
# $(OS): Optional; **uname**(1) value of the host operating system
7+
# $(CONFIGURATION): Build configuration name, e.g. Debug or Release
8+
#
9+
# Outputs:
10+
#
11+
# bin/Build$(CONFIGURATION)/MonoInfo.props:
12+
# MSBuild property file which contains:
13+
# * `$(MonoFrameworkPath)`: `$(JI_MONO_FRAMEWORK_PATH)` value.
14+
# * `$(MonoLibs)`: `$(JI_MONO_LIBS)` value.
15+
# * `@(MonoIncludePath)`: `$(JI_MONO_INCLUDE_PATHS)` values.
16+
# $(JI_MONO_FRAMEWORK_PATH):
17+
# Path to the `libmonosgen-2.0.1.dylib` file to link against.
18+
# $(JI_MONO_INCLUDE_PATHS):
19+
# One or more space separated paths containing Mono headers to pass as
20+
# -Ipath values to the compiler.
21+
# It DOES NOT contain the -I itself; use $(JI_MONO_INCLUDE_PATHS:%=-I%) for that.
22+
# $(JI_MONO_LIBS)
23+
# C compiler linker arguments to link against `$(JI_MONO_FRAMEWORK_PATH)`.
24+
# $(RUNTIME):
25+
# The **mono**(1) program to use to execute managed code.
26+
27+
OS ?= $(shell uname)
28+
RUNTIME := $(shell if [ -f "`which mono64`" ] ; then echo mono64 ; else echo mono; fi) --debug=casts
129

230
ifeq ($(OS),Darwin)
331
JI_MONO_FRAMEWORK_PATH = /Library/Frameworks/Mono.framework/Libraries/libmonosgen-2.0.1.dylib

tests/invocation-overhead/Makefile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
JNIENV_GEN = ../../bin/Debug/jnienv-gen.exe
2-
LOCAL_JDK_HEADERS = ../../LocalJDK/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers
1+
CONFIGURATION = Debug
2+
JNIENV_GEN = ../../bin/BuildDebug/jnienv-gen.exe
33

44
all: test-overheads.exe libjava-interop.dylib
55

66
clean:
77
-rm test-overheads.exe test-overheads.exe.mdb
88
-rm -Rf libJavaInterop.dylib*
99

10+
include ../../build-tools/scripts/mono.mk
11+
include ../../build-tools/scripts/jdk.mk
12+
13+
$(JNIENV_GEN):
14+
(cd ../../build-tools/jnienv-gen ; xbuild /p:Configuration=$(CONFIGURATION))
15+
1016
HANDLE_FEATURES = \
1117
-d:FEATURE_JNIENVIRONMENT_JI_INTPTRS \
1218
-d:FEATURE_JNIENVIRONMENT_JI_PINVOKES \
@@ -17,10 +23,10 @@ test-overheads.exe: test-overheads.cs jni.cs
1723
mcs -out:$@ -unsafe $(HANDLE_FEATURES) $^
1824

1925
jni.c jni.cs: $(JNIENV_GEN)
20-
mono $< jni.cs jni.c
26+
$(RUNTIME) $< jni.cs jni.c
2127

2228
libjava-interop.dylib: jni.c
23-
gcc -g -shared -o $@ $< -m32 -DJI_DLL_EXPORT -fvisibility=hidden -I $(LOCAL_JDK_HEADERS)
29+
gcc -g -shared -o $@ $< -m64 -DJI_DLL_EXPORT -fvisibility=hidden $(JI_JDK_INCLUDE_PATHS:%=-I%)
2430

2531
run:
26-
mono --debug test-overheads.exe
32+
$(RUNTIME) test-overheads.exe

0 commit comments

Comments
 (0)