diff options
Diffstat (limited to 'mcs/tools/mkbundle/mkbundle.cs')
-rw-r--r-- | mcs/tools/mkbundle/mkbundle.cs | 81 |
1 files changed, 18 insertions, 63 deletions
diff --git a/mcs/tools/mkbundle/mkbundle.cs b/mcs/tools/mkbundle/mkbundle.cs index 7fbda6bc581..959e0d6e146 100644 --- a/mcs/tools/mkbundle/mkbundle.cs +++ b/mcs/tools/mkbundle/mkbundle.cs @@ -9,7 +9,6 @@ // (C) Novell, Inc 2004 // using System; -using System.Diagnostics; using System.Xml; using System.Collections; using System.Reflection; @@ -36,8 +35,6 @@ class MakeBundle { ArrayList sources = new ArrayList (); int top = args.Length; link_paths.Add ("."); - - DetectOS (); for (int i = 0; i < top; i++){ switch (args [i]){ @@ -85,10 +82,6 @@ class MakeBundle { keeptemp = true; break; case "--static": - if (style == "windows") { - Console.Error.WriteLine ("The option `{0}' is not supported on this platform.", args [i]); - return 1; - } static_link = true; Console.WriteLine ("Note that statically linking the LGPL Mono runtime has more licensing restrictions than dynamically linking."); Console.WriteLine ("See http://www.mono-project.com/Licensing for details on licensing."); @@ -110,10 +103,6 @@ class MakeBundle { config_dir = args [++i]; break; case "-z": - if (style == "windows") { - Console.Error.WriteLine ("The option `{0}' is not supported on this platform.", args [i]); - return 1; - } compress = true; break; default: @@ -122,6 +111,8 @@ class MakeBundle { } } + DetectOS (); + Console.WriteLine ("Sources: {0} Auto-dependencies: {1}", sources.Count, autodeps); if (sources.Count == 0 || output == null) { Help (); @@ -162,14 +153,6 @@ class MakeBundle { "_{0}:\n", name, size); break; - case "windows": - sw.WriteLine ( - ".globl _{0}\n" + - "\t.section .rdata,\"dr\"\n" + - "\t.align 32\n" + - "_{0}:\n", - name, size); - break; } } @@ -177,7 +160,7 @@ class MakeBundle { { string temp_s = "temp.s"; // Path.GetTempFileName (); string temp_c = "temp.c"; - string temp_o = "temp.o"; + string temp_o = Path.GetTempFileName () + ".o"; if (compile_only) temp_c = output; @@ -204,8 +187,8 @@ class MakeBundle { } foreach (string url in files){ - string fname = new Uri (url).LocalPath; - string aname = Path.GetFileName (fname); + string fname = url.Substring (7); + string aname = fname.Substring (fname.LastIndexOf ("/") + 1); string encoded = aname.Replace ("-", "_").Replace (".", "_"); if (prog == null) @@ -296,8 +279,9 @@ class MakeBundle { ts.Close (); Console.WriteLine ("Compiling:"); - string cmd = String.Format ("{0} -o {1} {2} ", GetEnv ("AS", "as"), temp_o, temp_s); - int ret = Execute (cmd); + string cmd = String.Format ("as -o {0} {1} ", temp_o, temp_s); + Console.WriteLine (cmd); + int ret = system (cmd); if (ret != 0){ Error ("[Fail]"); return; @@ -344,7 +328,6 @@ class MakeBundle { string zlib = (compress ? "-lz" : ""); string debugging = "-g"; - string cc = GetEnv ("CC", IsUnix ? "cc" : "gcc -mno-cygwin"); if (style == "linux") debugging = "-ggdb"; @@ -354,17 +337,18 @@ class MakeBundle { smonolib = "`pkg-config --variable=libdir mono`/libmono.a "; else smonolib = "-Wl,-Bstatic -lmono -Wl,-Bdynamic "; - cmd = String.Format ("{4} -o {2} -Wall `pkg-config --cflags mono` {0} {3} " + + cmd = String.Format ("cc -o {2} -Wall `pkg-config --cflags mono` {0} {3}" + "`pkg-config --libs-only-L mono` " + smonolib + "`pkg-config --libs-only-l mono | sed -e \"s/\\-lmono //\"` {1}", - temp_c, temp_o, output, zlib, cc); + temp_c, temp_o, output, zlib); } else { - cmd = String.Format ("{4} " + debugging + " -o {2} -Wall {0} `pkg-config --cflags --libs mono` {3} {1}", - temp_c, temp_o, output, zlib, cc); + cmd = String.Format ("cc " + debugging + " -o {2} -Wall {0} `pkg-config --cflags --libs mono` {3} {1}", + temp_c, temp_o, output, zlib); } - ret = Execute (cmd); + Console.WriteLine (cmd); + ret = system (cmd); if (ret != 0){ Error ("[Fail]"); return; @@ -411,7 +395,7 @@ class MakeBundle { return; files.Add (codebase); - Assembly a = Assembly.LoadFrom (new Uri(codebase).LocalPath); + Assembly a = Assembly.LoadFrom (codebase); if (!autodeps) return; @@ -486,7 +470,7 @@ class MakeBundle { " --config F Bundle system config file `F'\n" + " --config-dir D Set MONO_CFG_DIR to `D'\n" + " --static Statically link to mono libs\n" + - " -z Compress the assemblies before embedding.\n"); + " -z Compress the assemblies before embedding.\n"); } [DllImport ("libc")] @@ -496,12 +480,6 @@ class MakeBundle { static void DetectOS () { - if (!IsUnix) { - Console.WriteLine ("OS is: Windows"); - style = "windows"; - return; - } - IntPtr buf = UnixMarshal.AllocHeap(8192); if (uname (buf) != 0){ Console.WriteLine ("Warning: Unable to detect OS"); @@ -514,29 +492,6 @@ class MakeBundle { UnixMarshal.FreeHeap(buf); } - - static bool IsUnix { - get { - int p = (int) Environment.OSVersion.Platform; - return ((p == 4) || (p == 128)); - } - } - - static int Execute (string cmdLine) - { - Console.WriteLine (cmdLine); - if (IsUnix) { - return system (cmdLine); - } else { - Process p = Process.Start ("sh", String.Format ("-c \"{0}\"", cmdLine)); - p.WaitForExit (); - return p.ExitCode; - } - } - - static string GetEnv (string name, string defaultValue) - { - string s = Environment.GetEnvironmentVariable (name); - return s != null ? s : defaultValue; - } + } + |