public override BackgroundProcess Build(NativePlugin plugin, NativeBuildOptions buildOptions)
        {
            StringBuilder cmakeArgs = GetBasePluginCMakeArgs(plugin);

            BuildType buildType;

            if (buildOptions.BuildType == BuildType.Default)
            {
                buildType = EditorUserBuildSettings.development ? BuildType.Debug : BuildType.Release;
            }
            else
            {
                buildType = buildOptions.BuildType;
            }
            AddCmakeArg(cmakeArgs, "CMAKE_BUILD_TYPE", buildType.ToString());

            AddCmakeArg(cmakeArgs, "OSX", "ON", "BOOL");
            cmakeArgs.AppendFormat("-B{0} ", "OSX");

            buildOptions.OutputDirectory = CombineFullPath(plugin.buildFolder, "OSX");

            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.FileName         = CMakeHelper.CMakeLocation;
            startInfo.Arguments        = cmakeArgs.ToString();
            startInfo.WorkingDirectory = plugin.buildFolder;

            BackgroundProcess backgroundProcess = new BackgroundProcess(startInfo);

            backgroundProcess.Name = string.Format("Building \"{0}\" for {1}", plugin.Name, "OSX");
            return(backgroundProcess);
        }
        public override BackgroundProcess Build(NativePlugin plugin, NativeBuildOptions buildOptions)
        {
            StringBuilder cmakeArgs = GetBasePluginCMakeArgs(plugin);

            AddCmakeArg(cmakeArgs, "CMAKE_CONFIGURATION_TYPES", "Debug;Release");

            BuildType buildType;

            if (buildOptions.BuildType == BuildType.Default)
            {
                buildType = EditorUserBuildSettings.development ? BuildType.Debug : BuildType.Release;
            }
            else
            {
                buildType = buildOptions.BuildType;
            }
            AddCmakeArg(cmakeArgs, "CMAKE_BUILD_TYPE", buildType.ToString());

            AddCmakeArg(cmakeArgs, "UWP", "ON", "BOOL");
            cmakeArgs.AppendFormat("-B{0}/{1} ", "UWP", buildOptions.Architecture.ToString());

            AddCmakeArg(cmakeArgs, "ARCH", buildOptions.Architecture.ToString(), "STRING");

            AddCmakeArg(cmakeArgs, "CMAKE_SYSTEM_NAME", "WindowsStore");
            AddCmakeArg(cmakeArgs, "CMAKE_SYSTEM_VERSION", "10.0");

            int vsVersion = WindowsBuilder.VisualStudioVersion;

            if (vsVersion == -1)
            {
                vsVersion = WindowsBuilder.InstalledVisualStudios.Last <int>();
            }
            cmakeArgs.AppendFormat("-G \"{0} {1}\" ", "Visual Studio", vsVersion);

            //Default is x86
            if (buildOptions.Architecture == Architecture.x86_64)
            {
                AddCmakeArg(cmakeArgs, "CMAKE_GENERATOR_PLATFORM", "x64", "STRING");
            }
            else if (buildOptions.Architecture == Architecture.ARM)
            {
                AddCmakeArg(cmakeArgs, "CMAKE_GENERATOR_PLATFORM", "ARM", "STRING");
            }

            buildOptions.OutputDirectory = CombineFullPath(plugin.buildFolder, "UWP", buildOptions.Architecture.ToString());

            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.FileName         = CMakeHelper.CMakeLocation;
            startInfo.Arguments        = cmakeArgs.ToString();
            startInfo.WorkingDirectory = plugin.buildFolder;

            BackgroundProcess backgroundProcess = new BackgroundProcess(startInfo);

            backgroundProcess.Name = string.Format("Building \"{0}\" for {1} ({2})", plugin.Name, "Universal Windows", buildOptions.Architecture.ToString());
            return(backgroundProcess);
        }
