public override Expression.EvalResult Execute(MakeState s) { var f = include_file.Evaluate(s).strval; var saved_this = s.GetDefine("THIS"); MakeState new_s = s.Clone(); var ret = TymakeLib.ExecuteFile(f, new_s); s.SetDefine("THIS", saved_this, true); return(ret); }
static void Main(string[] args) { var s = new TyMakeState(); TymakeLib.InitMakeState(s, Console.In, Console.Out, Console.Out); new TyProject().Execute(s); new TyProjectLibDirFunction().Execute(s); new TyProjectSetCscFunction().Execute(s); new RuleForFunction().Execute(s); new BuildCommandStatement().Execute(s); new AutoDirStatement().Execute(s); new ShellCommandFunction().Execute(s); /* Add in current environment variables */ System.Collections.IDictionary env_vars = Environment.GetEnvironmentVariables(); foreach (System.Collections.DictionaryEntry env_var in env_vars) { s.SetDefine(env_var.Key.ToString().ToUpper(), new Expression.EvalResult(env_var.Value.ToString())); } if (System.Environment.OSVersion.Platform == PlatformID.Unix) { s.SetDefine("EXEC_EXTENSIONS", new Expression.EvalResult(new Expression.EvalResult[] { new Expression.EvalResult("") })); s.SetDefine("PATH_SPLIT", new Expression.EvalResult(":")); s.SetDefine("DIR_SPLIT", new Expression.EvalResult("/")); s.SetDefine("PLATFORM", new Expression.EvalResult("unix")); } else { s.SetDefine("EXEC_EXTENSIONS", new Expression.EvalResult(new Expression.EvalResult[] { new Expression.EvalResult(".exe") })); s.SetDefine("PATH_SPLIT", new Expression.EvalResult(";")); s.SetDefine("DIR_SPLIT", new Expression.EvalResult("\\")); s.SetDefine("PLATFORM", new Expression.EvalResult("win")); } /* Include the standard library */ System.IO.FileInfo exec_fi = new System.IO.FileInfo(typeof(Program).Module.FullyQualifiedName); System.IO.FileInfo[] stdlib_fis = exec_fi.Directory.GetFiles("*.tmh"); foreach (System.IO.FileInfo stdlib_fi in stdlib_fis) { TymakeLib.ExecuteFile(stdlib_fi.FullName, s); } /* Determine what to run - either interpret the arguments as files or as commands */ bool immediate = false; foreach (string arg in args) { if (arg == "-") { immediate = true; } else if (Statement.FileDirExists(arg)) { var ret = TymakeLib.ExecuteFile(arg, s); if (ret.AsInt != 0) { System.Diagnostics.Debugger.Break(); } } else { var ret = TymakeLib.ExecuteString(arg, s); if (ret.AsInt != 0) { System.Diagnostics.Debugger.Break(); } } } if (immediate) { while (true) { Console.Write("> "); try { TymakeLib.ExecuteString(Console.ReadLine(), s); } catch (ParseException e) { Console.WriteLine(); Console.WriteLine(e.Message); } catch (Statement.SyntaxException e) { Console.WriteLine(); Console.WriteLine(e.Message); } } } }