Ejemplo n.º 1
0
        public ManagedProgram(string monodistribution, string profile, string executable, string arguments, bool setMonoEnvironmentVariables)
        {
            string[] parts = new string[] { monodistribution, "bin", "mono" };
            string   str   = PathCombine(parts);

            string[] textArray2 = new string[] { monodistribution, "lib", "mono", profile };
            string   str2       = PathCombine(textArray2);

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                str = CommandLineFormatter.PrepareFileName(str + ".exe");
            }
            ProcessStartInfo info = new ProcessStartInfo {
                Arguments              = CommandLineFormatter.PrepareFileName(executable) + " " + arguments,
                CreateNoWindow         = true,
                FileName               = str,
                RedirectStandardError  = true,
                RedirectStandardOutput = true,
                WorkingDirectory       = Application.dataPath + "/..",
                UseShellExecute        = false
            };

            if (setMonoEnvironmentVariables)
            {
                info.EnvironmentVariables["MONO_PATH"] = str2;
                string[] textArray3 = new string[] { monodistribution, "etc" };
                info.EnvironmentVariables["MONO_CFG_DIR"] = PathCombine(textArray3);
            }
            base._process.StartInfo = info;
        }
Ejemplo n.º 2
0
        private static ProcessStartInfo CreateDotNetCoreStartInfoForArgs(string arguments)
        {
            var dotnetExe = Paths.Combine(GetSdkRoot(), "dotnet");

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                dotnetExe = CommandLineFormatter.PrepareFileName(dotnetExe + ".exe");
            }

            var startInfo = new ProcessStartInfo
            {
                Arguments        = arguments,
                CreateNoWindow   = true,
                FileName         = dotnetExe,
                WorkingDirectory = Application.dataPath + "/..",
            };

            if (Application.platform == RuntimePlatform.OSXEditor)
            {
                // .NET Core needs to be able to find the newer openssl libraries that it requires on OSX
                var nativeDepsPath = Path.Combine(Path.Combine(Path.Combine(GetNetCoreRoot(), "NativeDeps"), "osx"), "lib");

                if (startInfo.EnvironmentVariables.ContainsKey("DYLD_LIBRARY_PATH"))
                {
                    startInfo.EnvironmentVariables["DYLD_LIBRARY_PATH"] = string.Format("{0}:{1}", nativeDepsPath, startInfo.EnvironmentVariables["DYLD_LIBRARY_PATH"]);
                }
                else
                {
                    startInfo.EnvironmentVariables.Add("DYLD_LIBRARY_PATH", nativeDepsPath);
                }
            }

            return(startInfo);
        }
Ejemplo n.º 3
0
        public void RunCompileAndLink()
        {
            var il2CppNativeCodeBuilder = m_PlatformProvider.CreateIl2CppNativeCodeBuilder();

            if (il2CppNativeCodeBuilder != null)
            {
                Il2CppNativeCodeBuilderUtils.ClearAndPrepareCacheDirectory(il2CppNativeCodeBuilder);

                var buildTargetGroup      = BuildPipeline.GetBuildTargetGroup(m_PlatformProvider.target);
                var compilerConfiguration = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup);
                var arguments             = Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, OutputFileRelativePath(), m_PlatformProvider.includePaths, m_PlatformProvider.libraryPaths, compilerConfiguration).ToList();

                var additionalArgs = IL2CPPUtils.GetAdditionalArguments();
                if (!string.IsNullOrEmpty(additionalArgs))
                {
                    arguments.Add(additionalArgs);
                }

                arguments.Add($"--map-file-parser={CommandLineFormatter.PrepareFileName(GetMapFileParserPath())}");
                arguments.Add($"--generatedcppdir={CommandLineFormatter.PrepareFileName(GetShortPathName(Path.GetFullPath(GetCppOutputDirectoryInStagingArea())))}");
                arguments.Add(string.Format("--dotnetprofile=\"{0}\"", IL2CPPUtils.ApiCompatibilityLevelToDotNetProfileArgument(PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup))));
                arguments.AddRange(IL2CPPUtils.GetDebuggerIL2CPPArguments(m_PlatformProvider, buildTargetGroup));
                Action <ProcessStartInfo> setupStartInfo = il2CppNativeCodeBuilder.SetupStartInfo;
                var managedDir = Path.GetFullPath(Path.Combine(m_StagingAreaData, "Managed"));

                RunIl2CppWithArguments(arguments, setupStartInfo, managedDir);
            }
        }
