diff options
author | lateralusX <lateralusx.github@gmail.com> | 2019-04-08 17:59:10 +0300 |
---|---|---|
committer | lateralusX <lateralusx.github@gmail.com> | 2019-04-08 17:59:10 +0300 |
commit | 03071d5acaa171442d7a65fdc4a877c9d85a9ec1 (patch) | |
tree | 4b7e0e245afe6eab92e637a2c1ce59300a9f3ab2 /msvc | |
parent | b49e72950e31975cdd3f0062e112b87ebf12d9d9 (diff) |
Make sure additional supported enable defines ends up in config.h on Windows.
Diffstat (limited to 'msvc')
-rw-r--r-- | msvc/mono.winconfig.targets | 77 |
1 files changed, 50 insertions, 27 deletions
diff --git a/msvc/mono.winconfig.targets b/msvc/mono.winconfig.targets index 17f3539d12e..320a5d12fb0 100644 --- a/msvc/mono.winconfig.targets +++ b/msvc/mono.winconfig.targets @@ -23,58 +23,58 @@ public class _WinConfigSetup : Task { bool GetVersionsFromConfigureAC (string configureACFile, out string monoVersion, out string monoCorlibVersion) - {
+ { bool result = true; monoVersion = null; monoCorlibVersion = null; if (File.Exists (configureACFile)) - {
- // These are both fairly arbitrary strings.
+ { + // These are both fairly arbitrary strings. var monoVersionRegEx = new Regex (@"^AC_INIT\s*\(\s*mono,\s*\[?\s*([^\],\s]+)"); - var monoCorlibVersionRegEx = new Regex (@"^MONO_CORLIB_VERSION\s*=\s*(\S+)");
+ var monoCorlibVersionRegEx = new Regex (@"^MONO_CORLIB_VERSION\s*=\s*(\S+)"); using (StreamReader reader = new StreamReader (configureACFile)) - {
+ { string line; while ((line = reader.ReadLine ()) != null && (monoVersion == null || monoCorlibVersion == null)) - {
+ { var monoVersionMatch = monoVersionRegEx.Match (line); if (monoVersionMatch.Success) - {
- if (monoVersion != null)
+ { + if (monoVersion != null) { - Log.LogError("duplicate MONO_INIT in {0}", configureACFile);
- result = false;
- }
+ Log.LogError("duplicate MONO_INIT in {0}", configureACFile); + result = false; + } monoVersion = monoVersionMatch.Groups[1].Value; - Log.LogMessage ("{0}:AC_INIT:MONO_VERSION=\"{1}\"", configureACFile, monoVersion);
+ Log.LogMessage ("{0}:AC_INIT:MONO_VERSION=\"{1}\"", configureACFile, monoVersion); continue; } var monoCorlibVersionMatch = monoCorlibVersionRegEx.Match (line); if (monoCorlibVersionMatch.Success) - {
- if (monoCorlibVersion != null)
- {
- // This is misleading. The loop stops when both found, so duplicates usually not noticed.
- Log.LogError("duplicate MONO_CORLIB_VERSION in {0}", configureACFile);
- result = false;
+ { + if (monoCorlibVersion != null) + { + // This is misleading. The loop stops when both found, so duplicates usually not noticed. + Log.LogError("duplicate MONO_CORLIB_VERSION in {0}", configureACFile); + result = false; } monoCorlibVersion = monoCorlibVersionMatch.Groups[1].Value; - Log.LogMessage ("{0}:MONO_CORLIB_VERSION=\"{1}\"", configureACFile, monoCorlibVersion);
+ Log.LogMessage ("{0}:MONO_CORLIB_VERSION=\"{1}\"", configureACFile, monoCorlibVersion); continue; } } } - }
+ } return result; } - string [] GetDisabledConfigFeatures (string path) + List<string> GetConfigFeatures (string path, string featuresRegex) { - var disabledFeatures = new List<string> (); + var features = new List<string> (); if (File.Exists (path)) { - var regex = new Regex (".*#define.*DISABLE_.*1"); + var regex = new Regex (featuresRegex); using (StreamReader reader = new StreamReader (path)) { string line; @@ -92,7 +92,7 @@ if (configItems != null && configItems.Length == 3) { // Second item should be the define. - disabledFeatures.Add (configItems[1]); + features.Add (configItems[1]); } } } @@ -100,7 +100,30 @@ } } } - return disabledFeatures.ToArray (); + return features; + } + + string [] GetEnabledConfigFeatures (string path, string enableDefines) + { + string [] supportedFeatures = { "ENABLE_ICALL_SYMBOL_MAP", + "ENABLE_LLVM", + "ENABLE_LLVM_RUNTIME" }; + + var enableFeatures = GetConfigFeatures(path, ".*#define.*ENABLE_.*1"); + if (enableDefines != null) + enableFeatures.AddRange (enableDefines.Split (';')); + + // Only keep supported features on Windows platforms using MSVC. + var features = new List<string> (); + foreach (var feature in enableFeatures) + if (Array.Exists(supportedFeatures, s => String.CompareOrdinal (s,feature) == 0)) + features.Add(feature); + return features.ToArray (); + } + + string [] GetDisabledConfigFeatures (string path) + { + return GetConfigFeatures(path, ".*#define.*DISABLE_.*1").ToArray (); } void CreateConfigUsingTemplate (string templatePath, string targetPath, string [] disabledDefines, string [] enabledDefines, string [] haveDefines, string monoVersion, string monoCorlibVersion) @@ -274,7 +297,7 @@ string monoVersion = null; string monoCorlibVersion = null; - if (!GetVersionsFromConfigureAC (configureACFile, out monoVersion, out monoCorlibVersion))
+ if (!GetVersionsFromConfigureAC (configureACFile, out monoVersion, out monoCorlibVersion)) return false; if (monoVersion == null) @@ -290,7 +313,7 @@ } var disableDefines = GetDisabledConfigFeatures (cygConfigFile); - var enableDefines = (EnableDefines != null) ? EnableDefines.Split (';') : null; + var enableDefines = GetEnabledConfigFeatures (cygConfigFile, EnableDefines); var haveDefines = (HaveDefines != null) ? HaveDefines.Split (';') : null; CreateConfigUsingTemplate (winConfigFile, configFile, disableDefines, enableDefines, haveDefines, monoVersion, monoCorlibVersion); |