Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnome.org>2009-04-30 04:00:27 +0400
committerMiguel de Icaza <miguel@gnome.org>2009-04-30 04:00:27 +0400
commit708c5869aed4b3a0d1c3d9e788be86ed4a1126f8 (patch)
tree956d663d4cc22b3b14adc77ff5c782cab68e617b /msvc/scripts/monowrap.cs
parent8af42f9138baa268fc468f361f5392a9b82d8b02 (diff)
Update
svn path=/trunk/mono/; revision=133096
Diffstat (limited to 'msvc/scripts/monowrap.cs')
-rwxr-xr-xmsvc/scripts/monowrap.cs174
1 files changed, 119 insertions, 55 deletions
diff --git a/msvc/scripts/monowrap.cs b/msvc/scripts/monowrap.cs
index 0caa1ba6d7b..63326f2e8bf 100755
--- a/msvc/scripts/monowrap.cs
+++ b/msvc/scripts/monowrap.cs
@@ -1,4 +1,40 @@
-using System;
+//
+// This is a wrapper used to invoke one of the Mono C#
+// compilers with the correct MONO_PATH depending on
+// where this command is located.
+//
+// This allows us to use MSBuild CscToolPath property to
+// point to this directory to use our compiler to drive
+// the build and set the MONO_PATH as it is expected to
+// be for bootstrap
+//
+// The MONO_PATH and the compiler are chosen based on the
+// directory that hosts the command.
+//
+// The directory specifies a profile, and the format is:
+// PROFILES-COMPILER
+//
+// Will request that the COMPILER compiler is used setting
+// MONO_PATH to PROFILES. The PROFILES string can contain
+// multiple directories, separated by dashes.
+//
+// COMPILER is one of:
+// basic -> class/lib/basic/mcs.exe
+// net_1_1_bootstrap -> class/lib/net_1_1_bootstrap/mcs.exe
+// net_1_1 -> class/lib/net_1_1/mcs.exe
+// net_2_0_bootstrap -> class/lib/net_2_0_bootstrap/gmcs.exe
+// gmcs -> mcs/gmcs.exe
+// net_2_1_bootstrap -> class/lib/net_2_1_bootstrap/smcs.exe
+// net_2_1_raw -> class/lib/net_2_1_raw/smcs.exe
+//
+// So for example:
+// net_2_1_bootstrap-net_2_0-net_2_1_bootstrap
+//
+// Will set MONO_PATH to "%MCS_ROOT%\class\lib\net_2_1_bootstrap;%MCS_ROOT\class\lib\net_2_0"
+// and run the compiler in %MCS_ROOT%\class\lib\net_2_1_bootstrap
+//
+
+using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
@@ -6,64 +42,92 @@ using System.Diagnostics;
namespace csc
{
- class Program
- {
- //
- // Executes the Mono command with MONO_PATH set to the
- // class/lib/PROFILE where PROFILE is the directory where
- // this executable is hosted, and the tool is the name
- // of this executable
- //
- // This allows us to use MSBuild CscToolPath property to
- // point to this directory to use our compiler to drive
- // the build and set the MONO_PATH as it is expected to
- // be for bootstrap
- //
- static int Main(string[] args)
- {
- string cmd = Environment.GetCommandLineArgs () [0];
- string tool = Path.GetFileName(cmd);
- string profile = Path.GetDirectoryName(cmd);
- int p = profile.LastIndexOf('\\');
- if (p == -1) {
- Console.Error.WriteLine("Could not find the profile name from this {0}", profile);
- return 1;
- }
- profile = profile.Substring(p+1);
+ class Program
+ {
+ static int Main(string[] args)
+ {
+ string cmd = Environment.GetCommandLineArgs () [0];
+ string tool = Path.GetFileName(cmd);
+ string profile = Path.GetDirectoryName(cmd);
+ int p = profile.LastIndexOf('\\');
+ if (p == -1) {
+ Console.Error.WriteLine("Could not find the profile name from this {0}", profile);
+ return 1;
+ }
+ profile = profile.Substring(p+1);
+
+ var root_mono = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(cmd), "..\\..\\.."));
+ if (!File.Exists(Path.Combine(root_mono, "mono\\mini\\mini.c"))) {
+ Console.WriteLine("My root is incorrect {0} based on {1}", root_mono, cmd);
+ Console.WriteLine("Must be in mono/msvc/scripts/PROFILE/COMMAND.exe");
+ return 1;
+ }
+
+ p = profile.LastIndexOf ('-');
+ if (p == -1){
+ Console.Error.WriteLine("The directory holding this executable should be MPATHS-COMPILER, instead it is: {0}", profile);
+ return 1;
+ }
+
+ var root_mcs = Path.GetFullPath (Path.Combine (root_mono, "..\\mcs"));
+ var mono_cmd = root_mono + "\\msvc\\Win32_Debug_eglib\\bin\\mono.exe";
- if (tool.ToLower () == "csc.exe"){
- if (profile.IndexOf ("net_2_0") != -1)
- tool = "gmcs.exe";
- else if (profile.IndexOf ("net_2_1") != -1)
- tool = "smcs.exe";
- else
- tool = "mcs.exe";
- }
+ string compiler = null;
+ switch (profile.Substring (p+1)){
+ case "basic":
+ compiler = root_mcs + "\\class\\lib\\basic\\mcs.exe";
+ break;
+ case "net_1_1_bootstrap":
+ compiler = root_mcs + "\\class\\lib\\net_1_1_bootstrap\\mcs.exe";
+ break;
+
+ case "net_1_1":
+ compiler = root_mcs + "\\class\\lib\\net_1_1\\mcs.exe";
+ break;
+
+ case "net_2_0_bootstrap":
+ compiler = root_mcs + "\\class\\lib\\net_2_0_bootstrap\\gmcs.exe";
+ break;
+
+ case "mcs":
+ compiler = root_mcs + "\\mcs\\gmcs.exe";
+ break;
+
+ case "net_2_1_bootstrap":
+ compiler = root_mcs + "\\class\\lib\\net_2_1_bootstrap\\smcs.exe";
+ break;
+
+ case "net_2_1_raw":
+ compiler = root_mcs + "\\class\\lib\\net_2_1_raw\\smcs.exe";
+ break;
- var root_mono = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(cmd), "..\\..\\.."));
- if (!File.Exists(Path.Combine(root_mono, "mono\\mini\\mini.c"))) {
- Console.WriteLine("My root is incorrect {0} based on {1}", root_mono, cmd);
- Console.WriteLine("Must be in mono/msvc/scripts/PROFILE/COMMAND.exe");
- return 1;
- }
- var root_mcs = Path.GetFullPath (Path.Combine (root_mono, "..\\mcs"));
- var mono_cmd = root_mono + "\\msvc\\Win32_Debug_eglib\\bin\\mono.exe";
- var tool_cmd = root_mcs + "\\class\\lib\\" + profile + "\\" + tool;
+ default:
+ Console.WriteLine ("Unknown compiler configuration: {0}", profile.Substring (p+1));
+ return 1;
- Console.WriteLine("root_mcs={0}\nmono_cmd={1}\ntool_cmd={2}", root_mcs, mono_cmd, tool_cmd);
- Environment.SetEnvironmentVariable ("MONO_PATH", root_mcs + "\\class\\lib\\net_1_1_bootstrap");
+ }
+ var paths = profile.Substring (0, p).Split (new char [] { '-' });
+ StringBuilder sb = new StringBuilder ();
+ foreach (string dir in paths){
+ if (sb.Length != 0)
+ sb.Append (";");
+ sb.Append (root_mcs + "\\class\\lib\\" + dir);
+ }
+ Environment.SetEnvironmentVariable ("MONO_PATH", sb.ToString ());
- var pi = new ProcessStartInfo() {
- FileName = mono_cmd,
- WindowStyle = ProcessWindowStyle.Hidden,
- Arguments = tool_cmd + " " + String.Join (" ", args),
- UseShellExecute = false
- };
+ Console.WriteLine ("Compiler: {0}", compiler);
+ Console.WriteLine ("MONO_PATH: {0}", sb.ToString ());
+ var pi = new ProcessStartInfo() {
+ FileName = mono_cmd,
+ WindowStyle = ProcessWindowStyle.Hidden,
+ Arguments = compiler + " " + String.Join (" ", args),
+ UseShellExecute = false
+ };
- var proc = Process.Start (pi);
+ var proc = Process.Start (pi);
- proc.WaitForExit();
- return proc.ExitCode;
- }
- }
+ proc.WaitForExit();
+ return proc.ExitCode;
+ }
+ }
}