Ejemplo n.º 4
0
        private static ProcessStartInfo CreateDotNetCoreStartInfoForArgs(string arguments)
        {
            string text = Paths.Combine(new string[]
            {
                NetCoreProgram.GetSdkRoot(),
                "dotnet"
            });

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                text = CommandLineFormatter.PrepareFileName(text + ".exe");
            }
            ProcessStartInfo processStartInfo = new ProcessStartInfo
            {
                Arguments        = arguments,
                CreateNoWindow   = true,
                FileName         = text,
                WorkingDirectory = Application.dataPath + "/.."
            };

            if (Application.platform == RuntimePlatform.OSXEditor)
            {
                string text2 = Path.Combine(Path.Combine(Path.Combine(NetCoreProgram.GetNetCoreRoot(), "NativeDeps"), "osx"), "lib");
                if (processStartInfo.EnvironmentVariables.ContainsKey("DYLD_LIBRARY_PATH"))
                {
                    processStartInfo.EnvironmentVariables["DYLD_LIBRARY_PATH"] = string.Format("{0}:{1}", text2, processStartInfo.EnvironmentVariables["DYLD_LIBRARY_PATH"]);
                }
                else
                {
                    processStartInfo.EnvironmentVariables.Add("DYLD_LIBRARY_PATH", text2);
                }
            }
            return(processStartInfo);
        }
        internal static string ArgumentsForUpdateAssembly(string assemblyPath, string tempOutputPath, IEnumerable <string> updateConfigSourcePaths)
        {
            var assemblyFullPath = ResolveAssemblyPath(assemblyPath);

            return("update -a "
                   + assemblyFullPath
                   + " --output " + CommandLineFormatter.PrepareFileName(tempOutputPath)
                   + APIVersionArgument()
                   + AssemblySearchPathArgument(updateConfigSourcePaths.Select(Path.GetDirectoryName).Distinct())
                   + ConfigurationProviderAssembliesPathArgument(updateConfigSourcePaths));
        }
        private static string ConfigurationProviderAssembliesPathArgument(IEnumerable <string> updateConfigSourcePaths)
        {
            var paths = new StringBuilder();

            foreach (var configSourcePath in updateConfigSourcePaths)
            {
                paths.AppendFormat(" {0}", CommandLineFormatter.PrepareFileName(configSourcePath));
            }

            return(paths.ToString());
        }
        private static bool RunAssemblyLinker(IEnumerable <string> args, out string @out, out string err, string linkerPath, string workingDirectory)
        {
            var argString    = args.Aggregate((buff, s) => buff + " " + s);
            var responseFile = Path.Combine(workingDirectory, "response.rsp");

            File.WriteAllText(responseFile, argString);
            UnityLogWriter.WriteStringToUnityLog($"Invoking UnityLinker with response file. response.rsp contents: {argString}\n");
            Runner.RunNetCoreProgram(linkerPath, $"@{CommandLineFormatter.PrepareFileName(responseFile)}", workingDirectory, null, null);

            @out = "";
            err  = "";

            return(true);
        }
Ejemplo n.º 8
0
        public static bool DoesAssemblyRequireUpgrade(string assemblyFullPath)
        {
            bool result;

            if (!File.Exists(assemblyFullPath))
            {
                result = false;
            }
            else if (!AssemblyHelper.IsManagedAssembly(assemblyFullPath))
            {
                result = false;
            }
            else if (!APIUpdaterHelper.MayContainUpdatableReferences(assemblyFullPath))
            {
                result = false;
            }
            else
            {
                string text;
                string text2;
                int    num = APIUpdaterHelper.RunUpdatingProgram("AssemblyUpdater.exe", string.Concat(new string[]
                {
                    APIUpdaterHelper.TimeStampArgument(),
                    APIUpdaterHelper.APIVersionArgument(),
                    "--check-update-required -a ",
                    CommandLineFormatter.PrepareFileName(assemblyFullPath),
                    APIUpdaterHelper.AssemblySearchPathArgument(),
                    APIUpdaterHelper.ConfigurationProviderAssembliesPathArgument()
                }), out text, out text2);
                Console.WriteLine("{0}{1}", text, text2);
                switch (num)
                {
                case 0:
                case 1:
                    result = false;
                    break;

                case 2:
                    result = true;
                    break;

                default:
                    UnityEngine.Debug.LogError(text + Environment.NewLine + text2);
                    result = false;
                    break;
                }
            }
            return(result);
        }
Ejemplo n.º 9
0
        public NetCoreProgram(string executable, string arguments, Action <ProcessStartInfo> setupStartInfo)
        {
            if (!IsNetCoreAvailable())
            {
                Debug.LogError("Creating NetCoreProgram, but IsNetCoreAvailable() == false; fix the caller!");
                // let it happen anyway to preserve previous behaviour
            }

            var startInfo = CreateDotNetCoreStartInfoForArgs(CommandLineFormatter.PrepareFileName(executable) + " " + arguments);

            if (setupStartInfo != null)
            {
                setupStartInfo(startInfo);
            }

            _process.StartInfo = startInfo;
        }
