Example #1
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder ();

            args.Add ("-r", "-y");
            args.AddQuoted (OutputFile.GetMetadata ("FullPath"));
            args.AddQuoted ("META-INF");

            long size = 0;
            int count = 0;

            foreach (var path in Directory.EnumerateFileSystemEntries (Source.ItemSpec)) {
                if (Directory.Exists (path)) {
                    foreach (var item in Directory.EnumerateFiles (path)) {
                        var info = new FileInfo (item);

                        size += info.Length;
                        count++;
                    }
                } else {
                    var info = new FileInfo (path);

                    size += info.Length;
                }

                args.AddQuoted (Path.GetFileName (path));
                count++;
            }

            SaveMetaFile (count, size);

            return args.ToString ();
        }
Example #2
0
        // Note: Xamarin.Mac and Xamarin.iOS should both override this method to do pass platform-specific verify rules
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder ();

            args.Add ("--verify");
            args.Add ("-vvvv");

            args.AddQuoted (Resource);

            return args.ToString ();
        }
Example #3
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder ();

            args.Add ("-o");
            args.AddQuoted (OutputLibrary);

            foreach (var item in Items)
                args.AddQuoted (item.ItemSpec);

            return args.ToString ();
        }
Example #4
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder ();

            args.Add ("--verify");
            args.Add ("-vvvv");
            args.Add ("-R='anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.1] exists and (certificate leaf[field.1.2.840.113635.100.6.1.2] exists or certificate leaf[field.1.2.840.113635.100.6.1.4] exists)'");

            args.AddQuoted (Resource);

            return args.ToString ();
        }
Example #5
0
        protected override string GenerateCommandLineCommands()
        {
            var prefixes = BundleResource.SplitResourcePrefixes (ResourcePrefix);
            var intermediate = Path.Combine (IntermediateOutputPath, ToolName);
            var logicalName = BundleResource.GetLogicalName (ProjectDir, prefixes, SourceFile);
            var path = Path.Combine (intermediate, logicalName);
            var args = new ProcessArgumentBuilder ();
            var dir = Path.GetDirectoryName (path);

            if (!Directory.Exists (dir))
                Directory.CreateDirectory (dir);

            OutputFile = new TaskItem (Path.ChangeExtension (path, ".air"));
            OutputFile.SetMetadata ("LogicalName", Path.ChangeExtension (logicalName, ".air"));

            args.Add ("-arch", "air64");
            args.Add ("-emit-llvm");
            args.Add ("-c");
            args.Add ("-gline-tables-only");
            args.Add ("-ffast-math");
            args.Add (string.Format ("-std={0}-metal1.0", OperatingSystem));

            args.Add ("-serialize-diagnostics");
            args.AddQuoted (Path.ChangeExtension (path, ".dia"));

            args.Add ("-o");
            args.AddQuoted (Path.ChangeExtension (path, ".air"));

            args.AddQuoted (SourceFile.ItemSpec);

            return args.ToString ();
        }
Example #6
0
 public GccOptions()
 {
     Arguments = new ProcessArgumentBuilder ();
     WeakFrameworks = new HashSet<string> ();
     Frameworks = new HashSet<string> ();
 }
