1d220e23fac778114dc662ab284b6103385f7bbe
[mono.git] / msvc / scripts / prepare.cs
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
9 class Prepare {
10         delegate void filt (StreamReader sr, StreamWriter sw);
11         
12         static void Filter (string inpath, string outpath, filt filter)
13         {
14                 using (var ins = new StreamReader (inpath)){
15                         using (var outs = new StreamWriter (outpath)){
16                                 filter (ins, outs);
17                         }
18                 }
19         }
20         
21         static void Main (string [] args)
22         {
23                 string bdir = args.Length == 0 ? "../../../mcs" : args [0];
24
25                 if (!Directory.Exists (Path.Combine(bdir, "class"))){
26                         Console.Error.WriteLine ("The directory {0} does not contain class at {1}", Path.GetFullPath (bdir), Environment.CurrentDirectory);
27                         Environment.Exit (1);
28                 }
29
30                 switch (args [1]){
31                 case "xml":
32                         Filter (bdir + "/class/System.XML/System.Xml.XPath/Parser.jay",
33                                 bdir + "/class/System.XML/Mono.Xml.Xsl/PatternParser.jay",
34                                 (i, o) => o.Write (i.ReadToEnd ().Replace ("%start Expr", "%start Pattern")));
35                         break;
36
37                 case "core":
38                         Filter (bdir + "/build/common/Consts.cs.in",
39                                 bdir + "/build/common/Consts.cs",
40                                 (i, o) => o.Write (i.ReadToEnd ().Replace ("@MONO_VERSION@", "2.5.0")));
41                         break;
42                         
43                 default:
44                         Console.Error.WriteLine ("Unknonw option to prepare.exe {0}", args [1]);
45                         Environment.Exit (1);
46                         break;
47                 }
48         }
49         
50 }