Skip to content

Commit e8ae026

Browse files
committed
Xamarin.Android build preparation utility
Testing: * Default mode: run `make bootstrap` * Verbose debug: run `make V=1 bootstrap` * CI mode: run `make BOOTSTRAP_CI=1 bootstrap` * Help: run `make bootstrap-help` * Logs: `bin/BuildDebug/logs/` Supported operating systems: * macOS * Linux Windows support is planned, present but not fully implemented or tested. This commit implements a `make prepare` replacement that does not rely on shell scripts or MSBuild. The idea is that a standalone C# program can perform all the steps in a more streamlined, more clear way than the current solution. One of the main goals is to make the process more approachable by external contributors, but also by the core developers who may want to change some aspects of XA build preparation (e.g. Android platforms, Mono version etc) but are not familiar with the build system. Towards that goal, the codebase is designed so that the minimum amount of searching around it is necessary to figure out where to make the desired change. Main location serving this purpose is the `build-tools/xabootstrap/xabootstrap/ConfigAndData` directory. It should be the *only* location where one needs to look in order to change all and any aspects of XA preparation. [TBC]
1 parent 8b23410 commit e8ae026

File tree

195 files changed

+15103
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+15103
-212
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
/build-tools/manifest-attribute-codegen @jonpryor
2121
/build-tools/scripts/PrepareWindows.targets @jonathanpeppers
2222
/build-tools/timing @jonathanpeppers @radekdoulik
23+
/build-tools/xabootstrap @grendello
2324

2425
/src/OpenTK-1.0 @radekdoulik @jonpryor
2526
/src/Mono.Android.Export @jonpryor

Configuration.props

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,16 @@
3838
<AndroidUseLatestPlatformSdk Condition=" '$(AndroidFrameworkVersion)' == '' And '$(_IsRunningNuGetRestore)' == 'True' ">True</AndroidUseLatestPlatformSdk>
3939
<DebugType Condition=" '$(DebugType)' == '' ">portable</DebugType>
4040
</PropertyGroup>
41+
<PropertyGroup Condition=" '$(HostOS)' == '' ">
42+
<HostOS Condition="$([MSBuild]::IsOSPlatform('windows'))">Windows</HostOS>
43+
<HostOS Condition="$([MSBuild]::IsOSPlatform('linux'))">Linux</HostOS>
44+
<HostOS Condition="$([MSBuild]::IsOSPlatform('osx'))">Darwin</HostOS>
45+
</PropertyGroup>
4146
<PropertyGroup>
4247
<AutoProvision Condition=" '$(AutoProvision)' == '' ">False</AutoProvision>
4348
<AutoProvisionUsesSudo Condition=" '$(AutoProvisionUsesSudo)' == '' ">False</AutoProvisionUsesSudo>
4449
<XAInstallPrefix Condition=" '$(XAInstallPrefix)' == '' ">$(MSBuildThisFileDirectory)bin\$(Configuration)\lib\xamarin.android\</XAInstallPrefix>
4550
<MingwDependenciesRootDirectory Condition=" '$(MingwDependenciesRootDirectory)' == '' ">$(MSBuildThisFileDirectory)\bin\Build$(Configuration)\mingw-deps</MingwDependenciesRootDirectory>
46-
<HostOS Condition=" '$(HostOS)' == '' And '$(OS)' == 'Windows_NT' ">Windows</HostOS>
4751
<HostCc Condition=" '$(HostCc)' == '' ">$(HostCc64)</HostCc>
4852
<HostCxx Condition=" '$(HostCxx)' == '' ">$(HostCxx64)</HostCxx>
4953
<HostCc Condition=" '$(HostCc)' == '' ">$(HostCc32)</HostCc>
@@ -171,7 +175,8 @@
171175
<AndroidSupportedTargetAotAbisSplit>$(AndroidSupportedTargetAotAbis.Split(':'))</AndroidSupportedTargetAotAbisSplit>
172176
</PropertyGroup>
173177
<PropertyGroup>
174-
<RemapAssemblyRefTool>$(ManagedRuntime) $(ManagedRuntimeArgs) &quot;$(MSBuildThisFileDirectory)bin\Build$(Configuration)\remap-assembly-ref.exe&quot;</RemapAssemblyRefTool>
178+
<RemapAssemblyRefToolExecutable>$(MSBuildThisFileDirectory)bin\Build$(Configuration)\remap-assembly-ref.exe</RemapAssemblyRefToolExecutable>
179+
<RemapAssemblyRefTool>$(ManagedRuntime) $(ManagedRuntimeArgs) &quot;$(RemapAssemblyRefToolExecutable)&quot;</RemapAssemblyRefTool>
175180
</PropertyGroup>
176181

