[mtouch/mmp] Move the Driver.PRODUCT constant to an Application.ProductName instance field. (#9280)

A few changes are required to have an Application instance at hand when we need to
get the ProductName from it.

This is necessary for .NET, since there will be a single linker library for all platforms,
which means we can't use a constant.
This commit is contained in:
Rolf Bjarne Kvinge 2020-08-06 16:10:06 +02:00 коммит произвёл GitHub
Родитель be095c5a26
Коммит 264fa44f6f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
10 изменённых файлов: 136 добавлений и 129 удалений

Просмотреть файл

@ -388,15 +388,15 @@ namespace Xamarin.Bundler {
RuntimeOptions = RuntimeOptions.Create (this, HttpMessageHandler, TlsProvider); RuntimeOptions = RuntimeOptions.Create (this, HttpMessageHandler, TlsProvider);
if (RequiresXcodeHeaders && SdkVersion < SdkVersions.GetVersion (Platform)) { if (RequiresXcodeHeaders && SdkVersion < SdkVersions.GetVersion (this)) {
throw ErrorHelper.CreateError (91, Errors.MX0091, ProductName, PlatformName, SdkVersions.GetVersion (Platform), SdkVersions.Xcode, Error91LinkerSuggestion); throw ErrorHelper.CreateError (91, Errors.MX0091, ProductName, PlatformName, SdkVersions.GetVersion (this), SdkVersions.Xcode, Error91LinkerSuggestion);
} }
if (DeploymentTarget != null) { if (DeploymentTarget != null) {
if (DeploymentTarget < Xamarin.SdkVersions.GetMinVersion (Platform)) if (DeploymentTarget < Xamarin.SdkVersions.GetMinVersion (this))
throw new ProductException (73, true, Errors.MT0073, Constants.Version, DeploymentTarget, Xamarin.SdkVersions.GetMinVersion (Platform), PlatformName, ProductName); throw new ProductException (73, true, Errors.MT0073, Constants.Version, DeploymentTarget, Xamarin.SdkVersions.GetMinVersion (this), PlatformName, ProductName);
if (DeploymentTarget > Xamarin.SdkVersions.GetVersion (Platform)) if (DeploymentTarget > Xamarin.SdkVersions.GetVersion (this))
throw new ProductException (74, true, Errors.MX0074, Constants.Version, DeploymentTarget, Xamarin.SdkVersions.GetVersion (Platform), PlatformName, ProductName); throw new ProductException (74, true, Errors.MX0074, Constants.Version, DeploymentTarget, Xamarin.SdkVersions.GetVersion (this), PlatformName, ProductName);
} }
if (Platform == ApplePlatform.WatchOS && EnableCoopGC.HasValue && !EnableCoopGC.Value) if (Platform == ApplePlatform.WatchOS && EnableCoopGC.HasValue && !EnableCoopGC.Value)

Просмотреть файл

@ -732,13 +732,13 @@ namespace Xamarin.Bundler {
} }
static string local_build; static string local_build;
public static string WalkUpDirHierarchyLookingForLocalBuild () public static string WalkUpDirHierarchyLookingForLocalBuild (Application app)
{ {
if (local_build == null) { if (local_build == null) {
var localPath = Path.GetDirectoryName (GetFullPath ()); var localPath = Path.GetDirectoryName (GetFullPath ());
while (localPath.Length > 1) { while (localPath.Length > 1) {
if (File.Exists (Path.Combine (localPath, "Make.config"))) { if (File.Exists (Path.Combine (localPath, "Make.config"))) {
local_build = Path.Combine (localPath, LOCAL_BUILD_DIR, "Library", "Frameworks", PRODUCT + ".framework", "Versions", "Current"); local_build = Path.Combine (localPath, LOCAL_BUILD_DIR, "Library", "Frameworks", app.ProductName + ".framework", "Versions", "Current");
return local_build; return local_build;
} }
@ -751,45 +751,42 @@ namespace Xamarin.Bundler {
// This is the 'Current' directory of the installed framework // This is the 'Current' directory of the installed framework
// For XI/XM installed from package it's /Library/Frameworks/Xamarin.iOS.framework/Versions/Current or /Library/Frameworks/Xamarin.Mac.framework/Versions/Current // For XI/XM installed from package it's /Library/Frameworks/Xamarin.iOS.framework/Versions/Current or /Library/Frameworks/Xamarin.Mac.framework/Versions/Current
static string framework_dir; static string framework_dir;
public static string FrameworkDirectory { public static string GetFrameworkCurrentDirectory (Application app)
get { {
if (framework_dir == null) { if (framework_dir == null) {
var env_framework_dir = Environment.GetEnvironmentVariable (FRAMEWORK_LOCATION_VARIABLE); var env_framework_dir = Environment.GetEnvironmentVariable (FRAMEWORK_LOCATION_VARIABLE);
if (!string.IsNullOrEmpty (env_framework_dir)) { if (!string.IsNullOrEmpty (env_framework_dir)) {
framework_dir = env_framework_dir; framework_dir = env_framework_dir;
} else { } else {
#if DEBUG #if DEBUG
// when launched from Visual Studio, the executable is not in the final install location, // when launched from Visual Studio, the executable is not in the final install location,
// so walk the directory hierarchy to find the root source directory. // so walk the directory hierarchy to find the root source directory.
framework_dir = WalkUpDirHierarchyLookingForLocalBuild (); framework_dir = WalkUpDirHierarchyLookingForLocalBuild (app);
#else #else
framework_dir = Path.GetDirectoryName (Path.GetDirectoryName (Path.GetDirectoryName (GetFullPath ()))); framework_dir = Path.GetDirectoryName (Path.GetDirectoryName (Path.GetDirectoryName (GetFullPath ())));
#endif #endif
}
framework_dir = Target.GetRealPath (framework_dir);
} }
return framework_dir; framework_dir = Target.GetRealPath (framework_dir);
} }
return framework_dir;
} }
// This is the 'Current/bin' directory of the installed framework // This is the 'Current/bin' directory of the installed framework
// For XI/XM installed from package it's one of these two: // For XI/XM installed from package it's one of these two:
// /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin // /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin
// /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/bin // /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/bin
public static string FrameworkBinDirectory { public static string GetFrameworkBinDirectory (Application app)
get { {
return Path.Combine (FrameworkDirectory, "bin"); return Path.Combine (GetFrameworkCurrentDirectory (app), "bin");
}
} }
// This is the 'Current/lib' directory of the installed framework // This is the 'Current/lib' directory of the installed framework
// For XI/XM installed from package it's one of these two: // For XI/XM installed from package it's one of these two:
// /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib // /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib
// /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib // /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib
public static string FrameworkLibDirectory { public static string GetFrameworkLibDirectory (Application app)
get { {
return Path.Combine (FrameworkDirectory, "lib"); return Path.Combine (GetFrameworkCurrentDirectory (app), "lib");
}
} }
// This is the directory where the libxamarin*.[a|dylib] and libxammac*.[a|dylib] libraries are // This is the directory where the libxamarin*.[a|dylib] and libxammac*.[a|dylib] libraries are
@ -814,19 +811,19 @@ namespace Xamarin.Bundler {
{ {
switch (app.Platform) { switch (app.Platform) {
case ApplePlatform.iOS: case ApplePlatform.iOS:
return Path.Combine (FrameworkLibDirectory, "mono", "Xamarin.iOS"); return Path.Combine (GetFrameworkLibDirectory (app), "mono", "Xamarin.iOS");
case ApplePlatform.WatchOS: case ApplePlatform.WatchOS:
return Path.Combine (FrameworkLibDirectory, "mono", "Xamarin.WatchOS"); return Path.Combine (GetFrameworkLibDirectory (app), "mono", "Xamarin.WatchOS");
case ApplePlatform.TVOS: case ApplePlatform.TVOS:
return Path.Combine (FrameworkLibDirectory, "mono", "Xamarin.TVOS"); return Path.Combine (GetFrameworkLibDirectory (app), "mono", "Xamarin.TVOS");
case ApplePlatform.MacOSX: case ApplePlatform.MacOSX:
#if MMP #if MMP
if (IsUnifiedMobile) if (IsUnifiedMobile)
return Path.Combine (FrameworkLibDirectory, "mono", "Xamarin.Mac"); return Path.Combine (GetFrameworkLibDirectory (app), "mono", "Xamarin.Mac");
return Path.Combine (FrameworkLibDirectory, "mono", "4.5"); return Path.Combine (GetFrameworkLibDirectory (app), "mono", "4.5");
#endif #endif
default: default:
throw ErrorHelper.CreateError (71, Errors.MX0071, app.Platform, PRODUCT); throw ErrorHelper.CreateError (71, Errors.MX0071, app.Platform, app.ProductName);
} }
} }
@ -884,7 +881,7 @@ namespace Xamarin.Bundler {
// /Library/Frameworks/Xamarin.*.framework/Versions/Current/SDKs/*.sdk // /Library/Frameworks/Xamarin.*.framework/Versions/Current/SDKs/*.sdk
public static string GetProductSdkDirectory (Application app) public static string GetProductSdkDirectory (Application app)
{ {
var sdksDir = Path.Combine (FrameworkDirectory, "SDKs"); var sdksDir = Path.Combine (GetFrameworkCurrentDirectory (app), "SDKs");
string sdkName; string sdkName;
switch (app.Platform) { switch (app.Platform) {
case ApplePlatform.iOS: case ApplePlatform.iOS:
@ -900,7 +897,7 @@ namespace Xamarin.Bundler {
sdkName = "Xamarin.macOS.sdk"; sdkName = "Xamarin.macOS.sdk";
break; break;
default: default:
throw ErrorHelper.CreateError (71, Errors.MX0071, app.Platform, PRODUCT); throw ErrorHelper.CreateError (71, Errors.MX0071, app.Platform, app.ProductName);
} }
return Path.Combine (sdksDir, sdkName); return Path.Combine (sdksDir, sdkName);
} }
@ -918,7 +915,7 @@ namespace Xamarin.Bundler {
case ApplePlatform.MacOSX: case ApplePlatform.MacOSX:
return "MacOSX"; return "MacOSX";
default: default:
throw ErrorHelper.CreateError (71, Errors.MX0071, app.Platform, PRODUCT); throw ErrorHelper.CreateError (71, Errors.MX0071, app.Platform, app.ProductName);
} }
} }
@ -941,11 +938,11 @@ namespace Xamarin.Bundler {
case ApplePlatform.MacOSX: case ApplePlatform.MacOSX:
return "Xamarin.Mac"; return "Xamarin.Mac";
default: default:
throw ErrorHelper.CreateError (71, Errors.MX0071, app.Platform, PRODUCT); throw ErrorHelper.CreateError (71, Errors.MX0071, app.Platform, app.ProductName);
} }
} }
static void ValidateXcode (bool accept_any_xcode_version, bool warn_if_not_found) static void ValidateXcode (Application app, bool accept_any_xcode_version, bool warn_if_not_found)
{ {
if (sdk_root == null) { if (sdk_root == null) {
sdk_root = FindSystemXcode (); sdk_root = FindSystemXcode ();
@ -1002,10 +999,10 @@ namespace Xamarin.Bundler {
if (!accept_any_xcode_version) { if (!accept_any_xcode_version) {
if (min_xcode_version != null && XcodeVersion < min_xcode_version) if (min_xcode_version != null && XcodeVersion < min_xcode_version)
throw ErrorHelper.CreateError (51, Errors.MT0051, Constants.Version, XcodeVersion.ToString (), sdk_root, PRODUCT, min_xcode_version); throw ErrorHelper.CreateError (51, Errors.MT0051, Constants.Version, XcodeVersion.ToString (), sdk_root, app.ProductName, min_xcode_version);
if (XcodeVersion < SdkVersions.XcodeVersion) if (XcodeVersion < SdkVersions.XcodeVersion)
ErrorHelper.Warning (79, Errors.MT0079, Constants.Version, XcodeVersion.ToString (), sdk_root, SdkVersions.Xcode, PRODUCT); ErrorHelper.Warning (79, Errors.MT0079, Constants.Version, XcodeVersion.ToString (), sdk_root, SdkVersions.Xcode, app.ProductName);
} }
Driver.Log (1, "Using Xcode {0} ({2}) found in {1}", XcodeVersion, sdk_root, XcodeProductVersion); Driver.Log (1, "Using Xcode {0} ({2}) found in {1}", XcodeVersion, sdk_root, XcodeProductVersion);
@ -1045,7 +1042,7 @@ namespace Xamarin.Bundler {
} }
static readonly Dictionary<string, string> tools = new Dictionary<string, string> (); static readonly Dictionary<string, string> tools = new Dictionary<string, string> ();
static string FindTool (string tool) static string FindTool (Application app, string tool)
{ {
string path; string path;
@ -1054,10 +1051,10 @@ namespace Xamarin.Bundler {
return path; return path;
} }
path = LocateTool (tool); path = LocateTool (app, tool);
static string LocateTool (string tool) static string LocateTool (Application app, string tool)
{ {
if (XcrunFind (tool, out var path)) if (XcrunFind (app, tool, out var path))
return path; return path;
// either /Developer (Xcode 4.2 and earlier), /Applications/Xcode.app/Contents/Developer (Xcode 4.3) or user override // either /Developer (Xcode 4.2 and earlier), /Applications/Xcode.app/Contents/Developer (Xcode 4.3) or user override
@ -1089,12 +1086,12 @@ namespace Xamarin.Bundler {
return path; return path;
} }
static bool XcrunFind (string tool, out string path) static bool XcrunFind (Application app, string tool, out string path)
{ {
return XcrunFind (ApplePlatform.None, false, tool, out path); return XcrunFind (app, ApplePlatform.None, false, tool, out path);
} }
static bool XcrunFind (ApplePlatform platform, bool is_simulator, string tool, out string path) static bool XcrunFind (Application app, ApplePlatform platform, bool is_simulator, string tool, out string path)
{ {
var env = new Dictionary<string, string> (); var env = new Dictionary<string, string> ();
// Unset XCODE_DEVELOPER_DIR_PATH. See https://github.com/xamarin/xamarin-macios/issues/3931. // Unset XCODE_DEVELOPER_DIR_PATH. See https://github.com/xamarin/xamarin-macios/issues/3931.
@ -1122,7 +1119,7 @@ namespace Xamarin.Bundler {
args.Add (is_simulator ? "watchsimulator" : "watchos"); args.Add (is_simulator ? "watchsimulator" : "watchos");
break; break;
default: default:
throw ErrorHelper.CreateError (71, Errors.MX0071 /* Unknown platform: {0}. This usually indicates a bug in {1}; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case. */, platform.ToString (), PRODUCT); throw ErrorHelper.CreateError (71, Errors.MX0071 /* Unknown platform: {0}. This usually indicates a bug in {1}; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case. */, platform.ToString (), app.ProductName);
} }
} }
args.Add ("-f"); args.Add ("-f");
@ -1162,63 +1159,63 @@ namespace Xamarin.Bundler {
return ret == 0; return ret == 0;
} }
public static void RunXcodeTool (string tool, params string[] arguments) public static void RunXcodeTool (Application app, string tool, params string[] arguments)
{ {
RunXcodeTool (tool, (IList<string>) arguments); RunXcodeTool (app, tool, (IList<string>) arguments);
} }
public static void RunXcodeTool (string tool, IList<string> arguments) public static void RunXcodeTool (Application app, string tool, IList<string> arguments)
{ {
var executable = FindTool (tool); var executable = FindTool (app, tool);
var rv = RunCommand (executable, arguments); var rv = RunCommand (executable, arguments);
if (rv != 0) if (rv != 0)
throw ErrorHelper.CreateError (5309, Errors.MX5309 /* Failed to execute the tool '{0}', it failed with an error code '{1}'. Please check the build log for details. */, tool, rv); throw ErrorHelper.CreateError (5309, Errors.MX5309 /* Failed to execute the tool '{0}', it failed with an error code '{1}'. Please check the build log for details. */, tool, rv);
} }
public static void RunClang (IList<string> arguments) public static void RunClang (Application app, IList<string> arguments)
{ {
RunXcodeTool ("clang", arguments); RunXcodeTool (app, "clang", arguments);
} }
public static void RunInstallNameTool (IList<string> arguments) public static void RunInstallNameTool (Application app, IList<string> arguments)
{ {
RunXcodeTool ("install_name_tool", arguments); RunXcodeTool (app, "install_name_tool", arguments);
} }
public static void RunBitcodeStrip (IList<string> arguments) public static void RunBitcodeStrip (Application app, IList<string> arguments)
{ {
RunXcodeTool ("bitcode_strip", arguments); RunXcodeTool (app, "bitcode_strip", arguments);
} }
public static void RunLipo (string output, IEnumerable<string> inputs) public static void RunLipo (Application app, string output, IEnumerable<string> inputs)
{ {
var sb = new List<string> (); var sb = new List<string> ();
sb.AddRange (inputs); sb.AddRange (inputs);
sb.Add ("-create"); sb.Add ("-create");
sb.Add ("-output"); sb.Add ("-output");
sb.Add (output); sb.Add (output);
RunLipo (sb); RunLipo (app, sb);
} }
public static void RunLipo (IList<string> options) public static void RunLipo (Application app, IList<string> options)
{ {
RunXcodeTool ("lipo", options); RunXcodeTool (app, "lipo", options);
} }
public static void CreateDsym (string output_dir, string appname, string dsym_dir) public static void CreateDsym (Application app, string output_dir, string appname, string dsym_dir)
{ {
RunDsymUtil (Path.Combine (output_dir, appname), "-num-threads", "4", "-z", "-o", dsym_dir); RunDsymUtil (app, Path.Combine (output_dir, appname), "-num-threads", "4", "-z", "-o", dsym_dir);
RunCommand ("/usr/bin/mdimport", dsym_dir); RunCommand ("/usr/bin/mdimport", dsym_dir);
} }
public static void RunDsymUtil (params string [] options) public static void RunDsymUtil (Application app, params string [] options)
{ {
RunXcodeTool ("dsymutil", options); RunXcodeTool (app, "dsymutil", options);
} }
public static void RunStrip (IList<string> options) public static void RunStrip (Application app, IList<string> options)
{ {
RunXcodeTool ("strip", options); RunXcodeTool (app, "strip", options);
} }
public static string CorlibName { public static string CorlibName {
@ -1233,7 +1230,7 @@ namespace Xamarin.Bundler {
{ {
var rv = Frameworks.GetFrameworks (app.Platform, app.IsSimulatorBuild); var rv = Frameworks.GetFrameworks (app.Platform, app.IsSimulatorBuild);
if (rv == null) if (rv == null)
throw ErrorHelper.CreateError (71, Errors.MX0071, app.Platform, PRODUCT); throw ErrorHelper.CreateError (71, Errors.MX0071, app.Platform, app.ProductName);
return rv; return rv;
} }

Просмотреть файл

@ -63,39 +63,39 @@ namespace Xamarin {
public static Version XcodeVersion { get { return new Version (Xcode); }} public static Version XcodeVersion { get { return new Version (Xcode); }}
#if MTOUCH || MMP #if MTOUCH || MMP
public static Version GetVersion (ApplePlatform platform) public static Version GetVersion (Application app)
{ {
switch (platform) { switch (app.Platform) {
case ApplePlatform.MacOSX: return OSXVersion; case ApplePlatform.MacOSX: return OSXVersion;
case ApplePlatform.iOS: return iOSVersion; case ApplePlatform.iOS: return iOSVersion;
case ApplePlatform.WatchOS: return WatchOSVersion; case ApplePlatform.WatchOS: return WatchOSVersion;
case ApplePlatform.TVOS: return TVOSVersion; case ApplePlatform.TVOS: return TVOSVersion;
default: default:
throw ErrorHelper.CreateError (71, "Unknown platform: {0}. This usually indicates a bug in {1}; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case.", platform, Application.ProductName); throw ErrorHelper.CreateError (71, "Unknown platform: {0}. This usually indicates a bug in {1}; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case.", app.Platform, app.ProductName);
} }
} }
public static Version GetTargetVersion (ApplePlatform platform) public static Version GetTargetVersion (Application app)
{ {
switch (platform) { switch (app.Platform) {
case ApplePlatform.MacOSX: return OSXVersion; case ApplePlatform.MacOSX: return OSXVersion;
case ApplePlatform.iOS: return iOSTargetVersion; case ApplePlatform.iOS: return iOSTargetVersion;
case ApplePlatform.WatchOS: return WatchOSTargetVersion; case ApplePlatform.WatchOS: return WatchOSTargetVersion;
case ApplePlatform.TVOS: return TVOSTargetVersion; case ApplePlatform.TVOS: return TVOSTargetVersion;
default: default:
throw ErrorHelper.CreateError (71, "Unknown platform: {0}. This usually indicates a bug in {1}; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case.", platform, Application.ProductName); throw ErrorHelper.CreateError (71, "Unknown platform: {0}. This usually indicates a bug in {1}; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case.", app.Platform, app.ProductName);
} }
} }
public static Version GetMinVersion (ApplePlatform platform) public static Version GetMinVersion (Application app)
{ {
switch (platform) { switch (app.Platform) {
case ApplePlatform.MacOSX: return MinOSXVersion; case ApplePlatform.MacOSX: return MinOSXVersion;
case ApplePlatform.iOS: return MiniOSVersion; case ApplePlatform.iOS: return MiniOSVersion;
case ApplePlatform.WatchOS: return MinWatchOSVersion; case ApplePlatform.WatchOS: return MinWatchOSVersion;
case ApplePlatform.TVOS: return MinTVOSVersion; case ApplePlatform.TVOS: return MinTVOSVersion;
default: default:
throw ErrorHelper.CreateError (71, "Unknown platform: {0}. This usually indicates a bug in {1}; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case.", platform, Application.ProductName); throw ErrorHelper.CreateError (71, "Unknown platform: {0}. This usually indicates a bug in {1}; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case.", app.Platform, app.ProductName);
} }
} }
#endif #endif

Просмотреть файл

@ -4,7 +4,7 @@ using System.Linq;
namespace Xamarin.Bundler { namespace Xamarin.Bundler {
public partial class Application public partial class Application
{ {
public const string ProductName = "Xamarin.Mac"; public string ProductName = "Xamarin.Mac";
public const string Error91LinkerSuggestion = "use the dynamic registrar or set the managed linker behaviour to Link Platform or Link Framework SDKs Only in your project's Mac Build Options > Linker Behavior"; public const string Error91LinkerSuggestion = "use the dynamic registrar or set the managed linker behaviour to Link Platform or Link Framework SDKs Only in your project's Mac Build Options > Linker Behavior";
public bool IsSimulatorBuild => false; public bool IsSimulatorBuild => false;

Просмотреть файл

@ -177,8 +177,19 @@ namespace Xamarin.Bundler {
// Allows tests to stub out actual compilation and parallelism // Allows tests to stub out actual compilation and parallelism
public RunCommandDelegate RunCommand { get; set; } = Driver.RunCommand; public RunCommandDelegate RunCommand { get; set; } = Driver.RunCommand;
public ParallelOptions ParallelOptions { get; set; } = new ParallelOptions () { MaxDegreeOfParallelism = Driver.Concurrency }; public ParallelOptions ParallelOptions { get; set; } = new ParallelOptions () { MaxDegreeOfParallelism = Driver.Concurrency };
public string XamarinMacPrefix { get; set; } = Driver.FrameworkDirectory; // FrameworkDirectory assumes GetExecutingAssembly in ways that are not valid for tests, so we must stub out
string xamarin_mac_prefix;
public string XamarinMacPrefix {
get {
if (xamarin_mac_prefix == null)
xamarin_mac_prefix = Driver.GetFrameworkCurrentDirectory (Driver.App);
return xamarin_mac_prefix;
}
set {
xamarin_mac_prefix = value;
}
}
AOTOptions options; AOTOptions options;
AOTCompilerType compilerType; AOTCompilerType compilerType;
bool IsRelease; bool IsRelease;

Просмотреть файл

@ -61,7 +61,6 @@ namespace Xamarin.Bundler {
public static partial class Driver { public static partial class Driver {
internal const string NAME = "mmp"; internal const string NAME = "mmp";
const string PRODUCT = "Xamarin.Mac";
const string LOCAL_BUILD_DIR = "_mac-build"; const string LOCAL_BUILD_DIR = "_mac-build";
const string FRAMEWORK_LOCATION_VARIABLE = "XAMMAC_FRAMEWORK_PATH"; const string FRAMEWORK_LOCATION_VARIABLE = "XAMMAC_FRAMEWORK_PATH";
internal static Application App = new Application (Environment.GetCommandLineArgs ()); internal static Application App = new Application (Environment.GetCommandLineArgs ());
@ -140,9 +139,9 @@ namespace Xamarin.Bundler {
public static string GetArch64Directory (Application app) public static string GetArch64Directory (Application app)
{ {
if (IsUnifiedMobile) if (IsUnifiedMobile)
return Path.Combine (FrameworkLibDirectory, "x86_64", "mobile"); return Path.Combine (GetFrameworkLibDirectory (app), "x86_64", "mobile");
else if (IsUnifiedFullXamMacFramework) else if (IsUnifiedFullXamMacFramework)
return Path.Combine (FrameworkLibDirectory, "x86_64", "full"); return Path.Combine (GetFrameworkLibDirectory (app), "x86_64", "full");
throw new InvalidOperationException ("Arch64Directory when not Mobile or Full?"); throw new InvalidOperationException ("Arch64Directory when not Mobile or Full?");
} }
@ -294,7 +293,7 @@ namespace Xamarin.Bundler {
} }
} }
ValidateXcode (false, true); ValidateXcode (App, false, true);
App.Initialize (); App.Initialize ();
@ -678,7 +677,7 @@ namespace Xamarin.Bundler {
static string MonoDirectory { static string MonoDirectory {
get { get {
if (IsUnifiedFullXamMacFramework || IsUnifiedMobile) if (IsUnifiedFullXamMacFramework || IsUnifiedMobile)
return FrameworkDirectory; return GetFrameworkCurrentDirectory (App);
return SystemMonoDirectory; return SystemMonoDirectory;
} }
} }
@ -736,7 +735,7 @@ namespace Xamarin.Bundler {
static string PartialStaticLibrary { static string PartialStaticLibrary {
get { get {
return Path.Combine (FrameworkLibDirectory, string.Format ("mmp/Xamarin.Mac.registrar.{0}.a", IsUnifiedMobile ? "mobile" : "full")); return Path.Combine (GetFrameworkLibDirectory (App), string.Format ("mmp/Xamarin.Mac.registrar.{0}.a", IsUnifiedMobile ? "mobile" : "full"));
} }
} }
@ -1067,7 +1066,7 @@ namespace Xamarin.Bundler {
sourceFiles.Add (main); sourceFiles.Add (main);
args.AddRange (sourceFiles); args.AddRange (sourceFiles);
RunClang (args); RunClang (App, args);
} catch (Win32Exception e) { } catch (Win32Exception e) {
throw new ProductException (5103, true, e, Errors.MM5103, "driver"); throw new ProductException (5103, true, e, Errors.MM5103, "driver");
} }
@ -1222,7 +1221,7 @@ namespace Xamarin.Bundler {
string libName = Path.GetFileName (linkWith); string libName = Path.GetFileName (linkWith);
string finalLibPath = Path.Combine (mmp_dir, libName); string finalLibPath = Path.Combine (mmp_dir, libName);
Application.UpdateFile (linkWith, finalLibPath); Application.UpdateFile (linkWith, finalLibPath);
RunInstallNameTool (new [] { "-id", "@executable_path/../" + App.CustomBundleName + "/" + libName, finalLibPath }); RunInstallNameTool (App, new [] { "-id", "@executable_path/../" + App.CustomBundleName + "/" + libName, finalLibPath });
native_libraries_copied_in.Add (libName); native_libraries_copied_in.Add (libName);
} }
} }
@ -1251,7 +1250,7 @@ namespace Xamarin.Bundler {
// if required update the paths inside the .dylib that was copied // if required update the paths inside the .dylib that was copied
if (sb.Count > 0) { if (sb.Count > 0) {
sb.Add (library); sb.Add (library);
RunInstallNameTool (sb); RunInstallNameTool (App, sb);
sb.Clear (); sb.Clear ();
} }
} }
@ -1389,7 +1388,7 @@ namespace Xamarin.Bundler {
if (native_references.Contains (real_src)) { if (native_references.Contains (real_src)) {
if (!isStaticLib) if (!isStaticLib)
RunInstallNameTool (new [] { "-id", "@executable_path/../" + App.CustomBundleName + "/" + name, dest }); RunInstallNameTool (App, new [] { "-id", "@executable_path/../" + App.CustomBundleName + "/" + name, dest });
native_libraries_copied_in.Add (name); native_libraries_copied_in.Add (name);
} }
@ -1422,7 +1421,7 @@ namespace Xamarin.Bundler {
return; return;
var arch = App.Abi.AsString (); var arch = App.Abi.AsString ();
RunLipo (new [] { dest, "-thin", arch, "-output", dest }); RunLipo (App, new [] { dest, "-thin", arch, "-output", dest });
if (name != "MonoPosixHelper" && name != "libmono-native-unified" && name != "libmono-native-compat") if (name != "MonoPosixHelper" && name != "libmono-native-unified" && name != "libmono-native-compat")
ErrorHelper.Warning (2108, Errors.MM2108, name, arch); ErrorHelper.Warning (2108, Errors.MM2108, name, arch);
} }
@ -1672,7 +1671,7 @@ namespace Xamarin.Bundler {
var arch = abi.AsArchString (); var arch = abi.AsArchString ();
switch (abi) { switch (abi) {
case Abi.x86_64: case Abi.x86_64:
return Path.Combine (Driver.FrameworkLibDirectory, arch, flavor, name + ".dll"); return Path.Combine (Driver.GetFrameworkLibDirectory (Driver.App), arch, flavor, name + ".dll");
default: default:
throw new ProductException (5205, true, Errors.MM5205, arch); throw new ProductException (5205, true, Errors.MM5205, arch);
} }

Просмотреть файл

@ -40,7 +40,7 @@ namespace Xamarin.Bundler {
public partial class Application public partial class Application
{ {
public const string ProductName = "Xamarin.iOS"; public string ProductName = "Xamarin.iOS";
public const string Error91LinkerSuggestion = "set the managed linker behaviour to Link Framework SDKs Only in your project's iOS Build Options > Linker Behavior"; public const string Error91LinkerSuggestion = "set the managed linker behaviour to Link Framework SDKs Only in your project's iOS Build Options > Linker Behavior";
public string ExecutableName; public string ExecutableName;
@ -1067,7 +1067,7 @@ namespace Xamarin.Bundler {
#endif #endif
if (DeploymentTarget == null) if (DeploymentTarget == null)
DeploymentTarget = Xamarin.SdkVersions.GetVersion (Platform); DeploymentTarget = Xamarin.SdkVersions.GetVersion (this);
if (Platform == ApplePlatform.iOS && (HasDynamicLibraries || HasFrameworks) && DeploymentTarget.Major < 8) { if (Platform == ApplePlatform.iOS && (HasDynamicLibraries || HasFrameworks) && DeploymentTarget.Major < 8) {
ErrorHelper.Warning (78, Errors.MT0078, DeploymentTarget); ErrorHelper.Warning (78, Errors.MT0078, DeploymentTarget);
@ -1263,6 +1263,7 @@ namespace Xamarin.Bundler {
if (link_tasks.Count > 1) { if (link_tasks.Count > 1) {
// If we have more than one executable, we must lipo them together. // If we have more than one executable, we must lipo them together.
var lipo_task = new LipoTask { var lipo_task = new LipoTask {
App = this,
InputFiles = link_tasks.Select ((v) => v.OutputFile), InputFiles = link_tasks.Select ((v) => v.OutputFile),
OutputFile = Executable, OutputFile = Executable,
}; };
@ -1464,10 +1465,10 @@ namespace Xamarin.Bundler {
if (files.Count == 1) { if (files.Count == 1) {
CopyFile (files.First (), targetPath); CopyFile (files.First (), targetPath);
} else { } else {
Driver.RunLipo (targetPath, files); Driver.RunLipo (this, targetPath, files);
} }
if (LibMonoLinkMode == AssemblyBuildTarget.Framework) if (LibMonoLinkMode == AssemblyBuildTarget.Framework)
Driver.RunInstallNameTool (new [] { "-change", "@rpath/libmonosgen-2.0.dylib", "@rpath/Mono.framework/Mono", targetPath }); Driver.RunInstallNameTool (this, new [] { "-change", "@rpath/libmonosgen-2.0.dylib", "@rpath/Mono.framework/Mono", targetPath });
// Remove architectures we don't care about. // Remove architectures we don't care about.
if (IsDeviceBuild) if (IsDeviceBuild)
@ -1492,7 +1493,7 @@ namespace Xamarin.Bundler {
Directory.CreateDirectory (frameworkDirectory); Directory.CreateDirectory (frameworkDirectory);
var allExecutables = Targets.SelectMany ((t) => t.Executables.Values).ToArray (); var allExecutables = Targets.SelectMany ((t) => t.Executables.Values).ToArray ();
if (allExecutables.Length > 1) { if (allExecutables.Length > 1) {
Lipo (frameworkExecutable, allExecutables); Lipo (this, frameworkExecutable, allExecutables);
} else { } else {
UpdateFile (allExecutables [0], frameworkExecutable); UpdateFile (allExecutables [0], frameworkExecutable);
} }
@ -1519,17 +1520,17 @@ namespace Xamarin.Bundler {
} }
sb.Add ("-o"); sb.Add ("-o");
sb.Add (macho_file); sb.Add (macho_file);
Driver.RunBitcodeStrip (sb); Driver.RunBitcodeStrip (this, sb);
} }
// Returns true if is up-to-date // Returns true if is up-to-date
public static bool Lipo (string output, params string [] inputs) public static bool Lipo (Application app, string output, params string [] inputs)
{ {
if (IsUptodate (inputs, new string [] { output })) { if (IsUptodate (inputs, new string [] { output })) {
Driver.Log (3, "Target '{0}' is up-to-date.", output); Driver.Log (3, "Target '{0}' is up-to-date.", output);
return true; return true;
} else { } else {
Driver.RunLipo (output, inputs); Driver.RunLipo (app, output, inputs);
return false; return false;
} }
} }
@ -1849,7 +1850,7 @@ namespace Xamarin.Bundler {
if (Directory.Exists (dsym_dir)) if (Directory.Exists (dsym_dir))
Directory.Delete (dsym_dir, true); Directory.Delete (dsym_dir, true);
Driver.CreateDsym (AppDirectory, ExecutableName, dsym_dir); Driver.CreateDsym (this, AppDirectory, ExecutableName, dsym_dir);
} else { } else {
Driver.Log (3, "Target '{0}' is up-to-date.", dsym_dir); Driver.Log (3, "Target '{0}' is up-to-date.", dsym_dir);
} }
@ -1890,7 +1891,7 @@ namespace Xamarin.Bundler {
if (Embeddinator) if (Embeddinator)
args.Add ("-ux"); args.Add ("-ux");
args.Add (Executable); args.Add (Executable);
Driver.RunStrip (args); Driver.RunStrip (this, args);
Driver.Watch ("Native Strip", 1); Driver.Watch ("Native Strip", 1);
} }
@ -2036,7 +2037,7 @@ namespace Xamarin.Bundler {
sb.AppendLine (" <key>DTPlatformName</key>"); sb.AppendLine (" <key>DTPlatformName</key>");
sb.AppendLine ($" <string>{Driver.GetPlatform (this).ToLowerInvariant ()}</string>"); sb.AppendLine ($" <string>{Driver.GetPlatform (this).ToLowerInvariant ()}</string>");
sb.AppendLine (" <key>DTPlatformVersion</key>"); sb.AppendLine (" <key>DTPlatformVersion</key>");
sb.AppendLine ($" <string>{SdkVersions.GetVersion (Platform)}</string>"); sb.AppendLine ($" <string>{SdkVersions.GetVersion (this)}</string>");
sb.AppendLine (" <key>DTSDKBuild</key>"); sb.AppendLine (" <key>DTSDKBuild</key>");
sb.AppendLine (" <string>12D508</string>"); sb.AppendLine (" <string>12D508</string>");
sb.AppendLine (" <key>DTSDKName</key>"); sb.AppendLine (" <key>DTSDKName</key>");

Просмотреть файл

@ -601,6 +601,7 @@ namespace Xamarin.Bundler
public class LipoTask : BuildTask public class LipoTask : BuildTask
{ {
public Application App;
public IEnumerable<string> InputFiles { get; set; } public IEnumerable<string> InputFiles { get; set; }
public string OutputFile { get; set; } public string OutputFile { get; set; }
@ -618,7 +619,7 @@ namespace Xamarin.Bundler
protected override void Execute () protected override void Execute ()
{ {
Application.Lipo (OutputFile, InputFiles.ToArray ()); Application.Lipo (App, OutputFile, InputFiles.ToArray ());
} }
public override string ToString () public override string ToString ()

Просмотреть файл

@ -1661,7 +1661,7 @@ namespace Xamarin.Bundler
} }
} }
public static void AdjustDylibs (string output) public void AdjustDylibs (string output)
{ {
var sb = new List<string> (); var sb = new List<string> ();
foreach (var dependency in Xamarin.MachO.GetNativeDependencies (output)) { foreach (var dependency in Xamarin.MachO.GetNativeDependencies (output)) {
@ -1674,7 +1674,7 @@ namespace Xamarin.Bundler
} }
if (sb.Count > 0) { if (sb.Count > 0) {
sb.Add (output); sb.Add (output);
Driver.RunInstallNameTool (sb); Driver.RunInstallNameTool (App, sb);
sb.Clear (); sb.Clear ();
} }
} }
@ -1705,7 +1705,7 @@ namespace Xamarin.Bundler
try { try {
var launcher = new StringBuilder (); var launcher = new StringBuilder ();
launcher.Append (Path.Combine (Driver.FrameworkBinDirectory, "simlauncher")); launcher.Append (Path.Combine (Driver.GetFrameworkBinDirectory (App), "simlauncher"));
if (Is32Build) if (Is32Build)
launcher.Append ("32"); launcher.Append ("32");
else if (Is64Build) else if (Is64Build)

Просмотреть файл

@ -79,7 +79,6 @@ namespace Xamarin.Bundler
{ {
public partial class Driver { public partial class Driver {
internal const string NAME = "mtouch"; internal const string NAME = "mtouch";
internal const string PRODUCT = "Xamarin.iOS";
const string LOCAL_BUILD_DIR = "_ios-build"; const string LOCAL_BUILD_DIR = "_ios-build";
const string FRAMEWORK_LOCATION_VARIABLE = "MD_MTOUCH_SDK_ROOT"; const string FRAMEWORK_LOCATION_VARIABLE = "MD_MTOUCH_SDK_ROOT";
@ -287,7 +286,7 @@ namespace Xamarin.Bundler
} }
if (enable_llvm) if (enable_llvm)
aot.Append ("llvm-path=").Append (FrameworkDirectory).Append ("/LLVM/bin/,"); aot.Append ("llvm-path=").Append (GetFrameworkCurrentDirectory (app)).Append ("/LLVM/bin/,");
aot.Append ("outfile=").Append (outputFile); aot.Append ("outfile=").Append (outputFile);
if (enable_llvm) if (enable_llvm)
@ -923,7 +922,7 @@ namespace Xamarin.Bundler
// Allow a few actions, since these seem to always work no matter the Xcode version. // Allow a few actions, since these seem to always work no matter the Xcode version.
var accept_any_xcode_version = action == Action.ListDevices || action == Action.ListCrashReports || action == Action.ListApps || action == Action.LogDev; var accept_any_xcode_version = action == Action.ListDevices || action == Action.ListCrashReports || action == Action.ListApps || action == Action.LogDev;
ValidateXcode (accept_any_xcode_version, false); ValidateXcode (app, accept_any_xcode_version, false);
switch (action) { switch (action) {
/* Device actions */ /* Device actions */
@ -945,7 +944,7 @@ namespace Xamarin.Bundler
case Action.LaunchWatchApp: case Action.LaunchWatchApp:
case Action.KillWatchApp: case Action.KillWatchApp:
case Action.ListSimulators: case Action.ListSimulators:
return CallMlaunch (); return CallMlaunch (app);
} }
if (app.SdkVersion == null) if (app.SdkVersion == null)
@ -986,7 +985,7 @@ namespace Xamarin.Bundler
throw new ProductException (82, true, Errors.MT0082); throw new ProductException (82, true, Errors.MT0082);
if (cross_prefix == null) if (cross_prefix == null)
cross_prefix = FrameworkDirectory; cross_prefix = GetFrameworkCurrentDirectory (app);
Watch ("Setup", 1); Watch ("Setup", 1);
@ -1033,23 +1032,22 @@ namespace Xamarin.Bundler
{ IsBackground = true }.Start (); { IsBackground = true }.Start ();
} }
static string MlaunchPath { static string GetMlaunchPath (Application app)
get { {
// check next to mtouch first // check next to mtouch first
var path = Path.Combine (FrameworkBinDirectory, "mlaunch"); var path = Path.Combine (GetFrameworkBinDirectory (app), "mlaunch");
if (File.Exists (path)) if (File.Exists (path))
return path; return path;
// check an environment variable // check an environment variable
path = Environment.GetEnvironmentVariable ("MLAUNCH_PATH"); path = Environment.GetEnvironmentVariable ("MLAUNCH_PATH");
if (File.Exists (path)) if (File.Exists (path))
return path; return path;
throw ErrorHelper.CreateError (93, Errors.MT0093); throw ErrorHelper.CreateError (93, Errors.MT0093);
}
} }
static int CallMlaunch () static int CallMlaunch (Application app)
{ {
Log (1, "Forwarding to mlaunch"); Log (1, "Forwarding to mlaunch");
using (var p = new Process ()) { using (var p = new Process ()) {
@ -1057,7 +1055,7 @@ namespace Xamarin.Bundler
p.StartInfo.RedirectStandardError = true; p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = MlaunchPath; p.StartInfo.FileName = GetMlaunchPath (app);
var sb = Environment.GetCommandLineArgs ().Skip (1).ToList (); var sb = Environment.GetCommandLineArgs ().Skip (1).ToList ();
p.StartInfo.Arguments = StringUtils.FormatArguments (sb); p.StartInfo.Arguments = StringUtils.FormatArguments (sb);