diff --git a/.gitignore b/.gitignore index 246ab4580..479deabb9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ bin +Configuration.Override.props obj JavaDeveloper-2013005_dp__11m4609.pkg LocalJDK diff --git a/Configuration.Override.props.in b/Configuration.Override.props.in new file mode 100644 index 000000000..e1da01c3c --- /dev/null +++ b/Configuration.Override.props.in @@ -0,0 +1,17 @@ + + + + /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/server/libjvm.dylib + /Library/Frameworks/Mono.framework/Libraries/libmonosgen-2.0.1.dylib + $(MSBuildThisFileDirectory)bin\$(Configuration)\ + + + + + + + + + + + diff --git a/Configuration.props b/Configuration.props new file mode 100644 index 000000000..36fce7812 --- /dev/null +++ b/Configuration.props @@ -0,0 +1,19 @@ + + + + + + + + $(MSBuildThisFileDirectory)bin\$(Configuration)\ + + diff --git a/README.md b/README.md index 9da8b3a24..f2f464ca5 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,13 @@ [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/xamarin/xamarin-android?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -**Java.Interop** is a brain-delusional [Second System Syndrome][sss] rebuild - of the monodroid/Xamarin.Android core, intended to fix some of the shortcomings - and design mistakes I've made over the years. +**Java.Interop** is a binding of the [Java Native Interface][jni] for use from +managed languages such as C#, and an associated set of code generators to +allow Java code to invoke managed code. It is *also* a brain-delusional +[Second System Syndrome][sss] rebuild of the monodroid/Xamarin.Android core, +intended to fix some of the shortcomings and design mistakes I've made over the years. +[jni]: http://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/jniTOC.html [sss]: http://en.wikipedia.org/wiki/Second-system_effect In particular, it attempts to fix the following issues: @@ -27,7 +30,7 @@ which returns a global reference while most other methods return a local ref. The `JNIEnv` API is also huge, unwieldy, and terrible. -## Requirements +## Build Requirements The current Oracle JDK7 installer only provides 64-bit binaries, while Mono for OS X is currently a 32-bit binary. These don't work together. :-( @@ -63,6 +66,52 @@ then run the `osx-setup` target: $ make osx-setup JDK=JavaDeveloper.pkg +## Build Configuration + +The Java.Interop build can be configured by overriding **make**(1) variables +on the command line or by specifying MSBuild properties to control behavior. + +### **make**(1) variables + +The following **make**(1) variables may be specified: + +* `$(CONFIGURATION)`: The product configuration to build, and corresponds + to the `$(Configuration)` MSBuild property when running `$(XBUILD)`. + Valid values are `Debug` and `Release`. Default value is `Debug`. +* `$(RUNTIME)`: The managed runtime to use to execute utilities, tests. + Default value is `mono64` if present in `$PATH`, otherwise `mono`. +* `$(TESTS)`: Which unit tests to execute. Useful in conjunction with the + `make run-tests` target: + + make run-tests TESTS=bin/Debug/Java.Interop.Dynamic-Tests.dll + +* `$(V)`: If set to a non-empty string, adds `/v:diag` to `$(XBUILD)` + invocations. +* `$(XBUILD)`: The MSBuild build tool to execute for builds. + Default value is `xbuild`. + + +### MSBuild Properties + +MSbuild properties may be placed into the file `Configuration.Override.props`, +which can be copied from +[`Configuration.Override.props.in`](Configuration.Override.props.in). +The `Configuration.Override.props` file is ``ed by +[`Configuration.props`](Configuration.props); there is no need to `` +it within other project files. + +Overridable MSBuild properties include: + +* `$(JdkJvmPath)`: Full path name to the JVM native library to link + [`java-interop`](src/java-interop) against. By default this is + probed for from numerious locations within + [`build-tools/scripts/jdk.mk`](build-tools/scripts/jdk.mk). +* `$(UtilityOutputFullPath)`: Directory to place various utilities such as + [`class-parse`](tools/class-parse), [`generator`](tools/generator), + and [`logcat-parse`](tools/logcat-parse). This value should be a full path. + By default this is `$(MSBuildThisFileDirectory)bin/$(Configuration)`. + + ## Type Safety The start of the reboot was to use strongly typed [`SafeHandle`][SafeHandle] diff --git a/build-tools/scripts/jdk.mk b/build-tools/scripts/jdk.mk index ab041f2c0..1a876e006 100644 --- a/build-tools/scripts/jdk.mk +++ b/build-tools/scripts/jdk.mk @@ -116,11 +116,11 @@ bin/Build$(CONFIGURATION)/JdkInfo.props: $(JI_JDK_INCLUDE_PATHS) $(JI_JVM_PATH) -rm "$@" echo '' > "$@" echo ' ' >> "$@" - echo " $(JI_JVM_PATH)" >> "$@" + echo " $(JI_JVM_PATH)" >> "$@" echo ' ' >> "$@" echo ' ' >> "$@" for p in $(JI_JDK_INCLUDE_PATHS); do \ - echo " " >> "$@"; \ + echo " " >> "$@"; \ done echo ' ' >> "$@" echo '' >> "$@" diff --git a/build-tools/scripts/mono.mk b/build-tools/scripts/mono.mk index 5e53ea468..0dac4088e 100644 --- a/build-tools/scripts/mono.mk +++ b/build-tools/scripts/mono.mk @@ -21,12 +21,12 @@ bin/Build$(CONFIGURATION)/MonoInfo.props: $(JI_MONO_INCLUDE_PATHS) $(JI_MONO_FRA -rm "$@" echo '' > "$@" echo ' ' >> "$@" - echo " $(JI_MONO_FRAMEWORK_PATH)" >> "$@" - echo ' $(JI_MONO_LIBS)' + echo " $(JI_MONO_FRAMEWORK_PATH)" >> "$@" + echo " $(JI_MONO_LIBS)" >> "$@" echo ' ' >> "$@" echo ' ' >> "$@" for p in $(JI_MONO_INCLUDE_PATHS); do \ - echo " " >> "$@"; \ + echo " " >> "$@"; \ done echo ' ' >> "$@" echo '' >> "$@" diff --git a/tools/class-parse/class-parse.csproj b/tools/class-parse/class-parse.csproj index e13176a40..d28b458fd 100644 --- a/tools/class-parse/class-parse.csproj +++ b/tools/class-parse/class-parse.csproj @@ -12,11 +12,12 @@ 8.0.30703 2.0 + true full false - ..\..\bin\Debug + $(UtilityOutputFullPath) DEBUG; prompt 4 @@ -26,7 +27,7 @@ full true - ..\..\bin\Release + $(UtilityOutputFullPath) prompt 4 true diff --git a/tools/generator/generator.csproj b/tools/generator/generator.csproj index e9b36829b..4c8cd2936 100644 --- a/tools/generator/generator.csproj +++ b/tools/generator/generator.csproj @@ -17,11 +17,12 @@ v4.5 + True full False - ..\..\bin\Debug + $(UtilityOutputFullPath) DEBUG;GENERATOR;USE_CECIL;JCW_ONLY_TYPE_NAMES prompt 4 @@ -30,7 +31,7 @@ none False - ..\..\bin\Release + $(UtilityOutputFullPath) prompt 4 True diff --git a/tools/logcat-parse/logcat-parse.csproj b/tools/logcat-parse/logcat-parse.csproj index 53eedd290..67fe5b425 100644 --- a/tools/logcat-parse/logcat-parse.csproj +++ b/tools/logcat-parse/logcat-parse.csproj @@ -12,11 +12,12 @@ v4.5 Xamarin.Android.Tools.LogcatParse.Program + true full false - ..\..\bin\Debug + $(UtilityOutputFullPath) DEBUG;TRACE prompt 4 @@ -26,7 +27,7 @@ full true - ..\..\bin\Release + $(UtilityOutputFullPath) TRACE prompt 4