xamarin-macios/tools/mtouch/mtouch.cs

1712 строки
68 KiB
C#
Исходник Обычный вид История

//
2016-04-21 15:58:45 +03:00
// mtouch.cs: A tool to generate the necessary code to boot a Mono
// application on the iPhone
//
// It has a couple of modes of operation:
//
// COMPILATION:
//
// Default
//
// Compiles the assemblies specified and produces Assembly
// language code and C files that can be incorporated into an
// existing project.
//
// -sim Compile to Simulator image
//
// This compiles the given assemblies into the specified
// directory. The target directory can then be used as
// the contents of the .app
//
// -dev Compile the Device image
//
// This compiles the given assemblies into the specified
// directory. The target directory can then be used as
// the contents of the .app
//
// LAUNCHING:
// -launchsim=APP
//
// This launches the specified File.App in the simulator
//
// -debugsim=AP
//
// Launches the application in debug mode on the simulator
//
// -launchdev=ID
//
// Launches the specified app bundle ID on the connected device
//
// Copyright 2009, Novell, Inc.
// Copyright 2011-2013 Xamarin Inc. All rights reserved.
//
// Authors:
// Miguel de Icaza
// Geoff Norton
// Jb Evain
// Sebastien Pouliot
//
using System;
using System.IO;
using System.Diagnostics;
using System.Linq;
using System.Collections.Generic;
using System.Globalization;
2016-04-21 15:58:45 +03:00
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using Mono.Options;
using Mono.Cecil;
using Mono.Cecil.Cil;
2016-04-21 15:58:45 +03:00
using Mono.Tuner;
using MonoTouch.Tuner;
using Registrar;
using ObjCRuntime;
2016-04-21 15:58:45 +03:00
using Xamarin.Linker;
using Xamarin.Utils;
using Xamarin.MacDev;
2016-04-21 15:58:45 +03:00
public enum OutputFormat {
Default,
Xml,
}
namespace Xamarin.Bundler
{
public partial class Driver {
[mtouch/mmp] Fix tracking of whether the static registrar should run again or not. Fixes #641. (#3534) * [tests] Improve debug spew for the RebuildTest_WithExtensions test. * [mtouch/mmp] Store/load if the dynamic registrar is removed or not into the cached link results. Store/load if the dynamic registrar is removed or not into the cached link results, so that we generate the correct main.m even if cached linker results are used. * [mtouch/mmp] The static registrar must not execute if we're loading cached results from the linker. The static registrar must not execute if we're loading cached results from the linker, because the static registrar needs information from the linker that's not restored from the cache. * [mtouch/mmp] Share Touch code. * [mtouch/mmp] Make it possible to touch inexistent files (to create them). * [mtouch/mmp] Fix tracking of whether the static registrar should run again or not. The recent changes to support optimizing away the dynamic registrar caused the Xamarin.MTouch.RebuildTest_WithExtensions test to regress. The problem ----------- * The linker now collects and stores information the static registrar needs. * This information is not restored from disk when the linker realizes that it can reload previously linked assemblies instead of executing again. * The static registrar runs again (for another reason). * The information the static registrar needs isn't available, and incorrect output follows. So fix 1: show an error if the static registrar runs when the linker loaded cached results. The exact scenario the test ran into is this: * 1st build: everything is new and everything is built. * 2nd build: contents of .exe changes, the linker runs again, the static registrar runs again, but sees that the generated output didn't change, so it doesn't write the new content to disk (this is an optimization to avoid compiling the registrar.m file again unless needed). * 3rd build: only the .exe timestamp changes, the linker sees nothing changes in the contents of the .exe and loads the previously linked assemblies from disk, the static registrar sees that the .exe's timestamp is newer than registrar.m's timestamp and run again, but doesn't produce the right result because it doesn't have the information it needs. Considered solutions -------------------- 1. Only track timestamps, not file contents. This is not ideal, since it will result in more work done: in particular for the case above, it would add a registrar.m compilation in build #2, and linker rerun + static registrar rerun + registrar.m compilation + final native link in build #3. 2. Always write the output of the static registrar, even if it hasn't changed. This is not ideal either, since it will also result in more work done: for the case above, it would add a registrar.m compilation + final native link in build #3. 3. Always write the output of the static registrar, but track if it changed or not, and if it didn't, just touch registrar.o instead of recompiling it. This only means the final native link in build #3 is added (see #5 for why this is worse than it sounds). 4. Always write the output of the static registrar, but track it it changed or not, and if it didn't, just touch registrar.o instead of recompiling it, and track that too, so that the final native link in build #3 isn't needed anymore. Unfortunately this may result in incorrect behavior, because now the msbuild tasks will detect that the executable has changed, and may run dsymutil + strip again. The executable didn't actually change, which means it would be the previously stripped executable, and thus we'd end up with an empty .dSYM because we ran dsymtil on an already stripped executable. 5. Idea #4, but write the output of the final link into a temporary directory instead of the .app, so that we could track whether we should update the executable in the .app or not. This is not optimal either, because executables can be *big* (I've seen multi-GB tvOS bitcode executables), and extra copies of such files should not be taken lightly. 6. Idea #4, but tell the MSBuild tasks that dsymutil/strip doesn't need to be rerun even if the timestamp of the executable changed. This might actually work, but now the solution's become quite complex. Implemented solution -------------------- Use stamp files to detect whether a file is up-to-date or not. In particular: * When we don't write to a file because the new contents are identical to the old contents, we now touch a .stamp file. This stamp file means "the accompanying file was determined to be up-to-date when the stamp was touched." * When checking whether a file is up-to-date, also check for the presence of a .stamp file, and if it exists, use the highest timestamp between the stamp file and the actual file. Now the test scenario becomes: * 1st build: everything is new and everything is built. * 2nd build: contents of .exe changes, the linker runs again, the static registrar runs again, but sees that the generated output didn't change, so it doesn't write the new content to disk, but it creates a registrar.m.stamp file to indicate the point in time when registrar.m was considered up-to- date. * 3rd build: only the .exe timestamp changes, the linker sees nothing changes in the contents of the .exe and loads the previously linked assemblies from disk, the static registrar sees that the .exe's timestamp is *older* than registrar.m.stamp's timestamp and doesn't run again. We only use the stamp file for source code (registrar.[m|h], main.[m|h], pinvokes.[m|h]), since using it every time has too much potential for running into other problems (for instance we should never create .stamp files inside the .app). Fixes these test failures: 1) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("single","",False,System.String[]) single Expected: <empty> But was: < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory371/testApp.app/testApp is modified, timestamp: 2/15/2018 3:04:11 PM > 2/15/2018 3:04:09 PM" > 2) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("dual","armv7,arm64",False,System.String[]) dual Expected: <empty> But was: < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory375/testApp.app/testApp is modified, timestamp: 2/15/2018 3:06:03 PM > 2/15/2018 3:06:00 PM" > 3) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("llvm","armv7+llvm",False,System.String[]) llvm Expected: <empty> But was: < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory379/testApp.app/testApp is modified, timestamp: 2/15/2018 3:07:14 PM > 2/15/2018 3:07:12 PM" > 4) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("debug","",True,System.String[]) debug Expected: <empty> But was: < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory383/testApp.app/testApp is modified, timestamp: 2/15/2018 3:08:16 PM > 2/15/2018 3:08:13 PM" > 5) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("single-framework","",False,System.String[]) single-framework Expected: <empty> But was: < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory387/testApp.app/testApp is modified, timestamp: 2/15/2018 3:09:18 PM > 2/15/2018 3:09:16 PM" > Fixes https://github.com/xamarin/maccore/issues/641
2018-02-19 22:28:04 +03:00
internal const string NAME = "mtouch";
2016-04-21 15:58:45 +03:00
public static void ShowHelp (OptionSet os)
{
Console.WriteLine ("mtouch - Mono Compiler for iOS");
Console.WriteLine ("Copyright 2009-2011, Novell, Inc.");
Console.WriteLine ("Copyright 2011-2016, Xamarin Inc.");
Console.WriteLine ("Usage is: mtouch [options]");
os.WriteOptionDescriptions (Console.Out);
}
enum Action {
None,
Help,
Version,
Build,
InstallSim,
LaunchSim,
DebugSim,
InstallDevice,
LaunchDevice,
DebugDevice,
KillApp,
KillAndLaunch,
ListDevices,
ListSimulators,
IsAppInstalled,
ListApps,
LogDev,
RunRegistrar,
ListCrashReports,
DownloadCrashReport,
KillWatchApp,
LaunchWatchApp,
2017-04-12 12:00:43 +03:00
Embeddinator,
2016-04-21 15:58:45 +03:00
}
static bool xcode_version_check = true;
//
// Output generation
static bool force = false;
static bool dot;
2016-04-21 15:58:45 +03:00
static string cross_prefix = Environment.GetEnvironmentVariable ("MONO_CROSS_PREFIX");
static string extra_args = Environment.GetEnvironmentVariable ("MTOUCH_ENV_OPTIONS");
static int verbose = GetDefaultVerbosity ();
public static bool Dot {
get {
return dot;
}
}
2016-04-21 15:58:45 +03:00
static int GetDefaultVerbosity ()
{
var v = 0;
var fn = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), ".mtouch-verbosity");
if (File.Exists (fn)) {
v = (int) new FileInfo (fn).Length;
if (v == 0)
v = 4; // this is the magic verbosity level we give everybody.
}
return v;
}
static string mtouch_dir;
public static void Log (string format, params object [] args)
{
Log (0, format, args);
}
public static void Log (int min_verbosity, string format, params object [] args)
{
if (min_verbosity > verbose)
return;
Console.WriteLine (format, args);
}
public static bool IsUnified {
get { return true; }
2016-04-21 15:58:45 +03:00
}
public static bool Force {
get { return force; }
set { force = value; }
}
public static string GetPlatform (Application app)
{
switch (app.Platform) {
case ApplePlatform.iOS:
return app.IsDeviceBuild ? "iPhoneOS" : "iPhoneSimulator";
case ApplePlatform.WatchOS:
return app.IsDeviceBuild ? "WatchOS" : "WatchSimulator";
case ApplePlatform.TVOS:
return app.IsDeviceBuild ? "AppleTVOS" : "AppleTVSimulator";
default:
throw ErrorHelper.CreateError (71, "Unknown platform: {0}. This usually indicates a bug in Xamarin.iOS; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case.", app.Platform);
2016-04-21 15:58:45 +03:00
}
}
public static string GetMonoTouchLibDirectory (Application app)
{
return Path.Combine (GetProductSdkDirectory (app), "usr", "lib");
2016-04-21 15:58:45 +03:00
}
public static string DriverBinDirectory {
get {
return MonoTouchBinDirectory;
}
}
public static string MonoTouchBinDirectory {
get {
return Path.Combine (MonoTouchDirectory, "bin");
}
}
public static string MonoTouchDirectory {
get {
if (mtouch_dir == null) {
mtouch_dir = Path.GetFullPath (GetFullPath () + "/../../..");
2016-04-21 15:58:45 +03:00
#if DEV
// when launched from Xamarin Studio, mtouch is not in the final install location,
// so walk the directory hierarchy to find the root source directory.
while (!File.Exists (Path.Combine (mtouch_dir, "Make.config")))
mtouch_dir = Path.GetDirectoryName (mtouch_dir);
mtouch_dir = Path.Combine (mtouch_dir, "_ios-build", "Library", "Frameworks", "Xamarin.iOS.framework", "Versions", "Current");
#endif
mtouch_dir = Target.GetRealPath (mtouch_dir);
}
return mtouch_dir;
}
}
public static string GetPlatformFrameworkDirectory (Application app)
{
switch (app.Platform) {
case ApplePlatform.iOS:
return Path.Combine (MonoTouchDirectory, "lib", "mono", "Xamarin.iOS");
case ApplePlatform.WatchOS:
return Path.Combine (MonoTouchDirectory, "lib", "mono", "Xamarin.WatchOS");
case ApplePlatform.TVOS:
return Path.Combine (MonoTouchDirectory, "lib", "mono", "Xamarin.TVOS");
default:
throw ErrorHelper.CreateError (71, "Unknown platform: {0}. This usually indicates a bug in Xamarin.iOS; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case.", app.Platform);
}
}
public static string GetArch32Directory (Application app)
{
switch (app.Platform) {
case ApplePlatform.iOS:
return Path.Combine (GetPlatformFrameworkDirectory (app), "..", "..", "32bits");
default:
throw ErrorHelper.CreateError (71, "Unknown platform: {0}. This usually indicates a bug in Xamarin.iOS; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case.", app.Platform);
}
}
public static string GetArch64Directory (Application app)
{
switch (app.Platform) {
case ApplePlatform.iOS:
return Path.Combine (GetPlatformFrameworkDirectory (app), "..", "..", "64bits");
default:
throw ErrorHelper.CreateError (71, "Unknown platform: {0}. This usually indicates a bug in Xamarin.iOS; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case.", app.Platform);
2016-04-21 15:58:45 +03:00
}
}
public static string GetProductSdkDirectory (Application app)
{
switch (app.Platform) {
case ApplePlatform.iOS:
return Path.Combine (MonoTouchDirectory, "SDKs", app.IsDeviceBuild ? "MonoTouch.iphoneos.sdk" : "MonoTouch.iphonesimulator.sdk");
case ApplePlatform.WatchOS:
return Path.Combine (MonoTouchDirectory, "SDKs", app.IsDeviceBuild ? "Xamarin.WatchOS.sdk" : "Xamarin.WatchSimulator.sdk");
case ApplePlatform.TVOS:
return Path.Combine (MonoTouchDirectory, "SDKs", app.IsDeviceBuild ? "Xamarin.AppleTVOS.sdk" : "Xamarin.AppleTVSimulator.sdk");
default:
throw ErrorHelper.CreateError (71, "Unknown platform: {0}. This usually indicates a bug in Xamarin.iOS; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case.", app.Platform);
2016-04-21 15:58:45 +03:00
}
}
public static string GetProductFrameworksDirectory (Application app)
{
return Path.Combine (GetProductSdkDirectory (app), "Frameworks");
2016-04-21 15:58:45 +03:00
}
// This is for the -mX-version-min=A.B compiler flag
public static string GetTargetMinSdkName (Application app)
{
switch (app.Platform) {
case ApplePlatform.iOS:
return app.IsDeviceBuild ? "iphoneos" : "ios-simulator";
case ApplePlatform.WatchOS:
return app.IsDeviceBuild ? "watchos" : "watchos-simulator";
case ApplePlatform.TVOS:
return app.IsDeviceBuild ? "tvos" : "tvos-simulator";
default:
throw ErrorHelper.CreateError (71, "Unknown platform: {0}. This usually indicates a bug in Xamarin.iOS; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case.", app.Platform);
2016-04-21 15:58:45 +03:00
}
}
public static string GetProductAssembly (Application app)
{
switch (app.Platform) {
case ApplePlatform.iOS:
return "Xamarin.iOS";
case ApplePlatform.WatchOS:
return "Xamarin.WatchOS";
case ApplePlatform.TVOS:
return "Xamarin.TVOS";
default:
throw ErrorHelper.CreateError (71, "Unknown platform: {0}. This usually indicates a bug in Xamarin.iOS; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case.", app.Platform);
2016-04-21 15:58:45 +03:00
}
}
public static bool GetLLVMAsmWriter (Application app)
{
if (app.LLVMAsmWriter.HasValue)
return app.LLVMAsmWriter.Value;
switch (app.Platform) {
case ApplePlatform.iOS:
return false;
case ApplePlatform.TVOS:
case ApplePlatform.WatchOS:
return true;
default:
throw ErrorHelper.CreateError (71, "Unknown platform: {0}. This usually indicates a bug in Xamarin.iOS; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case.", app.Platform);
2016-04-21 15:58:45 +03:00
}
}
static string sdk_root;
static string developer_directory;
const string XcodeDefault = "/Applications/Xcode.app";
static string FindSystemXcode ()
{
var output = new StringBuilder ();
if (Driver.RunCommand ("xcode-select", "-p", output: output) != 0) {
ErrorHelper.Warning (59, "Could not find the currently selected Xcode on the system: {0}", output.ToString ());
return null;
}
return output.ToString ().Trim ();
}
static void ValidateXcode (Action action)
2016-04-21 15:58:45 +03:00
{
// 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;
if (sdk_root == null) {
sdk_root = FindSystemXcode ();
if (sdk_root == null) {
// FindSystemXcode showed a warning in this case. In particular do not use 'string.IsNullOrEmpty' here,
// because FindSystemXcode may return an empty string (with no warning printed) if the xcode-select command
// succeeds, but returns nothing.
sdk_root = null;
} else if (!Directory.Exists (sdk_root)) {
ErrorHelper.Warning (60, "Could not find the currently selected Xcode on the system. 'xcode-select --print-path' returned '{0}', but that directory does not exist.", sdk_root);
sdk_root = null;
} else {
if (!accept_any_xcode_version)
ErrorHelper.Warning (61, "No Xcode.app specified (using --sdkroot), using the system Xcode as reported by 'xcode-select --print-path': {0}", sdk_root);
}
if (sdk_root == null) {
sdk_root = XcodeDefault;
if (!Directory.Exists (sdk_root))
throw ErrorHelper.CreateError (56, "Cannot find Xcode in the default location (/Applications/Xcode.app). Please install Xcode, or pass a custom path using --sdkroot <path>.");
ErrorHelper.Warning (62, "No Xcode.app specified (using --sdkroot or 'xcode-select --print-path'), using the default Xcode instead: {0}", sdk_root);
}
} else if (!Directory.Exists (sdk_root)) {
throw ErrorHelper.CreateError (55, "The Xcode path '{0}' does not exist.", sdk_root);
}
// Check what kind of path we got
if (File.Exists (Path.Combine (sdk_root, "Contents", "MacOS", "Xcode"))) {
// path to the Xcode.app
developer_directory = Path.Combine (sdk_root, "Contents", "Developer");
} else if (File.Exists (Path.Combine (sdk_root, "..", "MacOS", "Xcode"))) {
// path to Contents/Developer
developer_directory = Path.GetFullPath (Path.Combine (sdk_root, "..", "..", "Contents", "Developer"));
} else {
throw ErrorHelper.CreateError (57, "Cannot determine the path to Xcode.app from the sdk root '{0}'. Please specify the full path to the Xcode.app bundle.", sdk_root);
}
var plist_path = Path.Combine (Path.GetDirectoryName (DeveloperDirectory), "version.plist");
if (File.Exists (plist_path)) {
var plist = FromPList (plist_path);
var version = plist.GetString ("CFBundleShortVersionString");
xcode_version = new Version (version);
Bump to use Xcode 10 beta 1 (#4179) * Bump to use Xcode 10 beta 1 * Update Versions.plist * Add a dependency on Xcode 9.4. * [msbuild] Fix build with Xcode 10 beta 1. (#4182) Many years ago (in Xcode 7 according to code comment) Developer/Platforms/iPhoneOS.platform/Developer/usr disappeared, and we coped by looking at Developer/usr instead (and also the subsequent code to locate the bin directory was based on the location of the usr directory). Developer/Platforms/iPhoneOS.platform/Developer/usr reappeared in Xcode 10 beta 1, but it seems useless (for one it doesn't contain a bin directory), so in order to try to keep things sane don't look for this directory in Xcode 10 and instead go directly for Developer/usr (which is what we've been using as the usr directory for years anyway). Fixes this problem when building apps with Xcode 10 beta 1: /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(626,3): error : Could not locate SDK bin directory [/Users/rolf/Projects/TestApp/test-app.csproj] * [runtime] Build 32-bit mac executables using Xcode 9.4. * [mtouch] Work around broken tvOS headers in Xcode 10 beta 1. * [mtouch] Work around build problem with Apple's simd headers in Objective-C++ mode. * Use version-agnostic paths to sdk directories. * [tests][xtro] Add todo files (from unclassified) and adjust ignore files to avoid errors * [macos][security] Re-enable SSL[Get|Set]AlpnProtocols. Fixes #4001 (#4022) * [macos][security] Re-enable SSL[Get}Set]AlpnProtocols. Fixes #4001 This was fixed in macOS 10.13.4 https://github.com/xamarin/xamarin-macios/issues/4001 * [tests][monotouch-tests] Disable a few test cases (one crasher, other failures). Causes to be verified later * [xharness] Fix permission dialog suppression in Xcode 10. * [xharness] Ignore 32-bit macOS tests by default. * [tests] Execute mmp regression tests with Xcode 9.4 since many of them are 32-bit and needs porting to 64-bit. * [mmptest] Ignore 32-bit XM tests if we don't have a 32-bit-capable Xcode. * [registrar] Add workaround for broken headers in Xcode 10 beta 1 (radar 40824697). * [mtouch] Restrict another workaround for an Xcode 10 beta 1 bug to a specific Xcode version to remove it asap. * [tests] Fix some protocol changes (public or not) find by introspection tests * [tests][intro] Fix DefaultCtorAllowed failures * [Intents] Obsolete several Intents classes in watchOS. Several existing Intents classes have been marked as unavailable in watchOS in the headers in Xcode 10 beta 1, and corresponding tests are now failing. So obsolete the managed wrapper types, and fix tests accordingly. * Fix xtro wrt previous Ietents/intro changes * [tests] Minor adjustments to mtouch tests to work with Xcode 10. * [msbuild] Update tests to cope with additional files produced by the Core ML compiler. * [msbuild] Xcode 10 doesn't support building watchOS 1 apps, so show a clear error message explaining it. Also update tests accordingly. * [coreimage] Stub new filters and exclude ?removed? ones from tests * Update GameplayKit and SpriteKit NSSecureCoding _upgrade_ and fix other non-public cases (in tests) * [tests] Ignore some GameKit selectors that don't respond anymore (but seems to be available, at least in header files) * [tests] Fix intro 32bits testing for filters resutls * [msbuild] Slightly change error message to be better English.
2018-06-09 04:45:24 +03:00
xcode_bundle_version = plist.GetString ("CFBundleVersion");
2016-04-21 15:58:45 +03:00
} else {
throw ErrorHelper.CreateError (58, "The Xcode.app '{0}' is invalid (the file '{1}' does not exist).", Path.GetDirectoryName (Path.GetDirectoryName (developer_directory)), plist_path);
}
if (xcode_version_check && XcodeVersion < new Version (6, 0))
ErrorHelper.Error (51, "Xamarin.iOS {0} requires Xcode 6.0 or later. The current Xcode version (found in {2}) is {1}.", Constants.Version, XcodeVersion.ToString (), sdk_root);
if (XcodeVersion < new Version (7, 0) && !accept_any_xcode_version)
ErrorHelper.Warning (79, "The recommended Xcode version for Xamarin.iOS {0} is Xcode 7.0 or later. The current Xcode version (found in {2}) is {1}.", Constants.Version, XcodeVersion.ToString (), sdk_root);
Driver.Log (1, "Using Xcode {0} found in {1}", XcodeVersion, sdk_root);
}
public static string DeveloperDirectory {
get {
return developer_directory;
}
}
public static string GetFrameworkDirectory (Application app)
{
return GetFrameworkDir (GetPlatform (app), app.SdkVersion);
2016-04-21 15:58:45 +03:00
}
public static bool IsUsingClang (Application app)
{
return app.CompilerPath.EndsWith ("clang", StringComparison.Ordinal) || app.CompilerPath.EndsWith ("clang++", StringComparison.Ordinal);
2016-04-21 15:58:45 +03:00
}
public static string PlatformsDirectory {
get {
return Path.Combine (DeveloperDirectory, "Platforms");
}
}
public static string GetPlatformDirectory (Application app)
{
return Path.Combine (PlatformsDirectory, GetPlatform (app) + ".platform");
2016-04-21 15:58:45 +03:00
}
public static int XcodeRun (string command, string args, StringBuilder output = null)
{
string [] env = DeveloperDirectory != String.Empty ? new string [] { "DEVELOPER_DIR", DeveloperDirectory } : null;
int ret = RunCommand ("xcrun", String.Concat ("-sdk macosx ", command, " ", args), env, output);
if (ret != 0 && verbose > 1) {
StringBuilder debug = new StringBuilder ();
RunCommand ("xcrun", String.Concat ("--find ", command), env, debug);
Console.WriteLine ("failed using `{0}` from: {1}", command, debug);
}
return ret;
}
public static string GetAotCompiler (Application app, bool is64bits)
2016-04-21 15:58:45 +03:00
{
switch (app.Platform) {
case ApplePlatform.iOS:
if (is64bits) {
return Path.Combine (cross_prefix, "bin", "arm64-darwin-mono-sgen");
} else {
return Path.Combine (cross_prefix, "bin", "arm-darwin-mono-sgen");
}
case ApplePlatform.WatchOS:
return Path.Combine (cross_prefix, "bin", "armv7k-unknown-darwin-mono-sgen");
case ApplePlatform.TVOS:
return Path.Combine (cross_prefix, "bin", "arm64-darwin-mono-sgen");
2016-04-21 15:58:45 +03:00
default:
throw ErrorHelper.CreateError (71, "Unknown platform: {0}. This usually indicates a bug in Xamarin.iOS; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case.", app.Platform);
2016-04-21 15:58:45 +03:00
}
}
public static string GetAotArguments (Application app, string filename, Abi abi, string outputDir, string outputFile, string llvmOutputFile, string dataFile)
2016-04-21 15:58:45 +03:00
{
string fname = Path.GetFileName (filename);
StringBuilder args = new StringBuilder ();
bool enable_llvm = (abi & Abi.LLVM) != 0;
bool enable_thumb = (abi & Abi.Thumb) != 0;
bool enable_debug = app.EnableDebug;
bool enable_debug_symbols = app.PackageManagedDebugSymbols;
2016-04-21 15:58:45 +03:00
bool llvm_only = app.EnableLLVMOnlyBitCode;
Bump to mono:2018-06 (#4277) * Bump to mono:2018-06 * Bump mono * Updates compression to work with the public span * Bump mono * Fixes pointer check logic in Deflater * Bump mono * Fixes pointer check logic in Deflater * Bump mono * Bump Mono * [runtime] always use `mono_jit_set_aot_mode` (#4491) `mono_jit_set_aot_only` is deprecated and accidentally broke with https://github.com/mono/mono/pull/7887 This should fix device tests with `mono-2018-06` * Testing with Zoltan's patch * Include libmono-system-native on Xamarin.Mac * Bump Mono Commit list for mono/mono: * mono/mono@7bcda192a06 Bump llvm to release_60/fc854b8ec5873d294b80afa3e6cf6a88c5c48886. (#9786). (#9804) * mono/mono@23e95ec7ad7 Apply F# portable pdb debug fix for pinvokes & bump (#9797) * mono/mono@295f6d32afd [2018-06] [MacOS] On Mac, use the copyfile API to copy files (#9696) Diff: https://github.com/mono/mono/compare/7d5f4b61366008d47665bb473205f4ae1f716d1f...7bcda192a06267562af565d404c06d159f475c03 * Revert 4bacab3d5c7fa86a0e6437f64bb9f08ea3d0741b, it doesn't fix the ios aot problems. * Bump mono * [tests] Adjust the MT0137 test for mcs change in behavior. Starting with mono 5.16 mcs will now add assembly references when the assembly is only used in attributes (this was already the case for csc in both 5.14 and 5.16, so it seems to be a compatibility change). Adjust the MT0137 test accordingly. * [msbuild] Fix parsing of json parser errors to handle trailing periods in the error message. Fixes this test: 1) Test Failure : Xamarin.iOS.Tasks.Bug60536.TestACToolTaskCatchesJsonException ColumnNumber Expected: 2 But was: 0 * Bump mono * [builds] Install the old llvm binaries into the LLVM36 directory and make the 32 bit builds use that. * Bump mono * Bump mono * [jenkins] Don't give VSTS a fake branch. (#4667) Something in VSTS changed, and now fake branch names don't work anymore. So instead use real branch names (and for pull requests I've created a 'pull-request' branch we can use). * Assembly.LoadFile accepts only absolute path * [linker] Add new Facade (System.Threading.Tasks.Extensions). Fixes these MTouch test failures: 1. Xamarin.Linker.SdkTest.iOS_Unified : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > 2. Xamarin.Linker.SdkTest.tvOS : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > 3. Xamarin.Linker.SdkTest.watchOS : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > * [mono-sdks] Necessary changes to unify the LLVM provisioning for both iOS and Android. (#4732) * Bump Mono * [mtouch] add mixed-mode support (#4751) * [mtouch] add --interp-mixed option When enabling this option, mtouch will AOT compile `mscorlib.dll`. At runtime that means every method that wasn't AOT'd will be executed by the runtime interpreter. * [mtouch] Add support to --interpreter to list the assemblies to (not) interpret. * [msbuild] Simplify interpreter code to use a single variable. * Fix whitespace. * [mtouch] Move mtouch-specific code to mtouch-specific file. * [msbuild] An empty string is a valid value for 'Interpreter', so make it a non-required property. * [mtouch] Add sanity check for aot-compiling interpreted assemblies. * Bump Mono * [linker] Updates SDKs facades list * Bump mono * [msbuild] Adds facades which might override default nuget version to framework list The collision resolver task reads them from here https://github.com/dotnet/sdk/blob/master/src/Tasks/Common/ConflictResolution/FrameworkListReader.cs * Bump to a VSfM version that can build XM Classic projects.
2018-10-10 18:02:28 +03:00
bool interp = app.IsInterpreted (Assembly.GetIdentity (filename));
bool interp_full = !interp && app.UseInterpreter && fname == "mscorlib.dll";
bool is32bit = (abi & Abi.Arch32Mask) > 0;
2016-04-21 15:58:45 +03:00
string arch = abi.AsArchString ();
args.Append ("--debug ");
if (enable_llvm)
args.Append ("--llvm ");
if (!llvm_only && !interp)
2016-04-21 15:58:45 +03:00
args.Append ("-O=gsharedvt ");
args.Append (app.AotOtherArguments).Append (" ");
2016-04-21 15:58:45 +03:00
args.Append ("--aot=mtriple=");
args.Append (enable_thumb ? arch.Replace ("arm", "thumb") : arch);
args.Append ("-ios,");
args.Append ("data-outfile=").Append (StringUtils.Quote (dataFile)).Append (",");
args.Append (app.AotArguments);
2016-04-21 15:58:45 +03:00
if (llvm_only)
args.Append ("llvmonly,");
Bump to mono:2018-06 (#4277) * Bump to mono:2018-06 * Bump mono * Updates compression to work with the public span * Bump mono * Fixes pointer check logic in Deflater * Bump mono * Fixes pointer check logic in Deflater * Bump mono * Bump Mono * [runtime] always use `mono_jit_set_aot_mode` (#4491) `mono_jit_set_aot_only` is deprecated and accidentally broke with https://github.com/mono/mono/pull/7887 This should fix device tests with `mono-2018-06` * Testing with Zoltan's patch * Include libmono-system-native on Xamarin.Mac * Bump Mono Commit list for mono/mono: * mono/mono@7bcda192a06 Bump llvm to release_60/fc854b8ec5873d294b80afa3e6cf6a88c5c48886. (#9786). (#9804) * mono/mono@23e95ec7ad7 Apply F# portable pdb debug fix for pinvokes & bump (#9797) * mono/mono@295f6d32afd [2018-06] [MacOS] On Mac, use the copyfile API to copy files (#9696) Diff: https://github.com/mono/mono/compare/7d5f4b61366008d47665bb473205f4ae1f716d1f...7bcda192a06267562af565d404c06d159f475c03 * Revert 4bacab3d5c7fa86a0e6437f64bb9f08ea3d0741b, it doesn't fix the ios aot problems. * Bump mono * [tests] Adjust the MT0137 test for mcs change in behavior. Starting with mono 5.16 mcs will now add assembly references when the assembly is only used in attributes (this was already the case for csc in both 5.14 and 5.16, so it seems to be a compatibility change). Adjust the MT0137 test accordingly. * [msbuild] Fix parsing of json parser errors to handle trailing periods in the error message. Fixes this test: 1) Test Failure : Xamarin.iOS.Tasks.Bug60536.TestACToolTaskCatchesJsonException ColumnNumber Expected: 2 But was: 0 * Bump mono * [builds] Install the old llvm binaries into the LLVM36 directory and make the 32 bit builds use that. * Bump mono * Bump mono * [jenkins] Don't give VSTS a fake branch. (#4667) Something in VSTS changed, and now fake branch names don't work anymore. So instead use real branch names (and for pull requests I've created a 'pull-request' branch we can use). * Assembly.LoadFile accepts only absolute path * [linker] Add new Facade (System.Threading.Tasks.Extensions). Fixes these MTouch test failures: 1. Xamarin.Linker.SdkTest.iOS_Unified : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > 2. Xamarin.Linker.SdkTest.tvOS : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > 3. Xamarin.Linker.SdkTest.watchOS : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > * [mono-sdks] Necessary changes to unify the LLVM provisioning for both iOS and Android. (#4732) * Bump Mono * [mtouch] add mixed-mode support (#4751) * [mtouch] add --interp-mixed option When enabling this option, mtouch will AOT compile `mscorlib.dll`. At runtime that means every method that wasn't AOT'd will be executed by the runtime interpreter. * [mtouch] Add support to --interpreter to list the assemblies to (not) interpret. * [msbuild] Simplify interpreter code to use a single variable. * Fix whitespace. * [mtouch] Move mtouch-specific code to mtouch-specific file. * [msbuild] An empty string is a valid value for 'Interpreter', so make it a non-required property. * [mtouch] Add sanity check for aot-compiling interpreted assemblies. * Bump Mono * [linker] Updates SDKs facades list * Bump mono * [msbuild] Adds facades which might override default nuget version to framework list The collision resolver task reads them from here https://github.com/dotnet/sdk/blob/master/src/Tasks/Common/ConflictResolution/FrameworkListReader.cs * Bump to a VSfM version that can build XM Classic projects.
2018-10-10 18:02:28 +03:00
else if (interp) {
if (fname != "mscorlib.dll")
throw ErrorHelper.CreateError (99, $"Internal error: can only enable the interpreter for mscorlib.dll when AOT-compiling assemblies (tried to interpret {fname}). Please file an issue at https://github.com/xamarin/xamarin-macios/issues/new.");
args.Append ("interp,");
Bump to mono:2018-06 (#4277) * Bump to mono:2018-06 * Bump mono * Updates compression to work with the public span * Bump mono * Fixes pointer check logic in Deflater * Bump mono * Fixes pointer check logic in Deflater * Bump mono * Bump Mono * [runtime] always use `mono_jit_set_aot_mode` (#4491) `mono_jit_set_aot_only` is deprecated and accidentally broke with https://github.com/mono/mono/pull/7887 This should fix device tests with `mono-2018-06` * Testing with Zoltan's patch * Include libmono-system-native on Xamarin.Mac * Bump Mono Commit list for mono/mono: * mono/mono@7bcda192a06 Bump llvm to release_60/fc854b8ec5873d294b80afa3e6cf6a88c5c48886. (#9786). (#9804) * mono/mono@23e95ec7ad7 Apply F# portable pdb debug fix for pinvokes & bump (#9797) * mono/mono@295f6d32afd [2018-06] [MacOS] On Mac, use the copyfile API to copy files (#9696) Diff: https://github.com/mono/mono/compare/7d5f4b61366008d47665bb473205f4ae1f716d1f...7bcda192a06267562af565d404c06d159f475c03 * Revert 4bacab3d5c7fa86a0e6437f64bb9f08ea3d0741b, it doesn't fix the ios aot problems. * Bump mono * [tests] Adjust the MT0137 test for mcs change in behavior. Starting with mono 5.16 mcs will now add assembly references when the assembly is only used in attributes (this was already the case for csc in both 5.14 and 5.16, so it seems to be a compatibility change). Adjust the MT0137 test accordingly. * [msbuild] Fix parsing of json parser errors to handle trailing periods in the error message. Fixes this test: 1) Test Failure : Xamarin.iOS.Tasks.Bug60536.TestACToolTaskCatchesJsonException ColumnNumber Expected: 2 But was: 0 * Bump mono * [builds] Install the old llvm binaries into the LLVM36 directory and make the 32 bit builds use that. * Bump mono * Bump mono * [jenkins] Don't give VSTS a fake branch. (#4667) Something in VSTS changed, and now fake branch names don't work anymore. So instead use real branch names (and for pull requests I've created a 'pull-request' branch we can use). * Assembly.LoadFile accepts only absolute path * [linker] Add new Facade (System.Threading.Tasks.Extensions). Fixes these MTouch test failures: 1. Xamarin.Linker.SdkTest.iOS_Unified : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > 2. Xamarin.Linker.SdkTest.tvOS : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > 3. Xamarin.Linker.SdkTest.watchOS : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > * [mono-sdks] Necessary changes to unify the LLVM provisioning for both iOS and Android. (#4732) * Bump Mono * [mtouch] add mixed-mode support (#4751) * [mtouch] add --interp-mixed option When enabling this option, mtouch will AOT compile `mscorlib.dll`. At runtime that means every method that wasn't AOT'd will be executed by the runtime interpreter. * [mtouch] Add support to --interpreter to list the assemblies to (not) interpret. * [msbuild] Simplify interpreter code to use a single variable. * Fix whitespace. * [mtouch] Move mtouch-specific code to mtouch-specific file. * [msbuild] An empty string is a valid value for 'Interpreter', so make it a non-required property. * [mtouch] Add sanity check for aot-compiling interpreted assemblies. * Bump Mono * [linker] Updates SDKs facades list * Bump mono * [msbuild] Adds facades which might override default nuget version to framework list The collision resolver task reads them from here https://github.com/dotnet/sdk/blob/master/src/Tasks/Common/ConflictResolution/FrameworkListReader.cs * Bump to a VSfM version that can build XM Classic projects.
2018-10-10 18:02:28 +03:00
} else if (interp_full) {
if (fname != "mscorlib.dll")
throw ErrorHelper.CreateError (99, $"Internal error: can only enable the interpreter for mscorlib.dll when AOT-compiling assemblies (tried to interpret {fname}). Please file an issue at https://github.com/xamarin/xamarin-macios/issues/new.");
args.Append ("interp,full,");
} else
2016-04-21 15:58:45 +03:00
args.Append ("full,");
var aname = Path.GetFileNameWithoutExtension (fname);
var sdk_or_product = Profile.IsSdkAssembly (aname) || Profile.IsProductAssembly (aname);
if (enable_llvm)
args.Append ("nodebug,");
else if (!(enable_debug || enable_debug_symbols))
2016-04-21 15:58:45 +03:00
args.Append ("nodebug,");
else if (app.DebugAll || app.DebugAssemblies.Contains (fname) || !sdk_or_product)
2016-04-21 15:58:45 +03:00
args.Append ("soft-debug,");
args.Append ("dwarfdebug,");
/* Needed for #4587 */
if (enable_debug && !enable_llvm)
args.Append ("no-direct-calls,");
if (!app.UseDlsym (filename))
args.Append ("direct-pinvoke,");
if (app.EnableMSym) {
var msymdir = StringUtils.Quote (Path.Combine (outputDir, "Msym"));
args.Append ($"msym-dir={msymdir},");
}
2016-04-21 15:58:45 +03:00
if (enable_llvm)
Bump to mono:2018-06 (#4277) * Bump to mono:2018-06 * Bump mono * Updates compression to work with the public span * Bump mono * Fixes pointer check logic in Deflater * Bump mono * Fixes pointer check logic in Deflater * Bump mono * Bump Mono * [runtime] always use `mono_jit_set_aot_mode` (#4491) `mono_jit_set_aot_only` is deprecated and accidentally broke with https://github.com/mono/mono/pull/7887 This should fix device tests with `mono-2018-06` * Testing with Zoltan's patch * Include libmono-system-native on Xamarin.Mac * Bump Mono Commit list for mono/mono: * mono/mono@7bcda192a06 Bump llvm to release_60/fc854b8ec5873d294b80afa3e6cf6a88c5c48886. (#9786). (#9804) * mono/mono@23e95ec7ad7 Apply F# portable pdb debug fix for pinvokes & bump (#9797) * mono/mono@295f6d32afd [2018-06] [MacOS] On Mac, use the copyfile API to copy files (#9696) Diff: https://github.com/mono/mono/compare/7d5f4b61366008d47665bb473205f4ae1f716d1f...7bcda192a06267562af565d404c06d159f475c03 * Revert 4bacab3d5c7fa86a0e6437f64bb9f08ea3d0741b, it doesn't fix the ios aot problems. * Bump mono * [tests] Adjust the MT0137 test for mcs change in behavior. Starting with mono 5.16 mcs will now add assembly references when the assembly is only used in attributes (this was already the case for csc in both 5.14 and 5.16, so it seems to be a compatibility change). Adjust the MT0137 test accordingly. * [msbuild] Fix parsing of json parser errors to handle trailing periods in the error message. Fixes this test: 1) Test Failure : Xamarin.iOS.Tasks.Bug60536.TestACToolTaskCatchesJsonException ColumnNumber Expected: 2 But was: 0 * Bump mono * [builds] Install the old llvm binaries into the LLVM36 directory and make the 32 bit builds use that. * Bump mono * Bump mono * [jenkins] Don't give VSTS a fake branch. (#4667) Something in VSTS changed, and now fake branch names don't work anymore. So instead use real branch names (and for pull requests I've created a 'pull-request' branch we can use). * Assembly.LoadFile accepts only absolute path * [linker] Add new Facade (System.Threading.Tasks.Extensions). Fixes these MTouch test failures: 1. Xamarin.Linker.SdkTest.iOS_Unified : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > 2. Xamarin.Linker.SdkTest.tvOS : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > 3. Xamarin.Linker.SdkTest.watchOS : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > * [mono-sdks] Necessary changes to unify the LLVM provisioning for both iOS and Android. (#4732) * Bump Mono * [mtouch] add mixed-mode support (#4751) * [mtouch] add --interp-mixed option When enabling this option, mtouch will AOT compile `mscorlib.dll`. At runtime that means every method that wasn't AOT'd will be executed by the runtime interpreter. * [mtouch] Add support to --interpreter to list the assemblies to (not) interpret. * [msbuild] Simplify interpreter code to use a single variable. * Fix whitespace. * [mtouch] Move mtouch-specific code to mtouch-specific file. * [msbuild] An empty string is a valid value for 'Interpreter', so make it a non-required property. * [mtouch] Add sanity check for aot-compiling interpreted assemblies. * Bump Mono * [linker] Updates SDKs facades list * Bump mono * [msbuild] Adds facades which might override default nuget version to framework list The collision resolver task reads them from here https://github.com/dotnet/sdk/blob/master/src/Tasks/Common/ConflictResolution/FrameworkListReader.cs * Bump to a VSfM version that can build XM Classic projects.
2018-10-10 18:02:28 +03:00
args.Append ("llvm-path=").Append (MonoTouchDirectory).Append (is32bit ? "/LLVM36/bin/," : "/LLVM/bin/,");
2016-04-21 15:58:45 +03:00
if (!llvm_only)
args.Append ("outfile=").Append (StringUtils.Quote (outputFile));
2016-04-21 15:58:45 +03:00
if (!llvm_only && enable_llvm)
args.Append (",");
if (enable_llvm)
args.Append ("llvm-outfile=").Append (StringUtils.Quote (llvmOutputFile));
2016-04-21 15:58:45 +03:00
args.Append (" \"").Append (filename).Append ("\"");
return args.ToString ();
}
public static ProcessStartInfo CreateStartInfo (Application app, string file_name, string arguments, string mono_path, string mono_debug = null)
2016-04-21 15:58:45 +03:00
{
var info = new ProcessStartInfo (file_name, arguments);
info.UseShellExecute = false;
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
info.EnvironmentVariables ["MONO_PATH"] = mono_path;
if (mono_debug != null)
info.EnvironmentVariables ["MONO_DEBUG"] = mono_debug;
return info;
}
static string EncodeAotSymbol (string symbol)
{
var sb = new StringBuilder ();
/* This mimics what the aot-compiler does */
foreach (var b in System.Text.Encoding.UTF8.GetBytes (symbol)) {
char c = (char) b;
if ((c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z')) {
sb.Append (c);
continue;
}
sb.Append ('_');
}
return sb.ToString ();
}
// note: this is executed under Parallel.ForEach
public static string GenerateMain (Application app, IEnumerable<Assembly> assemblies, string assembly_name, Abi abi, string main_source, IList<string> registration_methods)
2016-04-21 15:58:45 +03:00
{
var assembly_externs = new StringBuilder ();
var assembly_aot_modules = new StringBuilder ();
var register_assemblies = new StringBuilder ();
var assembly_location = new StringBuilder ();
var assembly_location_count = 0;
2016-04-21 15:58:45 +03:00
var enable_llvm = (abi & Abi.LLVM) != 0;
register_assemblies.AppendLine ("\tguint32 exception_gchandle = 0;");
2016-04-21 15:58:45 +03:00
foreach (var s in assemblies) {
if (!s.IsAOTCompiled)
continue;
2016-04-21 15:58:45 +03:00
if ((abi & Abi.SimulatorArchMask) == 0) {
var info = s.AssemblyDefinition.Name.Name;
info = EncodeAotSymbol (info);
assembly_externs.Append ("extern void *mono_aot_module_").Append (info).AppendLine ("_info;");
assembly_aot_modules.Append ("\tmono_aot_register_module (mono_aot_module_").Append (info).AppendLine ("_info);");
}
string sname = s.FileName;
if (assembly_name != sname && IsBoundAssembly (s)) {
register_assemblies.Append ("\txamarin_open_and_register (\"").Append (sname).Append ("\", &exception_gchandle);").AppendLine ();
register_assemblies.AppendLine ("\txamarin_process_managed_exception_gchandle (exception_gchandle);");
}
2016-04-21 15:58:45 +03:00
}
if ((abi & Abi.SimulatorArchMask) == 0 || app.Embeddinator) {
var frameworks = assemblies.Where ((a) => a.BuildTarget == AssemblyBuildTarget.Framework)
.OrderBy ((a) => a.Identity, StringComparer.Ordinal);
foreach (var asm_fw in frameworks) {
var asm_name = asm_fw.Identity;
if (asm_fw.BuildTargetName == asm_name)
continue; // this is deduceable
var prefix = string.Empty;
if (!app.HasFrameworksDirectory && asm_fw.IsCodeShared)
prefix = "../../";
var suffix = string.Empty;
if (app.IsSimulatorBuild)
suffix = "/simulator";
assembly_location.AppendFormat ("\t{{ \"{0}\", \"{2}Frameworks/{1}.framework/MonoBundle{3}\" }},\n", asm_name, asm_fw.BuildTargetName, prefix, suffix);
assembly_location_count++;
}
}
2016-04-21 15:58:45 +03:00
try {
StringBuilder sb = new StringBuilder ();
using (var sw = new StringWriter (sb)) {
sw.WriteLine ("#include \"xamarin/xamarin.h\"");
if (assembly_location.Length > 0) {
sw.WriteLine ();
sw.WriteLine ("struct AssemblyLocation assembly_location_entries [] = {");
sw.WriteLine (assembly_location);
sw.WriteLine ("};");
sw.WriteLine ();
sw.WriteLine ("struct AssemblyLocations assembly_locations = {{ {0}, assembly_location_entries }};", assembly_location_count);
}
2016-04-21 15:58:45 +03:00
sw.WriteLine ();
sw.WriteLine (assembly_externs);
sw.WriteLine ("void xamarin_register_modules_impl ()");
sw.WriteLine ("{");
sw.WriteLine (assembly_aot_modules);
sw.WriteLine ("}");
sw.WriteLine ();
sw.WriteLine ("void xamarin_register_assemblies_impl ()");
sw.WriteLine ("{");
sw.WriteLine (register_assemblies);
sw.WriteLine ("}");
sw.WriteLine ();
if (registration_methods != null) {
foreach (var method in registration_methods) {
sw.Write ("extern \"C\" void ");
2016-04-21 15:58:45 +03:00
sw.Write (method);
sw.WriteLine ("();");
}
}
// Burn in a reference to the profiling symbol so that the native linker doesn't remove it
// On iOS we can pass -u to the native linker, but that doesn't work on tvOS, where
// we're building with bitcode (even when bitcode is disabled, we still build with the
// bitcode marker, which makes the linker reject -u).
if (app.EnableProfiling) {
[runtime] integrate mono 2017-10 (#2905) * Update the function name used to initialize libmono-profiler-log, its called mono_profiler_init_log () now. * [builds] Pass --with-cross-offsets= to crosstv's configure. * Bump mono to 2017-08. * Bump mono to 2017-08. * Force disable 'futimens' and 'utimensat' so that we build with Xcode 9. This is also needed to build with Xcode 8.3 on High Sierra. * Remove old AppleTls implementation. * Bump mono. * Bump mono to 2017-08. * Bump mono to 2017-08 * Reenable link-keep-resources-2 test - This reverts commit 76b759ef22c06cda3ba30aba1ac0d45634e4fbf4. - 2017-08 has linker fix * Bump mono to 2017-10 * Revert "Bump mono to 2017-10" This reverts commit bb7832724e18f8578449e46426382a537f3f4823. * Bump system mono to 2017-10 * Bump embedded mono to 2017-10 * [runtime] reflect eglib move https://github.com/mono/mono/commit/9be68f8952ea0e1aad582bfe2f47bad71aee2cc7 * bump mono * [btouch] remove Security.Tls usage from test * [mtouch tests] update the function name used to initialize libmono-profiler-log, its called mono_profiler_init_log () now. see https://github.com/mono/mono/commit/ea4e4a9ef6fc42570a23026adbe826cf7248290e fixes: ``` 1) Failed : Xamarin.MTouch.Profiling(tvOS) _mono_profiler_startup_log Expected: collection containing "_mono_profiler_startup_log" But was: < "_mono_profiler_init_log" > at Xamarin.MTouch.Profiling (Xamarin.Profile profile) [0x00106] in <511889694a624cc9a50e0e9b259b05c5>:0 2) Failed : Xamarin.MTouch.Profiling(watchOS) _mono_profiler_startup_log Expected: collection containing "_mono_profiler_startup_log" But was: < "_xamarin_get_block_descriptor", "_mono_profiler_init_log" > at Xamarin.MTouch.Profiling (Xamarin.Profile profile) [0x00106] in <511889694a624cc9a50e0e9b259b05c5>:0 ``` * [mmptest] update log profiler options. https://github.com/mono/mono/commit/826558a4af624bc0acaea98ec39784e65d278091 deprecated the dash prefix for the mlpd path. `noallocs` or `nocalls` are not needed, neither of them are default anymore. * [mmptest] fix link-keep-resources-2 test to cope with more corlib resources. another corlib resource (mscorlib.xml) was added: https://github.com/mono/mono/commit/11e95169e787#diff-2d1c64decd91d9a6e8842ab0f0e9438d * Revert "[mmptest] fix link-keep-resources-2 test to cope with more corlib resources." This reverts commit 350eb3c174288bbffcc3b7acb15cadb913af25b7. * [XHarness] Add the Mono.Data.Tds tests. * Address comments from rolf in the review. * [mmp regresssion tests] bump mono linker, so mscorlib.xml gets stripped the test was failing in that way: > Executing link-keep-resources-2... > [FAIL] i18n 4/2 data files present: charinfo.nlp, collation.core.bin, collation.tailoring.bin, mscorlib.xml also update the output, because it's actually expected at least three elements. fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=59277 * bump mono fixes crash in tvOS: https://github.com/mono/mono/pull/5812 * bump mono for updated BCL tests see https://github.com/mono/mono/pull/5820 * [mono] set 2017-10 branch in .gitmodules * [macos] Fix guiunit error on clean builds by depending on correct copy (#2912) * [macos] Fix guiunit error on clean builds by depending on correct copy - From a clean build making a BCL test would error due to the non-mobile guiunit not being built - This was because the Makefile-mac.inc target was incorrect - This was because xharness assumed that non variation based targets were always Modern - However, BCL tests are Full, not Modern * Code review change * Swap to var to reduce diff * Revert changes in the paths for GuiUnit. * [XHarness] Add the System.IO.Compression bcl tests. (#2918) * [XHarness] Add the System.IO.Compression bcl tests. * [XHarness] Add bcl tests for System.IO.Compression.FileSystem. (#2924) * [XHarness] Add the System.IO.Compression bcl tests. * Ensure that resources are correctly copied in the bundles. * [XHarness] Add bcl tests for System.IO.Compression.FileSystem. * As per review, make the Mac test app name match the tests that are ran. * [XHarness] Add Mono.CSharp tests on ios. (#2927) * [XHarness] Add Mono.CSharp tests on ios. * Bump mono to bring changes in the mono.csharp tests. * [xtro-sharpie] fix TypeDefinition access due to Cecil change * Bump mono * bump mono fixes - https://bugzilla.xamarin.com/show_bug.cgi?id=60480 - https://bugzilla.xamarin.com/show_bug.cgi?id=60482 * bump mono more fixes around conflicting paths when tests are run in parallel. * Bump for mono/mono@2017-10
2017-11-14 23:30:08 +03:00
sw.WriteLine ("extern \"C\" { void mono_profiler_init_log (); }");
sw.WriteLine ("typedef void (*xamarin_profiler_symbol_def)();");
sw.WriteLine ("extern xamarin_profiler_symbol_def xamarin_profiler_symbol;");
sw.WriteLine ("xamarin_profiler_symbol_def xamarin_profiler_symbol = NULL;");
}
if (app.UseInterpreter) {
sw.WriteLine ("extern \"C\" { void mono_ee_interp_init (const char *); }");
sw.WriteLine ("extern \"C\" { void mono_icall_table_init (void); }");
sw.WriteLine ("extern \"C\" { void mono_marshal_ilgen_init (void); }");
sw.WriteLine ("extern \"C\" { void mono_method_builder_ilgen_init (void); }");
sw.WriteLine ("extern \"C\" { void mono_sgen_mono_ilgen_init (void); }");
}
2016-04-21 15:58:45 +03:00
sw.WriteLine ("void xamarin_setup_impl ()");
sw.WriteLine ("{");
if (app.EnableProfiling)
[runtime] integrate mono 2017-10 (#2905) * Update the function name used to initialize libmono-profiler-log, its called mono_profiler_init_log () now. * [builds] Pass --with-cross-offsets= to crosstv's configure. * Bump mono to 2017-08. * Bump mono to 2017-08. * Force disable 'futimens' and 'utimensat' so that we build with Xcode 9. This is also needed to build with Xcode 8.3 on High Sierra. * Remove old AppleTls implementation. * Bump mono. * Bump mono to 2017-08. * Bump mono to 2017-08 * Reenable link-keep-resources-2 test - This reverts commit 76b759ef22c06cda3ba30aba1ac0d45634e4fbf4. - 2017-08 has linker fix * Bump mono to 2017-10 * Revert "Bump mono to 2017-10" This reverts commit bb7832724e18f8578449e46426382a537f3f4823. * Bump system mono to 2017-10 * Bump embedded mono to 2017-10 * [runtime] reflect eglib move https://github.com/mono/mono/commit/9be68f8952ea0e1aad582bfe2f47bad71aee2cc7 * bump mono * [btouch] remove Security.Tls usage from test * [mtouch tests] update the function name used to initialize libmono-profiler-log, its called mono_profiler_init_log () now. see https://github.com/mono/mono/commit/ea4e4a9ef6fc42570a23026adbe826cf7248290e fixes: ``` 1) Failed : Xamarin.MTouch.Profiling(tvOS) _mono_profiler_startup_log Expected: collection containing "_mono_profiler_startup_log" But was: < "_mono_profiler_init_log" > at Xamarin.MTouch.Profiling (Xamarin.Profile profile) [0x00106] in <511889694a624cc9a50e0e9b259b05c5>:0 2) Failed : Xamarin.MTouch.Profiling(watchOS) _mono_profiler_startup_log Expected: collection containing "_mono_profiler_startup_log" But was: < "_xamarin_get_block_descriptor", "_mono_profiler_init_log" > at Xamarin.MTouch.Profiling (Xamarin.Profile profile) [0x00106] in <511889694a624cc9a50e0e9b259b05c5>:0 ``` * [mmptest] update log profiler options. https://github.com/mono/mono/commit/826558a4af624bc0acaea98ec39784e65d278091 deprecated the dash prefix for the mlpd path. `noallocs` or `nocalls` are not needed, neither of them are default anymore. * [mmptest] fix link-keep-resources-2 test to cope with more corlib resources. another corlib resource (mscorlib.xml) was added: https://github.com/mono/mono/commit/11e95169e787#diff-2d1c64decd91d9a6e8842ab0f0e9438d * Revert "[mmptest] fix link-keep-resources-2 test to cope with more corlib resources." This reverts commit 350eb3c174288bbffcc3b7acb15cadb913af25b7. * [XHarness] Add the Mono.Data.Tds tests. * Address comments from rolf in the review. * [mmp regresssion tests] bump mono linker, so mscorlib.xml gets stripped the test was failing in that way: > Executing link-keep-resources-2... > [FAIL] i18n 4/2 data files present: charinfo.nlp, collation.core.bin, collation.tailoring.bin, mscorlib.xml also update the output, because it's actually expected at least three elements. fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=59277 * bump mono fixes crash in tvOS: https://github.com/mono/mono/pull/5812 * bump mono for updated BCL tests see https://github.com/mono/mono/pull/5820 * [mono] set 2017-10 branch in .gitmodules * [macos] Fix guiunit error on clean builds by depending on correct copy (#2912) * [macos] Fix guiunit error on clean builds by depending on correct copy - From a clean build making a BCL test would error due to the non-mobile guiunit not being built - This was because the Makefile-mac.inc target was incorrect - This was because xharness assumed that non variation based targets were always Modern - However, BCL tests are Full, not Modern * Code review change * Swap to var to reduce diff * Revert changes in the paths for GuiUnit. * [XHarness] Add the System.IO.Compression bcl tests. (#2918) * [XHarness] Add the System.IO.Compression bcl tests. * [XHarness] Add bcl tests for System.IO.Compression.FileSystem. (#2924) * [XHarness] Add the System.IO.Compression bcl tests. * Ensure that resources are correctly copied in the bundles. * [XHarness] Add bcl tests for System.IO.Compression.FileSystem. * As per review, make the Mac test app name match the tests that are ran. * [XHarness] Add Mono.CSharp tests on ios. (#2927) * [XHarness] Add Mono.CSharp tests on ios. * Bump mono to bring changes in the mono.csharp tests. * [xtro-sharpie] fix TypeDefinition access due to Cecil change * Bump mono * bump mono fixes - https://bugzilla.xamarin.com/show_bug.cgi?id=60480 - https://bugzilla.xamarin.com/show_bug.cgi?id=60482 * bump mono more fixes around conflicting paths when tests are run in parallel. * Bump for mono/mono@2017-10
2017-11-14 23:30:08 +03:00
sw.WriteLine ("\txamarin_profiler_symbol = mono_profiler_init_log;");
if (app.EnableLLVMOnlyBitCode)
2016-04-21 15:58:45 +03:00
sw.WriteLine ("\tmono_jit_set_aot_mode (MONO_AOT_MODE_LLVMONLY);");
else if (app.UseInterpreter) {
sw.WriteLine ("\tmono_icall_table_init ();");
sw.WriteLine ("\tmono_marshal_ilgen_init ();");
sw.WriteLine ("\tmono_method_builder_ilgen_init ();");
sw.WriteLine ("\tmono_sgen_mono_ilgen_init ();");
sw.WriteLine ("\tmono_ee_interp_init (NULL);");
sw.WriteLine ("\tmono_jit_set_aot_mode (MONO_AOT_MODE_INTERP);");
Bump to mono:2018-06 (#4277) * Bump to mono:2018-06 * Bump mono * Updates compression to work with the public span * Bump mono * Fixes pointer check logic in Deflater * Bump mono * Fixes pointer check logic in Deflater * Bump mono * Bump Mono * [runtime] always use `mono_jit_set_aot_mode` (#4491) `mono_jit_set_aot_only` is deprecated and accidentally broke with https://github.com/mono/mono/pull/7887 This should fix device tests with `mono-2018-06` * Testing with Zoltan's patch * Include libmono-system-native on Xamarin.Mac * Bump Mono Commit list for mono/mono: * mono/mono@7bcda192a06 Bump llvm to release_60/fc854b8ec5873d294b80afa3e6cf6a88c5c48886. (#9786). (#9804) * mono/mono@23e95ec7ad7 Apply F# portable pdb debug fix for pinvokes & bump (#9797) * mono/mono@295f6d32afd [2018-06] [MacOS] On Mac, use the copyfile API to copy files (#9696) Diff: https://github.com/mono/mono/compare/7d5f4b61366008d47665bb473205f4ae1f716d1f...7bcda192a06267562af565d404c06d159f475c03 * Revert 4bacab3d5c7fa86a0e6437f64bb9f08ea3d0741b, it doesn't fix the ios aot problems. * Bump mono * [tests] Adjust the MT0137 test for mcs change in behavior. Starting with mono 5.16 mcs will now add assembly references when the assembly is only used in attributes (this was already the case for csc in both 5.14 and 5.16, so it seems to be a compatibility change). Adjust the MT0137 test accordingly. * [msbuild] Fix parsing of json parser errors to handle trailing periods in the error message. Fixes this test: 1) Test Failure : Xamarin.iOS.Tasks.Bug60536.TestACToolTaskCatchesJsonException ColumnNumber Expected: 2 But was: 0 * Bump mono * [builds] Install the old llvm binaries into the LLVM36 directory and make the 32 bit builds use that. * Bump mono * Bump mono * [jenkins] Don't give VSTS a fake branch. (#4667) Something in VSTS changed, and now fake branch names don't work anymore. So instead use real branch names (and for pull requests I've created a 'pull-request' branch we can use). * Assembly.LoadFile accepts only absolute path * [linker] Add new Facade (System.Threading.Tasks.Extensions). Fixes these MTouch test failures: 1. Xamarin.Linker.SdkTest.iOS_Unified : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > 2. Xamarin.Linker.SdkTest.tvOS : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > 3. Xamarin.Linker.SdkTest.watchOS : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > * [mono-sdks] Necessary changes to unify the LLVM provisioning for both iOS and Android. (#4732) * Bump Mono * [mtouch] add mixed-mode support (#4751) * [mtouch] add --interp-mixed option When enabling this option, mtouch will AOT compile `mscorlib.dll`. At runtime that means every method that wasn't AOT'd will be executed by the runtime interpreter. * [mtouch] Add support to --interpreter to list the assemblies to (not) interpret. * [msbuild] Simplify interpreter code to use a single variable. * Fix whitespace. * [mtouch] Move mtouch-specific code to mtouch-specific file. * [msbuild] An empty string is a valid value for 'Interpreter', so make it a non-required property. * [mtouch] Add sanity check for aot-compiling interpreted assemblies. * Bump Mono * [linker] Updates SDKs facades list * Bump mono * [msbuild] Adds facades which might override default nuget version to framework list The collision resolver task reads them from here https://github.com/dotnet/sdk/blob/master/src/Tasks/Common/ConflictResolution/FrameworkListReader.cs * Bump to a VSfM version that can build XM Classic projects.
2018-10-10 18:02:28 +03:00
} else if (app.IsDeviceBuild)
sw.WriteLine ("\tmono_jit_set_aot_mode (MONO_AOT_MODE_FULL);");
if (assembly_location.Length > 0)
sw.WriteLine ("\txamarin_set_assembly_directories (&assembly_locations);");
2016-04-21 15:58:45 +03:00
if (registration_methods != null) {
for (int i = 0; i < registration_methods.Count; i++) {
sw.Write ("\t");
sw.Write (registration_methods [i]);
sw.WriteLine ("();");
}
}
if (app.EnableDebug)
sw.WriteLine ("\txamarin_gc_pump = {0};", app.DebugTrack.Value ? "TRUE" : "FALSE");
sw.WriteLine ("\txamarin_init_mono_debug = {0};", app.PackageManagedDebugSymbols ? "TRUE" : "FALSE");
2016-04-21 15:58:45 +03:00
sw.WriteLine ("\txamarin_executable_name = \"{0}\";", assembly_name);
sw.WriteLine ("\tmono_use_llvm = {0};", enable_llvm ? "TRUE" : "FALSE");
sw.WriteLine ("\txamarin_log_level = {0};", verbose.ToString (CultureInfo.InvariantCulture));
2016-04-21 15:58:45 +03:00
sw.WriteLine ("\txamarin_arch_name = \"{0}\";", abi.AsArchString ());
if (!app.IsDefaultMarshalManagedExceptionMode)
sw.WriteLine ("\txamarin_marshal_managed_exception_mode = MarshalManagedExceptionMode{0};", app.MarshalManagedExceptions);
sw.WriteLine ("\txamarin_marshal_objectivec_exception_mode = MarshalObjectiveCExceptionMode{0};", app.MarshalObjectiveCExceptions);
2016-04-21 15:58:45 +03:00
if (app.EnableDebug)
sw.WriteLine ("\txamarin_debug_mode = TRUE;");
if (!string.IsNullOrEmpty (app.MonoGCParams))
sw.WriteLine ("\tsetenv (\"MONO_GC_PARAMS\", \"{0}\", 1);", app.MonoGCParams);
foreach (var kvp in app.EnvironmentVariables)
2016-04-21 15:58:45 +03:00
sw.WriteLine ("\tsetenv (\"{0}\", \"{1}\", 1);", kvp.Key.Replace ("\"", "\\\""), kvp.Value.Replace ("\"", "\\\""));
sw.WriteLine ("\txamarin_supports_dynamic_registration = {0};", app.DynamicRegistrationSupported ? "TRUE" : "FALSE");
2016-04-21 15:58:45 +03:00
sw.WriteLine ("}");
sw.WriteLine ();
sw.Write ("int ");
sw.Write (app.IsWatchExtension ? "xamarin_watchextension_main" : "main");
sw.WriteLine (" (int argc, char **argv)");
sw.WriteLine ("{");
sw.WriteLine ("\tNSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];");
if (app.IsExtension) {
// the name of the executable must be the bundle id (reverse dns notation)
// but we do not want to impose that (ugly) restriction to the managed .exe / project name / ...
sw.WriteLine ("\targv [0] = (char *) \"{0}\";", Path.GetFileNameWithoutExtension (app.RootAssemblies [0]));
sw.WriteLine ("\tint rv = xamarin_main (argc, argv, XamarinLaunchModeExtension);");
2017-04-19 20:12:17 +03:00
} else {
sw.WriteLine ("\tint rv = xamarin_main (argc, argv, XamarinLaunchModeApp);");
2016-04-21 15:58:45 +03:00
}
sw.WriteLine ("\t[pool drain];");
sw.WriteLine ("\treturn rv;");
sw.WriteLine ("}");
sw.WriteLine ("void xamarin_initialize_callbacks () __attribute__ ((constructor));");
sw.WriteLine ("void xamarin_initialize_callbacks ()");
sw.WriteLine ("{");
sw.WriteLine ("\txamarin_setup = xamarin_setup_impl;");
sw.WriteLine ("\txamarin_register_assemblies = xamarin_register_assemblies_impl;");
sw.WriteLine ("\txamarin_register_modules = xamarin_register_modules_impl;");
sw.WriteLine ("}");
}
[mtouch/mmp] Fix tracking of whether the static registrar should run again or not. Fixes #641. (#3534) * [tests] Improve debug spew for the RebuildTest_WithExtensions test. * [mtouch/mmp] Store/load if the dynamic registrar is removed or not into the cached link results. Store/load if the dynamic registrar is removed or not into the cached link results, so that we generate the correct main.m even if cached linker results are used. * [mtouch/mmp] The static registrar must not execute if we're loading cached results from the linker. The static registrar must not execute if we're loading cached results from the linker, because the static registrar needs information from the linker that's not restored from the cache. * [mtouch/mmp] Share Touch code. * [mtouch/mmp] Make it possible to touch inexistent files (to create them). * [mtouch/mmp] Fix tracking of whether the static registrar should run again or not. The recent changes to support optimizing away the dynamic registrar caused the Xamarin.MTouch.RebuildTest_WithExtensions test to regress. The problem ----------- * The linker now collects and stores information the static registrar needs. * This information is not restored from disk when the linker realizes that it can reload previously linked assemblies instead of executing again. * The static registrar runs again (for another reason). * The information the static registrar needs isn't available, and incorrect output follows. So fix 1: show an error if the static registrar runs when the linker loaded cached results. The exact scenario the test ran into is this: * 1st build: everything is new and everything is built. * 2nd build: contents of .exe changes, the linker runs again, the static registrar runs again, but sees that the generated output didn't change, so it doesn't write the new content to disk (this is an optimization to avoid compiling the registrar.m file again unless needed). * 3rd build: only the .exe timestamp changes, the linker sees nothing changes in the contents of the .exe and loads the previously linked assemblies from disk, the static registrar sees that the .exe's timestamp is newer than registrar.m's timestamp and run again, but doesn't produce the right result because it doesn't have the information it needs. Considered solutions -------------------- 1. Only track timestamps, not file contents. This is not ideal, since it will result in more work done: in particular for the case above, it would add a registrar.m compilation in build #2, and linker rerun + static registrar rerun + registrar.m compilation + final native link in build #3. 2. Always write the output of the static registrar, even if it hasn't changed. This is not ideal either, since it will also result in more work done: for the case above, it would add a registrar.m compilation + final native link in build #3. 3. Always write the output of the static registrar, but track if it changed or not, and if it didn't, just touch registrar.o instead of recompiling it. This only means the final native link in build #3 is added (see #5 for why this is worse than it sounds). 4. Always write the output of the static registrar, but track it it changed or not, and if it didn't, just touch registrar.o instead of recompiling it, and track that too, so that the final native link in build #3 isn't needed anymore. Unfortunately this may result in incorrect behavior, because now the msbuild tasks will detect that the executable has changed, and may run dsymutil + strip again. The executable didn't actually change, which means it would be the previously stripped executable, and thus we'd end up with an empty .dSYM because we ran dsymtil on an already stripped executable. 5. Idea #4, but write the output of the final link into a temporary directory instead of the .app, so that we could track whether we should update the executable in the .app or not. This is not optimal either, because executables can be *big* (I've seen multi-GB tvOS bitcode executables), and extra copies of such files should not be taken lightly. 6. Idea #4, but tell the MSBuild tasks that dsymutil/strip doesn't need to be rerun even if the timestamp of the executable changed. This might actually work, but now the solution's become quite complex. Implemented solution -------------------- Use stamp files to detect whether a file is up-to-date or not. In particular: * When we don't write to a file because the new contents are identical to the old contents, we now touch a .stamp file. This stamp file means "the accompanying file was determined to be up-to-date when the stamp was touched." * When checking whether a file is up-to-date, also check for the presence of a .stamp file, and if it exists, use the highest timestamp between the stamp file and the actual file. Now the test scenario becomes: * 1st build: everything is new and everything is built. * 2nd build: contents of .exe changes, the linker runs again, the static registrar runs again, but sees that the generated output didn't change, so it doesn't write the new content to disk, but it creates a registrar.m.stamp file to indicate the point in time when registrar.m was considered up-to- date. * 3rd build: only the .exe timestamp changes, the linker sees nothing changes in the contents of the .exe and loads the previously linked assemblies from disk, the static registrar sees that the .exe's timestamp is *older* than registrar.m.stamp's timestamp and doesn't run again. We only use the stamp file for source code (registrar.[m|h], main.[m|h], pinvokes.[m|h]), since using it every time has too much potential for running into other problems (for instance we should never create .stamp files inside the .app). Fixes these test failures: 1) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("single","",False,System.String[]) single Expected: <empty> But was: < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory371/testApp.app/testApp is modified, timestamp: 2/15/2018 3:04:11 PM > 2/15/2018 3:04:09 PM" > 2) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("dual","armv7,arm64",False,System.String[]) dual Expected: <empty> But was: < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory375/testApp.app/testApp is modified, timestamp: 2/15/2018 3:06:03 PM > 2/15/2018 3:06:00 PM" > 3) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("llvm","armv7+llvm",False,System.String[]) llvm Expected: <empty> But was: < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory379/testApp.app/testApp is modified, timestamp: 2/15/2018 3:07:14 PM > 2/15/2018 3:07:12 PM" > 4) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("debug","",True,System.String[]) debug Expected: <empty> But was: < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory383/testApp.app/testApp is modified, timestamp: 2/15/2018 3:08:16 PM > 2/15/2018 3:08:13 PM" > 5) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("single-framework","",False,System.String[]) single-framework Expected: <empty> But was: < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory387/testApp.app/testApp is modified, timestamp: 2/15/2018 3:09:18 PM > 2/15/2018 3:09:16 PM" > Fixes https://github.com/xamarin/maccore/issues/641
2018-02-19 22:28:04 +03:00
WriteIfDifferent (main_source, sb.ToString (), true);
2016-04-21 15:58:45 +03:00
} catch (MonoTouchException) {
throw;
} catch (Exception e) {
throw new MonoTouchException (4001, true, e, "The main template could not be expanded to `{0}`.", main_source);
}
return main_source;
}
[DllImport (Constants.libSystemLibrary)]
static extern int symlink (string path1, string path2);
public static bool Symlink (string path1, string path2)
{
return symlink (path1, path2) == 0;
}
[DllImport (Constants.libSystemLibrary)]
static extern int unlink (string pathname);
public static void FileDelete (string file)
{
// File.Delete can't always delete symlinks (in particular if the symlink points to a file that doesn't exist).
unlink (file);
// ignore any errors.
}
public static void CopyAssembly (string source, string target, string target_dir = null)
{
if (File.Exists (target))
File.Delete (target);
if (target_dir == null)
target_dir = Path.GetDirectoryName (target);
if (!Directory.Exists (target_dir))
Directory.CreateDirectory (target_dir);
File.Copy (source, target);
string sconfig = source + ".config";
string tconfig = target + ".config";
if (File.Exists (tconfig))
File.Delete (tconfig);
if (File.Exists (sconfig))
File.Copy (sconfig, tconfig);
string tdebug = target + ".mdb";
if (File.Exists (tdebug))
File.Delete (tdebug);
string sdebug = source + ".mdb";
if (File.Exists (sdebug))
File.Copy (sdebug, tdebug);
string tpdb = Path.ChangeExtension (target, "pdb");
if (File.Exists (tpdb))
File.Delete (tpdb);
string spdb = Path.ChangeExtension (source, "pdb");
if (File.Exists (spdb))
File.Copy (spdb, tpdb);
2016-04-21 15:58:45 +03:00
}
public static bool SymlinkAssembly (Application app, string source, string target, string target_dir)
2016-04-21 15:58:45 +03:00
{
if (app.IsSimulatorBuild && Driver.XcodeVersion >= new Version (6, 0)) {
// Don't symlink with Xcode 6, it has a broken simulator (at least in
// that doesn't work properly when installing/upgrading apps with symlinks.
return false;
}
if (File.Exists (target))
File.Delete (target);
if (!Directory.Exists (target_dir))
Directory.CreateDirectory (target_dir);
if (!Symlink (source, target))
return false;
string sconfig = source + ".config";
string tconfig = target + ".config";
if (File.Exists (tconfig))
File.Delete (tconfig);
if (File.Exists (sconfig))
Symlink (sconfig, tconfig);
string tdebug = target + ".mdb";
if (File.Exists (tdebug))
File.Delete (tdebug);
string sdebug = source + ".mdb";
if (File.Exists (sdebug))
Symlink (sdebug, tdebug);
2017-02-07 16:39:17 +03:00
string tpdb = Path.ChangeExtension (target, "pdb");
if (File.Exists (tpdb))
File.Delete (tpdb);
string spdb = Path.ChangeExtension (source, "pdb");
if (File.Exists (spdb))
Symlink (spdb, tpdb);
2016-04-21 15:58:45 +03:00
return true;
}
public static bool CanWeSymlinkTheApplication (Application app)
2016-04-21 15:58:45 +03:00
{
if (app.Platform != ApplePlatform.iOS)
return false;
// We can not symlink when building an extension.
if (app.IsExtension)
return false;
// We can not symlink if we have to link with user frameworks.
if (app.Frameworks.Count > 0 || app.UseMonoFramework.Value)
return false;
foreach (var target in app.Targets) {
foreach (var assembly in target.Assemblies)
if (assembly.Frameworks != null && assembly.Frameworks.Count > 0)
return false;
}
//We can only symlink when running in the simulation
if (!app.IsSimulatorBuild)
return false;
//mtouch was invoked with --nofastsim, eg symlinking was explicit disabled
if (app.NoFastSim)
2016-04-21 15:58:45 +03:00
return false;
//Can't symlink if we are running the linker since the assemblies content will change
if (app.LinkMode != LinkMode.None)
return false;
//Custom gcc flags requires us to build template.m
if (!string.IsNullOrEmpty (app.UserGccFlags))
return false;
// Setting environment variables is done in the generated main.m, so we can't symlink in this case.
if (app.EnvironmentVariables.Count > 0)
2016-04-21 15:58:45 +03:00
return false;
// If we are asked to run with concurrent sgen we also need to pass environment variables
if (app.EnableSGenConc)
return false;
if (app.UseInterpreter)
return false;
if (app.Registrar == RegistrarMode.Static)
2016-04-21 15:58:45 +03:00
return false;
// The default exception marshalling differs between release and debug mode, but we
// only have one simlauncher, so to use the simlauncher we'd have to chose either
// debug or release mode. Debug is more frequent, so make that the fast path.
if (!app.EnableDebug)
return false;
if (app.MarshalObjectiveCExceptions != MarshalObjectiveCExceptionMode.UnwindManagedCode)
return false; // UnwindManagedCode is the default for debug builds.
if (app.Embeddinator)
return false;
2016-04-21 15:58:45 +03:00
return true;
}
internal static PDictionary FromPList (string name)
2016-04-21 15:58:45 +03:00
{
if (!File.Exists (name))
throw new MonoTouchException (24, true, "Could not find required file '{0}'.", name);
return PDictionary.FromFile (name);
2016-04-21 15:58:45 +03:00
}
internal static bool TryParseBool (string value, out bool result)
{
if (string.IsNullOrEmpty (value)) {
result = true;
return true;
}
switch (value.ToLowerInvariant ()) {
case "1":
case "yes":
case "true":
case "enable":
result = true;
return true;
case "0":
case "no":
case "false":
case "disable":
result = false;
return true;
default:
return bool.TryParse (value, out result);
}
}
internal static bool ParseBool (string value, string name, bool show_error = true)
{
bool result;
if (!TryParseBool (value, out result))
throw ErrorHelper.CreateError (26, "Could not parse the command line argument '-{0}:{1}'", name, value);
return result;
}
public static int Main (string [] args)
{
try {
Console.OutputEncoding = new UTF8Encoding (false, false);
SetCurrentLanguage ();
2016-04-21 15:58:45 +03:00
return Main2 (args);
}
catch (Exception e) {
ErrorHelper.Show (e);
}
finally {
Watch ("Total time", 0);
}
return 0;
}
static Application ParseArguments (string [] args, out Action a)
2016-04-21 15:58:45 +03:00
{
var action = Action.None;
var app = new Application (args);
2016-04-21 15:58:45 +03:00
if (extra_args != null) {
var l = new List<string> (args);
foreach (var s in extra_args.Split (new char [] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
l.Add (s);
args = l.ToArray ();
}
string tls_provider = null;
string http_message_handler = null;
Action<Action> SetAction = (Action value) =>
{
switch (action) {
case Action.None:
action = value;
break;
case Action.KillApp:
if (value == Action.LaunchDevice) {
action = Action.KillAndLaunch;
break;
}
goto default;
case Action.LaunchDevice:
if (value == Action.KillApp) {
action = Action.KillAndLaunch;
break;
}
goto default;
default:
throw new MonoTouchException (19, true, "Only one --[log|install|kill|launch]dev or --[launch|debug|list]sim option can be used.");
}
};
2016-04-21 15:58:45 +03:00
var os = new OptionSet () {
{ "h|?|help", "Displays the help", v => SetAction (Action.Help) },
{ "version", "Output version information and exit.", v => SetAction (Action.Version) },
{ "f|force", "Forces the recompilation of code, regardless of timestamps", v=>force = true },
{ "dot:", "Generate a dot file to visualize the build tree.", v => dot = true },
{ "cache=", "Specify the directory where object files will be cached", v => app.Cache.Location = v },
2016-04-21 15:58:45 +03:00
{ "aot=", "Arguments to the static compiler",
v => app.AotArguments = v + (v.EndsWith (",", StringComparison.Ordinal) ? String.Empty : ",") + app.AotArguments
2016-04-21 15:58:45 +03:00
},
{ "aot-options=", "Non AOT arguments to the static compiler",
v => {
if (v.Contains ("--profile") || v.Contains ("--attach"))
throw new Exception ("Unsupported flag to -aot-options");
app.AotOtherArguments = v + " " + app.AotOtherArguments;
2016-04-21 15:58:45 +03:00
}
},
{ "gsharedvt:", "Generic sharing for value-types - always enabled [Deprecated]", v => {} },
{ "v", "Verbose", v => verbose++ },
{ "q", "Quiet", v => verbose-- },
{ "time", v => WatchLevel++ },
2016-04-21 15:58:45 +03:00
{ "executable=", "Specifies the native executable name to output", v => app.ExecutableName = v },
{ "nofastsim", "Do not run the simulator fast-path build", v => app.NoFastSim = true },
[mtouch] Implement support for sharing code between app extensions and container apps. Implement support for sharing both code and resources between app extensions and their container app: * AOT-compiled code. Each shared assembly is only AOT-compiled once, and if the assembly is built to a framework or dynamic library, it will also only be included once in the final app (as a framework or dynamic library in the container app, referenced directly by the app extension). If the assemblies are built to static objects there won't be any size improvements in the app, but the build will be much faster, because the assemblies will only be AOT- compiled once. * Any resources related to managed assemblies (debug files, config files, satellite assemblies) will be put in the container app only. Since these improvements are significant, code sharing will be enabled by default. Test results ============ For an extreme test project with 7 extensions (embedded-frameworks)[1]: with code sharing cycle 9 difference build time 1m 47s 3m 33s -1m 46s = ~50% faster app size 26 MB 131 MB -105 MB = ~80% smaller For a more normal test project (MyTabbedApplication)[2] - this is a simple application with 1 extension: with code sharing cycle 9 difference build time 0m 44s 0m 48s -4s = ~ 8% faster app size 23 MB 37 MB -15 MB = ~40% smaller Another tvOS app with one extension also show similar gains (MyTVApp)[3]: with code sharing cycle 9 difference build time 0m 22s 0m 48s -26s = ~54% faster app size 22 MB 62 MB -40 MB = ~65% smaller [1]: https://github.com/rolfbjarne/embedded-frameworks [2]: https://github.com/xamarin/xamarin-macios/tree/cycle9/msbuild/tests/MyTabbedApplication [3]: https://github.com/xamarin/xamarin-macios/tree/cycle9/msbuild/tests/MyTVApp
2017-01-24 13:10:20 +03:00
{ "nodevcodeshare", "Do not share native code between extensions and main app.", v => app.NoDevCodeShare = true },
2016-04-21 15:58:45 +03:00
{ "nolink", "Do not link the assemblies", v => app.LinkMode = LinkMode.None },
{ "nodebugtrack", "Disable debug tracking of object resurrection bugs [DEPRECATED - already disabled by default]", v => app.DebugTrack = false, true },
{ "debugtrack:", "Enable debug tracking of object resurrection bugs", v => { app.DebugTrack = ParseBool (v, "--debugtrack"); } },
2016-04-21 15:58:45 +03:00
{ "linkerdumpdependencies", "Dump linker dependencies for linker-analyzer tool", v => app.LinkerDumpDependencies = true },
{ "linksdkonly", "Link only the SDK assemblies", v => app.LinkMode = LinkMode.SDKOnly },
{ "linkskip=", "Skip linking of the specified assembly", v => app.LinkSkipped.Add (v) },
{ "nolinkaway", "Disable the linker step which replace code with a 'Linked Away' exception.", v => app.LinkAway = false },
{ "xml=", "Provide an extra XML definition file to the linker", v => app.Definitions.Add (v) },
{ "i18n=", "List of i18n assemblies to copy to the output directory, separated by commas (none,all,cjk,mideast,other,rare,west)", v => app.I18n = LinkerOptions.ParseI18nAssemblies (v) },
{ "symbollist=", "Asks mtouch to create a file with all the symbols that should not be stripped instead of stripping.", v => app.SymbolList = v, true /* hidden, this is only used between mtouch and the MSBuild tasks, not for public consumption */ },
{ "nostrip", "Do not strip the AOT compiled assemblies", v => app.ManagedStrip = false },
{ "nosymbolstrip:", "A comma-separated list of symbols to not strip from the app (if the list is empty, stripping is disabled completely)", v =>
{
if (string.IsNullOrEmpty (v)) {
app.NativeStrip = false;
} else {
app.NoSymbolStrip.AddRange (v.Split (','));
}
} },
{ "dsym:", "Turn on (default for device) or off (default for simulator) .dSYM symbols.", v => app.BuildDSym = ParseBool (v, "dsym") },
{ "dlsym:", "Use dlsym to resolve pinvokes in AOT compiled assemblies", v => app.ParseDlsymOptions (v) },
{ "r|ref=", "Add an assembly to the resolver", v => app.References.Add (v) },
{ "gcc_flags=", "Set flags to be passed along to gcc at link time", v => app.UserGccFlags = v },
{ "framework=", "Link with the specified framework. This can either be a system framework (like 'UIKit'), or it can be a path to a custom framework ('/path/to/My.framework'). In the latter case the entire 'My.framework' directory is copied into the app as well.", (v) => app.Frameworks.Add (v) },
{ "weak-framework=", "Weak link with the specified framework. This can either be a system framework (like 'UIKit'), or it can be a path to a custom framework ('/path/to/My.framework'). In the latter case the entire 'My.framework' directory is copied into the app as well.", (v) => app.Frameworks.Add (v) },
// What we do
{ "sim=", "Compile for the Simulator, specify the output directory for code", v =>
{
SetAction (Action.Build);
app.AppDirectory = v;
2016-04-21 15:58:45 +03:00
app.BuildTarget = BuildTarget.Simulator;
}
},
{ "dev=", "Compile for the Device, specify the output directory for the code", v => {
SetAction (Action.Build);
app.AppDirectory = v;
2016-04-21 15:58:45 +03:00
app.BuildTarget = BuildTarget.Device;
}
},
// Configures the tooling used to build code.
{ "sdk=", "Specifies the name of the SDK to compile against (version, for example \"3.2\")",
v => {
try {
app.SdkVersion = StringUtils.ParseVersion (v);
2016-04-21 15:58:45 +03:00
} catch (Exception ex) {
ErrorHelper.Error (26, ex, $"Could not parse the command line argument '-sdk:{v}': {ex.Message}");
2016-04-21 15:58:45 +03:00
}
}
},
{ "targetver=", "Specifies the name of the minimum deployment target (version, for example \"" + Xamarin.SdkVersions.iOS.ToString () + "\")",
v => {
try {
app.DeploymentTarget = StringUtils.ParseVersion (v);
2016-04-21 15:58:45 +03:00
} catch (Exception ex) {
throw new MonoTouchException (26, true, ex, $"Could not parse the command line argument '-targetver:{v}': {ex.Message}");
2016-04-21 15:58:45 +03:00
}
}
},
{ "device=", "Specifies the device type to launch the simulator as [DEPRECATED]", v => { }, true },
// Launch/debug options
{ "timeout:", "Specify a timeout (in seconds) for the commands that doesn't have fixed/known duration. Default: 0.5 [DEPRECATED]", v => { }, true },
{ "listapps", "List the apps installed on the device to stderr. [DEPRECATED]", v => { SetAction (Action.ListApps); }, true },
{ "listsim=", "List the available simulators. The output is xml, and written to the specified file. [DEPRECATED]", v => { SetAction (Action.ListSimulators); }, true},
{ "listdev:", "List the currently connected devices and their UDIDs [DEPRECATED]", v => { SetAction (Action.ListDevices); }, true },
{ "installdev=", "Install the specified MonoTouch.app in the device [DEPRECATED]", v => { SetAction (Action.InstallDevice); }, true },
{ "launchdev=", "Launch an app that is installed on device, specified by bundle identifier [DEPRECATED]", v => { SetAction (Action.LaunchDevice); }, true },
{ "debugdev=", "Launch app app that is installed on device, specified by bundle identifer, and wait for a native debugger to attach. [DEPRECATED]", v => { SetAction (Action.DebugDevice); }, true },
{ "provide-assets=", "If the app contains on-demand resources, then mtouch should provide those from this .app directory. [DEPRECATED]", v => { }, true },
{ "wait-for-exit:", "If mtouch should wait until the launched app exits. [DEPRECATED]", v => { }, true },
2016-04-21 15:58:45 +03:00
{ "wait-for-unlock:", "If mtouch should wait until the device is unlocked when launching an app (or exit with an error code). [DEPRECATED]", v => { }, true },
{ "killdev=", "Kill an app that is running on device, specified by bundle identifier [DEPRECATED]", v => { SetAction (Action.KillApp); }, true },
{ "logdev", "Write the syslog from the device to the console [DEPRECATED]", v => { SetAction (Action.LogDev); }, true },
{ "list-crash-reports:", "Lists crash reports on the specified device [DEPRECATED]", v => { SetAction (Action.ListCrashReports); }, true },
{ "download-crash-report=", "Download a crash report from the specified device [DEPRECATED]", v => { SetAction (Action.DownloadCrashReport); }, true},
{ "download-crash-report-to=", "Specifies the file to save the downloaded crash report. [DEPRECATED]", v => { }, true },
{ "devname=", "Specify which device (when many are present) the [install|lauch|kill|log]dev command applies [DEPRECATED]", v => { }, true},
{ "isappinstalled=", "Check if the specified app id is installed. Returns 0 when installed, 1 if not. [DEPRECATED]", v => { SetAction (Action.IsAppInstalled); }, true },
{ "launchsim=", "Launch the specified MonoTouch.app in the simulator [DEPRECATED]", v => { SetAction (Action.LaunchSim); }, true },
{ "enable-native-debugging:", "Don't do anything that may interfere with native debugging (such as avoiding the iOS simulator launch timeout). [DEPRECATED]", v => { }, true },
{ "installsim=", "Install the specified MonoTouch.app in the simulator [DEPRECATED]", v => { SetAction (Action.InstallSim); }, true},
{ "launchsimwatch=", "Specify the watch app to launch [DEPRECATED]", v => { SetAction (Action.LaunchWatchApp); }, true },
{ "killsimwatch=", "Specify the watch app to kill [DEPRECATED]", v => { SetAction (Action.KillWatchApp); }, true },
{ "watchnotificationpayload=", "Specify the jSON notification payload file [DEPRECATED]", v => { }, true },
{ "watchlaunchmode=", "Specify the watch launch mode (Default|Glance|Notification) [DEPRECATED]", v => { }, true },
{ "enable-background-fetch", "Enable mode to send background fetch requests [Deprecated]", v => { }, true},
{ "launch-for-background-fetch", "Launch due to a background fetch [DEPRECATED]", v => { }, true},
{ "debugsim=", "Debug the specified MonoTouch.app in the simulator [DEPRECATED]", v => { SetAction (Action.DebugSim); }, true },
{ "argument=", "Launch the app with this command line argument. This must be specified multiple times for multiple arguments [DEPRECATED]", v => { }, true },
{ "setenv=", "Set the environment variable in the application on startup", v =>
{
int eq = v.IndexOf ('=');
if (eq <= 0)
throw new MonoTouchException (2, true, "Could not parse the environment variable '{0}'", v);
string name = v.Substring (0, eq);
string value = v.Substring (eq + 1);
app.EnvironmentVariables.Add (name, value);
2016-04-21 15:58:45 +03:00
}
},
{ "sgen:", "Enable the SGen garbage collector",
v => {
if (!ParseBool (v, "sgen"))
ErrorHelper.Warning (43, "The Boehm garbage collector is not supported. The SGen garbage collector has been selected instead.");
},
true // do not show the option anymore
},
{ "boehm:", "Enable the Boehm garbage collector",
v => {
if (ParseBool (v, "boehm"))
ErrorHelper.Warning (43, "The Boehm garbage collector is not supported. The SGen garbage collector has been selected instead."); },
true // do not show the option anymore
},
{ "new-refcount:", "Enable new refcounting logic",
v => {
if (!ParseBool (v, "new-refcount"))
ErrorHelper.Warning (80, "Disabling the new refcount logic is deprecated.");
},
true // do not show the option anymore
},
{ "abi=", "Comma-separated list of ABIs to target. Currently supported: armv7, armv7+llvm, armv7+llvm+thumb2, armv7s, armv7s+llvm, armv7s+llvm+thumb2, arm64, arm64+llvm, i386, x86_64", v => app.ParseAbi (v) },
{ "override-abi=", "Override any previous abi. Only used for testing.", v => { app.ClearAbi (); app.ParseAbi (v); }, true }, // Temporary command line arg until XS has better support for 64bit architectures.
{ "cxx", "Enable C++ support", v => { app.EnableCxx = true; }},
{ "enable-repl:", "Enable REPL support (simulator and not linking only)", v => { app.EnableRepl = ParseBool (v, "enable-repl"); }, true /* this is a hidden option until we've actually used it and made sure it works as expected */ },
{ "pie:", "Enable (default) or disable PIE (Position Independent Executable).", v => { app.EnablePie = ParseBool (v, "pie"); }},
{ "compiler=", "Specify the Objective-C compiler to use (valid values are gcc, g++, clang, clang++ or the full path to a GCC-compatible compiler).", v => { app.Compiler = v; }},
{ "fastdev", "Build an app that supports fastdev (this app will only work when launched using Xamarin Studio)", v => { app.AddAssemblyBuildTarget ("@all=dynamiclibrary"); }},
{ "force-thread-check", "Keep UI thread checks inside (even release) builds [DEPRECATED, use --optimize=-remove-uithread-checks instead]", v => { app.Optimizations.RemoveUIThreadChecks = false; }, true},
{ "disable-thread-check", "Remove UI thread checks inside (even debug) builds [DEPRECATED, use --optimize=remove-uithread-checks instead]", v => { app.Optimizations.RemoveUIThreadChecks = true; }, true},
2016-04-21 15:58:45 +03:00
{ "debug:", "Generate debug code in Mono for the specified assembly (set to 'all' to generate debug code for all assemblies, the default is to generate debug code for user assemblies only)",
v => {
app.EnableDebug = true;
if (v != null){
if (v == "all"){
app.DebugAll = true;
2016-04-21 15:58:45 +03:00
return;
}
app.DebugAssemblies.Add (Path.GetFileName (v));
2016-04-21 15:58:45 +03:00
}
}
},
{ "package-mdb:", "Specify whether debug info files (*.mdb) should be packaged in the app. Default is 'true' for debug builds and 'false' for release builds.", v => app.PackageManagedDebugSymbols = ParseBool (v, "package-mdb"), true },
{ "package-debug-symbols:", "Specify whether debug info files (*.mdb / *.pdb) should be packaged in the app. Default is 'true' for debug builds and 'false' for release builds.", v => app.PackageManagedDebugSymbols = ParseBool (v, "package-debug-symbols") },
2016-04-21 15:58:45 +03:00
{ "msym:", "Specify whether managed symbolication files (*.msym) should be created. Default is 'false' for debug builds and 'true' for release builds.", v => app.EnableMSym = ParseBool (v, "msym") },
{ "extension", v => app.IsExtension = true },
{ "app-extension=", "The path of app extensions that are included in the app. This must be specified once for each app extension.", v => app.Extensions.Add (v), true /* MSBuild-internal for now */ },
{ "profiling:", "Enable profiling", v => app.EnableProfiling = ParseBool (v, "profiling") },
{ "registrar:", "Specify the registrar to use (dynamic, static or default (dynamic in the simulator, static on device))", v =>
{
var split = v.Split ('=');
var name = split [0];
var value = split.Length > 1 ? split [1] : string.Empty;
switch (name) {
case "static":
app.Registrar = RegistrarMode.Static;
break;
case "dynamic":
app.Registrar = RegistrarMode.Dynamic;
break;
case "default":
app.Registrar = RegistrarMode.Default;
break;
default:
throw new MonoTouchException (20, true, "The valid options for '{0}' are '{1}'.", "--registrar", "static, dynamic or default");
}
switch (value) {
case "trace":
app.RegistrarOptions = RegistrarOptions.Trace;
break;
case "default":
case "":
app.RegistrarOptions = RegistrarOptions.Default;
break;
default:
throw new MonoTouchException (20, true, "The valid options for '{0}' are '{1}'.", "--registrar", "static, dynamic or default");
}
}
},
{ "runregistrar:", "Runs the registrar on the input assembly and outputs a corresponding native library.",
v => {
SetAction (Action.RunRegistrar);
app.RegistrarOutputLibrary = v;
},
true /* this is an internal option */
},
{ "stderr=", "Redirect the standard error for the simulated application to the specified file [DEPRECATED]", v => { }, true },
{ "stdout=", "Redirect the standard output for the simulated application to the specified file [DEPRECATED]", v => { }, true },
{ "sdkroot=", "Specify the location of Apple SDKs, default to 'xcode-select' value.", v => sdk_root = v },
2016-04-21 15:58:45 +03:00
{ "no-xcode-version-check", "Ignores the Xcode version check.", v => { xcode_version_check = false; }, true /* This is a non-documented option. Please discuss any customers running into the xcode version check on the maciosdev@ list before giving this option out to customers. */ },
{ "mono:", "Comma-separated list of options for how the Mono runtime should be included. Possible values: 'static' (link statically), 'framework' (linked as a user framework), '[no-]package-framework' (if the Mono.framework should be copied to the app bundle or not. The default value is 'framework' for extensions, and main apps if the app targets iOS 8.0 or later and contains extensions, otherwise 'static'. The Mono.framework will be copied to the app bundle if mtouch detects it's needed, but this may be overridden if the default values for 'framework' vs 'static' is overwridden.", v =>
{
foreach (var opt in v.Split (new char [] { ',' })) {
switch (opt) {
2016-04-21 15:58:45 +03:00
case "static":
app.UseMonoFramework = false;
break;
case "framework":
app.UseMonoFramework = true;
break;
case "package-framework":
app.PackageMonoFramework = true;
break;
case "no-package-framework":
app.PackageMonoFramework = false;
break;
default:
throw new MonoTouchException (20, true, "The valid options for '{0}' are '{1}'.", "--mono", "static, framework or [no-]package-framework");
}
}
}
},
{"target-framework=", "Specify target framework to use. Currently supported: 'MonoTouch,v1.0', 'Xamarin.iOS,v1.0', 'Xamarin.WatchOS,v1.0' and 'Xamarin.TVOS,v1.0' (defaults to '" + TargetFramework.Default + "')", v => SetTargetFramework (v) },
{ "bitcode:", "Enable generation of bitcode (asmonly, full, marker)", v =>
{
switch (v) {
case "asmonly":
app.BitCodeMode = BitCodeMode.ASMOnly;
break;
case "full":
app.BitCodeMode = BitCodeMode.LLVMOnly;
break;
case "marker":
app.BitCodeMode = BitCodeMode.MarkerOnly;
break;
default:
throw new MonoTouchException (20, true, "The valid options for '{0}' are '{1}'.", "--bitcode", "asmonly, full or marker");
}
}
},
{ "llvm-asm", "Make the LLVM compiler emit assembly files instead of object files. [Deprecated]", v => { app.LLVMAsmWriter = true; }, true},
{ "llvm-opt=", "Specify how to optimize the LLVM output (only applicable when using LLVM to compile to bitcode), per assembly: 'assembly'='optimizations', where 'assembly is the filename (including extension) of the assembly (the special value 'all' can be passed to set the same optimization for all assemblies), and 'optimizations' are optimization arguments. Valid optimization flags are Clang optimization flags.", v =>
{
var equals = v.IndexOf ('=');
if (equals == -1)
throw ErrorHelper.CreateError (26, "Could not parse the command line argument '{0}': {1}", "--llvm-opt=" + v, "Both assembly and optimization must be specified (assembly=optimization)");
var asm = v.Substring (0, equals);
var opt = v.Substring (equals + 1); // An empty string is valid here, meaning 'no optimizations'
app.LLVMOptimizations [asm] = opt;
}
},
Bump to mono:2018-06 (#4277) * Bump to mono:2018-06 * Bump mono * Updates compression to work with the public span * Bump mono * Fixes pointer check logic in Deflater * Bump mono * Fixes pointer check logic in Deflater * Bump mono * Bump Mono * [runtime] always use `mono_jit_set_aot_mode` (#4491) `mono_jit_set_aot_only` is deprecated and accidentally broke with https://github.com/mono/mono/pull/7887 This should fix device tests with `mono-2018-06` * Testing with Zoltan's patch * Include libmono-system-native on Xamarin.Mac * Bump Mono Commit list for mono/mono: * mono/mono@7bcda192a06 Bump llvm to release_60/fc854b8ec5873d294b80afa3e6cf6a88c5c48886. (#9786). (#9804) * mono/mono@23e95ec7ad7 Apply F# portable pdb debug fix for pinvokes & bump (#9797) * mono/mono@295f6d32afd [2018-06] [MacOS] On Mac, use the copyfile API to copy files (#9696) Diff: https://github.com/mono/mono/compare/7d5f4b61366008d47665bb473205f4ae1f716d1f...7bcda192a06267562af565d404c06d159f475c03 * Revert 4bacab3d5c7fa86a0e6437f64bb9f08ea3d0741b, it doesn't fix the ios aot problems. * Bump mono * [tests] Adjust the MT0137 test for mcs change in behavior. Starting with mono 5.16 mcs will now add assembly references when the assembly is only used in attributes (this was already the case for csc in both 5.14 and 5.16, so it seems to be a compatibility change). Adjust the MT0137 test accordingly. * [msbuild] Fix parsing of json parser errors to handle trailing periods in the error message. Fixes this test: 1) Test Failure : Xamarin.iOS.Tasks.Bug60536.TestACToolTaskCatchesJsonException ColumnNumber Expected: 2 But was: 0 * Bump mono * [builds] Install the old llvm binaries into the LLVM36 directory and make the 32 bit builds use that. * Bump mono * Bump mono * [jenkins] Don't give VSTS a fake branch. (#4667) Something in VSTS changed, and now fake branch names don't work anymore. So instead use real branch names (and for pull requests I've created a 'pull-request' branch we can use). * Assembly.LoadFile accepts only absolute path * [linker] Add new Facade (System.Threading.Tasks.Extensions). Fixes these MTouch test failures: 1. Xamarin.Linker.SdkTest.iOS_Unified : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > 2. Xamarin.Linker.SdkTest.tvOS : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > 3. Xamarin.Linker.SdkTest.watchOS : Facades Expected: But was: < "System.Threading.Tasks.Extensions" > * [mono-sdks] Necessary changes to unify the LLVM provisioning for both iOS and Android. (#4732) * Bump Mono * [mtouch] add mixed-mode support (#4751) * [mtouch] add --interp-mixed option When enabling this option, mtouch will AOT compile `mscorlib.dll`. At runtime that means every method that wasn't AOT'd will be executed by the runtime interpreter. * [mtouch] Add support to --interpreter to list the assemblies to (not) interpret. * [msbuild] Simplify interpreter code to use a single variable. * Fix whitespace. * [mtouch] Move mtouch-specific code to mtouch-specific file. * [msbuild] An empty string is a valid value for 'Interpreter', so make it a non-required property. * [mtouch] Add sanity check for aot-compiling interpreted assemblies. * Bump Mono * [linker] Updates SDKs facades list * Bump mono * [msbuild] Adds facades which might override default nuget version to framework list The collision resolver task reads them from here https://github.com/dotnet/sdk/blob/master/src/Tasks/Common/ConflictResolution/FrameworkListReader.cs * Bump to a VSfM version that can build XM Classic projects.
2018-10-10 18:02:28 +03:00
{ "interpreter:", "Enable the *experimental* interpreter. Optionally takes a comma-separated list of assemblies to interpret (if prefixed with a minus sign, the assembly will be AOT-compiled instead). 'all' can be used to specify all assemblies. This argument can be specified multiple times.", v =>
{
app.UseInterpreter = true;
if (!string.IsNullOrEmpty (v)) {
app.InterpretedAssemblies.AddRange (v.Split (new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries));
}
}
},
2016-04-21 15:58:45 +03:00
{ "http-message-handler=", "Specify the default HTTP message handler for HttpClient", v => { http_message_handler = v; }},
{ "output-format=", "Specify the output format for some commands. Possible values: Default, XML", v =>
{
}
},
{ "tls-provider=", "Specify the default TLS provider", v => { tls_provider = v; }},
{ "xamarin-framework-directory=", "The framework directory", v => { mtouch_dir = v; }, true },
{ "assembly-build-target=", "Specifies how to compile assemblies to native code. Possible values: 'staticobject' (default), 'dynamiclibrary' and 'framework'. " +
"Each option also takes an assembly and a potential name (defaults to the name of the assembly). Example: --assembly-build-target=mscorlib.dll=framework[=name]." +
"There also two special names: '@all' and '@sdk': --assembly-build-target=@all|@sdk=framework[=name].", v =>
{
app.AddAssemblyBuildTarget (v);
}
},
2016-04-21 15:58:45 +03:00
};
AddSharedOptions (app, os);
2016-04-21 15:58:45 +03:00
try {
app.RootAssemblies.AddRange (os.Parse (args));
2016-04-21 15:58:45 +03:00
}
catch (MonoTouchException) {
throw;
}
catch (Exception e) {
throw new MonoTouchException (10, true, e, "Could not parse the command line arguments: {0}", e);
}
a = action;
2016-04-21 15:58:45 +03:00
if (action == Action.Help) {
ShowHelp (os);
return null;
2016-04-21 15:58:45 +03:00
} else if (action == Action.Version) {
Console.Write ("mtouch {0}.{1}", Constants.Version, Constants.Revision);
Console.WriteLine ();
return null;
2016-04-21 15:58:45 +03:00
}
app.SetDefaultFramework ();
app.SetDefaultAbi ();
app.RuntimeOptions = RuntimeOptions.Create (app, http_message_handler, tls_provider);
2016-04-21 15:58:45 +03:00
if (action == Action.Build || action == Action.RunRegistrar) {
if (app.RootAssemblies.Count == 0)
throw new MonoTouchException (17, true, "You should provide a root assembly.");
}
return app;
}
static int Main2 (string[] args)
{
Action action;
var app = ParseArguments (args, out action);
if (app == null)
return 0;
LogArguments (args);
ErrorHelper.Verbosity = verbose;
ValidateXcode (action);
2016-04-21 15:58:45 +03:00
switch (action) {
/* Device actions */
case Action.LogDev:
case Action.InstallDevice:
case Action.ListDevices:
case Action.IsAppInstalled:
case Action.ListCrashReports:
case Action.DownloadCrashReport:
case Action.KillApp:
case Action.KillAndLaunch:
case Action.LaunchDevice:
case Action.DebugDevice:
case Action.ListApps:
/* Simulator actions */
case Action.DebugSim:
case Action.LaunchSim:
case Action.InstallSim:
case Action.LaunchWatchApp:
case Action.KillWatchApp:
case Action.ListSimulators:
return CallMlaunch ();
}
if (app.SdkVersion == null)
throw new MonoTouchException (25, true, "No SDK version was provided. Please add --sdk=X.Y to specify which {0} SDK should be used to build your application.", app.PlatformName);
var framework_dir = GetFrameworkDirectory (app);
Driver.Log ("Xamarin.iOS {0}.{1} using framework: {2}", Constants.Version, Constants.Revision, framework_dir);
2016-04-21 15:58:45 +03:00
if (action == Action.None)
throw new MonoTouchException (52, true, "No command specified.");
if (app.SdkVersion < new Version (6, 0) && app.IsArchEnabled (Abi.ARMv7s))
throw new MonoTouchException (14, true, "The iOS {0} SDK does not support building applications targeting {1}", app.SdkVersion, "ARMv7s");
2016-04-21 15:58:45 +03:00
if (app.SdkVersion < new Version (7, 0) && app.IsArchEnabled (Abi.ARM64))
throw new MonoTouchException (14, true, "The iOS {0} SDK does not support building applications targeting {1}", app.SdkVersion, "ARM64");
2016-04-21 15:58:45 +03:00
if (app.SdkVersion < new Version (7, 0) && app.IsArchEnabled (Abi.x86_64))
throw new MonoTouchException (14, true, "The iOS {0} SDK does not support building applications targeting {1}", app.SdkVersion, "x86_64");
2016-04-21 15:58:45 +03:00
if (!Directory.Exists (framework_dir)) {
Console.WriteLine ("Framework does not exist {0}", framework_dir);
Console.WriteLine (" Platform = {0}", GetPlatform (app));
Console.WriteLine (" SDK = {0}", app.SdkVersion);
2016-04-21 15:58:45 +03:00
Console.WriteLine (" Deployment Version: {0}", app.DeploymentTarget);
}
if (!Directory.Exists (GetPlatformDirectory (app)))
throw new MonoTouchException (6, true, "There is no devel platform at {0}, use --platform=PLAT to specify the SDK", GetPlatformDirectory (app));
2016-04-21 15:58:45 +03:00
if (!Directory.Exists (app.AppDirectory))
Directory.CreateDirectory (app.AppDirectory);
2016-04-21 15:58:45 +03:00
if (app.EnableRepl && app.BuildTarget != BuildTarget.Simulator)
throw new MonoTouchException (29, true, "REPL (--enable-repl) is only supported in the simulator (--sim)");
if (app.EnableRepl && app.LinkMode != LinkMode.None)
throw new MonoTouchException (82, true, "REPL (--enable-repl) is only supported when linking is not used (--nolink).");
if (cross_prefix == null)
cross_prefix = MonoTouchDirectory;
Watch ("Setup", 1);
if (action == Action.RunRegistrar) {
app.RunRegistrar ();
} else if (action == Action.Build) {
if (app.IsExtension && !app.IsWatchExtension) {
var sb = new StringBuilder ();
foreach (var arg in args)
sb.AppendLine (arg);
File.WriteAllText (Path.Combine (Path.GetDirectoryName (app.AppDirectory), "build-arguments.txt"), sb.ToString ());
} else {
foreach (var appex in app.Extensions) {
var f_path = Path.Combine (appex, "..", "build-arguments.txt");
if (!File.Exists (f_path))
continue;
Action app_action;
var ext = ParseArguments (File.ReadAllLines (f_path), out app_action);
ext.ContainerApp = app;
app.AppExtensions.Add (ext);
if (app_action != Action.Build)
throw ErrorHelper.CreateError (99, "Internal error: Extension build action is '{0}' when it should be 'Build'. Please file a bug report with a test case (https://github.com/xamarin/xamarin-macios/issues/new).", app_action);
}
[mtouch] Implement support for sharing code between app extensions and container apps. Implement support for sharing both code and resources between app extensions and their container app: * AOT-compiled code. Each shared assembly is only AOT-compiled once, and if the assembly is built to a framework or dynamic library, it will also only be included once in the final app (as a framework or dynamic library in the container app, referenced directly by the app extension). If the assemblies are built to static objects there won't be any size improvements in the app, but the build will be much faster, because the assemblies will only be AOT- compiled once. * Any resources related to managed assemblies (debug files, config files, satellite assemblies) will be put in the container app only. Since these improvements are significant, code sharing will be enabled by default. Test results ============ For an extreme test project with 7 extensions (embedded-frameworks)[1]: with code sharing cycle 9 difference build time 1m 47s 3m 33s -1m 46s = ~50% faster app size 26 MB 131 MB -105 MB = ~80% smaller For a more normal test project (MyTabbedApplication)[2] - this is a simple application with 1 extension: with code sharing cycle 9 difference build time 0m 44s 0m 48s -4s = ~ 8% faster app size 23 MB 37 MB -15 MB = ~40% smaller Another tvOS app with one extension also show similar gains (MyTVApp)[3]: with code sharing cycle 9 difference build time 0m 22s 0m 48s -26s = ~54% faster app size 22 MB 62 MB -40 MB = ~65% smaller [1]: https://github.com/rolfbjarne/embedded-frameworks [2]: https://github.com/xamarin/xamarin-macios/tree/cycle9/msbuild/tests/MyTabbedApplication [3]: https://github.com/xamarin/xamarin-macios/tree/cycle9/msbuild/tests/MyTVApp
2017-01-24 13:10:20 +03:00
app.BuildAll ();
}
} else {
throw ErrorHelper.CreateError (99, "Internal error: Invalid action: {0}. Please file a bug report with a test case (https://github.com/xamarin/xamarin-macios/issues/new).", action);
2016-04-21 15:58:45 +03:00
}
return 0;
}
static void RedirectStream (StreamReader @in, StreamWriter @out)
{
new Thread (() =>
{
string line;
while ((line = @in.ReadLine ()) != null) {
@out.WriteLine (line);
@out.Flush ();
}
})
{ IsBackground = true }.Start ();
}
static string MlaunchPath {
get {
// check next to mtouch first
var path = Path.Combine (MonoTouchDirectory, "bin", "mlaunch");
2016-04-21 15:58:45 +03:00
if (File.Exists (path))
return path;
// check an environment variable
path = Environment.GetEnvironmentVariable ("MLAUNCH_PATH");
if (File.Exists (path))
return path;
throw ErrorHelper.CreateError (93, "Could not find 'mlaunch'.");
2016-04-21 15:58:45 +03:00
}
}
static int CallMlaunch ()
{
Log (1, "Forwarding to mlaunch");
using (var p = new Process ()) {
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = MlaunchPath;
var sb = new StringBuilder ();
foreach (var str in Environment.GetCommandLineArgs ().Skip (1)) {
if (sb.Length > 0)
sb.Append (' ');
sb.Append (StringUtils.Quote (str));
2016-04-21 15:58:45 +03:00
}
p.StartInfo.Arguments = sb.ToString ();
p.Start ();
RedirectStream (new StreamReader (Console.OpenStandardInput ()), p.StandardInput);
RedirectStream (p.StandardOutput, new StreamWriter (Console.OpenStandardOutput ()));
RedirectStream (p.StandardError, new StreamWriter (Console.OpenStandardError ()));
p.WaitForExit ();
2016-04-21 15:58:45 +03:00
return p.ExitCode;
}
}
static string FindGcc (Application app, bool gpp)
2016-04-21 15:58:45 +03:00
{
var usr_bin = Path.Combine (GetPlatformDirectory (app), GetPlatform (app) + ".platform", "Developer", "usr", "bin");
2016-04-21 15:58:45 +03:00
var gcc = (gpp ? "g++" : "gcc");
var compiler_path = Path.Combine (usr_bin, gcc + "-4.2");
if (!File.Exists (compiler_path)) {
// latest iOS5 beta (6+) do not ship with a gcc-4.2 symlink - see bug #346
compiler_path = Path.Combine (usr_bin, gcc);
}
return compiler_path;
}
public static void CalculateCompilerPath (Application app)
2016-04-21 15:58:45 +03:00
{
var fallback_to_clang = false;
var original_compiler = string.Empty;
//
// The default is gcc, but if we can't find gcc,
// we try again with clang.
//
if (string.IsNullOrEmpty (app.Compiler)) {
2016-04-21 15:58:45 +03:00
// by default we use `gcc` before iOS7 SDK, falling back to `clang`. Otherwise we go directly to `clang`
// so we don't get bite by the fact that Xcode5 has a gcc compiler (which calls `clang`, even if not 100%
// compitable wrt options) for the simulator but not for devices!
// ref: https://bugzilla.xamarin.com/show_bug.cgi?id=13838
if (app.Platform == ApplePlatform.iOS) {
fallback_to_clang = app.SdkVersion < new Version (7, 0);
2016-04-21 15:58:45 +03:00
} else {
fallback_to_clang = false;
}
if (fallback_to_clang)
app.Compiler = app.EnableCxx ? "g++" : "gcc";
2016-04-21 15:58:45 +03:00
else
app.Compiler = app.EnableCxx ? "clang++" : "clang";
2016-04-21 15:58:45 +03:00
}
tryagain:
switch (app.Compiler) {
2016-04-21 15:58:45 +03:00
case "clang++":
app.CompilerPath = Path.Combine (DeveloperDirectory, "Toolchains", "XcodeDefault.xctoolchain", "usr", "bin", "clang++");
2016-04-21 15:58:45 +03:00
break;
case "clang":
app.CompilerPath = Path.Combine (DeveloperDirectory, "Toolchains", "XcodeDefault.xctoolchain", "usr", "bin", "clang");
2016-04-21 15:58:45 +03:00
break;
case "gcc":
app.CompilerPath = FindGcc (app, false);
2016-04-21 15:58:45 +03:00
break;
case "g++":
app.CompilerPath = FindGcc (app, true);
2016-04-21 15:58:45 +03:00
break;
default: // This is the full path to a compiler.
app.CompilerPath = app.Compiler;
2016-04-21 15:58:45 +03:00
break;
}
if (!File.Exists (app.CompilerPath)) {
2016-04-21 15:58:45 +03:00
if (fallback_to_clang) {
// Couldn't find gcc, try to find clang.
original_compiler = app.Compiler;
app.Compiler = app.EnableCxx ? "clang++" : "clang";
2016-04-21 15:58:45 +03:00
fallback_to_clang = false;
goto tryagain;
}
if (string.IsNullOrEmpty (original_compiler)) {
throw new MonoTouchException (5101, true, "Missing '{0}' compiler. Please install Xcode 'Command-Line Tools' component", app.Compiler);
2016-04-21 15:58:45 +03:00
} else {
throw new MonoTouchException (5103, true, "Could not find neither the '{0}' nor the '{1}' compiler. Please install Xcode 'Command-Line Tools' component", app.Compiler, original_compiler);
2016-04-21 15:58:45 +03:00
}
}
}
// workaround issues like:
// * Xcode 4.x versus 4.3 (location of /Developer); and
// * the (optional) installation of "Command-Line Tools" by Xcode
public static void RunStrip (string options)
{
// either /Developer (Xcode 4.2 and earlier), /Applications/Xcode.app/Contents/Developer (Xcode 4.3) or user override
string strip = FindTool ("strip");
if (strip == null)
throw new MonoTouchException (5301, "Missing 'strip' tool. Please install Xcode 'Command-Line Tools' component");
if (RunCommand (strip, options) != 0)
throw new MonoTouchException (5304, true, "Failed to strip the final binary. Please review the build log.");
}
static string FindTool (string tool)
{
// either /Developer (Xcode 4.2 and earlier), /Applications/Xcode.app/Contents/Developer (Xcode 4.3) or user override
var path = Path.Combine (DeveloperDirectory, "usr", "bin", tool);
if (File.Exists (path))
return path;
// Xcode "Command-Line Tools" install a copy in /usr/bin (and it can be there afterward)
path = Path.Combine ("/usr", "bin", tool);
if (File.Exists (path))
return path;
// Xcode 4.3 (without command-line tools) also has a copy of 'strip'
path = Path.Combine (DeveloperDirectory, "Toolchains", "XcodeDefault.xctoolchain", "usr", "bin", tool);
if (File.Exists (path))
return path;
return null;
}
public static void CreateDsym (string output_dir, string appname, string dsym_dir)
{
string quoted_app_path = StringUtils.Quote (Path.Combine (output_dir, appname));
string quoted_dsym_dir = StringUtils.Quote (dsym_dir);
2016-04-21 15:58:45 +03:00
RunDsymUtil (string.Format ("{0} -t 4 -z -o {1}", quoted_app_path, quoted_dsym_dir));
RunCommand ("/usr/bin/mdimport", quoted_dsym_dir);
}
public static void RunLipo (string options)
{
string lipo = FindTool ("lipo");
if (lipo == null)
throw new MonoTouchException (5305, true, "Missing 'lipo' tool. Please install Xcode 'Command-Line Tools' component");
if (RunCommand (lipo, options) != 0)
throw new MonoTouchException (5306, true, "Failed to create the a fat library. Please review the build log.");
}
static void RunDsymUtil (string options)
{
// either /Developer (Xcode 4.2 and earlier), /Applications/Xcode.app/Contents/Developer (Xcode 4.3) or user override
string dsymutil = FindTool ("dsymutil");
if (dsymutil == null) {
ErrorHelper.Warning (5302, "Missing 'dsymutil' tool. Please install Xcode 'Command-Line Tools' component");
return;
}
if (RunCommand (dsymutil, options) != 0)
throw new MonoTouchException (5303, true, "Failed to generate the debug symbols (dSYM directory). Please review the build log.");
}
static string GetFrameworkDir (string platform, Version iphone_sdk)
{
return Path.Combine (PlatformsDirectory, platform + ".platform", "Developer", "SDKs", platform + iphone_sdk.ToString () + ".sdk");
2016-04-21 15:58:45 +03:00
}
static bool IsBoundAssembly (Assembly s)
{
if (s.IsFrameworkAssembly)
return false;
AssemblyDefinition ad = s.AssemblyDefinition;
foreach (ModuleDefinition md in ad.Modules)
foreach (TypeDefinition td in md.Types)
if (td.IsNSObject (s.Target.LinkContext))
2016-04-21 15:58:45 +03:00
return true;
return false;
}
struct timespec {
public IntPtr tv_sec;
public IntPtr tv_nsec;
}
struct stat { /* when _DARWIN_FEATURE_64_BIT_INODE is defined */
public uint st_dev;
public ushort st_mode;
public ushort st_nlink;
public ulong st_ino;
public uint st_uid;
public uint st_gid;
public uint st_rdev;
public timespec st_atimespec;
public timespec st_mtimespec;
public timespec st_ctimespec;
public timespec st_birthtimespec;
public ulong st_size;
public ulong st_blocks;
public uint st_blksize;
public uint st_flags;
public uint st_gen;
public uint st_lspare;
public ulong st_qspare_1;
public ulong st_qspare_2;
}
[DllImport (Constants.libSystemLibrary, EntryPoint = "lstat$INODE64", SetLastError = true)]
static extern int lstat (string path, out stat buf);
public static bool IsSymlink (string file)
{
stat buf;
var rv = lstat (file, out buf);
if (rv != 0)
throw new Exception (string.Format ("Could not lstat '{0}': {1}", file, Marshal.GetLastWin32Error ()));
const int S_IFLNK = 40960;
return (buf.st_mode & S_IFLNK) == S_IFLNK;
}
public static Frameworks GetFrameworks (Application app)
{
switch (app.Platform) {
case ApplePlatform.iOS:
return Frameworks.GetiOSFrameworks (app);
case ApplePlatform.WatchOS:
return Frameworks.GetwatchOSFrameworks (app);
case ApplePlatform.TVOS:
return Frameworks.TVOSFrameworks;
default:
throw ErrorHelper.CreateError (71, "Unknown platform: {0}. This usually indicates a bug in Xamarin.iOS; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case.", app.Platform);
2016-04-21 15:58:45 +03:00
}
}
public static bool IsFrameworkAvailableInSimulator (Application app, string framework)
{
if (!GetFrameworks (app).TryGetValue (framework, out var fw))
return true; // Unknown framework, assume it's valid for the simulator
if (fw.VersionAvailableInSimulator == null)
return false;
if (fw.VersionAvailableInSimulator > app.SdkVersion)
return false;
return true;
}
2016-04-21 15:58:45 +03:00
}
}