diff options
Diffstat (limited to 'modules/mono/build_scripts')
-rw-r--r-- | modules/mono/build_scripts/api_solution_build.py | 5 | ||||
-rw-r--r-- | modules/mono/build_scripts/gen_cs_glue_version.py | 20 | ||||
-rw-r--r-- | modules/mono/build_scripts/godot_tools_build.py | 90 | ||||
-rw-r--r-- | modules/mono/build_scripts/make_cs_compressed_header.py | 62 |
4 files changed, 28 insertions, 149 deletions
diff --git a/modules/mono/build_scripts/api_solution_build.py b/modules/mono/build_scripts/api_solution_build.py index be54d0a679..639197c285 100644 --- a/modules/mono/build_scripts/api_solution_build.py +++ b/modules/mono/build_scripts/api_solution_build.py @@ -10,10 +10,7 @@ def build_api_solution(source, target, env): module_dir = env['module_dir'] - solution_path = os.path.join(module_dir, 'glue/Managed/Generated/GodotSharp.sln') - - if not os.path.isfile(solution_path): - raise RuntimeError("Godot API solution not found. Did you forget to run '--generate-mono-glue'?") + solution_path = os.path.join(module_dir, 'glue/GodotSharp/GodotSharp.sln') build_config = env['solution_build_config'] diff --git a/modules/mono/build_scripts/gen_cs_glue_version.py b/modules/mono/build_scripts/gen_cs_glue_version.py new file mode 100644 index 0000000000..5d1056c2fc --- /dev/null +++ b/modules/mono/build_scripts/gen_cs_glue_version.py @@ -0,0 +1,20 @@ + +def generate_header(solution_dir, version_header_dst): + import os + latest_mtime = 0 + for root, dirs, files in os.walk(solution_dir, topdown=True): + dirs[:] = [d for d in dirs if d not in ['Generated']] # Ignored generated files + files = [f for f in files if f.endswith('.cs')] + for file in files: + filepath = os.path.join(root, file) + mtime = os.path.getmtime(filepath) + latest_mtime = mtime if mtime > latest_mtime else latest_mtime + + glue_version = int(latest_mtime) # The latest modified time will do for now + + with open(version_header_dst, 'w') as version_header: + version_header.write('/* THIS FILE IS GENERATED DO NOT EDIT */\n') + version_header.write('#ifndef CS_GLUE_VERSION_H\n') + version_header.write('#define CS_GLUE_VERSION_H\n\n') + version_header.write('#define CS_GLUE_VERSION UINT32_C(' + str(glue_version) + ')\n') + version_header.write('\n#endif // CS_GLUE_VERSION_H\n') diff --git a/modules/mono/build_scripts/godot_tools_build.py b/modules/mono/build_scripts/godot_tools_build.py index 6e5273f5e0..6846a86240 100644 --- a/modules/mono/build_scripts/godot_tools_build.py +++ b/modules/mono/build_scripts/godot_tools_build.py @@ -13,65 +13,13 @@ def build_godot_tools(source, target, env): solution_path = os.path.join(module_dir, 'editor/GodotTools/GodotTools.sln') build_config = 'Debug' if env['target'] == 'debug' else 'Release' - from . solution_builder import build_solution, nuget_restore - nuget_restore(env, solution_path) - build_solution(env, solution_path, build_config) - - # Copy targets - - solution_dir = os.path.abspath(os.path.join(solution_path, os.pardir)) - - src_dir = os.path.join(solution_dir, 'GodotTools', 'bin', build_config) - dst_dir = os.path.abspath(os.path.join(str(target[0]), os.pardir)) - - if not os.path.isdir(dst_dir): - assert not os.path.isfile(dst_dir) - os.makedirs(dst_dir) - - def copy_target(target_path): - from shutil import copy - filename = os.path.basename(target_path) - copy(os.path.join(src_dir, filename), target_path) - - for scons_target in target: - copy_target(str(scons_target)) - - -def build_godot_tools_project_editor(source, target, env): - # source and target elements are of type SCons.Node.FS.File, hence why we convert them to str - - module_dir = env['module_dir'] - - project_name = 'GodotTools.ProjectEditor' - - csproj_dir = os.path.join(module_dir, 'editor/GodotTools', project_name) - csproj_path = os.path.join(csproj_dir, project_name + '.csproj') - build_config = 'Debug' if env['target'] == 'debug' else 'Release' + # Custom build target to make sure output is always copied to the data dir. + extra_build_args = ['/Target=BuildAlwaysCopyToDataDir'] from . solution_builder import build_solution, nuget_restore - - # Make sure to restore NuGet packages in the project directory for the project to find it - nuget_restore(env, os.path.join(csproj_dir, 'packages.config'), '-PackagesDirectory', - os.path.join(csproj_dir, 'packages')) - - build_solution(env, csproj_path, build_config) - - # Copy targets - - src_dir = os.path.join(csproj_dir, 'bin', build_config) - dst_dir = os.path.abspath(os.path.join(str(target[0]), os.pardir)) - - if not os.path.isdir(dst_dir): - assert not os.path.isfile(dst_dir) - os.makedirs(dst_dir) - - def copy_target(target_path): - from shutil import copy - filename = os.path.basename(target_path) - copy(os.path.join(src_dir, filename), target_path) - - for scons_target in target: - copy_target(str(scons_target)) + nuget_restore(env, solution_path) + build_solution(env, solution_path, build_config, extra_build_args) + # No need to copy targets. The GodotTools csproj takes care of copying them. def build(env_mono, api_sln_cmd): @@ -80,36 +28,12 @@ def build(env_mono, api_sln_cmd): output_dir = Dir('#bin').abspath editor_tools_dir = os.path.join(output_dir, 'GodotSharp', 'Tools') - target_filenames = [ - 'GodotTools.dll', 'GodotTools.IdeConnection.dll', 'GodotTools.BuildLogger.dll', - 'GodotTools.ProjectEditor.dll', 'DotNet.Glob.dll', 'GodotTools.Core.dll', - 'JetBrains.Annotations.dll', 'Newtonsoft.Json.dll' - ] + target_filenames = ['GodotTools.dll'] if env_mono['target'] == 'debug': - target_filenames += [ - 'GodotTools.pdb', 'GodotTools.IdeConnection.pdb', 'GodotTools.BuildLogger.pdb', - 'GodotTools.ProjectEditor.pdb', 'GodotTools.Core.pdb' - ] + target_filenames += ['GodotTools.pdb'] targets = [os.path.join(editor_tools_dir, filename) for filename in target_filenames] cmd = env_mono.CommandNoCache(targets, api_sln_cmd, build_godot_tools, module_dir=os.getcwd()) env_mono.AlwaysBuild(cmd) - - -def build_project_editor_only(env_mono): - assert env_mono['tools'] - - output_dir = Dir('#bin').abspath - editor_tools_dir = os.path.join(output_dir, 'GodotSharp', 'Tools') - - target_filenames = ['GodotTools.ProjectEditor.dll', 'DotNet.Glob.dll', 'GodotTools.Core.dll'] - - if env_mono['target'] == 'debug': - target_filenames += ['GodotTools.ProjectEditor.pdb', 'GodotTools.Core.pdb'] - - targets = [os.path.join(editor_tools_dir, filename) for filename in target_filenames] - - cmd = env_mono.CommandNoCache(targets, [], build_godot_tools_project_editor, module_dir=os.getcwd()) - env_mono.AlwaysBuild(cmd) diff --git a/modules/mono/build_scripts/make_cs_compressed_header.py b/modules/mono/build_scripts/make_cs_compressed_header.py deleted file mode 100644 index ed49db5bb2..0000000000 --- a/modules/mono/build_scripts/make_cs_compressed_header.py +++ /dev/null @@ -1,62 +0,0 @@ - -def generate_header(src, dst, version_dst): - from compat import byte_to_str - - with open(dst, 'w') as header: - header.write('/* THIS FILE IS GENERATED DO NOT EDIT */\n') - header.write('#ifndef CS_COMPRESSED_H\n') - header.write('#define CS_COMPRESSED_H\n\n') - header.write('#ifdef TOOLS_ENABLED\n\n') - header.write('#include "core/map.h"\n') - header.write('#include "core/ustring.h"\n') - inserted_files = '' - import os - latest_mtime = 0 - cs_file_count = 0 - for root, _, files in os.walk(src): - files = [f for f in files if f.endswith('.cs')] - for file in files: - cs_file_count += 1 - filepath = os.path.join(root, file) - filepath_src_rel = os.path.relpath(filepath, src) - mtime = os.path.getmtime(filepath) - latest_mtime = mtime if mtime > latest_mtime else latest_mtime - with open(filepath, 'rb') as f: - buf = f.read() - decompr_size = len(buf) - import zlib - buf = zlib.compress(buf) - compr_size = len(buf) - name = str(cs_file_count) - header.write('\n') - header.write('// ' + filepath_src_rel + '\n') - header.write('static const int _cs_' + name + '_compressed_size = ' + str(compr_size) + ';\n') - header.write('static const int _cs_' + name + '_uncompressed_size = ' + str(decompr_size) + ';\n') - header.write('static const unsigned char _cs_' + name + '_compressed[] = { ') - for i, buf_idx in enumerate(range(compr_size)): - if i > 0: - header.write(', ') - header.write(byte_to_str(buf[buf_idx])) - header.write(' };\n') - inserted_files += '\tr_files.insert("' + filepath_src_rel.replace('\\', '\\\\') + '", ' \ - 'GodotCsCompressedFile(_cs_' + name + '_compressed_size, ' \ - '_cs_' + name + '_uncompressed_size, ' \ - '_cs_' + name + '_compressed));\n' - header.write('\nstruct GodotCsCompressedFile\n' '{\n' - '\tint compressed_size;\n' '\tint uncompressed_size;\n' '\tconst unsigned char* data;\n' - '\n\tGodotCsCompressedFile(int p_comp_size, int p_uncomp_size, const unsigned char* p_data)\n' - '\t{\n' '\t\tcompressed_size = p_comp_size;\n' '\t\tuncompressed_size = p_uncomp_size;\n' - '\t\tdata = p_data;\n' '\t}\n' '\n\tGodotCsCompressedFile() {}\n' '};\n' - '\nvoid get_compressed_files(Map<String, GodotCsCompressedFile>& r_files)\n' '{\n' + inserted_files + '}\n' - ) - header.write('\n#endif // TOOLS_ENABLED\n') - header.write('\n#endif // CS_COMPRESSED_H\n') - - glue_version = int(latest_mtime) # The latest modified time will do for now - - with open(version_dst, 'w') as version_header: - version_header.write('/* THIS FILE IS GENERATED DO NOT EDIT */\n') - version_header.write('#ifndef CS_GLUE_VERSION_H\n') - version_header.write('#define CS_GLUE_VERSION_H\n\n') - version_header.write('#define CS_GLUE_VERSION UINT32_C(' + str(glue_version) + ')\n') - version_header.write('\n#endif // CS_GLUE_VERSION_H\n') |