Пример #1
0
        public void _ExportBeginImpl(string[] features, bool isDebug, string path, int flags)
        {
            // TODO Right now there is no way to stop the export process with an error

            if (File.Exists(GodotSharpDirs.ProjectSlnPath))
            {
                string buildConfig = isDebug ? "Debug" : "Release";

                string scriptsMetadataPath = Path.Combine(GodotSharpDirs.ResMetadataDir, $"scripts_metadata.{(isDebug ? "debug" : "release")}");
                CSharpProject.GenerateScriptsMetadata(GodotSharpDirs.ProjectCsProjPath, scriptsMetadataPath);

                AddFile(scriptsMetadataPath, scriptsMetadataPath);

                // Turn export features into defines
                var godotDefines = features;

                if (!GodotSharpBuilds.BuildProjectBlocking(buildConfig, godotDefines))
                {
                    GD.PushError("Failed to build project");
                    return;
                }

                // Add dependency assemblies

                var dependencies = new Godot.Collections.Dictionary <string, string>();

                var projectDllName = (string)ProjectSettings.GetSetting("application/config/name");
                if (projectDllName.Empty())
                {
                    projectDllName = "UnnamedProject";
                }

                string projectDllSrcDir  = Path.Combine(GodotSharpDirs.ResTempAssembliesBaseDir, buildConfig);
                string projectDllSrcPath = Path.Combine(projectDllSrcDir, $"{projectDllName}.dll");

                dependencies[projectDllName] = projectDllSrcPath;

                {
                    string templatesDir  = Internal.FullTemplatesDir;
                    string androidBclDir = Path.Combine(templatesDir, "android-bcl");

                    string customLibDir = features.Contains("Android") && Directory.Exists(androidBclDir) ? androidBclDir : string.Empty;

                    GetExportedAssemblyDependencies(projectDllName, projectDllSrcPath, buildConfig, customLibDir, dependencies);
                }

                string apiConfig        = isDebug ? "Debug" : "Release";
                string resAssembliesDir = Path.Combine(GodotSharpDirs.ResAssembliesBaseDir, apiConfig);

                foreach (var dependency in dependencies)
                {
                    string dependSrcPath = dependency.Value;
                    string dependDstPath = Path.Combine(resAssembliesDir, dependSrcPath.GetFile());
                    AddFile(dependSrcPath, dependDstPath);
                }
            }

            // Mono specific export template extras (data dir)
            ExportDataDirectory(features, isDebug, path);
        }
Пример #2
0
        public void BuildProjectPressed()
        {
            if (!File.Exists(GodotSharpDirs.ProjectSlnPath))
            {
                return; // No solution to build
            }
            string editorScriptsMetadataPath = Path.Combine(GodotSharpDirs.ResMetadataDir, "scripts_metadata.editor");
            string playerScriptsMetadataPath = Path.Combine(GodotSharpDirs.ResMetadataDir, "scripts_metadata.editor_player");

            CSharpProject.GenerateScriptsMetadata(GodotSharpDirs.ProjectCsProjPath, editorScriptsMetadataPath);

            if (File.Exists(editorScriptsMetadataPath))
            {
                try
                {
                    File.Copy(editorScriptsMetadataPath, playerScriptsMetadataPath);
                }
                catch (IOException e)
                {
                    GD.PushError($"Failed to copy scripts metadata file. Exception message: {e.Message}");
                    return;
                }
            }

            var godotDefines = new[]
            {
                OS.GetName(),
                Internal.GodotIs32Bits() ? "32" : "64"
            };

            bool buildSuccess = GodotSharpBuilds.BuildProjectBlocking("Tools", godotDefines);

            if (!buildSuccess)
            {
                return;
            }

            // Notify running game for hot-reload
            Internal.ScriptEditorDebuggerReloadScripts();

            // Hot-reload in the editor
            GodotSharpEditor.Instance.GetNode <HotReloadAssemblyWatcher>("HotReloadAssemblyWatcher").RestartTimer();

            if (Internal.IsAssembliesReloadingNeeded())
            {
                Internal.ReloadAssemblies(softReload: false);
            }
        }