diff --git a/Makefile b/Makefile index 01a115fe84f..cd53ef8ff7e 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ PREPARE_SCENARIO = PREPARE_CI_PR ?= 0 PREPARE_CI ?= 0 PREPARE_AUTOPROVISION ?= 0 -PREPARE_IGNORE_MONO_VERSION ?= 1 +PREPARE_AUTOPROVISION_SKIP_MONO ?= 0 _PREPARE_CI_MODE_PR_ARGS = --no-emoji --run-mode=CI _PREPARE_CI_MODE_ARGS = $(_PREPARE_CI_MODE_PR_ARGS) -a @@ -59,6 +59,10 @@ ifneq ($(PREPARE_AUTOPROVISION),0) _PREPARE_ARGS += --auto-provision=yes --auto-provision-uses-sudo=yes endif +ifneq ($(PREPARE_AUTOPROVISION_SKIP_MONO),0) +_PREPARE_ARGS += --auto-provision-skip-mono=yes +endif + ifneq ($(PREPARE_SCENARIO),) _PREPARE_ARGS += -s:"$(PREPARE_SCENARIO)" endif diff --git a/build-tools/xaprepare/README.md b/build-tools/xaprepare/README.md index 1d0fc5452e2..5559170e79d 100644 --- a/build-tools/xaprepare/README.md +++ b/build-tools/xaprepare/README.md @@ -155,8 +155,9 @@ You can append the following parameters to the command line: If set to `0` (the default), the utility will take notice of missing/outdated software the build depends on and exit with an error should any such condition is detected. Setting the property to `1` will let the utility install the software (installation **may** use `sudo` on Unix so you will need administrator/root credentials for it to work) - - `PREPARE_IGNORE_MONO_VERSION=0|1` - If set to `1` (the default), the utility will not enforce Mono version but rather will use any Mono version you have installed. + - `PREPARE_AUTOPROVISION_SKIP_MONO=0|1` + If set to `0` (the default), the utility will ensure the Mono MDK is installed. + Setting the property to `1` will allow you to skip Mono MDK installation. - `V=1` Causes the run to output much more information (making output much more messy in the process) to the console. Normally this additional information is placed only in the log files generated by the utility. diff --git a/build-tools/xaprepare/xaprepare/Application/Context.cs b/build-tools/xaprepare/xaprepare/Application/Context.cs index c69daa66c5b..9dbd137a863 100644 --- a/build-tools/xaprepare/xaprepare/Application/Context.cs +++ b/build-tools/xaprepare/xaprepare/Application/Context.cs @@ -138,14 +138,9 @@ partial class Context : AppObject public bool AutoProvisionUsesSudo { get; set; } /// - /// Do not terminate session when Mono is newer than specified in the dependencies + /// Skip automatic provision of the Mono MDK if missing /// - public bool IgnoreMaxMonoVersion { get; set; } = true; - - /// - /// Do not terminate session when Mono is older than specified in the dependencies - /// - public bool IgnoreMinMonoVersion { get; set; } = false; + public bool AutoProvisionSkipMono { get; set; } = false; /// /// Current session execution mode. See diff --git a/build-tools/xaprepare/xaprepare/Application/MonoPkgProgram.MacOS.cs b/build-tools/xaprepare/xaprepare/Application/MonoPkgProgram.MacOS.cs index ace1a12aed1..4d36a523533 100644 --- a/build-tools/xaprepare/xaprepare/Application/MonoPkgProgram.MacOS.cs +++ b/build-tools/xaprepare/xaprepare/Application/MonoPkgProgram.MacOS.cs @@ -42,8 +42,8 @@ public override async Task Install () protected override bool CheckWhetherInstalled () { - IgnoreMaximumVersion = Context.Instance.IgnoreMaxMonoVersion; - IgnoreMinimumVersion = Context.Instance.IgnoreMinMonoVersion; + IgnoreMaximumVersion = true; + IgnoreMinimumVersion = false; return base.CheckWhetherInstalled (); } @@ -55,6 +55,7 @@ protected override async Task DetermineCurrentVersion () return await base.DetermineCurrentVersion (); } +#pragma warning disable 1998 protected override async Task AfterDetect (bool installed) { if (!installed) @@ -62,6 +63,7 @@ protected override async Task AfterDetect (bool installed) AddToInventory (); } +#pragma warning restore 1998 public void AddToInventory () { diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/MacOS.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/MacOS.cs index 99e0b4114d4..b4f9fd5f4c9 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/MacOS.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/MacOS.cs @@ -13,11 +13,6 @@ partial class MacOS new HomebrewProgram ("make"), new HomebrewProgram ("ninja"), new HomebrewProgram ("p7zip", "7za"), - - new MonoPkgProgram ("Mono", "com.xamarin.mono-MDK.pkg", new Uri (Context.Instance.Properties.GetRequiredValue (KnownProperties.MonoDarwinPackageUrl))) { - MinimumVersion = Context.Instance.Properties.GetRequiredValue (KnownProperties.MonoRequiredMinimumVersion), - MaximumVersion = Context.Instance.Properties.GetRequiredValue (KnownProperties.MonoRequiredMaximumVersion), - }, }; static readonly HomebrewProgram git = new HomebrewProgram ("git") { @@ -28,10 +23,19 @@ protected override void InitializeDependencies () { Dependencies.AddRange (programs); + if (!Context.Instance.AutoProvisionSkipMono) { + Dependencies.Add ( + new MonoPkgProgram ("Mono", "com.xamarin.mono-MDK.pkg", new Uri (Context.Instance.Properties.GetRequiredValue (KnownProperties.MonoDarwinPackageUrl))) { + MinimumVersion = Context.Instance.Properties.GetRequiredValue (KnownProperties.MonoRequiredMinimumVersion), + MaximumVersion = Context.Instance.Properties.GetRequiredValue (KnownProperties.MonoRequiredMaximumVersion), + } + ); + } + // Allow using git from $PATH if it has the right version (bool success, string bv) = Utilities.GetProgramVersion (git.Name); - if (success && Version.TryParse (bv, out Version gitVersion) && - Version.TryParse (git.MinimumVersion, out Version gitMinVersion)) { + if (success && Version.TryParse (bv, out Version? gitVersion) && + Version.TryParse (git.MinimumVersion, out Version? gitMinVersion)) { if (gitVersion < gitMinVersion) Dependencies.Add (git); diff --git a/build-tools/xaprepare/xaprepare/Main.cs b/build-tools/xaprepare/xaprepare/Main.cs index 3233633feb4..7876a4d2392 100644 --- a/build-tools/xaprepare/xaprepare/Main.cs +++ b/build-tools/xaprepare/xaprepare/Main.cs @@ -27,8 +27,7 @@ sealed class ParsedOptions public string? Configuration { get; set; } public bool AutoProvision { get; set; } public bool AutoProvisionUsesSudo { get; set; } - public bool IgnoreMaxMonoVersion { get; set; } - public bool IgnoreMinMonoVersion { get; set; } + public bool AutoProvisionSkipMono { get; set; } public RefreshableComponent RefreshList { get; set; } public IEnumerable AndroidSdkPlatforms { get; set; } = new [] { "latest" }; } @@ -80,7 +79,6 @@ static async Task Run (string[] args) ParsedOptions parsedOptions = new ParsedOptions { AutoProvision = ParseBoolean (Context.Instance.Properties.GetValue (KnownProperties.AutoProvision)), AutoProvisionUsesSudo = ParseBoolean (Context.Instance.Properties.GetValue (KnownProperties.AutoProvisionUsesSudo)), - IgnoreMaxMonoVersion = ParseBoolean (Context.Instance.Properties.GetValue (KnownProperties.IgnoreMaxMonoVersion)), }; var opts = new OptionSet { @@ -103,8 +101,7 @@ static async Task Run (string[] args) "", {"auto-provision=", $"Automatically install software required by .NET for Android", v => parsedOptions.AutoProvision = ParseBoolean (v)}, {"auto-provision-uses-sudo=", $"Allow use of sudo(1) when provisioning", v => parsedOptions.AutoProvisionUsesSudo = ParseBoolean (v)}, - {"ignore-max-mono-version=", $"Ignore the maximum supported Mono version restriction", v => parsedOptions.IgnoreMaxMonoVersion = ParseBoolean (v)}, - {"ignore-min-mono-version=", $"Ignore the minimum supported Mono version restriction", v => parsedOptions.IgnoreMinMonoVersion = ParseBoolean (v)}, + {"auto-provision-skip-mono=", $"Do not automatically install the Mono MDK", v => parsedOptions.AutoProvisionSkipMono = ParseBoolean (v)}, {"android-sdk-platforms=", "Comma separated list of Android SDK platform levels to be installed or 'latest' or 'all'. Defaults to 'latest' if no value is provided.", v => parsedOptions.AndroidSdkPlatforms = ParseAndroidSdkPlatformLevels (v?.Trim () ?? String.Empty) }, "", {"h|help", "Show this help message", v => parsedOptions.ShowHelp = true }, @@ -135,8 +132,7 @@ static async Task Run (string[] args) Context.Instance.DebugFileExtension = parsedOptions.DebugFileExtension; Context.Instance.AutoProvision = parsedOptions.AutoProvision; Context.Instance.AutoProvisionUsesSudo = parsedOptions.AutoProvisionUsesSudo; - Context.Instance.IgnoreMaxMonoVersion = parsedOptions.IgnoreMaxMonoVersion; - Context.Instance.IgnoreMinMonoVersion = parsedOptions.IgnoreMinMonoVersion; + Context.Instance.AutoProvisionSkipMono = parsedOptions.AutoProvisionSkipMono; Context.Instance.ComponentsToRefresh = parsedOptions.RefreshList; Context.Instance.AndroidSdkPlatforms = parsedOptions.AndroidSdkPlatforms;