Skip to content

Commit 3e998b2

Browse files
pjcollinsjonpryor
authored andcommitted
[build] Add support for commercial builds (#2845)
Fixes: https://github.com/xamarin/monodroid/issues/800 Context: https://github.com/xamarin/monodroid/commit/bee5f69a0b41aaeb88fad86ce4d65960a959def9 When the Mono team works on a PR to bump mono (e.g. [PR 1536][0]), they need to deal with two different build systems: 1. The xamarin-android build system, and 2. The monodroid build system. Shocking as this may sound, the OSS xamarin-android build system gets more love from the Xamarin.Android team than the commercial monodroid build system. As such, the monodroid build system is "baroque", not well tested off of a limited number of machines, prone to peculiar breakages, and otherwise adds a level of complexity and annoyance that everyone would rather do without. Unfortunately, *because* the monodroid repo is private, we can't have the xamarin-android repo contain a "proper" git submodule to it, as that would break all external contributors. Thus, historically, the monodroid repo instead had a git submodule reference to the xamarin-android repo, which brings a *different* set of problems, e.g. the commercial builds are *always* older than the OSS builds, and accidental breakage is caught much later than we'd like. The solution? For commercial builds, instead of "starting with" the monodroid repo, which submodules xamarin-android and (not-always- correctly) builds xamarin-android, we instead have the xamarin-android repo "reference" the monodroid repo, and have "hooks" in the xamarin-android build system so that monodroid can be built *from xamarin-android*. This will simplify life for the Mono team, allow for (hopefully) easier and more frequent commercial builds, simplify integration testing of commercial builds, and hopefully result in fewer apologies from @jonpryor about monodroid builds. Now, about that "reference": if we can't use git submodules to link the monodroid repo to the xamarin-android repo, how do we maintain that reference? ~~ .external ~~ There is a (seldom-used) convention among some Xamarin projects: the [`.external`][1] file. This is a plain-text file which allows specifying external dependencies. Blank lines and lines beginning with `#` are ignored, as well as lines which don't match a valid format. The external dependency reference format is: $(RepoOwner)/$(RepoName):$(BranchName)@$(CommitHash) We will use the `.external` file in order to link a specific monodroid commit to the xamarin-android build. This file *may* be used in the future for mono, as part of the [Mono Archive][2] work. The new `make prepare-external-git-dependencies` rule will clone all git submodule references listed in the `.external` file. This rule indirectly uses the new `external-git-dependencies.targets` MSBuild file, which exposes two new targets: * `ParseExternalFile`: Parses `.external` and creates the `@(Externals)` item group, which contains item metadata: * `%(Owner)`: The GitHub owner/organization * `%(Name)`: The git repo name * `%(Branch)`: The git repo branch * `%(Identity)`: The git commit in the repo * `CheckoutExternalGitDependency`: Clones or updates the git repos specified in `@(Externals)` into `$(ExternalSourceDependencyDirectory)`, which defaults to the top-level `external` directory. The new `<ParseExternalGitDependencies/>` task which is used by the `ParseExternalFile` target, while the new `<CheckoutExternalGitDependency/>` task is used by the `CheckoutExternalGitDependency` target. `external-git-dependencies.target` is `<Import/>`ed by `xa-prep-tasks.csproj` to allow us to easily checkout, download, and process the `.external` file. ~~ Build system hooks ~~ The `make jenkins` target has been turned into a [double-colon rule][3], which allows the `make jenkins` target to be specified multiple times, in multiple files, separately. There is also now an optional [**make** `include`][4] to `external/monodroid/xa-integration.mk`. `monodroid/xa-integration.mk` overrides the `make jenkins` target so that it can integrate it's build into the xamarin-android build. ~~ Installers ~~ `OpenTK.dll` and it's related files have been removed from the installers, in an effort to start reducing the interdependencies between the monodroid & xamarin-android repos. Finally, add a way to override a portion of our installer filenames, while still using version information from xamarin-android, by setting `$(UseCommercialInstallerName)`=True. [0]: #1836 [1]: https://github.com/xamarin/external [2]: https://github.com/xamarin/xamarin-android/projects/10 [3]: https://www.gnu.org/software/make/manual/html_node/Double_002dColon.html [4]: https://www.gnu.org/software/make/manual/html_node/Include.html
1 parent 09d8c58 commit 3e998b2

File tree

18 files changed

+227
-22
lines changed

18 files changed

+227
-22
lines changed

.external

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
xamarin/monodroid:master@97e4c3035f953076bd07f7737810810804d996db

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ apk-sizes-*.txt
2121
*.binlog
2222
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props
2323
*~
24+
external/monodroid/

Documentation/building/unix/instructions.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ can also be used by setting the `$(MSBUILD)` make variable to `xbuild`.
1616

1717
4. (Optional) [Configure the build](../configuration.md).
1818

19-
5. Prepare the project:
19+
5. (Optional) Prepare external/proprietary git dependencies
20+
21+
make prepare-external-git-dependencies
22+
23+
This will clone or update a monodroid checkout in `external` and
24+
ensure that subsequent `prepare` and `make` invocations will build
25+
proprietary components.
26+
27+
6. Prepare the project:
2028

2129
make prepare
2230
# -or-
@@ -26,7 +34,7 @@ can also be used by setting the `$(MSBUILD)` make variable to `xbuild`.
2634
`git submodule update`, download NuGet dependencies, and other
2735
"preparatory" and pre-build tasks that need to be performed.
2836

29-
6. Build the project:
37+
7. Build the project:
3038

3139
make
3240
# -or-
@@ -46,6 +54,17 @@ can also be used by setting the `$(MSBUILD)` make variable to `xbuild`.
4654
make jenkins MSBUILD=msbuild
4755

4856

57+
# Creating installers
58+
59+
Once `make all` or `make jenkins` have completed, macOS (.pkg)
60+
and Windows (.vsix) installer files can be built with:
61+
62+
make create-installers
63+
64+
Commercial installers will be created by this command if the
65+
`make prepare-external-git-dependencies` command was ran before building.
66+
67+
4968
# Building Unit Tests
5069

5170
Once `make all` or `make jenkins` have completed, the unit tests may

Documentation/building/windows/instructions.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,21 @@ MSBuild version 15 or later is required.
1818

1919
4. (Optional) [Configure the build](../configuration.md).
2020

21-
5. In a [Developer Command Prompt][developer-prompt], prepare the project:
21+
5. (Optional) In a [Developer Command Prompt][developer-prompt], prepare external git dependencies:
22+
23+
msbuild Xamarin.Android.sln /t:PrepareExternal
24+
25+
This will configure external proprietary components such as monodroid.
26+
27+
6. In a [Developer Command Prompt][developer-prompt], prepare the project:
2228

2329
msbuild Xamarin.Android.sln /t:Prepare
2430

2531
This will ensure that the build dependencies are installed, perform
2632
`git submodule update`, download NuGet dependencies, and other
2733
"preparatory" and pre-build tasks that need to be performed.
2834

29-
6. Build the project:
35+
7. Build the project:
3036

3137
msbuild Xamarin.Android.sln
3238

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,17 @@ THIRD_PARTY_NOTICE_LICENSE_TYPE = microsoft-oss
203203
$(eval $(call CREATE_THIRD_PARTY_NOTICES_RULE,ThirdPartyNotices.txt,foundation,False,False))
204204
$(eval $(call CREATE_THIRD_PARTY_NOTICES_RULE,bin/$(CONFIGURATION)/lib/xamarin.android/ThirdPartyNotices.txt,$(THIRD_PARTY_NOTICE_LICENSE_TYPE),True,False))
205205

206+
# Used by External XA Build
207+
EXTERNAL_XA_PATH=$(topdir)
208+
EXTERNAL_GIT_PATH=$(topdir)/external
209+
210+
prepare-external-git-dependencies:
211+
$(call MSBUILD_BINLOG,prep-external-tasks) build-tools/xa-prep-tasks/xa-prep-tasks.csproj
212+
$(call MSBUILD_BINLOG,prep-external-checkout) build-tools/xa-prep-tasks/xa-prep-tasks.csproj \
213+
/t:CheckoutExternalGitSources /p:ExternalSourceDependencyDirectory='$(EXTERNAL_GIT_PATH)'
214+
215+
-include $(EXTERNAL_GIT_PATH)/monodroid/xa-integration.mk
216+
206217
run-all-tests:
207218
@echo "PRINTING MONO VERSION"
208219
mono --version

build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,17 @@
5858
<Compile Include="Xamarin.Android.Tools.BootstrapTasks\KillProcess.cs" />
5959
<Compile Include="Xamarin.Android.Tools.BootstrapTasks\RunUITests.cs" />
6060
<Compile Include="Xamarin.Android.Tools.BootstrapTasks\RunInstrumentationTests.cs" />
61+
<Compile Include="Xamarin.Android.Tools.BootstrapTasks\JdkInfo.cs" />
6162
</ItemGroup>
6263
<ItemGroup>
6364
<ProjectReference Include="..\xa-prep-tasks\xa-prep-tasks.csproj">
6465
<Project>{7CE69551-BD73-4726-ACAA-AAF89C84BAF8}</Project>
6566
<Name>xa-prep-tasks</Name>
6667
</ProjectReference>
68+
<ProjectReference Include="..\..\external\xamarin-android-tools\src\Xamarin.Android.Tools.AndroidSdk\Xamarin.Android.Tools.AndroidSdk.csproj">
69+
<Project>{E34BCFA0-CAA4-412C-AA1C-75DB8D67D157}</Project>
70+
<Name>Xamarin.Android.Tools.AndroidSdk</Name>
71+
</ProjectReference>
6772
</ItemGroup>
6873
<Import Project="..\scripts\libzip-references.projitems" />
6974
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/JdkInfo.cs renamed to build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/JdkInfo.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
using System.IO;
88
using System.Linq;
99
using System.Text;
10-
using Xamarin.Android.Tools;
1110

12-
namespace Xamarin.Android.BuildTools.PrepTasks
11+
namespace Xamarin.Android.Tools.BootstrapTasks
1312
{
1413
public class JdkInfo : Task
1514
{
@@ -40,7 +39,7 @@ public override bool Execute ()
4039
} else {
4140
maxVersion = new Version (MaxJdkVersion);
4241
}
43-
42+
4443
var defaultJdk = new [] { new Tools.JdkInfo (androidSdk.JavaSdkPath) };
4544
var jdk = defaultJdk.Concat (Tools.JdkInfo.GetKnownSystemJdkInfos (logger))
4645
.Where (j => maxVersion != null ? j.Version <= maxVersion : true)

build-tools/create-pkg/create-pkg.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<AssemblyName>create-pkg</AssemblyName>
1010
<OutputPath>..\..\bin\Build$(Configuration)</OutputPath>
1111
</PropertyGroup>
12-
<Import Project="..\..\Configuration.props" />
12+
<Import Project="create-pkg.targets" />
1313
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1414
<DebugSymbols>true</DebugSymbols>
1515
<DebugType>full</DebugType>
@@ -29,5 +29,4 @@
2929
<None Include="distribution.xml.in" />
3030
</ItemGroup>
3131
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
32-
<Import Project="create-pkg.targets" />
3332
</Project>

build-tools/create-pkg/create-pkg.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
DependsOnTargets="_FinalizePayload">
116116
<MakeDir Directories="$(PkgOutputPath)"/>
117117
<PropertyGroup>
118+
<PkgProductOutputPath Condition="'$(UseCommercialInstallerName)' == 'True'">$(OutputPath)xamarin.android-$(XAVersion).pkg</PkgProductOutputPath>
118119
<PkgProductOutputPath Condition="'$(PkgProductOutputPath)' == ''">$(OutputPath)Xamarin.Android.Sdk-$(XAOSSInstallerSuffix).pkg</PkgProductOutputPath>
119120
</PropertyGroup>
120121
<ItemGroup>
@@ -133,5 +134,6 @@
133134
<ProductBuildArgs Include="&quot;$(PkgProductOutputPath)&quot;" />
134135
</ItemGroup>
135136
<Exec Command="productbuild @(ProductBuildArgs, ' ')" />
137+
<RemoveDir Directories="$(OutputPath)\pkg"/>
136138
</Target>
137139
</Project>

build-tools/create-vsix/create-vsix.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
<Target Name="_GetVsixPath"
8484
DependsOnTargets="GetXAVersionInfo">
8585
<PropertyGroup>
86+
<VsixPath Condition=" '$(UseCommercialInstallerName)' == 'True' ">..\..\bin\Build$(Configuration)\$(AssemblyName)-$(XAVersion).vsix</VsixPath>
8687
<VsixPath Condition=" '$(VsixPath)' == '' ">..\..\bin\Build$(Configuration)\$(AssemblyName)-$(XAOSSInstallerSuffix).vsix</VsixPath>
8788
<_VsixDir>$([System.IO.Path]::GetDirectoryName ($(VsixPath)))</_VsixDir>
8889
</PropertyGroup>

0 commit comments

Comments
 (0)