Ejemplo n.º 10
0
        public ManagedProgram(string monodistribution, string profile, string executable, string arguments, bool setMonoEnvironmentVariables, Action <ProcessStartInfo> setupStartInfo)
        {
            string text = ManagedProgram.PathCombine(new string[]
            {
                monodistribution,
                "bin",
                "mono"
            });
            string value = ManagedProgram.PathCombine(new string[]
            {
                monodistribution,
                "lib",
                "mono",
                profile
            });

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                text = CommandLineFormatter.PrepareFileName(text + ".exe");
            }
            ProcessStartInfo processStartInfo = new ProcessStartInfo
            {
                Arguments              = CommandLineFormatter.PrepareFileName(executable) + " " + arguments,
                CreateNoWindow         = true,
                FileName               = text,
                RedirectStandardError  = true,
                RedirectStandardOutput = true,
                WorkingDirectory       = Application.dataPath + "/..",
                UseShellExecute        = false
            };

            if (setMonoEnvironmentVariables)
            {
                processStartInfo.EnvironmentVariables["MONO_PATH"]    = value;
                processStartInfo.EnvironmentVariables["MONO_CFG_DIR"] = ManagedProgram.PathCombine(new string[]
                {
                    monodistribution,
                    "etc"
                });
            }
            if (setupStartInfo != null)
            {
                setupStartInfo(processStartInfo);
            }
            this._process.StartInfo = processStartInfo;
        }
Ejemplo n.º 11
0
        public void RunCompileAndLink(string il2cppBuildCacheSource)
        {
            if (string.Equals(Path.GetFullPath(il2cppBuildCacheSource), Path.GetFullPath(m_PlatformProvider.il2cppBuildCacheDirectory), StringComparison.OrdinalIgnoreCase))
            {
                throw new ArgumentException("IIl2CppPlatformProvider.il2cppBuildCacheDirectory cannot be the same as il2cppBuildCacheDirectory. You probably forgot to override il2cppBuildCacheDirectory on your IIl2CppPlatformProvider.");
            }

            var il2CppNativeCodeBuilder = m_PlatformProvider.CreateIl2CppNativeCodeBuilder();

            if (il2CppNativeCodeBuilder != null)
            {
                Il2CppNativeCodeBuilderUtils.ClearAndPrepareCacheDirectory(il2CppNativeCodeBuilder);

                var buildCacheDirectory = m_PlatformProvider.il2cppBuildCacheDirectory;
                Directory.CreateDirectory(buildCacheDirectory);

                var buildCacheNativeOutputFile = Path.Combine(GetNativeOutputRelativeDirectory(buildCacheDirectory), m_PlatformProvider.nativeLibraryFileName);
                var buildTargetGroup           = BuildPipeline.GetBuildTargetGroup(m_PlatformProvider.target);
                var compilerConfiguration      = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup);
                var arguments = Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, buildCacheNativeOutputFile, m_PlatformProvider.includePaths, m_PlatformProvider.libraryPaths, compilerConfiguration).ToList();

                var additionalArgs = IL2CPPUtils.GetAdditionalArguments();
                if (!string.IsNullOrEmpty(additionalArgs))
                {
                    arguments.Add(additionalArgs);
                }

                foreach (var buildingArgument in IL2CPPUtils.GetBuildingIL2CPPArguments(m_PlatformProvider, buildTargetGroup))
                {
                    if (!arguments.Contains(buildingArgument))
                    {
                        arguments.Add(buildingArgument);
                    }
                }

                arguments.Add($"--generatedcppdir={CommandLineFormatter.PrepareFileName(GetCppOutputDirectory(il2cppBuildCacheSource))}");
                arguments.Add($"--dotnetprofile=\"{IL2CPPUtils.ApiCompatibilityLevelToDotNetProfileArgument(PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup), m_PlatformProvider.target)}\"");
                arguments.AddRange(IL2CPPUtils.GetDebuggerIL2CPPArguments(m_PlatformProvider, buildTargetGroup));
                Action <ProcessStartInfo> setupStartInfo = il2CppNativeCodeBuilder.SetupStartInfo;

                RunIl2CppWithArguments(arguments, setupStartInfo);
            }
        }
        private static string ConfigurationProviderAssembliesPathArgument()
        {
            var paths = new StringBuilder();

            foreach (var ext in ModuleManager.packageManager.unityExtensions)
            {
                foreach (var dllPath in ext.files.Where(f => f.Value.type == Unity.DataContract.PackageFileType.Dll).Select(pi => pi.Key))
                {
                    paths.AppendFormat(" {0}", CommandLineFormatter.PrepareFileName(Path.Combine(ext.basePath, dllPath)));
                }
            }

            var editorManagedPath = GetUnityEditorManagedPath();

            paths.AppendFormat(" {0}", CommandLineFormatter.PrepareFileName(Path.Combine(editorManagedPath, "UnityEngine.dll")));
            paths.AppendFormat(" {0}", CommandLineFormatter.PrepareFileName(Path.Combine(editorManagedPath, "UnityEditor.dll")));

            return(paths.ToString());
        }
    static ProcessStartInfo CreateOSDependentStartInfo(
        bool isWindows, string processPath, string processArguments, string unityEditorDataDir
        )
    {
        ProcessStartInfo startInfo;

        if (isWindows)
        {
            startInfo = new ProcessStartInfo(processPath, processArguments);
        }
        else
        {
            string runtimePath;

            if (File.Exists("/Library/Frameworks/Mono.framework/Commands/mono"))
            {
                runtimePath = "/Library/Frameworks/Mono.framework/Commands/mono";
            }
            else if (File.Exists("/usr/local/bin/mono"))
            {
                runtimePath = "/usr/local/bin/mono";
            }
            else
            {
                runtimePath = Path.Combine(unityEditorDataDir, "MonoBleedingEdge/bin/mono");
            }
            startInfo = new ProcessStartInfo(runtimePath, $"{CommandLineFormatter.PrepareFileName(processPath)} {processArguments}");
        }

        var vars = startInfo.EnvironmentVariables;

        vars.Add("UNITY_DATA", unityEditorDataDir);
        // vars["RoslynCommandLineLogFile"] = Path.Combine(Directory.GetCurrentDirectory(), "clogs");

        startInfo.CreateNoWindow         = true;
        startInfo.WorkingDirectory       = Application.dataPath + "/..";
        startInfo.RedirectStandardError  = true;
        startInfo.RedirectStandardOutput = true;
        startInfo.UseShellExecute        = false;

        return(startInfo);
    }