Example #7
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder ();
            TargetArchitecture architectures;

            if (string.IsNullOrEmpty (Architectures) || !Enum.TryParse (Architectures, out architectures))
                architectures = TargetArchitecture.Default;

            if (architectures == TargetArchitecture.ARMv6) {
                Log.LogError ("Target architecture ARMv6 is no longer supported in Xamarin.iOS. Please select a supported architecture.");
                return null;
            }

            if (IsClassic && minimumOSVersion < IPhoneSdkVersion.V3_1 && architectures.HasFlag (TargetArchitecture.ARMv7)) {
                Log.LogWarning (null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, "Deployment Target changed from iOS {0} to iOS 3.1 (minimum requirement for ARMv7)", minimumOSVersion);
                minimumOSVersion = IPhoneSdkVersion.V3_1;
            }

            if (!string.IsNullOrEmpty (IntermediateOutputPath)) {
                Directory.CreateDirectory (IntermediateOutputPath);

                args.Add ("--cache");
                args.AddQuoted (Path.GetFullPath (IntermediateOutputPath));
            }

            if (IsClassic || IPhoneSdks.MonoTouch.Version < new IPhoneSdkVersion (8, 5, 0)) {
                args.Add ("--nomanifest");
                args.Add ("--nosign");
            }

            args.Add (SdkIsSimulator ? "--sim" : "--dev");
            args.AddQuoted (Path.GetFullPath (AppBundleDir));

            if (AppleSdkSettings.XcodeVersion.Major >= 5 && IPhoneSdks.MonoTouch.Version.CompareTo (new IPhoneSdkVersion (6, 3, 7)) < 0)
                args.Add ("--compiler", "clang");

            args.Add ("--executable");
            args.AddQuoted (ExecutableName);

            if (IsAppExtension)
                args.Add ("--extension");

            if (Debug) {
                if (FastDev && IPhoneSdks.MonoTouch.SupportsFastDev)
                    args.Add ("--fastdev");

                args.Add ("--debug");
            }

            if (Profiling)
                args.Add ("--profiling");

            if (LinkerDumpDependencies)
                args.Add ("--linkerdumpdependencies");

            switch (LinkMode.ToLowerInvariant ()) {
            case "sdkonly": args.Add ("--linksdkonly"); break;
            case "none":    args.Add ("--nolink"); break;
            }

            if (!string.IsNullOrEmpty (I18n)) {
                args.Add ("--i18n");
                args.AddQuotedFormat (I18n);
            }

            args.Add ("--sdkroot");
            args.AddQuoted (SdkRoot);

            args.Add ("--sdk");
            args.AddQuoted (SdkVersion);

            if (!minimumOSVersion.IsUseDefault) {
                args.Add ("--targetver");
                args.AddQuoted (minimumOSVersion.ToString ());
            }

            if (UseFloat32 /* We want to compile 32-bit floating point code to use 32-bit floating point operations */)
                args.Add ("--aot-options=-O=float32");

            if (IPhoneSdks.MonoTouch.SupportsGenericValueTypeSharing) {
                if (!EnableGenericValueTypeSharing)
                    args.Add ("--gsharedvt=false");
            }

            if (LinkDescriptions != null) {
                foreach (var desc in LinkDescriptions)
                    args.AddQuoted (string.Format ("--xml={0}", desc.ItemSpec));
            }

            if (EnableBitcode) {
                switch (Framework) {
                case PlatformFramework.WatchOS:
                    args.Add ("--bitcode=full");
                    break;
                case PlatformFramework.TVOS:
                    args.Add ("--bitcode=asmonly");
                    break;
                default:
                    throw new InvalidOperationException (string.Format ("Bitcode is currently not supported on {0}.", Framework));
                }
            }

            if (!string.IsNullOrEmpty (HttpClientHandler))
                args.Add (string.Format ("--http-message-handler={0}", HttpClientHandler));

            if (!string.IsNullOrEmpty (TLSProvider))
                args.Add (string.Format ("--tls-provider={0}", TLSProvider.ToLowerInvariant()));

            string thumb = UseThumb && UseLlvm ? "+thumb2" : "";
            string llvm = UseLlvm ? "+llvm" : "";
            string abi = "";

            if (SdkIsSimulator) {
                if (architectures.HasFlag (TargetArchitecture.i386))
                    abi += (abi.Length > 0 ? "," : "") + "i386";

                if (architectures.HasFlag (TargetArchitecture.x86_64))
                    abi += (abi.Length > 0 ? "," : "") + "x86_64";

                if (string.IsNullOrEmpty (abi)) {
                    architectures = TargetArchitecture.i386;
                    abi = "i386";
                }
            } else {
                if (architectures == TargetArchitecture.Default)
                    architectures = TargetArchitecture.ARMv7;

                if (architectures.HasFlag (TargetArchitecture.ARMv7))
                    abi += (abi.Length > 0 ? "," : "") + "armv7" + llvm + thumb;

                if (architectures.HasFlag (TargetArchitecture.ARMv7s))
                    abi += (abi.Length > 0 ? "," : "") + "armv7s" + llvm + thumb;

                if (architectures.HasFlag (TargetArchitecture.ARM64)) {
                    // Note: ARM64 does not have thumb.
                    abi += (abi.Length > 0 ? "," : "") + "arm64" + llvm;
                }

                if (architectures.HasFlag (TargetArchitecture.ARMv7k))
                    abi += (abi.Length > 0 ? "," : "") + "armv7k";

                if (string.IsNullOrEmpty (abi))
                    abi = "armv7" + llvm + thumb;
            }

            // Output the CompiledArchitectures
            CompiledArchitectures = architectures.ToString ();

            args.Add ("--abi=" + abi);

            // output symbols to preserve when stripping
            args.Add ("--symbollist");
            args.AddQuoted (Path.GetFullPath (SymbolsList));

            // don't have mtouch generate the dsyms...
            args.Add ("--dsym=no");

            var gcc = new GccOptions ();

            if (!string.IsNullOrEmpty (ExtraArgs)) {
                var extraArgs = ProcessArgumentBuilder.Parse (ExtraArgs);
                var target = MainAssembly.ItemSpec;
                string projectDir;

                if (ProjectDir.StartsWith ("~/", StringComparison.Ordinal)) {
                    // Note: Since the Visual Studio plugin doesn't know the user's home directory on the Mac build host,
                    // it simply uses paths relative to "~/". Expand these paths to their full path equivalents.
                    var home = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile);

                    projectDir = Path.Combine (home, ProjectDir.Substring (2));
                } else {
                    projectDir = ProjectDir;
                }

                var customTags = new Dictionary<string, string> (StringComparer.OrdinalIgnoreCase) {
                    { "projectdir",   projectDir },
                    // Apparently msbuild doesn't propagate the solution path, so we can't get it.
                    // { "solutiondir",  proj.ParentSolution != null ? proj.ParentSolution.BaseDirectory : proj.BaseDirectory },
                    { "appbundledir", AppBundleDir },
                    { "targetpath",   Path.Combine (Path.GetDirectoryName (target), Path.GetFileName (target)) },
                    { "targetdir",    Path.GetDirectoryName (target) },
                    { "targetname",   Path.GetFileName (target) },
                    { "targetext",    Path.GetExtension (target) },
                };

                for (int i = 0; i < extraArgs.Length; i++) {
                    if (extraArgs[i] == "-gcc_flags" || extraArgs[i] == "--gcc_flags") {
                        // user-defined -gcc_flags argument
                        if (i + 1 < extraArgs.Length && !string.IsNullOrEmpty (extraArgs[i + 1])) {
                            var gccArgs = ProcessArgumentBuilder.Parse (extraArgs[i + 1]);

                            for (int j = 0; j < gccArgs.Length; j++)
                                gcc.Arguments.Add (StringParserService.Parse (gccArgs[j], customTags));
                        }

                        i++;
                    } else {
                        // other user-defined mtouch arguments
                        args.AddQuoted (StringParserService.Parse (extraArgs[i], customTags));
                    }
                }
            }

            BuildNativeReferenceFlags (gcc);
            BuildEntitlementFlags (gcc);

            foreach (var framework in gcc.Frameworks) {
                args.Add ("-framework");
                args.AddQuoted (framework);
            }

            foreach (var framework in gcc.WeakFrameworks) {
                args.Add ("-weak-framework");
                args.AddQuoted (framework);
            }

            if (gcc.Cxx)
                args.Add ("--cxx");

            if (gcc.Arguments.Length > 0) {
                args.Add ("--gcc_flags");
                args.AddQuoted (gcc.Arguments.ToString ());
            }

            foreach (var asm in References) {
                args.Add ("-r");
                if (IsFrameworkItem(asm)) {
                    args.AddQuoted (ResolveFrameworkFile(asm.ItemSpec));
                } else {
                    args.AddQuoted (Path.GetFullPath (asm.ItemSpec));
                }
            }

            foreach (var ext in AppExtensionReferences) {
                args.Add ("--app-extension");
                args.AddQuoted (Path.GetFullPath (ext.ItemSpec));
            }

            args.Add ("--target-framework");
            args.Add (TargetFrameworkIdentifier + "," + TargetFrameworkVersion);

            args.AddQuoted (MainAssembly.ItemSpec);

            // We give the priority to the ExtraArgs to set the mtouch verbosity.
            if (string.IsNullOrEmpty (ExtraArgs) || (!string.IsNullOrEmpty (ExtraArgs) && !ExtraArgs.Contains ("-q") && !ExtraArgs.Contains ("-v")))
                args.Add (GetVerbosityLevel (Verbosity));

            if (!string.IsNullOrWhiteSpace (License))
                args.Add (string.Format("--license={0}", License));

            return args.ToString ();
        }
