diff options
author | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2019-12-28 19:12:32 +0100 |
---|---|---|
committer | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2019-12-28 20:48:55 +0100 |
commit | 86274b9fc9e63c0eb6112bf4d87d67dd97fb0b86 (patch) | |
tree | 36b9c9909da20b9c7f0310a506542474bf2d1cba /modules/mono/build_scripts/godot_tools_build.py | |
parent | 318c69351624f7794c51b5385d252af397c0404a (diff) |
Mono/C#: Re-structure API solution and GodotTools post-build target
Previously we had a placeholder solution called 'Managed' to benefit from
tooling while editing the a part of the C# API.
Later the bindings generator would create the final 'GodotSharp' solution
including these C# files as well as the auto-generated C# API.
Now we replaced the 'Managed' solution with the final 'GodotSharp' solution
which is no longer auto-generated, and the bindings generator only takes
care of the auto-generated C# API.
This has the following benefits:
- It's less confusing as there will no longer be two versions of the same file
(the original and a generated copy of it). Now there's only one.
- We no longer need placeholder for auto-generated API classes, like Node or
Resource. We used them for benefiting from tooling. Now we can just use the
auto-generated API itself.
- Simplifies the build system and bindings generator. Removed lot of code
that is not needed anymore.
Also added a post-build target to the GodotTools project to copy the output to
the data dir. This makes it easy to iterate when doing changes to GodotTools,
as SCons doesn't have to be executed anymore just to copy these new files.
Diffstat (limited to 'modules/mono/build_scripts/godot_tools_build.py')
-rw-r--r-- | modules/mono/build_scripts/godot_tools_build.py | 90 |
1 files changed, 7 insertions, 83 deletions
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) |