[versions-check.csharp] Improve this script a bit (#10323)

* Pass -s to csharp to tell it the rest of the arguments are the script and its arguments.

    Fixes these warnings printed to the terminal:

        warning CS2002: Source file `7.0' specified multiple times
        warning CS2002: Source file `10.15' specified multiple times

* Add an exception handler and return 1 if there are any exceptions.
This commit is contained in:
Rolf Bjarne Kvinge 2021-01-11 10:47:57 +01:00 коммит произвёл GitHub
Родитель 031e14f1a3
Коммит fa65fc4bcf
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 75 добавлений и 66 удалений

Просмотреть файл

@ -1,4 +1,4 @@
#!/usr/bin/env /Library/Frameworks/Mono.framework/Commands/csharp
#!/usr/bin/env /Library/Frameworks/Mono.framework/Commands/csharp -s
// this script is to make sure our versions.plist files are not out of date with our min/max supported OS versions.
@ -7,35 +7,40 @@
using System.IO;
using System.Xml;
var args = Environment.GetCommandLineArgs ();
if (args.Length != 13 /* 2 default + 9 real */) {
try {
var args = Environment.GetCommandLineArgs ();
var defaultArgumentsCount = 3;
var expectedArgumentCount = 11;
if (args.Length != defaultArgumentsCount + expectedArgumentCount) {
// first arg is "/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/4.5/csharp.exe"
// second arg the script itself
// then comes the ones we care about
Console.WriteLine ("Need 11 arguments, got {0}", args.Length - 2);
Environment.Exit (1);
return;
}
}
var plistPath = args [2];
var iOSMin = args [3];
var iOSMax = args [4];
var tvOSMin = args [5];
var tvOSMax = args [6];
var watchOSMin = args [7];
var watchOSMax = args [8];
var macOSMin = args [9];
var macOSMax = args [10];
var MacCatalystMin = args [11];
var MacCatalystMax = args [12];
args = args.Skip (defaultArgumentsCount).ToArray ();
var doc = new System.Xml.XmlDocument ();
doc.Load (plistPath);
var plistPath = args [0];
var iOSMin = args [1];
var iOSMax = args [2];
var tvOSMin = args [3];
var tvOSMax = args [4];
var watchOSMin = args [5];
var watchOSMax = args [6];
var macOSMin = args [7];
var macOSMax = args [8];
var MacCatalystMin = args [9];
var MacCatalystMax = args [10];
var failed = false;
var doc = new System.Xml.XmlDocument ();
doc.Load (plistPath);
var check = new Action<string, string, string> ((product, min, max) =>
{
var failed = false;
var check = new Action<string, string, string> ((product, min, max) =>
{
var minVersion = Version.Parse (min);
var maxVersion = Version.Parse (max);
var foundMax = false;
@ -69,12 +74,16 @@ var check = new Action<string, string, string> ((product, min, max) =>
Console.Error.WriteLine ($"Could not find the min {product} version {min} in {Path.GetFileName (plistPath)}.");
failed = true;
}
});
});
check ("iOS", iOSMin, iOSMax);
check ("tvOS", tvOSMin, tvOSMax);
check ("watchOS", watchOSMin, watchOSMax);
check ("macOS", macOSMin, macOSMax);
check ("MacCatalyst", MacCatalystMin, MacCatalystMax);
check ("iOS", iOSMin, iOSMax);
check ("tvOS", tvOSMin, tvOSMax);
check ("watchOS", watchOSMin, watchOSMax);
check ("macOS", macOSMin, macOSMax);
check ("MacCatalyst", MacCatalystMin, MacCatalystMax);
Environment.Exit (failed ? 1 : 0);
Environment.Exit (failed ? 1 : 0);
} catch (Exception e) {
Console.WriteLine (e);
Environment.Exit (1);
}