Example #8
0
        protected int Compile(ITaskItem[] items, ITaskItem output, ITaskItem manifest)
        {
            var environment = new Dictionary<string, string> ();
            var args = new ProcessArgumentBuilder ();

            if (!string.IsNullOrEmpty (SdkBinPath))
                environment.Add ("PATH", SdkBinPath);

            if (!string.IsNullOrEmpty (SdkUsrPath))
                environment.Add ("XCODE_DEVELOPER_USR_PATH", SdkUsrPath);

            args.Add ("--errors", "--warnings", "--notices");
            args.Add ("--output-format", "xml1");

            AppendCommandLineArguments (environment, args, items);

            if (Link)
                args.Add ("--link");
            else if (UseCompilationDirectory)
                args.Add ("--compilation-directory");
            else
                args.Add ("--compile");

            args.AddQuoted (output.GetMetadata ("FullPath"));

            foreach (var item in items)
                args.AddQuoted (item.GetMetadata ("FullPath"));

            var startInfo = GetProcessStartInfo (environment, GetFullPathToTool (), args.ToString ());

            try {
                Log.LogMessage (MessageImportance.Normal, "Tool {0} execution started with arguments: {1}", startInfo.FileName, startInfo.Arguments);

                using (var stdout = File.CreateText (manifest.ItemSpec)) {
                    var errors = new StringBuilder ();
                    int exitCode;

                    using (var stderr = new StringWriter (errors)) {
                        var process = ProcessUtils.StartProcess (startInfo, stdout, stderr);

                        process.Wait ();

                        exitCode = process.Result;
                    }

                    Log.LogMessage (MessageImportance.Low, "Tool {0} execution finished (exit code = {1}).", startInfo.FileName, exitCode);

                    if (exitCode != 0)
                        Log.LogError (null, null, null, items[0].ItemSpec, 0, 0, 0, 0, "{0}", errors);

                    return exitCode;
                }
            } catch (Exception ex) {
                Log.LogError ("Error executing tool '{0}': {1}", startInfo.FileName, ex.Message);
                File.Delete (manifest.ItemSpec);
                return -1;
            }
        }