Ejemplo n.º 14
0
        private static string ConfigurationProviderAssembliesPathArgument()
        {
            StringBuilder stringBuilder = new StringBuilder();

            foreach (Unity.DataContract.PackageInfo current in ModuleManager.packageManager.unityExtensions)
            {
                foreach (string current2 in from f in current.files
                         where f.Value.type == PackageFileType.Dll
                         select f into pi
                         select pi.Key)
                {
                    stringBuilder.AppendFormat(" {0}", CommandLineFormatter.PrepareFileName(Path.Combine(current.basePath, current2)));
                }
            }
            string unityEditorManagedPath = APIUpdaterHelper.GetUnityEditorManagedPath();

            stringBuilder.AppendFormat(" {0}", CommandLineFormatter.PrepareFileName(Path.Combine(unityEditorManagedPath, "UnityEngine.dll")));
            stringBuilder.AppendFormat(" {0}", CommandLineFormatter.PrepareFileName(Path.Combine(unityEditorManagedPath, "UnityEditor.dll")));
            return(stringBuilder.ToString());
        }
Ejemplo n.º 15
0
        public NetCoreRunProgram(string executable, string arguments, Action <ProcessStartInfo> setupStartInfo)
        {
            if (!IsSupported())
            {
                throw new NotSupportedException("NetCoreRunProgram is not supported on this platform");
            }

            var startInfo = new ProcessStartInfo
            {
                FileName       = netcoreRunPath,
                Arguments      = $"{CommandLineFormatter.PrepareFileName(executable)} {arguments}",
                CreateNoWindow = true
            };

            if (setupStartInfo != null)
            {
                setupStartInfo(startInfo);
            }

            _process.StartInfo = startInfo;
        }
Ejemplo n.º 16
0
        private static string ConfigurationProviderAssembliesPathArgument()
        {
            StringBuilder stringBuilder = new StringBuilder();

            using (IEnumerator <PackageInfo> enumerator = ModuleManager.packageManager.get_unityExtensions().GetEnumerator())
            {
                while (((IEnumerator)enumerator).MoveNext())
                {
                    PackageInfo current = enumerator.Current;
                    foreach (string path2 in ((IEnumerable <KeyValuePair <string, PackageFileData> >)current.get_files()).Where <KeyValuePair <string, PackageFileData> >((Func <KeyValuePair <string, PackageFileData>, bool>)(f => f.Value.type == 3)).Select <KeyValuePair <string, PackageFileData>, string>((Func <KeyValuePair <string, PackageFileData>, string>)(pi => pi.Key)))
                    {
                        stringBuilder.AppendFormat(" {0}", (object)CommandLineFormatter.PrepareFileName(Path.Combine((string)current.basePath, path2)));
                    }
                }
            }
            string editorManagedPath = APIUpdaterHelper.GetUnityEditorManagedPath();

            stringBuilder.AppendFormat(" {0}", (object)CommandLineFormatter.PrepareFileName(Path.Combine(editorManagedPath, "UnityEngine.dll")));
            stringBuilder.AppendFormat(" {0}", (object)CommandLineFormatter.PrepareFileName(Path.Combine(editorManagedPath, "UnityEditor.dll")));
            return(stringBuilder.ToString());
        }
