Skip to content
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 .external
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
xamarin/monodroid:master@97e4c3035f953076bd07f7737810810804d996db
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ apk-sizes-*.txt
*.binlog
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props
*~
external/monodroid/
23 changes: 21 additions & 2 deletions Documentation/building/unix/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ can also be used by setting the `$(MSBUILD)` make variable to `xbuild`.

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

5. Prepare the project:
5. (Optional) Prepare external/proprietary git dependencies

make prepare-external-git-dependencies

This will clone or update a monodroid checkout in `external` and
ensure that subsequent `prepare` and `make` invocations will build
proprietary components.

6. Prepare the project:

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

6. Build the project:
7. Build the project:

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


# Creating installers

Once `make all` or `make jenkins` have completed, macOS (.pkg)
and Windows (.vsix) installer files can be built with:

make create-installers

Commercial installers will be created by this command if the
`make prepare-external-git-dependencies` command was ran before building.


# Building Unit Tests

Once `make all` or `make jenkins` have completed, the unit tests may
Expand Down
10 changes: 8 additions & 2 deletions Documentation/building/windows/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,21 @@ MSBuild version 15 or later is required.

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

5. In a [Developer Command Prompt][developer-prompt], prepare the project:
5. (Optional) In a [Developer Command Prompt][developer-prompt], prepare external git dependencies:

msbuild Xamarin.Android.sln /t:PrepareExternal

This will configure external proprietary components such as monodroid.

6. In a [Developer Command Prompt][developer-prompt], prepare the project:

msbuild Xamarin.Android.sln /t:Prepare

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

6. Build the project:
7. Build the project:

msbuild Xamarin.Android.sln

Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,17 @@ THIRD_PARTY_NOTICE_LICENSE_TYPE = microsoft-oss
$(eval $(call CREATE_THIRD_PARTY_NOTICES_RULE,ThirdPartyNotices.txt,foundation,False,False))
$(eval $(call CREATE_THIRD_PARTY_NOTICES_RULE,bin/$(CONFIGURATION)/lib/xamarin.android/ThirdPartyNotices.txt,$(THIRD_PARTY_NOTICE_LICENSE_TYPE),True,False))

# Used by External XA Build
EXTERNAL_XA_PATH=$(topdir)
EXTERNAL_GIT_PATH=$(topdir)/external

prepare-external-git-dependencies:
$(call MSBUILD_BINLOG,prep-external-tasks) build-tools/xa-prep-tasks/xa-prep-tasks.csproj
$(call MSBUILD_BINLOG,prep-external-checkout) build-tools/xa-prep-tasks/xa-prep-tasks.csproj \
/t:CheckoutExternalGitSources /p:ExternalSourceDependencyDirectory='$(EXTERNAL_GIT_PATH)'

-include $(EXTERNAL_GIT_PATH)/monodroid/xa-integration.mk

run-all-tests:
@echo "PRINTING MONO VERSION"
mono --version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,17 @@
<Compile Include="Xamarin.Android.Tools.BootstrapTasks\KillProcess.cs" />
<Compile Include="Xamarin.Android.Tools.BootstrapTasks\RunUITests.cs" />
<Compile Include="Xamarin.Android.Tools.BootstrapTasks\RunInstrumentationTests.cs" />
<Compile Include="Xamarin.Android.Tools.BootstrapTasks\JdkInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\xa-prep-tasks\xa-prep-tasks.csproj">
<Project>{7CE69551-BD73-4726-ACAA-AAF89C84BAF8}</Project>
<Name>xa-prep-tasks</Name>
</ProjectReference>
<ProjectReference Include="..\..\external\xamarin-android-tools\src\Xamarin.Android.Tools.AndroidSdk\Xamarin.Android.Tools.AndroidSdk.csproj">
<Project>{E34BCFA0-CAA4-412C-AA1C-75DB8D67D157}</Project>
<Name>Xamarin.Android.Tools.AndroidSdk</Name>
</ProjectReference>
</ItemGroup>
<Import Project="..\scripts\libzip-references.projitems" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
using System.IO;
using System.Linq;
using System.Text;
using Xamarin.Android.Tools;