Example #9
0
 protected abstract void AppendCommandLineArguments(IDictionary<string, string> environment, ProcessArgumentBuilder args, ITaskItem[] items);
Example #10
0
        protected override void AppendCommandLineArguments(IDictionary<string, string> environment, ProcessArgumentBuilder args, ITaskItem[] items)
        {
            string minimumDeploymentTarget;

            if (plist != null) {
                PString value;

                if (!plist.TryGetValue (MinimumDeploymentTargetKey, out value) || string.IsNullOrEmpty (value.Value))
                    minimumDeploymentTarget = SdkVersion;
                else
                    minimumDeploymentTarget = value.Value;

                var assetDirs = new HashSet<string> (items.Select (x => x.ItemSpec));

                if (plist.TryGetValue (ManifestKeys.XSAppIconAssets, out value) && !string.IsNullOrEmpty (value.Value)) {
                    int index = value.Value.IndexOf (".xcassets" + Path.DirectorySeparatorChar, StringComparison.Ordinal);
                    string assetDir = null;
                    var rpath = value.Value;

                    if (index != -1)
                        assetDir = rpath.Substring (0, index + ".xcassets".Length);

                    if (assetDirs != null && assetDirs.Contains (assetDir)) {
                        var assetName = Path.GetFileNameWithoutExtension (rpath);

                        if (PartialAppManifest == null) {
                            args.Add ("--output-partial-info-plist");
                            args.AddQuoted (partialAppManifest.GetMetadata ("FullPath"));

                            PartialAppManifest = partialAppManifest;
                        }

                        args.Add ("--app-icon");
                        args.AddQuoted (assetName);
                    }
                }

                if (plist.TryGetValue (ManifestKeys.XSLaunchImageAssets, out value) && !string.IsNullOrEmpty (value.Value)) {
                    int index = value.Value.IndexOf (".xcassets" + Path.DirectorySeparatorChar, StringComparison.Ordinal);
                    string assetDir = null;
                    var rpath = value.Value;

                    if (index != -1)
                        assetDir = rpath.Substring (0, index + ".xcassets".Length);

                    if (assetDirs != null && assetDirs.Contains (assetDir)) {
                        var assetName = Path.GetFileNameWithoutExtension (rpath);

                        if (PartialAppManifest == null) {
                            args.Add ("--output-partial-info-plist");
                            args.AddQuoted (partialAppManifest.GetMetadata ("FullPath"));

                            PartialAppManifest = partialAppManifest;
                        }

                        args.Add ("--launch-image");
                        args.AddQuoted (assetName);
                    }
                }

                if (plist.TryGetValue (ManifestKeys.CLKComplicationGroup, out value) && !string.IsNullOrEmpty (value.Value))
                    args.Add ("--complication", value);
            } else {
                minimumDeploymentTarget = SdkVersion;
            }

            if (OptimizePNGs)
                args.Add ("--compress-pngs");

            if (AppleSdkSettings.XcodeVersion.Major >= 7) {
                if (!string.IsNullOrEmpty (outputSpecs))
                    args.Add ("--enable-on-demand-resources", "YES");

                if (!string.IsNullOrEmpty (DeviceModel))
                    args.Add ("--filter-for-device-model", DeviceModel);

                if (!string.IsNullOrEmpty (DeviceOSVersion))
                    args.Add ("--filter-for-device-os-version", DeviceOSVersion);

                if (!string.IsNullOrEmpty (outputSpecs)) {
                    args.Add ("--asset-pack-output-specifications");
                    args.AddQuoted (Path.GetFullPath (outputSpecs));
                }
            }

            if (plist != null) {
                foreach (var targetDevice in GetTargetDevices (plist))
                    args.Add ("--target-device", targetDevice);
            }

            args.Add ("--minimum-deployment-target", minimumDeploymentTarget);

            switch (SdkPlatform) {
            case "iPhoneSimulator":
                args.Add ("--platform", IsWatchApp ? "watchsimulator" : "iphonesimulator");
                break;
            case "iPhoneOS":
                args.Add ("--platform", IsWatchApp ? "watchos" : "iphoneos");
                break;
            case "MacOSX":
                args.Add ("--platform", "macosx");
                break;
            case "WatchSimulator":
                args.Add ("--platform", "watchsimulator");
                break;
            case "WatchOS":
                args.Add ("--platform", "watchos");
                break;
            case "AppleTVSimulator":
                args.Add ("--platform", "appletvsimulator");
                break;
            case "AppleTVOS":
                args.Add ("--platform", "appletvos");
                break;
            }
        }