Ejemplo n.º 17
0
        public ManagedProgram(string monodistribution, string profile, string executable, string arguments, bool setMonoEnvironmentVariables)
        {
            string str1 = ManagedProgram.PathCombine(monodistribution, "bin", "mono");
            string str2 = ManagedProgram.PathCombine(monodistribution, "lib", "mono", profile);

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                str1 = CommandLineFormatter.PrepareFileName(str1 + ".exe");
            }
            ProcessStartInfo processStartInfo = new ProcessStartInfo()
            {
                Arguments = CommandLineFormatter.PrepareFileName(executable) + " " + arguments, CreateNoWindow = true, FileName = str1, RedirectStandardError = true, RedirectStandardOutput = true, WorkingDirectory = Application.dataPath + "/..", UseShellExecute = false
            };

            if (setMonoEnvironmentVariables)
            {
                processStartInfo.EnvironmentVariables["MONO_PATH"]    = str2;
                processStartInfo.EnvironmentVariables["MONO_CFG_DIR"] = ManagedProgram.PathCombine(monodistribution, "etc");
            }
            this._process.StartInfo = processStartInfo;
        }
Ejemplo n.º 18
0
        public ManagedProgram(string monodistribution, string profile, string executable, string arguments, bool setMonoEnvironmentVariables, Action <ProcessStartInfo> setupStartInfo)
        {
            var monoexe = PathCombine(monodistribution, "bin", "mono");

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                monoexe = CommandLineFormatter.PrepareFileName(monoexe + ".exe");
            }

            var startInfo = new ProcessStartInfo
            {
                Arguments              = CommandLineFormatter.PrepareFileName(executable) + " " + arguments,
                CreateNoWindow         = true,
                FileName               = monoexe,
                RedirectStandardError  = true,
                RedirectStandardOutput = true,
                WorkingDirectory       = Application.dataPath + "/..",
                UseShellExecute        = false
            };

            if (setMonoEnvironmentVariables)
            {
                var profileAbspath = PathCombine(monodistribution, "lib", "mono", profile);
                startInfo.EnvironmentVariables["MONO_PATH"]    = profileAbspath;
                startInfo.EnvironmentVariables["MONO_CFG_DIR"] = PathCombine(monodistribution, "etc");
            }

            // if you ever need to debug assembly loading, uncomment the following two lines
            //startInfo.EnvironmentVariables["MONO_LOG_LEVEL"] = "info";
            //startInfo.EnvironmentVariables["MONO_LOG_MASK"] = "asm";

            if (setupStartInfo != null)
            {
                setupStartInfo(startInfo);
            }

            _process.StartInfo = startInfo;
        }
Ejemplo n.º 19
0
        public static bool DoesAssemblyRequireUpgrade(string assetFullPath)
        {
            if (!File.Exists(assetFullPath))
            {
                return(false);
            }
            if (!InternalEditorUtility.DetectDotNetDll(assetFullPath))
            {
                return(false);
            }
            string text;
            string text2;
            int    num = APIUpdaterHelper.RunUpdatingProgram("AssemblyUpdater.exe", string.Concat(new string[]
            {
                APIUpdaterHelper.TimeStampArgument(),
                APIUpdaterHelper.APIVersionArgument(),
                "--check-update-required -a ",
                CommandLineFormatter.PrepareFileName(assetFullPath),
                APIUpdaterHelper.AssemblySearchPathArgument()
            }), out text, out text2);

            Console.WriteLine("{0}{1}", text, text2);
            switch (num)
            {
            case 0:
            case 1:
                return(false);

            case 2:
                return(true);

            default:
                UnityEngine.Debug.LogError(text + Environment.NewLine + text2);
                return(false);
            }
        }
Ejemplo n.º 20
0
 public Program AppDeploy(string provider, string applicationId, string environment, NPath applicationPath) =>
 CreateProgram(new[] { "app-deploy", "--environment", environment, provider, applicationId, CommandLineFormatter.PrepareFileName(applicationPath.ToString()) });
