Skip to content

Commit 65a0157

Browse files
authored
Merge pull request #113 from jonpryor/jonp-msbuild
Support building with `msbuild`
2 parents 4273e5c + 146fe8d commit 65a0157

File tree

7 files changed

+55
-14
lines changed

7 files changed

+55
-14
lines changed

Makefile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
OS ?= $(shell uname)
22

3+
V ?= 0
34
CONFIGURATION = Debug
45

56
ifeq ($(OS),Darwin)
@@ -39,7 +40,6 @@ PTESTS = \
3940
ATESTS = \
4041
bin/Test$(CONFIGURATION)/Android.Interop-Tests.dll
4142

42-
XBUILD = xbuild $(if $(V),/v:diag,)
4343
NUNIT_CONSOLE = packages/NUnit.Runners.2.6.3/tools/nunit-console.exe
4444

4545
BUILD_PROPS = bin/Build$(CONFIGURATION)/JdkInfo.props bin/Build$(CONFIGURATION)/MonoInfo.props
@@ -57,12 +57,13 @@ prepare-external: $(PACKAGES) $(NUNIT_CONSOLE)
5757
git submodule update --init --recursive
5858

5959
clean:
60-
-$(XBUILD) /t:Clean
60+
-$(MSBUILD) $(MSBUILD_FLAGS) /t:Clean
6161
-rm -Rf bin/$(CONFIGURATION) bin/Build$(CONFIGURATION) bin/Test$(CONFIGURATION) bin/XAIntegration$(CONFIGURATION)
6262
-rm src/Java.Runtime.Environment/Java.Runtime.Environment.dll.config
6363

6464
include build-tools/scripts/mono.mk
6565
include build-tools/scripts/jdk.mk
66+
include build-tools/scripts/msbuild.mk
6667

6768
$(PACKAGES) $(NUNIT_CONSOLE):
6869
nuget restore
@@ -97,7 +98,7 @@ endif
9798
# Usage: $(call TestAssemblyTemplate,assembly-basename)
9899
define TestAssemblyTemplate
99100
bin/Test$$(CONFIGURATION)/$(1)-Tests.dll: $(wildcard src/$(1)/*/*.cs src/$(1)/Test*/*/*.cs)
100-
$$(XBUILD)
101+
$$(MSBUILD) $$(MSBUILD_FLAGS)
101102
touch $$@
102103
endef # TestAssemblyTemplate
103104

@@ -107,15 +108,15 @@ $(eval $(call TestAssemblyTemplate,Java.Interop.Export))
107108
$(eval $(call TestAssemblyTemplate,Java.Interop.Tools.JavaCallableWrappers))
108109

109110
bin/Test$(CONFIGURATION)/Java.Interop-PerformanceTests.dll: $(wildcard tests/Java.Interop-PerformanceTests/*.cs) bin/Test$(CONFIGURATION)/$(NATIVE_TIMING_LIB)
110-
$(XBUILD)
111+
$(MSBUILD) $(MSBUILD_FLAGS)
111112
touch $@
112113

113114
bin/Test$(CONFIGURATION)/Android.Interop-Tests.dll: $(wildcard src/Android.Interop/*/*.cs src/Android.Interop/Tests/*/*.cs)
114-
$(XBUILD)
115+
$(MSBUILD) $(MSBUILD_FLAGS)
115116
touch $@
116117

117118
bin/$(XA_CONFIGURATION)/Java.Interop.dll: $(wildcard src/Java.Interop/*/*.cs) src/Java.Interop/Java.Interop.csproj
118-
$(XBUILD) /p:Configuration=$(XA_CONFIGURATION) $(if $(SNK),"/p:AssemblyOriginatorKeyFile=$(SNK)",)
119+
$(MSBUILD) $(if $(V),/v:diag,) /p:Configuration=$(XA_CONFIGURATION) $(if $(SNK),"/p:AssemblyOriginatorKeyFile=$(SNK)",)
119120