177182
<!-- Unit Test Properties -->

Makefile

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,59 @@
1-
export OS_NAME := $(shell uname)
2-
export OS_ARCH := $(shell uname -m)
3-
export NO_SUDO ?= false
41
V ?= 0
52
prefix = /usr/local
63
CONFIGURATION = Debug
74
RUNTIME := $(shell which mono64 2> /dev/null && echo mono64 || echo mono) --debug=casts
85
SOLUTION = Xamarin.Android.sln
96
TEST_TARGETS = build-tools/scripts/RunTests.targets
107
API_LEVEL ?=
8+
BOOTSTRAP_ARGS =
9+
BOOTSTRAP_BUILD_LOG = bin/Build$(CONFIGURATION)/logs/bootstrap-build.binlog
10+
BOOTSTRAP_SOURCE_DIR = build-tools/xabootstrap
11+
BOOTSTRAP_SOLUTION = $(BOOTSTRAP_SOURCE_DIR)/xabootstrap.sln
12+
BOOTSTRAP_EXE = $(BOOTSTRAP_SOURCE_DIR)/xabootstrap/bin/$(CONFIGURATION)/xabootstrap.exe
13+
BOOTSTRAP_MSBUILD_ARGS = /p:Configuration=$(CONFIGURATION) /binaryLogger:"$(BOOTSTRAP_BUILD_LOG)"
14+
BOOTSTRAP_CI ?= 0
1115

12-
ifeq ($(OS_NAME),Darwin)
13-
export MACOSX_DEPLOYMENT_TARGET := 10.11
14-
HOMEBREW_PREFIX ?= $(shell brew --prefix)
15-
else
16-
HOMEBREW_PREFIX := $prefix
16+
-include bin/Build$(CONFIGURATION)/rules.mk
17+
18+
ifeq ($(OS_NAME),)
19+
export OS_NAME := $(shell uname)
20+
endif
21+
22+
ifeq ($(OS_ARCH),)
23+
export OS_ARCH := $(shell uname -m)
24+
endif
25+
26+
export NO_SUDO ?= false
27+
28+
ifneq ($(NO_SUDO),false)
29+
BOOTSTRAP_ARGS += --no-sudo
1730
endif
1831

1932
ifneq ($(V),0)
2033
MONO_OPTIONS += --debug
2134
NUGET_VERBOSITY = -Verbosity Detailed
35+
BOOTSTRAP_ARGS += -v:d
2236
endif
2337

24-
ifneq ($(MONO_OPTIONS),)
25-
export MONO_OPTIONS
38+
ifneq($(BOOTSTRAP_CI),0)
39+
BOOTSTRAP_ARGS += --no-sudo --no-emoji --run-mode=CI
40+
endif
41+
42+
ifeq ($(OS_NAME),Darwin)
43+
44+
ifeq ($(MACOSX_DEPLOYMENT_TARGET),)
45+
export MACOSX_DEPLOYMENT_TARGET := 10.11
46+
endif
47+
48+
ifeq ($(HOMEBREW_PREFIX),)
49+
HOMEBREW_PREFIX ?= $(shell brew --prefix)
50+
endif
51+
else
52+
HOMEBREW_PREFIX := $prefix
53+
endif
54+
55+
ifeq ($(wildcard Configuration.OperatingSystem.props),)
56+
BOOTSTRAP_MSBUILD_ARGS += "/p:HostHomebrewPrefix=$(HOMEBREW_PREFIX)"
2657
endif
2758

2859
include build-tools/scripts/msbuild.mk
@@ -257,3 +288,16 @@ list-nunit-tests:
257288
$(MSBUILD) $(MSBUILD_FLAGS) $(TEST_TARGETS) /t:ListNUnitTests
258289

259290
include build-tools/scripts/runtime-helpers.mk
291+
292+
.PHONY: bootstrap-build
293+
bootstrap-build:
294+
mkdir -p $(dir $(BOOTSTRAP_BUILD_LOG))
295+
msbuild $(BOOTSTRAP_MSBUILD_ARGS) $(BOOTSTRAP_SOLUTION)
296+
297+
bootstrap:
298+
$(MAKE) bootstrap-build
299+
mono --debug $(BOOTSTRAP_EXE) $(BOOTSTRAP_ARGS)
300+
301+
bootstrap-help:
302+
$(MAKE) bootstrap-build
303+
mono --debug $(BOOTSTRAP_EXE) -h

0 commit comments

Comments
 (0)