Beispiel #3
0
        public override BackgroundProcess Build(NativePlugin plugin, NativeBuildOptions buildOptions)
        {
            StringBuilder cmakeArgs = GetBasePluginCMakeArgs(plugin);

            BuildType buildType;

            if (buildOptions.BuildType == BuildType.Default)
            {
                buildType = EditorUserBuildSettings.development ? BuildType.Debug : BuildType.Release;
            }
            else
            {
                buildType = buildOptions.BuildType;
            }
            AddCmakeArg(cmakeArgs, "CMAKE_BUILD_TYPE", buildType.ToString());

            AddCmakeArg(cmakeArgs, "WEBGL", "ON", "BOOL");
            cmakeArgs.AppendFormat("-B{0} ", "WebGL");

            if (EditorPlatform == RuntimePlatform.WindowsEditor)
            {
                cmakeArgs.AppendFormat(string.Format("-G {0} ", "\"MinGW Makefiles\""));
                AddCmakeArg(cmakeArgs, "CMAKE_MAKE_PROGRAM", MinGW32MakeLocation, "FILEPATH");
            }
            else
            {
                cmakeArgs.AppendFormat(string.Format("-G {0} ", "\"Unix Makefiles\""));
            }

            //We need our own copy of the toolchain, because we need to pass --em-config to emcc.
            //args.Add(string.Format("-DCMAKE_TOOLCHAIN_FILE=\"{0}{1}\" ", GetEmscriptenLocation(), "/cmake/Modules/Platform/Emscripten.cmake"));
            AddCmakeArg(cmakeArgs, "CMAKE_TOOLCHAIN_FILE", CombineFullPath(plugin.buildFolder, "../Emscripten.cmake"), "FILEPATH");
            AddCmakeArg(cmakeArgs, "EMSCRIPTEN_ROOT_PATH", GetEmscriptenLocation(), "PATH");

            string emconfig = RefreshEmscriptenConfig(plugin.buildFolder);

            AddCmakeArg(cmakeArgs, "EM_CONFIG", emconfig, "FILEPATH");

            buildOptions.OutputDirectory = CombineFullPath(plugin.buildFolder, "WebGL");

            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.FileName         = CMakeHelper.CMakeLocation;
            startInfo.Arguments        = cmakeArgs.ToString();
            startInfo.WorkingDirectory = plugin.buildFolder;

            BackgroundProcess backgroundProcess = new BackgroundProcess(startInfo);

            backgroundProcess.Name = string.Format("Building \"{0}\" for {1}", plugin.Name, "WebGL");
            return(backgroundProcess);
        }
Beispiel #4
0
        public override BackgroundProcess Build(NativePlugin plugin, NativeBuildOptions buildOptions)
        {
            StringBuilder cmakeArgs = GetBasePluginCMakeArgs(plugin);

            BuildType buildType;

            if (buildOptions.BuildType == BuildType.Default)
            {
                buildType = EditorUserBuildSettings.development ? BuildType.Debug : BuildType.Release;
            }
            else
            {
                buildType = buildOptions.BuildType;
            }
            AddCmakeArg(cmakeArgs, "CMAKE_BUILD_TYPE", buildType.ToString());

            cmakeArgs.AppendFormat("-G {0} ", "\"Unix Makefiles\"");
            AddCmakeArg(cmakeArgs, "ANDROID", "ON", "BOOL");

            string ndkLocation = NDKLocation;

            AddCmakeArg(cmakeArgs, "ANDROID_NDK", ndkLocation, "PATH");

            string toolchain = CombineFullPath(ndkLocation, "build/cmake/android.toolchain.cmake");

            AddCmakeArg(cmakeArgs, "CMAKE_TOOLCHAIN_FILE", "\"" + toolchain + "\"", "FILEPATH");

            string archName = buildOptions.Architecture == Architecture.ARMv7 ? "armeabi-v7a" : "x86";

            AddCmakeArg(cmakeArgs, "ANDROID_ABI", archName);
            cmakeArgs.AppendFormat("-B{0}/{1} ", "Android", archName);
            //Do we need to target a specific api?
            if (buildOptions.AndroidSdkVersion > 0)
            {
                AddCmakeArg(cmakeArgs, "ANDROID_PLATFORM", "android-" + buildOptions.AndroidSdkVersion);
            }

            buildOptions.OutputDirectory = CombineFullPath(plugin.buildFolder, "Android", archName);

            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.FileName         = CMakeHelper.CMakeLocation;
            startInfo.Arguments        = cmakeArgs.ToString();
            startInfo.WorkingDirectory = plugin.buildFolder;

            BackgroundProcess backgroundProcess = new BackgroundProcess(startInfo);

            backgroundProcess.Name = string.Format("Building \"{0}\" for {1} ({2})", plugin.Name, "Android", archName);
            return(backgroundProcess);
        }
        public override BackgroundProcess Install(NativePlugin plugin, NativeBuildOptions buildOptions)
        {
            BackgroundProcess backgroundProcess = base.Install(plugin, buildOptions);
            BuildType         buildType;

            if (buildOptions.BuildType == BuildType.Default)
            {
                buildType = EditorUserBuildSettings.development ? BuildType.Debug : BuildType.Release;
            }
            else
            {
                buildType = buildOptions.BuildType;
            }
            backgroundProcess.Process.StartInfo.Arguments += " --config " + buildType.ToString();
            return(backgroundProcess);
        }
