-
Notifications
You must be signed in to change notification settings - Fork 533
Open
Description
CppSharp/src/Parser/ParserOptions.cs
Lines 193 to 235 in b658ff3
private void GetUnixCompilerInfo(string headersPath, out string compiler, | |
out string longVersion, out string shortVersion) | |
{ | |
if (!Platform.IsLinux) | |
{ | |
compiler = "gcc"; | |
// Search for the available GCC versions on the provided headers. | |
var versions = Directory.EnumerateDirectories(Path.Combine(headersPath, | |
"usr", "include", "c++")); | |
if (!versions.Any()) | |
throw new Exception("No valid GCC version found on system include paths"); | |
var gccVersionPath = versions.First(); | |
longVersion = shortVersion = gccVersionPath.Substring( | |
gccVersionPath.LastIndexOf(Path.DirectorySeparatorChar) + 1); | |
return; | |
} | |
var info = new ProcessStartInfo(Environment.GetEnvironmentVariable("CXX") ?? "gcc", "-v") | |
{ | |
RedirectStandardError = true, | |
CreateNoWindow = true, | |
UseShellExecute = false | |
}; | |
var process = Process.Start(info); | |
if (process == null) | |
throw new SystemException("GCC compiler was not found."); | |
process.WaitForExit(); | |
var output = process.StandardError.ReadToEnd(); | |
var match = Regex.Match(output, "(gcc|clang) version (([0-9]+\\.[0-9]+)\\.[0-9]+)"); | |
if (!match.Success) | |
throw new SystemException("GCC compiler was not found."); | |
compiler = match.Groups[1].ToString(); | |
longVersion = match.Groups[2].ToString(); | |
shortVersion = match.Groups[3].ToString(); | |
} |
This function fails to find the GCC compiler on my system with my normal LANG=de_DE.UTF8
, but succeeds if I export LANG=C
before running the relevant code.
Unfortunately the Code running this is proprietary, so I cannot share more about it, but it is literally:
$ ./myCode # fails
$ export LANG=C
$ ./myCode # succeeds
Metadata
Metadata
Assignees
Labels
No labels