Example #11
0
        protected static int Ditto(string source, string destination)
        {
            var args = new ProcessArgumentBuilder ();

            args.Add ("-rsrc");

            args.AddQuoted (source);
            args.AddQuoted (destination);

            var psi = new ProcessStartInfo ("/usr/bin/ditto", args.ToString ()) {
                RedirectStandardOutput = false,
                RedirectStandardError = false,
                UseShellExecute = false,
                CreateNoWindow = true,
            };

            var process = Process.Start (psi);
            process.WaitForExit ();

            return process.ExitCode;
        }
Example #12
0
        int CopySceneKitAssets(string scnassets, string output, string intermediate)
        {
            var environment = new Dictionary<string, string> ();
            var args = new ProcessArgumentBuilder ();

            environment.Add ("PATH", DeveloperRootBinDir);
            environment.Add ("DEVELOPER_DIR", SdkDevPath);
            environment.Add ("XCODE_DEVELOPER_USR_PATH", DeveloperRootBinDir);

            args.AddQuoted (Path.GetFullPath (scnassets));
            args.Add ("-o");
            args.AddQuoted (Path.GetFullPath (output));
            args.AddQuotedFormat ("--sdk-root={0}", SdkRoot);
            args.AddQuotedFormat ("--target-version-{0}={1}", OperatingSystem, SdkVersion);
            args.AddQuotedFormat ("--target-build-dir={0}", Path.GetFullPath (intermediate));

            var startInfo = GetProcessStartInfo (environment, GetFullPathToTool (), args.ToString ());

            try {
                using (var process = new Process ()) {
                    Log.LogMessage (MessageImportance.Normal, "Tool {0} execution started with arguments: {1}", startInfo.FileName, startInfo.Arguments);

                    process.StartInfo = startInfo;
                    process.OutputDataReceived += (sender, e) => {
                        if (e.Data == null)
                            return;

                        Log.LogMessage (MessageImportance.Low, "{0}", e.Data);
                    };

                    process.Start ();
                    process.BeginOutputReadLine ();
                    process.WaitForExit ();

                    Log.LogMessage (MessageImportance.Low, "Tool {0} execution finished.", startInfo.FileName);

                    return process.ExitCode;
                }
            } catch (Exception ex) {
                Log.LogError ("Error executing tool '{0}': {1}", startInfo.FileName, ex.Message);
                return -1;
            }
        }