Beispiel #6
0
        public static void Add(BackgroundProcess process)
        {
            BackgroundProcesses.Add(process);
            process.Exited += (exitCode, outputData, errorData) =>
            {
                BackgroundProcesses.Remove(process);
                RepaintEditorWindow();
            };
            process.OutputLine += (outputLine) =>
            {
                RepaintEditorWindow();
            };

            process.ErrorLine += (errorLine) =>
            {
                RepaintEditorWindow();
            };
        }
        public virtual BackgroundProcess Install(NativePlugin plugin, NativeBuildOptions buildOptions)
        {
            if (string.IsNullOrEmpty(buildOptions.OutputDirectory))
            {
                throw new ArgumentNullException("OutputDirectory not set");
            }

            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.FileName         = CMakeHelper.CMakeLocation;
            startInfo.Arguments        = "--build . --target install --clean-first";
            startInfo.WorkingDirectory = buildOptions.OutputDirectory;

            BackgroundProcess backgroundProcess = new BackgroundProcess(startInfo);

            backgroundProcess.Name = string.Format("Installing \"{0}\" for {1} ({2})",
                                                   plugin.Name, buildOptions.BuildPlatform.ToString(), buildOptions.Architecture.ToString());

            return(backgroundProcess);
        }
Beispiel #8
0
        public static void GetCMakeVersion(Action <string> callback, bool refresh = false)
        {
            if (!refresh)
            {
                string version = EditorPrefs.GetString("cmakeVersion");
                if (!string.IsNullOrEmpty(version))
                {
                    cmakeVersion = version;
                    callback(version);
                    return;
                }
            }

            ProcessStartInfo  startInfo         = new ProcessStartInfo(CMakeLocation, "--version");
            BackgroundProcess backgroundProcess = new BackgroundProcess(startInfo);

            backgroundProcess.Name    = "Getting CMake version \"cmake --version\"";
            backgroundProcess.Exited += (exitCode, outputData, errorData) => {
                if (exitCode == 0)
                {
                    outputData = outputData.ToLower();
                    if (outputData.Contains("version"))
                    {
                        outputData = outputData.Substring(outputData.IndexOf("version") + "version".Length).Trim().Split(' ')[0];
                    }
                    EditorPrefs.SetString("cmakeVersion", outputData);
                    cmakeVersion = outputData;
                    callback(outputData);
                }
                else
                {
                    errorData = "Not able to get CMake version. Are you sure CMake is installed?\n" + errorData;
                    throw new Exception(errorData);
                }
            };

            backgroundProcess.Start();
        }
Beispiel #9
0
        public void Build()
        {
            bool nothingToBuild = true;

            foreach (NativeBuildOptions options in buildOptions)
            {
                if (!options.isEnabled)
                {
                    continue;
                }

                nothingToBuild = false;
                PluginBuilderBase builder = PluginBuilderBase.GetBuilderForTarget(options.BuildPlatform);

                builder.PreBuild(this, options);

                BackgroundProcess buildProcess = builder.Build(this, options);

                buildProcess.Exited += (exitCode, outputData, errorData) => {
                    if (!string.IsNullOrEmpty(outputData))
                    {
                        string log = string.Format("{0}:\n{1}", buildProcess.Name, outputData);
                        File.WriteAllText(PluginBuilderBase.CombineFullPath(options.OutputDirectory, "Build_StdOut.log"), log);
                        Debug.Log(log);
                    }

                    if (!string.IsNullOrEmpty(errorData))
                    {
                        string log = string.Format("{0}:\n{1}", buildProcess.Name, errorData);
                        File.WriteAllText(PluginBuilderBase.CombineFullPath(options.OutputDirectory, "Build_StdErr.log"), log);
                        if (exitCode == 0)
                        {
                            Debug.LogWarning(log);
                        }
                        else
                        {
                            Debug.LogError(log);
                        }
                    }
                };

                BackgroundProcess installProcess = builder.Install(this, options);

                installProcess.StartAfter(buildProcess);

                installProcess.Exited += (exitCode, outputData, errorData) => {
                    if (!string.IsNullOrEmpty(outputData))
                    {
                        string log = string.Format("{0}:\n{1}", installProcess.Name, outputData);
                        File.WriteAllText(PluginBuilderBase.CombineFullPath(options.OutputDirectory, "Install_StdOut.log"), log);
                        Debug.Log(log);
                    }

                    if (!string.IsNullOrEmpty(errorData))
                    {
                        string log = string.Format("{0}:\n{1}", installProcess.Name, errorData);
                        File.WriteAllText(PluginBuilderBase.CombineFullPath(options.OutputDirectory, "Install_StdErr.log"), log);
                        if (exitCode == 0)
                        {
                            Debug.LogWarning(log);
                        }
                        else
                        {
                            Debug.LogError(log);
                        }
                    }

                    if (exitCode == 0)
                    {
                        builder.PostBuild(this, options);
                    }
                };

                buildProcess.Start();
            }

            if (nothingToBuild)
            {
                Debug.Log(string.Format("{0}: Nothing to build.", Name));
            }
        }
Beispiel #10
0
 public void StartAfter(BackgroundProcess backgroundProcess, bool stopOnError = true)
 {
     backgroundProcess.nextProcess     = this;
     backgroundProcess.nextStopOnError = stopOnError;
 }