コード例 #1
0
ファイル: GodotSharpBuilds.cs プロジェクト: zloop1982/godot
        private static string _ApiFolderName(ApiAssemblyType apiType)
        {
            ulong apiHash = apiType == ApiAssemblyType.Core ?
                            Internal.GetCoreApiHash() :
                            Internal.GetEditorApiHash();

            return($"{apiHash}_{BindingsGenerator.Version}_{BindingsGenerator.CsGlueVersion}");
        }
コード例 #2
0
ファイル: Internal.cs プロジェクト: sunn-e/godot
 private static extern void internal_MetadataSetApiAssemblyInvalidated(ApiAssemblyType apiType, bool invalidated);
コード例 #3
0
ファイル: Internal.cs プロジェクト: sunn-e/godot
 private static extern bool internal_MetadataIsApiAssemblyInvalidated(ApiAssemblyType apiType);
コード例 #4
0
ファイル: Internal.cs プロジェクト: sunn-e/godot
 public static void MetadataSetApiAssemblyInvalidated(ApiAssemblyType apiType, bool invalidated) =>
 internal_MetadataSetApiAssemblyInvalidated(apiType, invalidated);
コード例 #5
0
ファイル: Internal.cs プロジェクト: sunn-e/godot
 public static bool MetadataIsApiAssemblyInvalidated(ApiAssemblyType apiType) =>
 internal_MetadataIsApiAssemblyInvalidated(apiType);
コード例 #6
0
        public static bool MakeApiAssembly(ApiAssemblyType apiType, string config)
        {
            string apiName = apiType == ApiAssemblyType.Core ? ApiAssemblyNames.Core : ApiAssemblyNames.Editor;

            string editorPrebuiltApiDir = Path.Combine(GodotSharpDirs.DataEditorPrebuiltApiDir, config);
            string resAssembliesDir     = Path.Combine(GodotSharpDirs.ResAssembliesBaseDir, config);

            if (File.Exists(Path.Combine(editorPrebuiltApiDir, $"{apiName}.dll")))
            {
                using (var copyProgress = new EditorProgress("mono_copy_prebuilt_api_assembly", $"Copying prebuilt {apiName} assembly...", 1))
                {
                    copyProgress.Step($"Copying {apiName} assembly", 0);
                    return(CopyApiAssembly(editorPrebuiltApiDir, resAssembliesDir, apiName, apiType));
                }
            }

            const string apiSolutionName = ApiAssemblyNames.SolutionName;

            using (var pr = new EditorProgress($"mono_build_release_{apiSolutionName}", $"Building {apiSolutionName} solution...", 3))
            {
                pr.Step($"Generating {apiSolutionName} solution", 0);

                string apiSlnDir  = Path.Combine(GodotSharpDirs.MonoSolutionsDir, _ApiFolderName(ApiAssemblyType.Core));
                string apiSlnFile = Path.Combine(apiSlnDir, $"{apiSolutionName}.sln");

                if (!Directory.Exists(apiSlnDir) || !File.Exists(apiSlnFile))
                {
                    var bindingsGenerator = new BindingsGenerator();

                    if (!Godot.OS.IsStdoutVerbose())
                    {
                        bindingsGenerator.LogPrintEnabled = false;
                    }

                    Error err = bindingsGenerator.GenerateCsApi(apiSlnDir);
                    if (err != Error.Ok)
                    {
                        ShowBuildErrorDialog($"Failed to generate {apiSolutionName} solution. Error: {err}");
                        return(false);
                    }
                }

                pr.Step($"Building {apiSolutionName} solution", 1);

                if (!BuildApiSolution(apiSlnDir, config))
                {
                    return(false);
                }

                pr.Step($"Copying {apiName} assembly", 2);

                // Copy the built assembly to the assemblies directory
                string apiAssemblyDir = Path.Combine(apiSlnDir, apiName, "bin", config);
                if (!CopyApiAssembly(apiAssemblyDir, resAssembliesDir, apiName, apiType))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #7
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);
        }