godot_net_sdk_build.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Build Godot.NET.Sdk solution
  2. import os
  3. from SCons.Script import Dir
  4. def build_godot_net_sdk(source, target, env):
  5. # source and target elements are of type SCons.Node.FS.File, hence why we convert them to str
  6. module_dir = env["module_dir"]
  7. solution_path = os.path.join(module_dir, "editor/Godot.NET.Sdk/Godot.NET.Sdk.sln")
  8. build_config = "Release"
  9. from .solution_builder import build_solution
  10. extra_msbuild_args = ["/p:GodotPlatform=" + env["platform"]]
  11. build_solution(env, solution_path, build_config, extra_msbuild_args)
  12. # No need to copy targets. The Godot.NET.Sdk csproj takes care of copying them.
  13. def build(env_mono):
  14. assert env_mono["tools"]
  15. output_dir = Dir("#bin").abspath
  16. editor_tools_dir = os.path.join(output_dir, "GodotSharp", "Tools")
  17. nupkgs_dir = os.path.join(editor_tools_dir, "nupkgs")
  18. module_dir = os.getcwd()
  19. package_version_file = os.path.join(
  20. module_dir, "editor", "Godot.NET.Sdk", "Godot.NET.Sdk", "Godot.NET.Sdk_PackageVersion.txt"
  21. )
  22. with open(package_version_file, mode="r") as f:
  23. version = f.read().strip()
  24. target_filenames = ["Godot.NET.Sdk.%s.nupkg" % version]
  25. targets = [os.path.join(nupkgs_dir, filename) for filename in target_filenames]
  26. cmd = env_mono.CommandNoCache(targets, [], build_godot_net_sdk, module_dir=module_dir)
  27. env_mono.AlwaysBuild(cmd)