Ejemplo n.º 21
0
        private static bool StripAssembliesTo(string outputFolder, out string output, out string error, IEnumerable <string> linkXmlFiles, UnityLinkerRunInformation runInformation)
        {
            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }

            var assemblies = runInformation.AssembliesToProcess();

            var args = new List <string>
            {
                $"-out={CommandLineFormatter.PrepareFileName(outputFolder)}",
            };

            if (!UseUnityLinkerEngineModuleStripping)
            {
                args.Add($"-x={CommandLineFormatter.PrepareFileName(GetModuleWhitelist("Core", runInformation.platformProvider.moduleStrippingInformationFolder))}");
            }

            args.AddRange(linkXmlFiles.Select(path => $"-x={CommandLineFormatter.PrepareFileName(path)}"));
            args.AddRange(runInformation.SearchDirectories.Select(d => $"-d={CommandLineFormatter.PrepareFileName(d)}"));
            args.AddRange(assemblies.Select(assembly => $"--include-unity-root-assembly={CommandLineFormatter.PrepareFileName(Path.GetFullPath(assembly))}"));
            args.Add($"--dotnetruntime={runInformation.argumentProvider.Runtime}");
            args.Add($"--dotnetprofile={runInformation.argumentProvider.Profile}");
            args.Add("--use-editor-options");
            args.Add($"--include-directory={CommandLineFormatter.PrepareFileName(runInformation.managedAssemblyFolderPath)}");

            if (EditorUserBuildSettings.allowDebugging)
            {
                args.Add("--editor-settings-flag=AllowDebugging");
            }

            if (EditorUserBuildSettings.development)
            {
                args.Add("--editor-settings-flag=Development");
            }

            args.Add($"--rule-set={runInformation.argumentProvider.RuleSet}");
            args.Add($"--editor-data-file={CommandLineFormatter.PrepareFileName(runInformation.EditorToLinkerDataPath)}");

            if (runInformation.platformProvider.AllowOutputToBeMadePlatformDependent)
            {
                var platform = runInformation.platformProvider.Platform;
                if (string.IsNullOrEmpty(platform))
                {
                    throw new ArgumentException($"Platform is required if AllowOutputToBeMadePlatformDependent is true");
                }

                args.Add($"--platform={platform}");
            }

            if (runInformation.platformProvider.AllowOutputToBeMadeArchitectureDependent)
            {
                var architecture = runInformation.platformProvider.Architecture;
                if (string.IsNullOrEmpty(architecture))
                {
                    throw new ArgumentException($"Architecture is required if AllowOutputToBeMadeArchitectureDependent is true");
                }
                args.Add($"--architecture={architecture}");
            }

            if (!UseUnityLinkerEngineModuleStripping)
            {
                args.Add("--disable-engine-module-support");
            }

            if (runInformation.performEngineStripping)
            {
                args.Add("--enable-engine-module-stripping");

                if (UnityEngine.Connect.UnityConnectSettings.enabled)
                {
                    args.Add("--engine-stripping-flag=EnableUnityConnect");
                }

                if (UnityEngine.Analytics.PerformanceReporting.enabled)
                {
                    args.Add("--engine-stripping-flag=EnablePerformanceReporting");
                }

                if (UnityEngine.Analytics.Analytics.enabled)
                {
                    args.Add("--engine-stripping-flag=EnableAnalytics");
                }

                if (UnityEditor.CrashReporting.CrashReportingSettings.enabled)
                {
                    args.Add("--engine-stripping-flag=EnableCrashReporting");
                }

                if (UnityEditorInternal.VR.VRModule.ShouldInjectVRDependenciesForBuildTarget(runInformation.target))
                {
                    args.Add("--engine-stripping-flag=EnableVR");
                }
            }

            var modulesAssetPath = runInformation.ModulesAssetFilePath;

            if (File.Exists(modulesAssetPath))
            {
                args.Add($"--engine-modules-asset-file={CommandLineFormatter.PrepareFileName(modulesAssetPath)}");
            }

            var additionalArgs = System.Environment.GetEnvironmentVariable("UNITYLINKER_ADDITIONAL_ARGS");

            if (!string.IsNullOrEmpty(additionalArgs))
            {
                args.Add(additionalArgs);
            }

            additionalArgs = Debug.GetDiagnosticSwitch("VMUnityLinkerAdditionalArgs") as string;
            if (!string.IsNullOrEmpty(additionalArgs))
            {
                args.Add(additionalArgs.Trim('\''));
            }

            return(RunAssemblyLinker(args, out output, out error, UnityLinkerPath, runInformation.managedAssemblyFolderPath));
        }
Ejemplo n.º 22
0
 private static string AssemblySearchPathArgument()
 {
     return(" -e " + CommandLineFormatter.PrepareFileName(GetUnityEditorManagedPath()) + " -p " + CommandLineFormatter.PrepareFileName(Application.dataPath));
 }
Ejemplo n.º 23
0
        public NetCoreProgram(string executable, string arguments, Action <ProcessStartInfo> setupStartInfo)
        {
            if (!NetCoreProgram.IsNetCoreAvailable())
            {
                UnityEngine.Debug.LogError("Creating NetCoreProgram, but IsNetCoreAvailable() == false; fix the caller!");
            }
            ProcessStartInfo processStartInfo = NetCoreProgram.CreateDotNetCoreStartInfoForArgs(CommandLineFormatter.PrepareFileName(executable) + " " + arguments);

            if (setupStartInfo != null)
            {
                setupStartInfo(processStartInfo);
            }
            this._process.StartInfo = processStartInfo;
        }
        public static bool DoesAssemblyRequireUpgrade(string assemblyFullPath)
        {
            if (!File.Exists(assemblyFullPath))
            {
                return(false);
            }

            if (!AssemblyHelper.IsManagedAssembly(assemblyFullPath))
            {
                return(false);
            }

            if (!MayContainUpdatableReferences(assemblyFullPath))
            {
                return(false);
            }

            string stdOut, stdErr;
            var    ret = RunUpdatingProgram("AssemblyUpdater.exe", TimeStampArgument() + APIVersionArgument() + "--check-update-required -a " + CommandLineFormatter.PrepareFileName(assemblyFullPath) + AssemblySearchPathArgument() + ConfigurationProviderAssembliesPathArgument(), out stdOut, out stdErr);
            {
                Console.WriteLine("{0}{1}", stdOut, stdErr);
                switch (ret)
                {
                // See AssemblyUpdater/Program.cs
                case 0:
                case 1: return(false);

                case 2: return(true);

                default:
                    Debug.LogError(stdOut + Environment.NewLine + stdErr);
                    return(false);
                }
            }
        }
