Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Add support for Configuration.Override.props #45

Merged
merged 1 commit into from
Jun 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bin
Configuration.Override.props
obj
JavaDeveloper-2013005_dp__11m4609.pkg
LocalJDK
Expand Down
17 changes: 17 additions & 0 deletions Configuration.Override.props.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<JdkJvmPath>/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/server/libjvm.dylib</JdkJvmPath>
<MonoFrameworkPath>/Library/Frameworks/Mono.framework/Libraries/libmonosgen-2.0.1.dylib</MonoFrameworkPath>
<UtilityOutputFullPath>$(MSBuildThisFileDirectory)bin\$(Configuration)\</UtilityOutputFullPath>
</PropertyGroup>
<ItemGroup>
<!-- JDK C `include` directories -->
<JdkIncludePath Include="/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/include" />
<JdkIncludePath Include="/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/include/darwin" />
</ItemGroup>
<ItemGroup>
<!-- Mono C `include` directories -->
<MonoIncludePath Include="/Library/Frameworks/Mono.framework/Headers/mono-2.0" />
</ItemGroup>
</Project>
19 changes: 19 additions & 0 deletions Configuration.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Note: MUST be imported *after* $(Configuration) is set! -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can add:

<PropertyGroup>
   <Configuration Condition="'$(Configuration)' == ''">ConfigurationNotSetInConfigurationPropsForProject-$(MSBuildProjectFile)</Configuration>
</PropertyGroup>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'll result in obscure/bizarre errors, as a non-existent configuration could be used for building:

<!-- "bad" .csproj -->
<Project ...>
  <Import Project="..\..\Configuration.props" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
</Project>

With such a "bad" project, $(Configuration) will be set, causing MSBuild to look for the ConfigurationNotSetInConfigurationPropsForProject|AnyCPU configuration, which doesn't exist.

At best, it'll still compile but you have no idea where the output file is.

More likely -- if #if is used at all -- is that the project will fail to build with some "bizarro" error that in no way suggests that the error is "an invalid $(Configuration) value was specified, dummy!".

<Import
Project="$(MSBuildThisFileDirectory)Configuration.Override.props"
Condition="Exists('$(MSBuildThisFileDirectory)Configuration.Override.props')"
/>
<Import
Project="$(MSBuildThisFileDirectory)bin\Build$(Configuration)\JdkInfo.props"
Condition="Exists('$(MSBuildThisFileDirectory)bin\Build$(Configuration)\JdkInfo.props')"
/>
<Import
Project="$(MSBuildThisFileDirectory)bin\Build$(Configuration)\MonoInfo.props"
Condition="Exists('$(MSBuildThisFileDirectory)bin\Build$(Configuration)\MonoInfo.props')"
/>
<PropertyGroup>
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPath)' == '' ">$(MSBuildThisFileDirectory)bin\$(Configuration)\</UtilityOutputFullPath>
</PropertyGroup>
</Project>
57 changes: 53 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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. :-(
Expand Down Expand Up @@ -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 `<Import/>`ed by
[`Configuration.props`](Configuration.props); there is no need to `<Import/>`
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]
Expand Down
4 changes: 2 additions & 2 deletions build-tools/scripts/jdk.mk
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ bin/Build$(CONFIGURATION)/JdkInfo.props: $(JI_JDK_INCLUDE_PATHS) $(JI_JVM_PATH)
-rm "$@"
echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' > "$@"
echo ' <PropertyGroup>' >> "$@"
echo " <JdkJvmPath>$(JI_JVM_PATH)</JdkJvmPath>" >> "$@"
echo " <JdkJvmPath Condition=\" '\$$(JdkJvmPath)' == '' \">$(JI_JVM_PATH)</JdkJvmPath>" >> "$@"
echo ' </PropertyGroup>' >> "$@"
echo ' <ItemGroup>' >> "$@"
for p in $(JI_JDK_INCLUDE_PATHS); do \
echo " <JdkIncludePath Include=\"$$p\" />" >> "$@"; \
echo " <JdkIncludePath Condition=\" '\$$(JdkJvmPath)' == '' \" Include=\"$$p\" />" >> "$@"; \
done
echo ' </ItemGroup>' >> "$@"
echo '</Project>' >> "$@"
6 changes: 3 additions & 3 deletions build-tools/scripts/mono.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ bin/Build$(CONFIGURATION)/MonoInfo.props: $(JI_MONO_INCLUDE_PATHS) $(JI_MONO_FRA
-rm "$@"
echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' > "$@"
echo ' <PropertyGroup>' >> "$@"
echo " <MonoFrameworkPath>$(JI_MONO_FRAMEWORK_PATH)</MonoFrameworkPath>" >> "$@"
echo ' <MonoLibs>$(JI_MONO_LIBS)</MonoLibs>'
echo " <MonoFrameworkPath Condition=\" '\$$(MonoFrameworkPath)' == '' \">$(JI_MONO_FRAMEWORK_PATH)</MonoFrameworkPath>" >> "$@"
echo " <MonoLibs Condition=\" '\$$(MonoLibs)' == '' \">$(JI_MONO_LIBS)</MonoLibs>" >> "$@"
echo ' </PropertyGroup>' >> "$@"
echo ' <ItemGroup>' >> "$@"
for p in $(JI_MONO_INCLUDE_PATHS); do \
echo " <MonoIncludePath Include=\"$$p\" />" >> "$@"; \
echo " <MonoIncludePath Condition=\" '\$$(MonoFrameworkPath)' == '' \" Include=\"$$p\" />" >> "$@"; \
done
echo ' </ItemGroup>' >> "$@"
echo '</Project>' >> "$@"
5 changes: 3 additions & 2 deletions tools/class-parse/class-parse.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="..\..\Configuration.props" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\bin\Debug</OutputPath>
<OutputPath>$(UtilityOutputFullPath)</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -26,7 +27,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\bin\Release</OutputPath>
<OutputPath>$(UtilityOutputFullPath)</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
Expand Down
5 changes: 3 additions & 2 deletions tools/generator/generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
</EnvironmentVariables>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<Import Project="..\..\Configuration.props" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
<OutputPath>..\..\bin\Debug</OutputPath>
<OutputPath>$(UtilityOutputFullPath)</OutputPath>
<DefineConstants>DEBUG;GENERATOR;USE_CECIL;JCW_ONLY_TYPE_NAMES</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -30,7 +31,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>False</Optimize>
<OutputPath>..\..\bin\Release</OutputPath>
<OutputPath>$(UtilityOutputFullPath)</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>True</Externalconsole>
Expand Down
5 changes: 3 additions & 2 deletions tools/logcat-parse/logcat-parse.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<StartupObject>Xamarin.Android.Tools.LogcatParse.Program</StartupObject>
</PropertyGroup>
<Import Project="..\..\Configuration.props" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\bin\Debug</OutputPath>
<OutputPath>$(UtilityOutputFullPath)</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -26,7 +27,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\bin\Release</OutputPath>
<OutputPath>$(UtilityOutputFullPath)</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand Down