prepare.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // C# implementation of a handful of shell steps
  3. // this is used to automate the buidl in Windows
  4. //
  5. using System;
  6. using System.Text;
  7. using System.IO;
  8. class Prepare {
  9. delegate void filt (StreamReader sr, StreamWriter sw);
  10. static void Filter (string inpath, string outpath, filt filter)
  11. {
  12. using (var ins = new StreamReader (inpath)){
  13. using (var outs = new StreamWriter (outpath)){
  14. filter (ins, outs);
  15. }
  16. }
  17. }
  18. static void Main (string [] args)
  19. {
  20. string bdir = args.Length == 0 ? "../../../mcs" : args [0];
  21. if (!Directory.Exists (Path.Combine(bdir, "class"))){
  22. Console.Error.WriteLine ("The directory {0} does not contain class at {1}", Path.GetFullPath (bdir), Environment.CurrentDirectory);
  23. Environment.Exit (1);
  24. }
  25. switch (args [1]){
  26. case "xml":
  27. Filter (bdir + "/class/System.XML/System.Xml.XPath/Parser.jay",
  28. bdir + "/class/System.XML/Mono.Xml.Xsl/PatternParser.jay",
  29. (i, o) => o.Write (i.ReadToEnd ().Replace ("%start Expr", "%start Pattern")));
  30. break;
  31. case "core":
  32. Filter (bdir + "/build/common/Consts.cs.in",
  33. bdir + "/build/common/Consts.cs",
  34. (i, o) => o.Write (i.ReadToEnd ().Replace ("@MONO_VERSION@", "2.5.0")));
  35. break;
  36. default:
  37. Console.Error.WriteLine ("Unknonw option to prepare.exe {0}", args [1]);
  38. Environment.Exit (1);
  39. break;
  40. }
  41. }
  42. }