Ejemplo n.º 25
0
 static string PrepareFileName(string fileName)
 {
     return(CommandLineFormatter.PrepareFileName(fileName));
 }
Ejemplo n.º 26
0
        private static bool StripAssembliesTo(string[] assemblies, string[] searchDirs, string outputFolder, string workingDirectory, out string output, out string error, string linkerPath, IIl2CppPlatformProvider platformProvider, IEnumerable <string> additionalBlacklist, BuildTargetGroup buildTargetGroup, ManagedStrippingLevel managedStrippingLevel)
        {
            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }

            additionalBlacklist = additionalBlacklist.Select(s => Path.IsPathRooted(s) ? s : Path.Combine(workingDirectory, s)).Where(File.Exists);

            var userBlackLists = GetUserBlacklistFiles();

            foreach (var ub in userBlackLists)
            {
                Console.WriteLine("UserBlackList: " + ub);
            }

            additionalBlacklist = additionalBlacklist.Concat(userBlackLists);

            var args = new List <string>
            {
                "-out=\"" + outputFolder + "\"",
                "-x=\"" + GetModuleWhitelist("Core", platformProvider.moduleStrippingInformationFolder) + "\"",
            };

            args.AddRange(additionalBlacklist.Select(path => "-x \"" + path + "\""));

            args.AddRange(searchDirs.Select(d => "-d \"" + d + "\""));
            args.AddRange(assemblies.Select(assembly => "--include-unity-root-assembly=\"" + Path.GetFullPath(assembly) + "\""));
            args.Add($"--dotnetruntime={GetRuntimeArgumentValueForLinker(buildTargetGroup)}");
            args.Add($"--dotnetprofile={GetProfileArgumentValueForLinker(buildTargetGroup)}");
            args.Add("--use-editor-options");
            args.Add($"--include-directory={CommandLineFormatter.PrepareFileName(workingDirectory)}");

            if (EditorUserBuildSettings.allowDebugging)
            {
                args.Add("--editor-settings-flag=AllowDebugging");
            }

            if (EditorUserBuildSettings.development)
            {
                args.Add("--editor-settings-flag=Development");
            }

            args.Add($"--rule-set={GetRuleSetForStrippingLevel(managedStrippingLevel)}");

            // One final check to make sure we only run high on latest runtime.
            if ((managedStrippingLevel == ManagedStrippingLevel.High) && (PlayerSettingsEditor.IsLatestApiCompatibility(PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup))))
            {
                // Prepare the arguments to run the UnityLinker.  When in high mode, need to also
                // supply the IL2CPP compiler platform and compiler architecture.  When the scripting backend
                // is not IL2CPP, we have to map those strings and use a utility function to figure out proper strings.

                // Currently only need to do this on the non aot platforms of Android, Windows, Mac, Linux.
                var compilerPlatform     = "";
                var compilerArchitecture = "";
                Il2CppNativeCodeBuilder il2cppNativeCodeBuilder = platformProvider.CreateIl2CppNativeCodeBuilder();
                if (il2cppNativeCodeBuilder != null)
                {
                    compilerPlatform     = il2cppNativeCodeBuilder.CompilerPlatform;
                    compilerArchitecture = il2cppNativeCodeBuilder.CompilerArchitecture;
                }
                else
                {
                    GetUnityLinkerPlatformStringsFromBuildTarget(platformProvider.target, out compilerPlatform, out compilerArchitecture);
                }

                args.Add($"--platform={compilerPlatform}");
                if (platformProvider.target != BuildTarget.Android)
                {
                    args.Add($"--architecture={compilerArchitecture}");
                }
            }

            var additionalArgs = System.Environment.GetEnvironmentVariable("UNITYLINKER_ADDITIONAL_ARGS");

            if (!string.IsNullOrEmpty(additionalArgs))
            {
                args.Add(additionalArgs);
            }

            additionalArgs = Debug.GetDiagnosticSwitch("VMUnityLinkerAdditionalArgs") as string;
            if (!string.IsNullOrEmpty(additionalArgs))
            {
                args.Add(additionalArgs.Trim('\''));
            }

            return(RunAssemblyLinker(args, out output, out error, linkerPath, workingDirectory));
        }