Example #13
0
        protected override string GenerateCommandLineCommands()
        {
            Log.LogMessage ("Creating installer package");

            var args = new ProcessArgumentBuilder ();

            if (!string.IsNullOrEmpty(ProductDefinition)) {
                args.Add ("--product");
                args.AddQuoted (ProductDefinition);
            }

            args.Add ("--component");
            args.AddQuoted (Path.Combine (OutputDirectory, Path.GetFileName (AppBundleDir)));
            args.Add ("/Applications");

            if (EnablePackageSigning) {
                args.Add ("--sign");
                args.AddQuoted (GetPackageSigningCertificateCommonName ());
            }

            if (!string.IsNullOrEmpty (PackagingExtraArgs)) {
                try {
                    AppendExtraArgs (args, PackagingExtraArgs);
                } catch (FormatException) {
                    Log.LogError ("Package creation failed. Could not parse extra arguments.");
                    return string.Empty;
                }
            }

            string projectVersion = GetProjectVersion ();
            string target = string.Format ("{0}{1}.pkg", Name, String.IsNullOrEmpty (projectVersion) ? "" : "-" + projectVersion);
            args.AddQuoted (Path.Combine (OutputDirectory, target));
            return args.ToString ();
        }
Example #14
0
        void AppendExtraArgs(ProcessArgumentBuilder args, string extraArgs)
        {
            var target = this.MainAssembly.ItemSpec;

            string[] argv = ProcessArgumentBuilder.Parse (extraArgs);
            var customTags = new Dictionary<string, string> (StringComparer.OrdinalIgnoreCase) {
                { "projectdir",   Path.GetDirectoryName (this.ProjectPath) },
            // Apparently msbuild doesn't propagate the solution path, so we can't get it. - MTouchTaskBase.cs
            // 	{ "solutiondir",  proj.ParentSolution != null ? proj.ParentSolution.BaseDirectory : proj.BaseDirectory },
                { "appbundledir", this.AppBundleDir },
                { "targetpath",   Path.Combine (Path.GetDirectoryName (target), Path.GetFileName (target)) },
                { "targetdir",    Path.GetDirectoryName (target) },
                { "targetname",   Path.GetFileName (target) },
                { "targetext",    Path.GetExtension (target) },
            };

            for (int i = 0; i < argv.Length; i++)
                args.AddQuoted (StringParserService.Parse (argv[i], customTags));
        }