namespace Xamarin.Android.BuildTools.PrepTasks
namespace Xamarin.Android.Tools.BootstrapTasks
{
public class JdkInfo : Task
{
Expand Down Expand Up @@ -40,7 +39,7 @@ public override bool Execute ()
} else {
maxVersion = new Version (MaxJdkVersion);
}

var defaultJdk = new [] { new Tools.JdkInfo (androidSdk.JavaSdkPath) };
var jdk = defaultJdk.Concat (Tools.JdkInfo.GetKnownSystemJdkInfos (logger))
.Where (j => maxVersion != null ? j.Version <= maxVersion : true)
Expand Down
3 changes: 1 addition & 2 deletions build-tools/create-pkg/create-pkg.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AssemblyName>create-pkg</AssemblyName>
<OutputPath>..\..\bin\Build$(Configuration)</OutputPath>
</PropertyGroup>
<Import Project="..\..\Configuration.props" />
<Import Project="create-pkg.targets" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
Expand All @@ -29,5 +29,4 @@
<None Include="distribution.xml.in" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="create-pkg.targets" />
</Project>
2 changes: 2 additions & 0 deletions build-tools/create-pkg/create-pkg.targets
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
DependsOnTargets="_FinalizePayload">
<MakeDir Directories="$(PkgOutputPath)"/>
<PropertyGroup>
<PkgProductOutputPath Condition="'$(UseCommercialInstallerName)' == 'True'">$(OutputPath)xamarin.android-$(XAVersion).pkg</PkgProductOutputPath>
<PkgProductOutputPath Condition="'$(PkgProductOutputPath)' == ''">$(OutputPath)Xamarin.Android.Sdk-$(XAOSSInstallerSuffix).pkg</PkgProductOutputPath>
</PropertyGroup>
<ItemGroup>
Expand All @@ -133,5 +134,6 @@
<ProductBuildArgs Include="&quot;$(PkgProductOutputPath)&quot;" />
</ItemGroup>
<Exec Command="productbuild @(ProductBuildArgs, ' ')" />
<RemoveDir Directories="$(OutputPath)\pkg"/>
</Target>
</Project>
1 change: 1 addition & 0 deletions build-tools/create-vsix/create-vsix.targets
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<Target Name="_GetVsixPath"
DependsOnTargets="GetXAVersionInfo">
<PropertyGroup>
<VsixPath Condition=" '$(UseCommercialInstallerName)' == 'True' ">..\..\bin\Build$(Configuration)\$(AssemblyName)-$(XAVersion).vsix</VsixPath>
<VsixPath Condition=" '$(VsixPath)' == '' ">..\..\bin\Build$(Configuration)\$(AssemblyName)-$(XAOSSInstallerSuffix).vsix</VsixPath>
<_VsixDir>$([System.IO.Path]::GetDirectoryName ($(VsixPath)))</_VsixDir>
</PropertyGroup>
Expand Down
4 changes: 1 addition & 3 deletions build-tools/installers/create-installers.targets
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<LibExtension Condition=" '$(HostOS)' == 'Linux' ">so</LibExtension>
<LibExtension Condition=" '$(HostOS)' == 'Windows' ">dll</LibExtension>
<IncludeMonoBundleComponents Condition="'$(IncludeMonoBuildComponents)' == ''">True</IncludeMonoBundleComponents>
<UseCommercialInstallerName Condition="'$(UseCommercialInstallerName)' == ''">False</UseCommercialInstallerName>
</PropertyGroup>
<ItemGroup>
<_FrameworkFiles Include="$(FrameworkSrcDir)\$(FirstInstallerFrameworkVersion)\AndroidApiInfo.xml" />
Expand Down Expand Up @@ -189,9 +190,6 @@
</ItemGroup>
<!-- monodroid -->
<ItemGroup Condition="Exists('$(MSBuildSrcDir)\Mono.Android.DebugRuntime-debug.apk')">
<_FrameworkFiles Include="$(FrameworkSrcDir)\$(FirstInstallerFrameworkVersion)\OpenTK.dll" />
<_FrameworkFiles Include="$(FrameworkSrcDir)\$(FirstInstallerFrameworkVersion)\OpenTK.pdb" />
<_FrameworkFilesWin Include="$(FrameworkSrcDir)\$(FirstInstallerFrameworkVersion)\OpenTK.xml" />
<_FrameworkFilesWin Include="$(FrameworkSrcDir)\$(FirstInstallerFrameworkVersion)\Mono.Android.xml" />
<_FrameworkFilesWin Include="$(FrameworkSrcDir)\v4.4.87\Mono.Android.xml" />
<_FrameworkFilesWin Include="$(FrameworkSrcDir)\v5.0\Mono.Android.xml" />
Expand Down
2 changes: 1 addition & 1 deletion build-tools/scripts/BuildEverything.mk
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ _MSBUILD_ARGS = \
.PHONY: leeroy jenkins leeroy-all opentk-jcw framework-assemblies
.PHONY: create-vsix

jenkins: prepare leeroy $(ZIP_OUTPUT)
jenkins:: prepare leeroy $(ZIP_OUTPUT)

leeroy: leeroy-all framework-assemblies opentk-jcw

Expand Down
2 changes: 2 additions & 0 deletions build-tools/scripts/Packaging.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ create-pkg:
$(if $(PACKAGE_VERSION_REV),/p:XAVersionCommitCount="$(PACKAGE_VERSION_REV)") \
$(if $(PKG_LICENSE_EN),/p:PkgLicenseSrcEn="$(PKG_LICENSE_EN)") \
$(if $(PKG_OUTPUT_PATH),/p:PkgProductOutputPath="$(PKG_OUTPUT_PATH)") \
$(if $(USE_COMMERCIAL_INSTALLER_NAME),/p:UseCommercialInstallerName="$(USE_COMMERCIAL_INSTALLER_NAME)") \
$(if $(_MSBUILD_ARGS),"$(_MSBUILD_ARGS)")

create-vsix:
Expand All @@ -28,6 +29,7 @@ create-vsix:
$(if $(PACKAGE_HEAD_BRANCH),/p:XAVersionBranch="$(PACKAGE_HEAD_BRANCH)") \
$(if $(PACKAGE_VERSION_REV),/p:XAVersionCommitCount="$(PACKAGE_VERSION_REV)") \
$(if $(COMMIT),/p:XAVersionHash="$(COMMIT)") \
$(if $(USE_COMMERCIAL_INSTALLER_NAME),/p:UseCommercialInstallerName="$(USE_COMMERCIAL_INSTALLER_NAME)") \
$(if $(_MSBUILD_ARGS),"$(_MSBUILD_ARGS)")

package-oss-name:
Expand Down
7 changes: 6 additions & 1 deletion build-tools/scripts/PrepareWindows.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
<_NuGetVerbosity>-Verbosity Detailed</_NuGetVerbosity>
</PropertyGroup>
<Import Project="$(_TopDir)\Configuration.props" />
<UsingTask AssemblyFile="$(_TopDir)\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.JdkInfo" />
<UsingTask AssemblyFile="$(_TopDir)\bin\Build$(Configuration)\Xamarin.Android.Tools.BootstrapTasks.dll" TaskName="Xamarin.Android.Tools.BootstrapTasks.JdkInfo" />
<UsingTask AssemblyFile="$(_TopDir)\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.ReplaceFileContents" />
<Target Name="PrepareExternal">
<MSBuild Projects="$(MSBuildThisFileDirectory)..\xa-prep-tasks\xa-prep-tasks.csproj" />
<MSBuild Projects="$(MSBuildThisFileDirectory)..\xa-prep-tasks\xa-prep-tasks.csproj" Targets="CheckoutExternalGitSources"/>
</Target>
<Target Name="Prepare">
<Error
Text="The specified `%24(AndroidToolchainDirectory)` '$(AndroidToolchainDirectory)' contains a space. Android NDK commands do not support this. Please create a Configuration.Override.props file that sets the AndroidToolchainDirectory property to a different path."
Expand Down Expand Up @@ -37,6 +41,7 @@
WorkingDirectory="$(_TopDir)"
IgnoreStandardErrorWarningFormat="True"
/>
<MSBuild Projects="$(MSBuildThisFileDirectory)..\Xamarin.Android.Tools.BootstrapTasks\Xamarin.Android.Tools.BootstrapTasks.csproj" />
<MSBuild Projects="tests\Xamarin.Forms-Performance-Integration\Xamarin.Forms.Performance.Integration.csproj" Targets="Restore" />
<MSBuild Projects="$(MSBuildThisFileDirectory)..\android-toolchain\android-toolchain.csproj" />
<!--NOTE: need to restore test sln *after* android-toolchain has the Android SDK in place-->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using System.IO;
using Microsoft.Build.Framework;

namespace Xamarin.Android.BuildTools.PrepTasks
{
public class CheckoutExternalGitDependency : Git
{
[Required]
public ITaskItem ExternalGitDependency { get; set; }

protected override bool LogTaskMessages {
get { return false; }
}

string commit;
string owner;
string name;

public override bool Execute ()
{
commit = ExternalGitDependency.ItemSpec;
owner = ExternalGitDependency.GetMetadata ("Owner");
name = ExternalGitDependency.GetMetadata ("Name");
string destination = Path.Combine (GetWorkingDirectory (), name);

if (!Directory.Exists (destination)) {
Clone (destination);
}

WorkingDirectory.ItemSpec = destination;
Fetch ();
CheckoutCommit ();

return !Log.HasLoggedErrors;
}

void Clone (string destination)
{
string ghToken = Environment.GetEnvironmentVariable("GH_AUTH_SECRET");
if (!string.IsNullOrEmpty (ghToken)) {
Arguments = $"clone https://{ghToken}@github.com/{owner}/{name} --progress \"{destination}\"";
} else {
// Fallback to SSH URI
Arguments = $"clone git@github.com:{owner}/{name} --progress \"{destination}\"";
}

base.Execute ();
}

void Fetch ()
{
Arguments = $"fetch --all --no-recurse-submodules --progress";
base.Execute ();
}

void CheckoutCommit ()
{
Arguments = $"checkout {commit} --force --progress";
base.Execute ();
}

protected override void LogToolCommand(string message)
{
// Do nothing
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

namespace Xamarin.Android.BuildTools.PrepTasks
{
public class ParseExternalGitDependencies : Task
{
[Required]
public string ExternalFilePath { get; set; }

/* %(ExternalGitDependencies.Owner) - Repo owner
* %(ExternalGitDependencies.Name) - Repo name
* %(ExternalGitDependencies.Branch) - Branch name
* %(ExternalGitDependencies.Identity) - Commit hash
*/
[Output]
public ITaskItem[] ExternalGitDependencies { get; set; }

static readonly Regex externalRegex = new Regex (@"
^
\s*
(?<comment>\#.*)
|
(
\s*
(?<owner>[^/]+)
/
(?<repo>[^:]+)
:
(?<branch>[^@]+)
@
(?<commit>.*)
)
$
", RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace);

public override bool Execute ()
{
if (!File.Exists (ExternalFilePath)) {
Log.LogError($"Unable to find dependency file at: {ExternalFilePath}");
return false;
}

string[] unparsedExternals = File.ReadAllLines (ExternalFilePath);
var externals = new List<TaskItem> (unparsedExternals.Length);

foreach (string external in unparsedExternals) {
Match match = externalRegex.Match (external);
if (match != null && match.Success) {
if (match.Groups["comment"].Success) {
// Ignore matching lines which start with '#'.
continue;
}
var e = new TaskItem (match.Groups["commit"].Value);
e.SetMetadata ("Owner", match.Groups["owner"].Value);
e.SetMetadata ("Name", match.Groups["repo"].Value);
e.SetMetadata ("Branch", match.Groups["branch"].Value);
externals.Add (e);
}
}

ExternalGitDependencies = externals.ToArray ();
return !Log.HasLoggedErrors;
}
}
}
22 changes: 22 additions & 0 deletions build-tools/xa-prep-tasks/external-git-dependencies.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.Git" />
<UsingTask AssemblyFile="..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.ParseExternalGitDependencies" />
<UsingTask AssemblyFile="..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.CheckoutExternalGitDependency" />
<PropertyGroup>
<ExternalSourceDependencyDirectory>$(XamarinAndroidSourcePath)\external</ExternalSourceDependencyDirectory>
</PropertyGroup>
<Target Name="ParseExternalFile">
<ParseExternalGitDependencies
ExternalFilePath="$(XamarinAndroidSourcePath)\.external" >
<Output TaskParameter="ExternalGitDependencies" ItemName="Externals" />
</ParseExternalGitDependencies>
</Target>
<Target Name="CheckoutExternalGitSources"
DependsOnTargets="ParseExternalFile">
<CheckoutExternalGitDependency
WorkingDirectory="$(ExternalSourceDependencyDirectory)"
ExternalGitDependency="@(Externals)"
/>
</Target>
</Project>
Loading