public static int Main(string[] args) { if (args.Length == 0) { System.Console.WriteLine("No arguments!"); return(0); } string[] resolvedArgs = null; string paramFileTag = "/paramFile:"; if (args.Length == 1 && args[0].StartsWith(paramFileTag)) { string paramFile = args[0].Replace(paramFileTag, ""); if (File.Exists(paramFile)) { string longArgs = File.ReadAllText(paramFile); var tokenizer = new ToolArgsTokenizer(); resolvedArgs = tokenizer.Tokenize(longArgs); } else { System.Console.WriteLine("Error:<{0}> is not found", paramFile); return(0); } } if (resolvedArgs == null) { resolvedArgs = args; } var stopwatch = new Stopwatch(); stopwatch.Start(); CollectionExtensions.Parallel = ConfigurationManager.AppSettings["Parallel"] == "true"; CollectionExtensions.ParallelPreAction = () => Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; //Console.AutoFlush = true; System.Console.WriteLine("Parallel=" + CollectionExtensions.Parallel); var skc = new CompilerTool { CommandLineArguments = resolvedArgs }; skc.Init(); #if DEBUG skc.Debug = true; #endif var res = skc.Run(); stopwatch.Stop(); System.Console.WriteLine("Total: {0}ms", stopwatch.ElapsedMilliseconds); //System.Console.Flush(); if (res < 0 && skc.Args.exitReadKey.GetValueOrDefault()) { System.Console.ReadKey(); } return(res); }
internal void SaveAs(string filename, string format, CompilerTool compiler) { var tmpFile = filename; using (var writer = JsWriter.Create(tmpFile, false)) { var att = compiler.GetJsExportAttribute(); if (format == null) { format = "JavaScript"; } writer.Format = format; try { if (CompilerConfiguration.Current.EnableLogging && compiler != null) { writer.Visiting += node => compiler.Log.Debug(String.Format("JsWriter: Visit JsNode: {0}", filename)); } foreach (var unit in Units) { if (unit.Tokens == null) { unit.Tokens = writer.GetTokens(unit); } else { } var formatted = unit.TokensByFormat.TryGetValue(format); if (formatted == null) { formatted = writer.FormatTokens(unit.Tokens); unit.TokensByFormat[format] = formatted; } else { } writer.WriteTokens(formatted); writer.Flush(); } } catch (Exception e) { if (compiler != null) { compiler.Log.Log(new CompilerLogItem { Type = CompilerLogItemType.Error, ProjectRelativeFilename = tmpFile, Text = e.Message }); } throw e; } } }
public CompileResponse Compile(CompileRequest req) { var skc = new CompilerTool { Args = req.Args, Log = new CompilerLogger { Console = { AutoFlush = false } }, }; if (req.CommandLineArgs.IsNotNullOrEmpty()) { skc.CommandLineArguments = new ToolArgsTokenizer().Tokenize(req.CommandLineArgs); } skc.Init(); var x = skc.Run(); var xx = new CompileResponse { Output = skc.Log.Console.Items.ToList(), ExitCode = x }; return xx; }
internal void SaveAs(string filename, string format, CompilerTool compiler) { var tmpFile = filename; using (var writer = JsWriter.Create(tmpFile, false)) { var att = compiler.GetJsExportAttribute(); if (format == null) format = "JavaScript"; writer.Format = format; try { if (CompilerConfiguration.Current.EnableLogging && compiler != null) { writer.Visiting += node => compiler.Log.Debug(String.Format("JsWriter: Visit JsNode: {0}", filename)); } foreach (var unit in Units) { if (unit.Tokens == null) unit.Tokens = writer.GetTokens(unit); else { } var formatted = unit.TokensByFormat.TryGetValue(format); if (formatted == null) { formatted = writer.FormatTokens(unit.Tokens); unit.TokensByFormat[format] = formatted; } else { } writer.WriteTokens(formatted); writer.Flush(); } } catch (Exception e) { if (compiler != null) compiler.Log.Log(new CompilerLogItem { Type = CompilerLogItemType.Error, ProjectRelativeFilename = tmpFile, Text = e.Message }); throw e; } } }
public static int Main(string[] args) { var stopwatch = new Stopwatch(); stopwatch.Start(); CollectionExtensions.Parallel = ConfigurationManager.AppSettings["Parallel"] == "true"; CollectionExtensions.ParallelPreAction = () => Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; //Console.AutoFlush = true; System.Console.WriteLine("Parallel=" + CollectionExtensions.Parallel); var skc = new CompilerTool { CommandLineArguments = args }; skc.Init(); #if DEBUG skc.Debug = true; #endif var res = skc.Run(); stopwatch.Stop(); System.Console.WriteLine("Total: {0}ms", stopwatch.ElapsedMilliseconds); //System.Console.Flush(); return res; }
public CompileResponse Compile(CompileRequest req) { var skc = new CompilerTool { Args = req.Args, Log = new CompilerLogger { Console = { AutoFlush = false } }, }; if (req.CommandLineArgs.IsNotNullOrEmpty()) { skc.CommandLineArguments = new ToolArgsTokenizer().Tokenize(req.CommandLineArgs); } skc.Init(); var x = skc.Run(); var xx = new CompileResponse { Output = skc.Log.Console.Items.ToList(), ExitCode = x }; return(xx); }
public static int Main(string[] args) { var stopwatch = new Stopwatch(); stopwatch.Start(); CollectionExtensions.Parallel = ConfigurationManager.AppSettings["Parallel"] == "true"; CollectionExtensions.ParallelPreAction = () => Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; //Console.AutoFlush = true; System.Console.WriteLine("Parallel=" + CollectionExtensions.Parallel); var skc = new CompilerTool { CommandLineArguments = args }; skc.Init(); #if DEBUG skc.Debug = true; #endif var res = skc.Run(); stopwatch.Stop(); System.Console.WriteLine("Total: {0}ms", stopwatch.ElapsedMilliseconds); //System.Console.Flush(); return(res); }