Example #15
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder ();

            args.Add ("/verbose");

            if (Debug)
                args.Add ("/debug");

            if (!string.IsNullOrEmpty (OutputPath))
                args.AddQuoted ("/output:" + Path.GetFullPath (OutputPath));

            if (!string.IsNullOrEmpty (ApplicationName))
                args.AddQuoted ("/name:" + ApplicationName);

            if (TargetFrameworkIdentifier == "Xamarin.Mac")
                args.Add ("/profile:Xamarin.Mac");
            else if (TargetFrameworkVersion.StartsWith ("v", StringComparison.Ordinal))
                args.Add ("/profile:" + TargetFrameworkVersion.Substring (1));

            if (TargetFrameworkIdentifier == "Xamarin.Mac" || UseXamMacFullFramework) {
                XamMacArch arch;
                if (!Enum.TryParse<XamMacArch> (Architecture, true, out arch))
                    arch = XamMacArch.Default;

                if (arch == XamMacArch.Default)
                    arch = XamMacArch.x86_64;

                if (arch.HasFlag (XamMacArch.i386))
                    args.Add ("/arch:i386");

                if (arch.HasFlag (XamMacArch.x86_64))
                    args.Add ("/arch:x86_64");
            }
            else {
                args.Add ("/arch:i386");
            }

            args.Add (string.Format ("--http-message-handler={0}", HttpClientHandler));

            if (AppManifest != null) {
                try {
                    var plist = PDictionary.FromFile (AppManifest.ItemSpec);

                    PString v;
                    string minimumDeploymentTarget;

                    if (!plist.TryGetValue (ManifestKeys.LSMinimumSystemVersion, out v) || string.IsNullOrEmpty (v.Value))
                        minimumDeploymentTarget = SdkVersion;
                    else
                        minimumDeploymentTarget = v.Value;

                    args.Add (string.Format("/minos={0}", minimumDeploymentTarget));
                }
                catch (Exception ex) {
                    Log.LogWarning (null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, "Error loading '{0}': {1}", AppManifest.ItemSpec, ex.Message);
                }
            }

            if (TargetFrameworkIdentifier == "Xamarin.Mac" && !string.IsNullOrEmpty (TLSProvider))
                args.Add (string.Format ("--tls-provider={0}", TLSProvider.ToLowerInvariant()));

            if (Profiling)
                args.Add ("/profiling");

            switch ((LinkMode ?? String.Empty).ToLower ()) {
            case "full":
                break;
            case "sdkonly":
                args.Add ("/linksdkonly");
                break;
            default:
                args.Add ("/nolink");
                break;
            }

            if (!string.IsNullOrEmpty (I18n))
                args.AddQuoted ("/i18n:" + I18n);

            if (ExplicitReferences != null) {
                foreach (var asm in ExplicitReferences)
                    args.AddQuoted ("/assembly:" + Path.GetFullPath (asm));
            }

            if (!string.IsNullOrEmpty (ApplicationAssembly))
                args.AddQuoted (Path.GetFullPath (ApplicationAssembly));

            if (!string.IsNullOrWhiteSpace (ExtraArguments))
                args.Add (ExtraArguments);

            if (NativeReferences != null) {
                foreach (var nr in NativeReferences)
                    args.AddQuoted ("/native-reference:" + Path.GetFullPath (nr));
            }

            args.Add ("/sdkroot");
            args.AddQuoted (SdkRoot);

            if (!string.IsNullOrEmpty (IntermediateOutputPath)) {
                Directory.CreateDirectory (IntermediateOutputPath);

                args.Add ("--cache");
                args.AddQuoted (Path.GetFullPath (IntermediateOutputPath));
            }

            return args.ToString ();
        }
Example #16
0
        protected override void AppendCommandLineArguments(IDictionary<string, string> environment, ProcessArgumentBuilder args, ITaskItem[] items)
        {
            environment.Add ("IBSC_MINIMUM_COMPATIBILITY_VERSION", minimumDeploymentTarget);
            environment.Add ("IBC_MINIMUM_COMPATIBILITY_VERSION", minimumDeploymentTarget);

            if (AppleSdkSettings.XcodeVersion.Major >= 5)
                args.Add ("--minimum-deployment-target", minimumDeploymentTarget);

            foreach (var targetDevice in GetTargetDevices (plist))
                args.Add ("--target-device", targetDevice);

            if (AppleSdkSettings.XcodeVersion.Major >= 6 && AutoActivateCustomFonts)
                args.Add ("--auto-activate-custom-fonts");

            if (!string.IsNullOrEmpty (SdkRoot)) {
                args.Add ("--sdk");
                args.AddQuoted (SdkRoot);
            }
        }