static void Main(string[] args) { // 添加 clang 目录到环境变量 string envPath = Environment.GetEnvironmentVariable("PATH"); string clangPath = Path.GetFullPath("../../../tools/clang/bin"); envPath = clangPath + ';' + envPath; Environment.SetEnvironmentVariable("PATH", envPath); try { Helper.RunCommand("clang", "-v", null, null, null); Helper.RunCommand("llvm-link", "--help", null, null, null); } catch (System.ComponentModel.Win32Exception) { Console.Error.Write("error: Cannot find clang toolchain!"); try { Console.ReadKey(); } catch { } return; } if (args.Length > 0) { var srcFiles = ParseArgs(args); var make = new Maker(".", "output"); make.OptLevel = OptLevel; make.GenOptCount = GenOptCount; make.FinalOptCount = FinalOptCount; make.AddCFlags = AddCFlags; make.Invoke(new HashSet <string>(srcFiles)); } else { Console.Error.WriteLine("error: Please run 'build.cmd' to compile"); Console.ReadKey(); } }
static void Main(string[] args) { try { Helper.RunCommand("clang", "-v", null, null, null); Helper.RunCommand("llvm-link", "--help", null, null, null); } catch (System.ComponentModel.Win32Exception) { Console.Error.Write("error: Cannot find clang toolchain,\nplease download it from "); var oldColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Cyan; Console.Error.WriteLine("http://releases.llvm.org/download.html"); Console.ForegroundColor = oldColor; try { Console.ReadKey(); } catch { } return; } if (args.Length > 0) { var srcFiles = ParseArgs(args); var make = new Maker(".", "output"); make.OptLevel = OptLevel; make.GenOptCount = GenOptCount; make.FinalOptCount = FinalOptCount; make.Invoke(new HashSet <string>(srcFiles)); } else { Console.Error.WriteLine("error: Please run 'build.cmd' to compile"); Console.ReadKey(); } }