Ejemplo n.º 27
0
        private void ConvertPlayerDlltoCpp(Il2CppBuildPipelineData data, string outputDirectory, string workingDirectory, bool platformSupportsManagedDebugging)
        {
            ProcessBuildPipelineOnBeforeConvertRun(m_PlatformProvider.buildReport, data);

            var arguments = new List <string>();

            arguments.Add("--convert-to-cpp");

            if (m_PlatformProvider.emitNullChecks)
            {
                arguments.Add("--emit-null-checks");
            }

            if (m_PlatformProvider.enableStackTraces)
            {
                arguments.Add("--enable-stacktrace");
            }

            if (m_PlatformProvider.enableArrayBoundsCheck)
            {
                arguments.Add("--enable-array-bounds-check");
            }

            if (m_PlatformProvider.enableDivideByZeroCheck)
            {
                arguments.Add("--enable-divide-by-zero-check");
            }

            if (m_PlatformProvider.development && m_PlatformProvider.enableDeepProfilingSupport)
            {
                arguments.Add("--enable-deep-profiler");
            }

            if (m_BuildForMonoRuntime)
            {
                arguments.Add("--mono-runtime");
            }

            var buildTargetGroup      = BuildPipeline.GetBuildTargetGroup(m_PlatformProvider.target);
            var apiCompatibilityLevel = PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup);

            arguments.Add(string.Format("--dotnetprofile=\"{0}\"", IL2CPPUtils.ApiCompatibilityLevelToDotNetProfileArgument(apiCompatibilityLevel)));


            var il2CppNativeCodeBuilder = m_PlatformProvider.CreateIl2CppNativeCodeBuilder();

            if (il2CppNativeCodeBuilder != null)
            {
                var compilerConfiguration = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup);
                Il2CppNativeCodeBuilderUtils.ClearAndPrepareCacheDirectory(il2CppNativeCodeBuilder);
                arguments.AddRange(Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, OutputFileRelativePath(), m_PlatformProvider.includePaths, m_PlatformProvider.libraryPaths, compilerConfiguration));
            }

            arguments.AddRange(IL2CPPUtils.GetDebuggerIL2CPPArguments(m_PlatformProvider, buildTargetGroup));
            arguments.AddRange(IL2CPPUtils.GetBuildingIL2CPPArguments(m_PlatformProvider, buildTargetGroup));
            arguments.Add($"--map-file-parser={CommandLineFormatter.PrepareFileName(GetMapFileParserPath())}");

            var additionalArgs = IL2CPPUtils.GetAdditionalArguments();

            if (!string.IsNullOrEmpty(additionalArgs))
            {
                arguments.Add(additionalArgs);
            }

            arguments.Add($"--directory={CommandLineFormatter.PrepareFileName(Path.GetFullPath(data.inputDirectory))}");

            arguments.Add($"--generatedcppdir={CommandLineFormatter.PrepareFileName(Path.GetFullPath(outputDirectory))}");

            // NOTE: any arguments added here that affect how generated code is built need
            // to also be added to PlatformDependent\Win\Extensions\Managed\VisualStudioProjectHelpers.cs
            // as that file generated project files that invoke back into IL2CPP in order to build
            // generated code

            string progressMessage = "Converting managed assemblies to C++";

            if (il2CppNativeCodeBuilder != null)
            {
                progressMessage = "Building native binary with IL2CPP...";
            }

            if (EditorUtility.DisplayCancelableProgressBar("Building Player", progressMessage, 0.3f))
            {
                throw new OperationCanceledException();
            }

            Action <ProcessStartInfo> setupStartInfo = null;

            if (il2CppNativeCodeBuilder != null)
            {
                setupStartInfo = il2CppNativeCodeBuilder.SetupStartInfo;
            }

            if (PlayerBuildInterface.ExtraTypesProvider != null)
            {
                var extraTypes = new HashSet <string>();
                foreach (var extraType in PlayerBuildInterface.ExtraTypesProvider())
                {
                    extraTypes.Add(extraType);
                }

                var tempFile = Path.GetFullPath(Path.Combine(m_TempFolder, "extra-types.txt"));
                File.WriteAllLines(tempFile, extraTypes.ToArray());
                arguments.Add($"--extra-types-file={CommandLineFormatter.PrepareFileName(tempFile)}");
            }

            RunIl2CppWithArguments(arguments, setupStartInfo, workingDirectory);
        }
Ejemplo n.º 28
0
 private static string AssemblySearchPathArgument()
 {
     return(" -s " + CommandLineFormatter.PrepareFileName(APIUpdaterHelper.GetUnityEngineDLLPath()) + ",+" + CommandLineFormatter.PrepareFileName(Application.dataPath));
 }
 private static string ResolveAssemblyPath(string assemblyPath)
 {
     return(CommandLineFormatter.PrepareFileName(assemblyPath));
 }
Ejemplo n.º 30
0
 private static string AssemblySearchPathArgument()
 {
     string[] textArray1 = new string[] { " -s ", CommandLineFormatter.PrepareFileName(Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Managed")), ",+", CommandLineFormatter.PrepareFileName(Path.Combine(EditorApplication.applicationContentsPath, "UnityExtensions/Unity")), ",+", CommandLineFormatter.PrepareFileName(Application.dataPath) };
     return(string.Concat(textArray1));
 }