Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
using System;
using System.Reflection;
// Attributes visible in " --help"
[assembly: AssemblyTitle ("macpack.exe")]
[assembly: AssemblyVersion (Consts.MonoVersion)]
[assembly: AssemblyDescription ("MacPack")]
[assembly: AssemblyCopyright ("MIT/X11")]

View File

@@ -0,0 +1,67 @@
2006-11-16 Miguel de Icaza <miguel@novell.com>
* MacPack.cs: Do not crash, and provide a warning message.
2006-04-30 Aaron Flynt <aaron@aaronflynt.com>
* MacPack.cs: Fixed typo in main method causing -i argument to be
treated like -o.
2006-03-13 Miguel de Icaza <miguel@novell.com>
* MacPack.cs: Remove Mono.GetOptions to provide better handling of
the command line and better error reporting.
2005-11-05 Kornél Pál <kornelpal@hotmail.com>
* AssemblyInfo.cs: Use Consts.MonoVersion as AssemblyVersion.
* macpack.exe.sources: Added Consts.cs.
2005-10-18 Geoff Norton <gnorton@customerdna.com>
* MacPack.cs: Support Application Icons that are referenced from
something other than cwd.
2005-10-13 Geoff Norton <gnorton@customerdna.com>
* MacPack.cs:
PLIST: Support Application Icons
2005-09-31 Geoff Norton <gnorton@customerdna.com>
* LOADER: Whoops; forgot to rm the new file.
2005-09-31 Geoff Norton <gnorton@customerdna.com>
* LOADER: We exposed an apple bug. This caused duplicates of the
main window to open by having AppName in Resources. Modified from
a patch provided by Aaron Flynt (aaron@aaronflynt.com)
2005-09-31 Geoff Norton <gnorton@customerdna.com>
* LOADER: Launch a runtime generated symlink to mono instead of
/usr/bin/mono. This makes the Application Title in the menu appear
correctly and not as "mono".
2005-03-30 Geoff Norton <gnorton@customerdna.com>
* LOADER: Handle names with " " in them. Thanks to
Edward J. Sabol (sabol@alderaan.gsfc.nasa.gov)
2005-03-24 Geoff Norton <gnorton@customerdna.com>
* MacPack.cs:
LOADER:
Add support for macpacking Gtk#/X11 applications.
2005-02-01 Raja R Harinath <rharinath@novell.com>
* Makefile (EXTRA_DISTFILES): Distribute the resource files too.
2005-02-01 Geoff Norton <gnorton@customerdna.com>
* Makefile: Fix the build with CSC
2005-01-31 Geoff Norton <gnorton@customerdna.com>
* Initial import

43
mcs/tools/macpack/LOADER Executable file
View File

@@ -0,0 +1,43 @@
#!/bin/sh
#
# This is a stub script that allows .apps to be relocatable on OSX but still
# find the managed assembly.
#
# You should never have to edit this file directly as its generated by the
# bundle maker.
#
X11_MODE=%X11_MODE%
MWF_MODE=%MWF_MODE%
COCOASHARP_MODE=%COCOASHARP_MODE%
PWD=`pwd`
# Fetch the path relative to the launch point where this shell script exists.
APP_PATH=`echo $0 | awk '{split($0,patharr,"/"); idx=1; while(patharr[idx+3] != "") { if (patharr[idx] != "/") {printf("%s/", patharr[idx]); idx++ }} }'`
# Fetch the app name (its our own name)
APP_NAME=`echo $0 | awk '{split($0,patharr,"/"); idx=1; while(patharr[idx+1] != "") {idx++} printf("%s", patharr[idx]); }'`
ASSEMBLY=`echo $0 | awk '{split($0,patharr,"/"); idx=1; while(patharr[idx+1] != "") {idx++} printf("%s.exe", patharr[idx]); }'`
# Setup the environment for MWF if needed
if [ "$MWF_MODE" -eq "1" ]; then
export MONO_MWF_USE_CARBON_BACKEND=1
export GDIPLUS_NOX=1
fi
# Setup the environment for Cocoa# if needed
if [ "$COCOASHARP_MODE" -eq "1" ]; then
export MONO_GDIP_USE_COCOA_BACKEND=1
export DYLD_LIBRARY_PATH=$PWD/$APP_PATH/Contents/Resources:$DYLD_LIBRARY_PATH
fi
cd "$APP_PATH/Contents/Resources"
if [ "$X11_MODE" -eq "1" ]; then
open-x11 "$APP_NAME"
else
if [ ! -d "./bin" ]; then mkdir bin ; fi
if [ -f "./bin/$APP_NAME" ]; then rm -f "./bin/$APP_NAME" ; fi
ln -s `which mono` "./bin/$APP_NAME"
"./bin/$APP_NAME" "$ASSEMBLY"
fi

