int CopySceneKitAssets(string scnassets, string output, string intermediate)
        {
            var environment = new Dictionary <string, string> ();
            var args        = new CommandLineArgumentBuilder();

            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);

            if (AppleSdkSettings.XcodeVersion.Major >= 10)
            {
                var platform = PlatformUtils.GetTargetPlatform(SdkPlatform, IsWatchApp);
                if (platform != null)
                {
                    args.Add("--target-platform", platform);
                }

                args.AddQuotedFormat("--target-version={0}", SdkVersion);
            }
            else
            {
                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);
            }
        }
Exemplo n.º 2
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new CommandLineArgumentBuilder();

            args.Add("--compress");
            args.AddQuoted(InputScene);
            args.Add("-o");
            args.AddQuoted(OutputScene);
            args.AddQuotedFormat("--sdk-root={0}", SdkRoot);
            args.AddQuotedFormat("--target-version-{0}={1}", OperatingSystem, SdkVersion);
            args.AddQuotedFormat("--target-build-dir={0}", IntermediateOutputPath);

            return(args.ToString());
        }
Exemplo n.º 3
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new CommandLineArgumentBuilder();

            args.Add("--compress");
            args.AddQuoted(InputScene);
            args.Add("-o");
            args.AddQuoted(OutputScene);
            args.AddQuotedFormat("--sdk-root={0}", SdkRoot);
            args.AddQuotedFormat("--target-build-dir={0}", IntermediateOutputPath);
            if (AppleSdkSettings.XcodeVersion.Major >= 13)
            {
                // I'm not sure which Xcode version these options are available in, but it's at least Xcode 13+
                args.AddQuotedFormat("--target-version={0}", SdkVersion);
                args.AddQuotedFormat("--target-platform={0}", PlatformUtils.GetTargetPlatform(SdkPlatform, IsWatchApp));
            }
            else
            {
                args.AddQuotedFormat("--target-version-{0}={1}", OperatingSystem, SdkVersion);
            }

            return(args.ToString());
        }
Exemplo n.º 4
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new CommandLineArgumentBuilder();
            TargetArchitecture architectures;
            bool msym;

            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 (!string.IsNullOrEmpty(IntermediateOutputPath))
            {
                Directory.CreateDirectory(IntermediateOutputPath);

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

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

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

            args.AddQuoted("--executable=" + ExecutableName);

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

            if (Debug)
            {
                if (FastDev && !SdkIsSimulator)
                {
                    args.Add("--fastdev");
                }

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

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

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

            if (EnableSGenConc)
            {
                args.Add("--sgen-conc");
            }

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

            case "none":    args.Add("--nolink"); break;
            }

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

            args.AddQuoted("--sdkroot=" + SdkRoot);

            args.AddQuoted("--sdk=" + SdkVersion);

            if (!minimumOSVersion.IsUseDefault)
            {
                args.AddQuoted("--targetver=" + 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");
            }
            else
            {
                args.Add("--aot-options=-O=-float32");
            }

            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));
            }

            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" + llvm;
                }

                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.AddQuoted("--symbollist=" + Path.GetFullPath(SymbolsList));

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

            if (!string.IsNullOrEmpty(ArchiveSymbols) && bool.TryParse(ArchiveSymbols.Trim(), out msym))
            {
                args.Add("--msym=" + (msym ? "yes" : "no"));
            }

            var gcc = new GccOptions();

            if (!string.IsNullOrEmpty(ExtraArgs))
            {
                var    extraArgs = CommandLineArgumentBuilder.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++)
                {
                    var argument   = extraArgs[i];
                    int startIndex = 0;

                    while (argument.Length > startIndex && argument[startIndex] == '-')
                    {
                        startIndex++;
                    }

                    int endIndex = startIndex;
                    while (endIndex < argument.Length && argument[endIndex] != '=')
                    {
                        endIndex++;
                    }

                    int length = endIndex - startIndex;

                    if (length == 9 && string.CompareOrdinal(argument, startIndex, "gcc_flags", 0, 9) == 0)
                    {
                        // user-defined -gcc_flags argument
                        string flags = null;

                        if (endIndex < extraArgs[i].Length)
                        {
                            flags = Unquote(argument, endIndex + 1);
                        }
                        else if (i + 1 < extraArgs.Length)
                        {
                            flags = extraArgs[++i];
                        }

                        if (!string.IsNullOrEmpty(flags))
                        {
                            var gccArgs = CommandLineArgumentBuilder.Parse(flags);

                            for (int j = 0; j < gccArgs.Length; j++)
                            {
                                gcc.Arguments.Add(StringParserService.Parse(gccArgs[j], customTags));
                            }
                        }
                    }
                    else
                    {
                        // other user-defined mtouch arguments
                        args.AddQuoted(StringParserService.Parse(argument, customTags));
                    }
                }
            }

            BuildNativeReferenceFlags(gcc);
            BuildEntitlementFlags(gcc);

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

            foreach (var framework in gcc.WeakFrameworks)
            {
                args.AddQuoted("--weak-framework=" + 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)
            {
                if (IsFrameworkItem(asm))
                {
                    args.AddQuoted("-r=" + ResolveFrameworkFile(asm.ItemSpec));
                }
                else
                {
                    args.AddQuoted("-r=" + Path.GetFullPath(asm.ItemSpec));
                }
            }

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

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

            args.AddQuoted("--root-assembly=" + Path.GetFullPath(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());
        }