Example #1
0
        private static bool CopyApiAssembly(string srcDir, string dstDir, string assemblyName, ApiAssemblyType apiType)
        {
            // Create destination directory if needed
            if (!Directory.Exists(dstDir))
            {
                try
                {
                    Directory.CreateDirectory(dstDir);
                }
                catch (IOException e)
                {
                    ShowBuildErrorDialog($"Failed to create destination directory for the API assemblies. Exception message: {e.Message}");
                    return(false);
                }
            }

            string assemblyFile = assemblyName + ".dll";
            string assemblySrc  = Path.Combine(srcDir, assemblyFile);
            string assemblyDst  = Path.Combine(dstDir, assemblyFile);

            if (!File.Exists(assemblyDst) || File.GetLastWriteTime(assemblySrc) > File.GetLastWriteTime(assemblyDst) ||
                Internal.MetadataIsApiAssemblyInvalidated(apiType))
            {
                string xmlFile = $"{assemblyName}.xml";
                string pdbFile = $"{assemblyName}.pdb";

                try
                {
                    File.Copy(Path.Combine(srcDir, xmlFile), Path.Combine(dstDir, xmlFile));
                }
                catch (IOException e)
                {
                    Godot.GD.PushWarning(e.ToString());
                }

                try
                {
                    File.Copy(Path.Combine(srcDir, pdbFile), Path.Combine(dstDir, pdbFile));
                }
                catch (IOException e)
                {
                    Godot.GD.PushWarning(e.ToString());
                }

                try
                {
                    File.Copy(assemblySrc, assemblyDst);
                }
                catch (IOException e)
                {
                    ShowBuildErrorDialog($"Failed to copy {assemblyFile}. Exception message: {e.Message}");
                    return(false);
                }

                Internal.MetadataSetApiAssemblyInvalidated(apiType, false);
            }

            return(true);
        }
        public static bool EditorBuildCallback()
        {
            if (!File.Exists(GodotSharpDirs.ProjectSlnPath))
            {
                return(true); // No solution to build
            }
            string editorScriptsMetadataPath = Path.Combine(GodotSharpDirs.ResMetadataDir, "scripts_metadata.editor");
            string playerScriptsMetadataPath = Path.Combine(GodotSharpDirs.ResMetadataDir, "scripts_metadata.editor_player");

            CsProjOperations.GenerateScriptsMetadata(GodotSharpDirs.ProjectCsProjPath, editorScriptsMetadataPath);

            if (File.Exists(editorScriptsMetadataPath))
            {
                File.Copy(editorScriptsMetadataPath, playerScriptsMetadataPath);
            }

            var currentPlayRequest = GodotSharpEditor.Instance.CurrentPlaySettings;

            if (currentPlayRequest != null)
            {
                if (currentPlayRequest.Value.HasDebugger)
                {
                    // Set the environment variable that will tell the player to connect to the IDE debugger
                    // TODO: We should probably add a better way to do this
                    Environment.SetEnvironmentVariable("GODOT_MONO_DEBUGGER_AGENT",
                                                       "--debugger-agent=transport=dt_socket" +
                                                       $",address={currentPlayRequest.Value.DebuggerHost}:{currentPlayRequest.Value.DebuggerPort}" +
                                                       ",server=n");
                }

                if (!currentPlayRequest.Value.BuildBeforePlaying)
                {
                    return(true); // Requested play from an external editor/IDE which already built the project
                }
            }

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

            return(BuildProjectBlocking("Debug", godotDefines));
        }
Example #3
0
        public static bool EditorBuildCallback()
        {
            if (!File.Exists(GodotSharpDirs.ProjectSlnPath))
            {
                return(true); // No solution to build
            }
            string editorScriptsMetadataPath = Path.Combine(GodotSharpDirs.ResMetadataDir, "scripts_metadata.editor");
            string playerScriptsMetadataPath = Path.Combine(GodotSharpDirs.ResMetadataDir, "scripts_metadata.editor_player");

            CsProjOperations.GenerateScriptsMetadata(GodotSharpDirs.ProjectCsProjPath, editorScriptsMetadataPath);

            if (File.Exists(editorScriptsMetadataPath))
            {
                File.Copy(editorScriptsMetadataPath, playerScriptsMetadataPath);
            }

            if (GodotSharpEditor.Instance.SkipBuildBeforePlaying)
            {
                return(true); // Requested play from an external editor/IDE which already built the project
            }
            return(BuildProjectBlocking("Debug"));
        }
Example #4
0
        public static bool EditorBuildCallback()
        {
            if (!File.Exists(GodotSharpDirs.ProjectSlnPath))
            {
                return(true); // 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))
            {
                File.Copy(editorScriptsMetadataPath, playerScriptsMetadataPath);
            }

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

            return(BuildProjectBlocking("Tools", godotDefines));
        }