Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions tools/mmp/driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,9 @@ static void CopyDependencies (IDictionary<string, List<MethodDefinition>> librar
string libName = Path.GetFileName (linkWith);
string finalLibPath = Path.Combine (mmp_dir, libName);
Application.UpdateFile (linkWith, finalLibPath);
XcodeRun ("install_name_tool -id", string.Format ("{0} {1}", Quote("@executable_path/../" + BundleName + "/" + libName), finalLibPath));
int ret = XcodeRun ("install_name_tool -id", string.Format ("{0} {1}", Quote("@executable_path/../" + BundleName + "/" + libName), finalLibPath));
if (ret != 0)
throw new MonoMacException (5310, true, "install_name_tool failed with an error code '{0}'. Check build log for details.", ret);
native_libraries_copied_in.Add (libName);
}
}
Expand All @@ -1249,7 +1251,9 @@ static void CopyDependencies (IDictionary<string, List<MethodDefinition>> librar
// if required update the paths inside the .dylib that was copied
if (sb.Length > 0) {
sb.Append (' ').Append (Quote (library));
XcodeRun ("install_name_tool", sb.ToString ());
int ret = XcodeRun ("install_name_tool", sb.ToString ());
if (ret != 0)
throw new MonoMacException (5310, true, "install_name_tool failed with an error code '{0}'. Check build log for details.", ret);
sb.Clear ();
}
}
Expand Down Expand Up @@ -1373,13 +1377,17 @@ static void ProcessNativeLibrary (HashSet<string> processed, string library, Lis
Console.WriteLine ("Dependency {0} was already at destination, skipping.", Path.GetFileName (real_src));
}
else {
File.Copy (real_src, dest, true);
// install_name_tool gets angry if you copy in a read only native library
CopyFileAndRemoveReadOnly (real_src, dest);
}

bool isStaticLib = real_src.EndsWith (".a");
if (native_references.Contains (real_src)) {
if (!isStaticLib)
XcodeRun ("install_name_tool -id", string.Format ("{0} {1}", Quote("@executable_path/../" + BundleName + "/" + name), dest));
if (!isStaticLib) {
int ret = XcodeRun ("install_name_tool -id", string.Format ("{0} {1}", Quote("@executable_path/../" + BundleName + "/" + name), dest));
if (ret != 0)
throw new MonoMacException (5310, true, "install_name_tool failed with an error code '{0}'. Check build log for details.", ret);
}
native_libraries_copied_in.Add (name);
}

Expand Down Expand Up @@ -1483,13 +1491,22 @@ static void CopyI18nAssemblies (I18nAssemblies i18n)
resolved_assemblies.Add (Path.Combine (fx_dir, "I18N.West.dll"));
}

static void CopyFileAndRemoveReadOnly (string src, string dest) {
File.Copy (src, dest, true);

FileAttributes attrs = File.GetAttributes (dest);
if ((attrs & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
File.SetAttributes (dest, attrs & ~FileAttributes.ReadOnly);
}

static void CopyAssemblies () {
foreach (string asm in resolved_assemblies) {
var mdbfile = string.Format ("{0}.mdb", asm);
var configfile = string.Format ("{0}.config", asm);
string filename = Path.GetFileName (asm);

File.Copy (asm, Path.Combine (mmp_dir, filename), true);
// The linker later gets angry if you copy in a read only assembly
CopyFileAndRemoveReadOnly (asm, Path.Combine (mmp_dir, filename));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's the best place to solve this as it leave the 3 other linkers (XI, XA and monolinker) code base with an identical issue.

if (verbose > 0)
Console.WriteLine ("Added assembly {0}", asm);

Expand Down
3 changes: 2 additions & 1 deletion tools/mmp/error.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace Xamarin.Bundler {
// MM2010 Unknown HttpMessageHandler `{0}`. Valid values are HttpClientHandler (default), CFNetworkHandler or NSUrlSessionHandler
// MM2011 Unknown TLSProvider `{0}. Valid values are default, legacy or appletls
// MM2012 Only first {0} of {1} "Referenced by" warnings shown. ** This message related to 2009 **
// Warning MM2013 Failed to resolve the reference to "{0}", referenced in "{1}". The app will not include the referenced assembly, and may fail at runtime.
// Warning MM2013 Failed to resolve the reference to "{0}", referenced in "{1}". The app will not include the referenced assembly, and may fail at runtime.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only whitespace change?

// MM4xxx code generation
// MM40xx driver.m
// MM4001 The main template could not be expansed to `{0}`.
Expand Down Expand Up @@ -96,6 +96,7 @@ namespace Xamarin.Bundler {
// MM5306 Missing dependencies. Please install Xcode 'Command-Line Tools' component
// MM5308 Xcode license agreement may not have been accepted. Please launch Xcode.
// MM5309 Native linking failed with error code 1. Check build log for details.
// MT5310 install_name_tool failed with an error code '{0}'. Check build log for details.
// MM6xxx mmp internal tools
// MM7xxx reserved
// MM8xxx runtime
Expand Down
1 change: 1 addition & 0 deletions tools/mtouch/error.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ namespace Xamarin.Bundler {
// MT5307 Failed to sign the executable. Please review the build log.
// MT5308 ** reserved Xamarin.Mac **
// MT5309 ** reserved Xamarin.Mac **
// MT5310 ** reserved Xamarin.Mac **
// MT6xxx mtouch internal tools
// MT600x Stripper
// MT6001 Running version of Cecil doesn't support assembly stripping
Expand Down