View File

@@ -0,0 +1,284 @@
//
// Author: Geoff Norton
// de-MonoOptionification: miguel.
//
// Copyright (C) 2004-2005 Geoff Norton.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.IO;
using System.Text;
using System.Reflection;
using System.Runtime.InteropServices;
namespace Mac {
public class PackOptions {
public string appname;
public string output;
public string assembly;
public string icon;
public string[] resource;
public int mode;
}
public class Pack {
private PackOptions opts;
public Pack () {}
public Pack (PackOptions opts) {
this.opts = opts;
}
public bool Generate () {
if (opts.output == null){
opts.output = ".";
}
if (opts.assembly == null){
Console.Error.WriteLine ("Error: No assembly to macpack was specified");
Usage ();
return false;
}
if (opts.appname == null){
string t = Path.ChangeExtension (opts.assembly, null);
int p = t.IndexOf (Path.DirectorySeparatorChar);
if (p != -1)
t = t.Substring (p+1);
opts.appname = t;
}
if (Directory.Exists (Path.Combine (opts.output, String.Format ("{0}.app", opts.appname)))) {
Console.WriteLine ("ERROR: That application already exists. Please delete it first");
return false;
}
Directory.CreateDirectory (Path.Combine (opts.output, String.Format ("{0}.app", opts.appname)));
Directory.CreateDirectory (Path.Combine (opts.output, String.Format ("{0}.app/Contents", opts.appname)));
Directory.CreateDirectory (Path.Combine (opts.output, String.Format ("{0}.app/Contents/MacOS", opts.appname)));
Directory.CreateDirectory (Path.Combine (opts.output, String.Format ("{0}.app/Contents/Resources", opts.appname)));
if (opts.resource != null) {
foreach (string res in opts.resource) {
try {
if (Directory.Exists (res)) {
CopyDirectory (res, Path.Combine (opts.output, String.Format ("{0}.app/Contents/Resources/{1}", opts.appname, Path.GetFileName (res))));
} else {
File.Copy (res, Path.Combine (opts.output, String.Format ("{0}.app/Contents/Resources/{1}", opts.appname, Path.GetFileName (res))));
}
} catch (Exception e){
Console.Error.WriteLine ("Error while processing {0} (Details: {1})", res, e.GetType ());
}
}
}
if (opts.icon != null)
File.Copy (opts.icon, Path.Combine (opts.output, String.Format ("{0}.app/Contents/Resources/{1}", opts.appname, Path.GetFileName (opts.icon))));
if (opts.mode <= 2) {
File.Copy (opts.assembly, Path.Combine (opts.output, String.Format ("{0}.app/Contents/Resources/{0}.exe", opts.appname)));
} else {
File.Copy (opts.assembly, Path.Combine (opts.output, String.Format ("{0}.app/Contents/Resources/{0}", opts.appname)));
}
Stream s = Assembly.GetEntryAssembly ().GetManifestResourceStream ("LOADER");
BinaryReader reader = new BinaryReader (s);
byte[] data = reader.ReadBytes ((int)s.Length);
reader.Close ();
BinaryWriter writer = new BinaryWriter (File.Create (Path.Combine (opts.output, String.Format ("{0}.app/Contents/MacOS/{0}", opts.appname))));
string script = Encoding.ASCII.GetString (data);
switch (opts.mode) {
default:
case 0:
script = script.Replace ("%MWF_MODE%", "0");
script = script.Replace ("%COCOASHARP_MODE%", "0");
script = script.Replace ("%X11_MODE%", "0");
break;
case 1:
script = script.Replace ("%MWF_MODE%", "1");
script = script.Replace ("%COCOASHARP_MODE%", "0");
script = script.Replace ("%X11_MODE%", "0");
break;
case 2:
script = script.Replace ("%MWF_MODE%", "0");
script = script.Replace ("%COCOASHARP_MODE%", "1");
script = script.Replace ("%X11_MODE%", "0");
break;
case 3:
script = script.Replace ("%MWF_MODE%", "0");
script = script.Replace ("%COCOASHARP_MODE%", "0");
script = script.Replace ("%X11_MODE%", "1");
break;
}
data = Encoding.ASCII.GetBytes (script);
writer.Write (data, 0, data.Length);
writer.Close ();
try {
chmod (Path.Combine (opts.output,
String.Format ("{0}.app/Contents/MacOS/{0}", opts.appname)),
Convert.ToUInt32 ("755", 8));
} catch {
Console.WriteLine ("WARNING: It was not possible to set the executable permissions on\n" +
"the file {0}.app/Contents/MacOS/{0}, the bundle might not work", opts.appname);
}
s = Assembly.GetEntryAssembly ().GetManifestResourceStream ("PLIST");
reader = new BinaryReader (s);
data = reader.ReadBytes ((int)s.Length);
reader.Close ();
writer = new BinaryWriter (File.Create (Path.Combine (opts.output, String.Format ("{0}.app/Contents/Info.plist", opts.appname))));
string plist = Encoding.UTF8.GetString (data);
plist = plist.Replace ("%APPNAME%", opts.appname);
plist = plist.Replace ("%ICONFILE%", Path.GetFileName (opts.icon));
data = Encoding.UTF8.GetBytes (plist);
writer.Write (data, 0, data.Length);
writer.Close ();
return true;
}
public static void CopyDirectory (string src, string dest) {
string [] files;
if (dest [dest.Length-1] != Path.DirectorySeparatorChar) {
dest += Path.DirectorySeparatorChar;
}
if (!Directory.Exists (dest)) {
Directory.CreateDirectory (dest);
}
files = Directory.GetFileSystemEntries (src);
foreach (string file in files) {
if (Directory.Exists (file)) {
CopyDirectory (file, dest + Path.GetFileName (file));
} else {
File.Copy (file, dest + Path.GetFileName (file), true);
}
}
}
static void Usage ()
{
Console.WriteLine ("\n" +
"Usage is:\n" +
"macpack [options] assembly\n" +
" -n appname -appname:appname Application Name\n" +
" -o output -output:OUTPUT Output directory\n" +
" -a assembly Assembly to pack\n" +
" -i file -icon file Icon filename\n" +
" -r resource1,resource2 Additional files to bundle\n" +
" -m [winforms|cocoa|x11|console] The mode for the application");
}
static int Main (string [] args) {
PackOptions options = new PackOptions ();
ArrayList resources = new ArrayList ();
for (int i = 0; i < args.Length; i++){
string s = args [i];
string key, value;
if (s.Length > 2){
int p = s.IndexOf (':');
if (p != -1){
key = s.Substring (0, p);
value = s.Substring (p + 1);
} else {
key = s;
value = null;
}
} else {
key = s;
if (i+1 < args.Length)
value = args [i+1];
else
value = null;
}
switch (key){
case "-n": case "-appname":
options.appname = value;
break;
case "-o": case "-output":
options.output = value;
break;
case "-a": case "-assembly":
options.assembly = value;
break;
case "-i": case "-icon":
options.icon = value;
break;
case "-r": case "-resource":
foreach (string ss in value.Split (new char [] {','}))
resources.Add (ss);
break;
case "-about":
Console.WriteLine ("MacPack 1.0 by Geoff Norton\n");
break;
case "-m": case "-mode":
switch (value){
case "winforms":
options.mode = 1;
break;
case "x11":
options.mode = 3;
break;
case "console":
options.mode = 0;
break;
case "cocoa":
options.mode = 2;
break;
default:
try {
options.mode = Int32.Parse (value);
} catch {
Console.Error.WriteLine ("Could not recognize option {0} as the mode", value);
}
break;
}
break;
case "-h": case "-help":
Usage ();
break;
default:
options.assembly = key;
break;
}
}
options.resource = (string [])resources.ToArray (typeof (string));
Pack pack = new Pack (options);
if (pack.Generate ())
return 0;
return -1;
}
[DllImport ("libc")]
static extern int chmod (string path, uint mode);
}
}

View File

@@ -0,0 +1,16 @@
thisdir = tools/macpack
SUBDIRS =
RESOURCE_FILES = \
LOADER \
PLIST
include ../../build/rules.make
LOCAL_MCS_FLAGS = \
$(RESOURCE_FILES:%=/resource:%)
PROGRAM = macpack.exe
EXTRA_DISTFILES = $(RESOURCE_FILES)
include ../../build/executable.make

12
mcs/tools/macpack/PLIST Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>%APPNAME%</string>
<key>CFBundleExecutable</key>
<string>%APPNAME%</string>
<key>CFBundleIconFile</key>
<string>%ICONFILE%</string>
</dict>
</plist>

View File

@@ -0,0 +1,3 @@
MacPack.cs
AssemblyInfo.cs
../../build/common/Consts.cs