Esempio n. 1
0
        public async Task <TargetTriple> GetHostTargetTripleAsync()
        {
            var result = await CommandHelper.RunAsync(RustcExecutable, "-vV");

            Match hostMatch = Regex.Match(result.Output, "^host:\\s*(.+)$", RegexOptions.Multiline);

            if (hostMatch.Groups.Count < 2)
            {
                return(null);
            }
            return(TargetTriple.Create(hostMatch.Groups[1].Value.TrimEnd()));
        }
Esempio n. 2
0
        private static IEnumerable <TargetTriple> SniffTargets(string installPath)
        {
            // This path is used in the installers for versions < 1.6
            string oldRoot = Path.Combine(installPath, "bin", "rustlib");
            // This path is used in the installers >= 1.6
            string newRoot          = Path.Combine(installPath, "lib", "rustlib");
            var    oldSourceTargets = GetTargetCandidates(oldRoot);
            var    newSourceTargets = GetTargetCandidates(newRoot);

            return(oldSourceTargets
                   .Union(newSourceTargets)
                   .Select(name => TargetTriple.Create(name))
                   .Where(triple => triple != null));
        }
Esempio n. 3
0
        private static bool CanBuildTarget(string exePath, string target)
        {
            if (!File.Exists(exePath))
            {
                return(false);
            }
            if (String.Equals(DefaultTarget, target, StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }
            TargetTriple triple = GetTarget(exePath);

            return(triple != null &&
                   String.Equals(triple.ToString(), target, StringComparison.OrdinalIgnoreCase));
        }
Esempio n. 4
0
        // TODO: this is wrong, because we're checking the host triple, not the availability of a target
        public static TargetTriple GetTarget(string exePath)
        {
            if (!File.Exists(exePath))
            {
                return(null);
            }
            ProcessStartInfo psi = new ProcessStartInfo
            {
                UseShellExecute        = false,
                CreateNoWindow         = true,
                FileName               = exePath,
                RedirectStandardOutput = true,
                Arguments              = "-Vv",
                StandardOutputEncoding = Encoding.UTF8,
                StandardErrorEncoding  = Encoding.UTF8
            };
            string verboseVersion;

            try
            {
                Process proc = Process.Start(psi);
                verboseVersion = proc.StandardOutput.ReadToEnd();
            }
            catch (Win32Exception)
            {
                return(null);
            }
            catch (IOException)
            {
                return(null);
            }
            Match hostMatch = Regex.Match(verboseVersion, "^host:\\s*(.+)$", RegexOptions.Multiline);

            if (hostMatch.Groups.Count == 1)
            {
                return(null);
            }
            return(TargetTriple.Create(hostMatch.Groups[1].Value));
        }