120121
CSHARP_REFS = \
121122
bin/$(CONFIGURATION)/Java.Interop.dll \
@@ -150,7 +151,7 @@ bin/Test$(CONFIGURATION)/$(JAVA_INTEROP_LIB): bin/$(CONFIGURATION)/$(JAVA_INTERO
150151
cp $< $@
151152

152153
run-android: $(ATESTS)
153-
(cd src/Android.Interop/Tests; $(XBUILD) '/t:Install;RunTests' $(if $(FIXTURE),/p:TestFixture=$(FIXTURE)))
154+
(cd src/Android.Interop/Tests; $(MSBUILD) $(MSBUILD_FLAGS) '/t:Install;RunTests' $(if $(FIXTURE),/p:TestFixture=$(FIXTURE)))
154155

155156
run-test-jnimarshal: bin/Test$(CONFIGURATION)/Java.Interop.Export-Tests.dll bin/Test$(CONFIGURATION)/$(JAVA_INTEROP_LIB)
156157
MONO_TRACE_LISTENER=Console.Out \

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ on the command line or by specifying MSBuild properties to control behavior.
7676
The following **make**(1) variables may be specified:
7777

7878
* `$(CONFIGURATION)`: The product configuration to build, and corresponds
79-
to the `$(Configuration)` MSBuild property when running `$(XBUILD)`.
79+
to the `$(Configuration)` MSBuild property when running `$(MSBUILD)`.
8080
Valid values are `Debug` and `Release`. Default value is `Debug`.
8181
* `$(RUNTIME)`: The managed runtime to use to execute utilities, tests.
8282
Default value is `mono64` if present in `$PATH`, otherwise `mono`.
@@ -85,9 +85,9 @@ The following **make**(1) variables may be specified:
8585

8686
make run-tests TESTS=bin/Debug/Java.Interop.Dynamic-Tests.dll
8787

88-
* `$(V)`: If set to a non-empty string, adds `/v:diag` to `$(XBUILD)`
88+
* `$(V)`: If set to a non-empty string, adds `/v:diag` to `$(MSBUILD_FLAGS)`
8989
invocations.
90-
* `$(XBUILD)`: The MSBuild build tool to execute for builds.
90+
* `$(MSBUILD)`: The MSBuild build tool to execute for builds.
9191
Default value is `xbuild`.
9292

9393

build-tools/scripts/mono.mk

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#
66
# $(OS): Optional; **uname**(1) value of the host operating system
77
# $(CONFIGURATION): Build configuration name, e.g. Debug or Release
8+
# $(V): Output verbosity. If != 0, then `MONO_OPTIONS` is exported with --debug.
89
#
910
# Outputs:
1011
#
@@ -27,6 +28,14 @@
2728
OS ?= $(shell uname)
2829
RUNTIME := $(shell if [ -f "`which mono64`" ] ; then echo mono64 ; else echo mono; fi) --debug=casts
2930

31+
ifneq ($(V),0)
32+
MONO_OPTIONS += --debug
33+
endif # $(V) != 0
34+
35+
ifneq ($(MONO_OPTIONS),)
36+
export MONO_OPTIONS
37+
endif # $(MONO_OPTIONS) != ''
38+
3039
ifeq ($(OS),Darwin)
3140
JI_MONO_FRAMEWORK_PATH = /Library/Frameworks/Mono.framework/Libraries/libmonosgen-2.0.1.dylib
3241
JI_MONO_INCLUDE_PATHS = /Library/Frameworks/Mono.framework/Headers/mono-2.0

build-tools/scripts/msbuild.mk

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# MSBuild Abstraction.
3+
#
4+
# Makefile targets which need to invoke MSBuild should use `$(MSBUILD)`,
5+
# not some specific MSBuild program such as `xbuild` or `msbuild`.
6+
#
7+
# Typical use will also include `$(MSBUILD_FLAGS)`, which provides the
8+
# Configuration and logging verbosity, as per $(CONFIGURATION) and $(V):
9+
#
10+
# $(MSBUILD) $(MSBUILD_FLAGS) path/to/Project.csproj
11+
#
12+
# Inputs:
13+
#
14+
# $(CONFIGURATION): Build configuration name, e.g. Debug or Release
15+
# $(MSBUILD): The MSBuild program to use.
16+
# $(MSBUILD_ARGS): Extra arguments to pass to $(MSBUILD); embedded into $(MSBUILD_FLAGS)
17+
# $(V): Build verbosity
18+
#
19+
# Outputs:
20+
#
21+
# $(MSBUILD): The MSBuild program to use. Defaults to `xbuild` unless overridden.
22+
# $(MSBUILD_FLAGS): Additional MSBuild flags; contains $(CONFIGURATION), $(V), $(MSBUILD_ARGS).
23+
24+
MSBUILD = xbuild
25+
MSBUILD_FLAGS = /p:Configuration=$(CONFIGURATION) $(MSBUILD_ARGS)
26+
27+
ifneq ($(V),0)
28+
MSBUILD_FLAGS += /v:d
29+
endif # $(V) != 0

src/Xamarin.Android.Cecil/Xamarin.Android.Cecil.targets

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
<PropertyGroup>
44
<CecilDirectory>$(MSBuildThisFileDirectory)\..\..\external\cecil</CecilDirectory>
55
<CecilPreparedFlag>prepared.flag</CecilPreparedFlag>
6-
<OutputPath Condition=" '$(OutputPath)' == '' ">$(MSBuildThisFileDirectory)\..\..\bin\$(Configuration)</OutputPath>
7-
<CecilOutputPath>$([System.IO.Path]::GetFullPath ('$(OutputPath)'))</CecilOutputPath>
6+
<OutputPath Condition=" '$(OutputPath)' == '' ">..\..\bin\$(Configuration)</OutputPath>
7+
<CecilOutputPath>$([System.IO.Path]::Combine ($(MSBuildThisFileDirectory), $(OutputPath)))</CecilOutputPath>
8+
<CecilOutputPath>$([System.IO.Path]::GetFullPath ($(CecilOutputPath)))</CecilOutputPath>
89
<CecilAssemblies>$(OutputPath)\Xamarin.Android.Cecil.dll;$(OutputPath)\Xamarin.Android.Cecil.Mdb.dll</CecilAssemblies>
910
</PropertyGroup>
1011
<Target Name="PrepareCecil"

src/java-interop/java-interop.mdproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
Inputs="@(Compile)"
8282
Outputs="@(MacLibLipo)">
8383
<PropertyGroup>
84-
<_FixedDefines>$(DefineSymbols.Replace(' ', ';'))</_FixedDefines>
84+
<_FixedDefines>$(DefineSymbols.Split(' '))</_FixedDefines>
8585
</PropertyGroup>
8686
<ItemGroup>
8787
<_Defines Include="$(_FixedDefines)" />

tests/invocation-overhead/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ clean:
99

1010
include ../../build-tools/scripts/mono.mk
1111
include ../../build-tools/scripts/jdk.mk
12+
include ../../build-tools/scripts/msbuild.mk
1213

1314
$(JNIENV_GEN):
14-
(cd ../../build-tools/jnienv-gen ; xbuild /p:Configuration=$(CONFIGURATION))
15+
(cd ../../build-tools/jnienv-gen ; $(MSBUILD) $(MSBUILD_FLAGS) )
1516

1617
HANDLE_FEATURES = \
1718
-d:FEATURE_JNIENVIRONMENT_JI_INTPTRS \

0 commit comments

Comments
 (0)