mono was the bottleneck restricting our ability to use a newer C# version. mono 6.12 is currently available. Although poorly documented on their website, this supports C# 9. https://www.mono-project.com/docs/about-mono/versioning/#mono-source-versioning indicates mono 6.12 uses Roslyn 3.9.0. https://github.com/dotnet/roslyn/blob/main/docs/wiki/NuGet-packages.md#versioning indicates Roslyn 3.9.0 supports C# 9. This unlocks C# 8 and C# 9 features previously unavailable to us. - https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history#c-version-80 - https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history#c-version-9 A newer version of StyleCop is required to avoid rules tripping up on the new syntax. Currently only prerelease versions are available but their use is encouraged https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3420#issuecomment-994899135 Fix style rule violations on existing rules where the newer language version makes some existing casts redundant or allows use of the null coalescing assignment operator.
74 lines
2.1 KiB
C
74 lines
2.1 KiB
C
/*
|
|
* Copyright (c) The OpenRA Developers and Contributors
|
|
* This file is part of OpenRA, which is free software. It is made
|
|
* available to you under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation. For more information,
|
|
* see COPYING.
|
|
*/
|
|
|
|
//
|
|
// NOTE: Mono.framework only ships intel dylibs, so cannot be loaded by the arm64 slice of the Launcher utility.
|
|
// Splitting checkmono into its own intel-only utility allows it to be called through rosetta if the user
|
|
// wants to force the game to run under mono-through-rosetta.
|
|
//
|
|
// Based on https://github.com/mono/monodevelop/blob/main/main/build/MacOSX/monostub.mm and https://github.com/mono/monodevelop/blob/main/main/build/MacOSX/monostub-utils.h
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <dlfcn.h>
|
|
|
|
#define SYSTEM_MONO_PATH "/Library/Frameworks/Mono.framework/Versions/Current/"
|
|
#define SYSTEM_MONO_MIN_VERSION "6.12"
|
|
|
|
typedef char *(* mono_get_runtime_build_info)(void);
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
void *libmono = dlopen(SYSTEM_MONO_PATH "lib/libmonosgen-2.0.dylib", RTLD_LAZY);
|
|
if (libmono == NULL)
|
|
{
|
|
fprintf (stderr, "Failed to load libmonosgen-2.0.dylib: %s\n", dlerror());
|
|
return 1;
|
|
}
|
|
|
|
mono_get_runtime_build_info _mono_get_runtime_build_info = (mono_get_runtime_build_info)dlsym(libmono, "mono_get_runtime_build_info");
|
|
if (!_mono_get_runtime_build_info)
|
|
{
|
|
fprintf(stderr, "Could not load mono_get_runtime_build_info(): %s\n", dlerror());
|
|
return 1;
|
|
}
|
|
|
|
char *version = _mono_get_runtime_build_info();
|
|
char *req_end, *end;
|
|
long req_val, val;
|
|
char *req_version = SYSTEM_MONO_MIN_VERSION;
|
|
|
|
while (*req_version && *version)
|
|
{
|
|
req_val = strtol(req_version, &req_end, 10);
|
|
if (req_version == req_end || (*req_end && *req_end != '.'))
|
|
{
|
|
fprintf(stderr, "Bad version requirement string '%s'\n", req_end);
|
|
return 1;
|
|
}
|
|
|
|
val = strtol(version, &end, 10);
|
|
if (version == end || val < req_val)
|
|
return 1;
|
|
|
|
if (val > req_val)
|
|
return 0;
|
|
|
|
if (*req_end == '.' && *end != '.')
|
|
return 1;
|
|
|
|
req_version = req_end;
|
|
if (*req_version)
|
|
req_version++;
|
|
|
|
version = end + 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|