Skip to content

Commit dbc72c8

Browse files
authored
[build] Add option to skip Mono MDK provisioning (#8993)
The mono related CLI parameters for xaprepare have been updated to make it possible to skip installation of the Mono MDK via the following: make prepare-update-mono PREPARE_AUTOPROVISION=1 PREPARE_AUTOPROVISION_SKIP_MONO=1 make prepare PREPARE_AUTOPROVISION=1 PREPARE_AUTOPROVISION_SKIP_MONO=1 Unused `ignore-*-mono-version=` parameters have been removed and replaced with their default values. Build warnings in the project have also been fixed on macOS.
1 parent f5fcd4d commit dbc72c8

File tree

6 files changed

+28
-26
lines changed

6 files changed

+28
-26
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PREPARE_SCENARIO =
1515
PREPARE_CI_PR ?= 0
1616
PREPARE_CI ?= 0
1717
PREPARE_AUTOPROVISION ?= 0
18-
PREPARE_IGNORE_MONO_VERSION ?= 1
18+
PREPARE_AUTOPROVISION_SKIP_MONO ?= 0
1919

2020
_PREPARE_CI_MODE_PR_ARGS = --no-emoji --run-mode=CI
2121
_PREPARE_CI_MODE_ARGS = $(_PREPARE_CI_MODE_PR_ARGS) -a
@@ -59,6 +59,10 @@ ifneq ($(PREPARE_AUTOPROVISION),0)
5959
_PREPARE_ARGS += --auto-provision=yes --auto-provision-uses-sudo=yes
6060
endif
6161

62+
ifneq ($(PREPARE_AUTOPROVISION_SKIP_MONO),0)
63+
_PREPARE_ARGS += --auto-provision-skip-mono=yes
64+
endif
65+
6266
ifneq ($(PREPARE_SCENARIO),)
6367
_PREPARE_ARGS += -s:"$(PREPARE_SCENARIO)"
6468
endif

build-tools/xaprepare/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,9 @@ You can append the following parameters to the command line:
155155
If set to `0` (the default), the utility will take notice of missing/outdated software the build depends on and exit with an error
156156
should any such condition is detected. Setting the property to `1` will let the utility install the software (installation **may**
157157
use `sudo` on Unix so you will need administrator/root credentials for it to work)
158-
- `PREPARE_IGNORE_MONO_VERSION=0|1`
159-
If set to `1` (the default), the utility will not enforce Mono version but rather will use any Mono version you have installed.
158+
- `PREPARE_AUTOPROVISION_SKIP_MONO=0|1`
159+
If set to `0` (the default), the utility will ensure the Mono MDK is installed.
160+
Setting the property to `1` will allow you to skip Mono MDK installation.
160161
- `V=1`
161162
Causes the run to output much more information (making output much more messy in the process) to the console. Normally this additional
162163
information is placed only in the log files generated by the utility.

build-tools/xaprepare/xaprepare/Application/Context.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,9 @@ partial class Context : AppObject
138138
public bool AutoProvisionUsesSudo { get; set; }
139139

140140
/// <summary>
141-
/// Do not terminate session when Mono is newer than specified in the dependencies
141+
/// Skip automatic provision of the Mono MDK if missing
142142
/// </summary>
143-
public bool IgnoreMaxMonoVersion { get; set; } = true;
144-
145-
/// <summary>
146-
/// Do not terminate session when Mono is older than specified in the dependencies
147-
/// </summary>
148-
public bool IgnoreMinMonoVersion { get; set; } = false;
143+
public bool AutoProvisionSkipMono { get; set; } = false;
149144

150145
/// <summary>
151146
/// Current session execution mode. See <see cref="t:ExecutionMode" />

build-tools/xaprepare/xaprepare/Application/MonoPkgProgram.MacOS.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public override async Task<bool> Install ()
4242

4343
protected override bool CheckWhetherInstalled ()
4444
{
45-
IgnoreMaximumVersion = Context.Instance.IgnoreMaxMonoVersion;
46-
IgnoreMinimumVersion = Context.Instance.IgnoreMinMonoVersion;
45+
IgnoreMaximumVersion = true;
46+
IgnoreMinimumVersion = false;
4747
return base.CheckWhetherInstalled ();
4848
}
4949

@@ -55,13 +55,15 @@ protected override async Task<bool> DetermineCurrentVersion ()
5555
return await base.DetermineCurrentVersion ();
5656
}
5757

58+
#pragma warning disable 1998
5859
protected override async Task AfterDetect (bool installed)
5960
{
6061
if (!installed)
6162
return;
6263

6364
AddToInventory ();
6465
}
66+
#pragma warning restore 1998
6567

6668
public void AddToInventory ()
6769
{

build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/MacOS.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ partial class MacOS
1313
new HomebrewProgram ("make"),
1414
new HomebrewProgram ("ninja"),
1515
new HomebrewProgram ("p7zip", "7za"),
16-
17-
new MonoPkgProgram ("Mono", "com.xamarin.mono-MDK.pkg", new Uri (Context.Instance.Properties.GetRequiredValue (KnownProperties.MonoDarwinPackageUrl))) {
18-
MinimumVersion = Context.Instance.Properties.GetRequiredValue (KnownProperties.MonoRequiredMinimumVersion),
19-
MaximumVersion = Context.Instance.Properties.GetRequiredValue (KnownProperties.MonoRequiredMaximumVersion),
20-
},
2116
};
2217

