[sre-save] Handle ConstructorBuilder custom attribute constructors.
[mono-project.git] / msvc / scripts / prepare.cs
blob20f78e5cf85b836bfc219964fc9d1a7f6af2cdbb
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;
9 class Prepare {
10 delegate void filt (StreamReader sr, StreamWriter sw);
12 static void Filter (string inpath, string outpath, filt filter)
14 using (var ins = new StreamReader (inpath)){
15 using (var outs = new StreamWriter (outpath)){
16 filter (ins, outs);
21 static void SystemDataConnectionReplace (string srcdir, string targetdir, string target, string ns, string factory, string conn)
23 var t = File.ReadAllText (Path.Combine (srcdir, "DbConnectionHelper.cs"));
25 File.WriteAllText (Path.Combine (targetdir, target), t.Replace ("NAMESPACE", ns).Replace ("CONNECTIONFACTORYOBJECTNAME", factory).Replace ("CONNECTIONOBJECTNAME", conn));
28 static void SystemDataParameterReplace (string srcdir, string targetdir, string target, string resns, string ns, string parname)
30 var t = File.ReadAllText (Path.Combine (srcdir, "DbParameterHelper.cs"));
32 File.WriteAllText (Path.Combine (targetdir, target), t.Replace ("RESNAMESPACE", resns).Replace ("NAMESPACE", ns).Replace ("PARAMETEROBJECTNAME", parname));
35 static void SystemDataParameterCollReplace (string srcdir, string targetdir, string target, string resns, string ns, string parname)
37 var t = File.ReadAllText (Path.Combine (srcdir, "DbParameterCollectionHelper.cs"));
39 Console.WriteLine ("Creating " + Path.Combine (targetdir, target));
40 File.WriteAllText (Path.Combine (targetdir, target), t.Replace ("RESNAMESPACE", resns).Replace ("PARAMETERCOLLECTIONOBJECTNAME", parname + "Collection").Replace ("NAMESPACE", ns).Replace ("PARAMETEROBJECTNAME", parname));
43 static void GenerateSystemData (string bdir)
45 var rs = Path.Combine (bdir, "class", "referencesource", "System.Data", "System", "Data", "ProviderBase");
46 var sd = Path.Combine (bdir, "class", "System.Data");
48 SystemDataConnectionReplace (rs, sd, "gen_OdbcConnection.cs", "System.Data.Odbc", "OdbcConnectionFactory.SingletonInstance", "OdbcConnection");
49 SystemDataConnectionReplace (rs, sd, "gen_OleDbConnection.cs", "System.Data.OleDb", "OleDbConnectionFactory.SingletonInstance", "OleDbConnection");
50 SystemDataConnectionReplace (rs, sd, "gen_SqlConnection.cs", "System.Data.SqlClient", "SqlConnectionFactory.SingletonInstance", "SqlConnection");
52 SystemDataParameterReplace (rs, sd, "gen_OdbcParameter.cs", "System.Data", "System.Data.Odbc", "OdbcParameter");
53 SystemDataParameterReplace (rs, sd, "gen_OleDbParameter.cs", "System.Data", "System.Data.OleDb", "OleDbParameter");
54 SystemDataParameterReplace (rs, sd, "gen_SqlParameter.cs", "System.Data", "System.Data.SqlClient", "SqlParameter");
56 SystemDataParameterCollReplace (rs, sd, "gen_OdbcParameterCollection.cs", "System.Data", "System.Data.Odbc", "OdbcParameter");
57 SystemDataParameterCollReplace (rs, sd, "gen_OleDbParameterCollection.cs", "System.Data", "System.Data.OleDb", "OleDbParameter");
58 SystemDataParameterCollReplace (rs, sd, "gen_SqlParameterCollection.cs", "System.Data", "System.Data.SqlClient", "SqlParameter");
61 static void Main (string [] args)
63 string bdir = args.Length == 0 ? "../../../mcs" : args [0];
65 if (!Directory.Exists (Path.Combine(bdir, "class"))){
66 Console.Error.WriteLine ("The directory {0} does not contain class at {1}", Path.GetFullPath (bdir), Environment.CurrentDirectory);
67 Environment.Exit (1);
70 switch (args [1]){
71 case "core":
72 Filter (bdir + "/build/common/Consts.cs.in",
73 bdir + "/build/common/Consts.cs",
74 (i, o) => o.Write (i.ReadToEnd ().Replace ("@MONO_VERSION@", "2.5.0")));
76 GenerateSystemData (bdir);
77 break;
79 default:
80 Console.Error.WriteLine ("Unknonw option to prepare.exe {0}", args [1]);
81 Environment.Exit (1);
82 break;