diff --git a/.external b/.external new file mode 100644 index 00000000000..1e22997d78d --- /dev/null +++ b/.external @@ -0,0 +1 @@ +xamarin/monodroid:master@97e4c3035f953076bd07f7737810810804d996db diff --git a/.gitignore b/.gitignore index 2dfd2713367..e6b730ef72c 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ apk-sizes-*.txt *.binlog src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props *~ +external/monodroid/ diff --git a/Documentation/building/unix/instructions.md b/Documentation/building/unix/instructions.md index eec93dd9b82..26066120e3c 100644 --- a/Documentation/building/unix/instructions.md +++ b/Documentation/building/unix/instructions.md @@ -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- @@ -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- @@ -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 diff --git a/Documentation/building/windows/instructions.md b/Documentation/building/windows/instructions.md index ea9ef8f8b86..a4cb9a8bbc5 100644 --- a/Documentation/building/windows/instructions.md +++ b/Documentation/building/windows/instructions.md @@ -18,7 +18,13 @@ 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 @@ -26,7 +32,7 @@ MSBuild version 15 or later is required. `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 diff --git a/Makefile b/Makefile index 64ea6210e21..24f6605ab32 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj index 3914d3ea5e8..b4580bc9769 100644 --- a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj +++ b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj @@ -56,12 +56,17 @@ + {7CE69551-BD73-4726-ACAA-AAF89C84BAF8} xa-prep-tasks + + {E34BCFA0-CAA4-412C-AA1C-75DB8D67D157} + Xamarin.Android.Tools.AndroidSdk + diff --git a/build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/JdkInfo.cs b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/JdkInfo.cs similarity index 97% rename from build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/JdkInfo.cs rename to build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/JdkInfo.cs index 775c11bf5ff..2095f5b21c4 100644 --- a/build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/JdkInfo.cs +++ b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/JdkInfo.cs @@ -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 { @@ -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) diff --git a/build-tools/create-pkg/create-pkg.csproj b/build-tools/create-pkg/create-pkg.csproj index a1bfb659dd2..9cf036cb250 100644 --- a/build-tools/create-pkg/create-pkg.csproj +++ b/build-tools/create-pkg/create-pkg.csproj @@ -9,7 +9,7 @@ create-pkg ..\..\bin\Build$(Configuration) - + true full @@ -29,5 +29,4 @@ - \ No newline at end of file diff --git a/build-tools/create-pkg/create-pkg.targets b/build-tools/create-pkg/create-pkg.targets index c6c7d873a37..730aeff142a 100644 --- a/build-tools/create-pkg/create-pkg.targets +++ b/build-tools/create-pkg/create-pkg.targets @@ -115,6 +115,7 @@ DependsOnTargets="_FinalizePayload"> + $(OutputPath)xamarin.android-$(XAVersion).pkg $(OutputPath)Xamarin.Android.Sdk-$(XAOSSInstallerSuffix).pkg @@ -133,5 +134,6 @@ + diff --git a/build-tools/create-vsix/create-vsix.targets b/build-tools/create-vsix/create-vsix.targets index 31b7c2158c0..1266a9cb27a 100644 --- a/build-tools/create-vsix/create-vsix.targets +++ b/build-tools/create-vsix/create-vsix.targets @@ -83,6 +83,7 @@ + ..\..\bin\Build$(Configuration)\$(AssemblyName)-$(XAVersion).vsix ..\..\bin\Build$(Configuration)\$(AssemblyName)-$(XAOSSInstallerSuffix).vsix <_VsixDir>$([System.IO.Path]::GetDirectoryName ($(VsixPath))) diff --git a/build-tools/installers/create-installers.targets b/build-tools/installers/create-installers.targets index 2da5933361a..82eef0fcef9 100644 --- a/build-tools/installers/create-installers.targets +++ b/build-tools/installers/create-installers.targets @@ -17,6 +17,7 @@ so dll True + False <_FrameworkFiles Include="$(FrameworkSrcDir)\$(FirstInstallerFrameworkVersion)\AndroidApiInfo.xml" /> @@ -189,9 +190,6 @@ - <_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" /> diff --git a/build-tools/scripts/BuildEverything.mk b/build-tools/scripts/BuildEverything.mk index 29d94166f1d..b97ce25e7fd 100644 --- a/build-tools/scripts/BuildEverything.mk +++ b/build-tools/scripts/BuildEverything.mk @@ -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 diff --git a/build-tools/scripts/Packaging.mk b/build-tools/scripts/Packaging.mk index 8975ca91f52..e6b2ac8ae69 100644 --- a/build-tools/scripts/Packaging.mk +++ b/build-tools/scripts/Packaging.mk @@ -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: @@ -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: diff --git a/build-tools/scripts/PrepareWindows.targets b/build-tools/scripts/PrepareWindows.targets index 30079e4c0fe..ebb39ca618f 100644 --- a/build-tools/scripts/PrepareWindows.targets +++ b/build-tools/scripts/PrepareWindows.targets @@ -7,8 +7,12 @@ <_NuGetVerbosity>-Verbosity Detailed - + + + + + + diff --git a/build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/CheckoutExternalGitDependency.cs b/build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/CheckoutExternalGitDependency.cs new file mode 100644 index 00000000000..2d6dde9638f --- /dev/null +++ b/build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/CheckoutExternalGitDependency.cs @@ -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 + } + } +} diff --git a/build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/ParseExternalGitDependencies.cs b/build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/ParseExternalGitDependencies.cs new file mode 100644 index 00000000000..71a89b40252 --- /dev/null +++ b/build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/ParseExternalGitDependencies.cs @@ -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* +(?\#.*) +| +( + \s* + (?[^/]+) + / + (?[^:]+) + : + (?[^@]+) + @ + (?.*) +) +$ +", 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 (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; + } + } +} diff --git a/build-tools/xa-prep-tasks/external-git-dependencies.targets b/build-tools/xa-prep-tasks/external-git-dependencies.targets new file mode 100644 index 00000000000..4fe1155df0b --- /dev/null +++ b/build-tools/xa-prep-tasks/external-git-dependencies.targets @@ -0,0 +1,22 @@ + + + + + + + $(XamarinAndroidSourcePath)\external + + + + + + + + + + diff --git a/build-tools/xa-prep-tasks/xa-prep-tasks.csproj b/build-tools/xa-prep-tasks/xa-prep-tasks.csproj index a80a2f1adab..74fc1a92966 100644 --- a/build-tools/xa-prep-tasks/xa-prep-tasks.csproj +++ b/build-tools/xa-prep-tasks/xa-prep-tasks.csproj @@ -1,4 +1,4 @@ - + Debug @@ -44,7 +44,7 @@ - + @@ -61,13 +61,9 @@ - - - - {E34BCFA0-CAA4-412C-AA1C-75DB8D67D157} - Xamarin.Android.Tools.AndroidSdk - + +