2318
static readonly HomebrewProgram git = new HomebrewProgram ("git") {
@@ -28,10 +23,19 @@ protected override void InitializeDependencies ()
2823
{
2924
Dependencies.AddRange (programs);
3025

26+
if (!Context.Instance.AutoProvisionSkipMono) {
27+
Dependencies.Add (
28+
new MonoPkgProgram ("Mono", "com.xamarin.mono-MDK.pkg", new Uri (Context.Instance.Properties.GetRequiredValue (KnownProperties.MonoDarwinPackageUrl))) {
29+
MinimumVersion = Context.Instance.Properties.GetRequiredValue (KnownProperties.MonoRequiredMinimumVersion),
30+
MaximumVersion = Context.Instance.Properties.GetRequiredValue (KnownProperties.MonoRequiredMaximumVersion),
31+
}
32+
);
33+
}
34+
3135
// Allow using git from $PATH if it has the right version
3236
(bool success, string bv) = Utilities.GetProgramVersion (git.Name);
33-
if (success && Version.TryParse (bv, out Version gitVersion) &&
34-
Version.TryParse (git.MinimumVersion, out Version gitMinVersion)) {
37+
if (success && Version.TryParse (bv, out Version? gitVersion) &&
38+
Version.TryParse (git.MinimumVersion, out Version? gitMinVersion)) {
3539
if (gitVersion < gitMinVersion)
3640
Dependencies.Add (git);
3741

build-tools/xaprepare/xaprepare/Main.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ sealed class ParsedOptions
2727
public string? Configuration { get; set; }
2828
public bool AutoProvision { get; set; }
2929
public bool AutoProvisionUsesSudo { get; set; }
30-
public bool IgnoreMaxMonoVersion { get; set; }
31-
public bool IgnoreMinMonoVersion { get; set; }
30+
public bool AutoProvisionSkipMono { get; set; }
3231
public RefreshableComponent RefreshList { get; set; }
3332
public IEnumerable<string> AndroidSdkPlatforms { get; set; } = new [] { "latest" };
3433
}
@@ -80,7 +79,6 @@ static async Task<int> Run (string[] args)
8079
ParsedOptions parsedOptions = new ParsedOptions {
8180
AutoProvision = ParseBoolean (Context.Instance.Properties.GetValue (KnownProperties.AutoProvision)),
8281
AutoProvisionUsesSudo = ParseBoolean (Context.Instance.Properties.GetValue (KnownProperties.AutoProvisionUsesSudo)),
83-
IgnoreMaxMonoVersion = ParseBoolean (Context.Instance.Properties.GetValue (KnownProperties.IgnoreMaxMonoVersion)),
8482
};
8583

8684
var opts = new OptionSet {
@@ -103,8 +101,7 @@ static async Task<int> Run (string[] args)
103101
"",
104102
{"auto-provision=", $"Automatically install software required by .NET for Android", v => parsedOptions.AutoProvision = ParseBoolean (v)},
105103
{"auto-provision-uses-sudo=", $"Allow use of sudo(1) when provisioning", v => parsedOptions.AutoProvisionUsesSudo = ParseBoolean (v)},
106-
{"ignore-max-mono-version=", $"Ignore the maximum supported Mono version restriction", v => parsedOptions.IgnoreMaxMonoVersion = ParseBoolean (v)},
107-
{"ignore-min-mono-version=", $"Ignore the minimum supported Mono version restriction", v => parsedOptions.IgnoreMinMonoVersion = ParseBoolean (v)},
104+
{"auto-provision-skip-mono=", $"Do not automatically install the Mono MDK", v => parsedOptions.AutoProvisionSkipMono = ParseBoolean (v)},
108105
{"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) },
109106
"",
110107
{"h|help", "Show this help message", v => parsedOptions.ShowHelp = true },
@@ -135,8 +132,7 @@ static async Task<int> Run (string[] args)
135132
Context.Instance.DebugFileExtension = parsedOptions.DebugFileExtension;
136133
Context.Instance.AutoProvision = parsedOptions.AutoProvision;
137134
Context.Instance.AutoProvisionUsesSudo = parsedOptions.AutoProvisionUsesSudo;
138-
Context.Instance.IgnoreMaxMonoVersion = parsedOptions.IgnoreMaxMonoVersion;
139-
Context.Instance.IgnoreMinMonoVersion = parsedOptions.IgnoreMinMonoVersion;
135+
Context.Instance.AutoProvisionSkipMono = parsedOptions.AutoProvisionSkipMono;
140136
Context.Instance.ComponentsToRefresh = parsedOptions.RefreshList;
141137
Context.Instance.AndroidSdkPlatforms = parsedOptions.AndroidSdkPlatforms;
142138

0 commit comments

Comments
 (0)