api_solution_build.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # Build the Godot API solution
  2. import os
  3. from SCons.Script import Dir
  4. def build_api_solution(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, "glue/GodotSharp/GodotSharp.sln")
  8. build_config = env["solution_build_config"]
  9. extra_msbuild_args = ["/p:NoWarn=1591"] # Ignore missing documentation warnings
  10. from .solution_builder import build_solution
  11. build_solution(env, solution_path, build_config, extra_msbuild_args=extra_msbuild_args)
  12. # Copy targets
  13. core_src_dir = os.path.abspath(os.path.join(solution_path, os.pardir, "GodotSharp", "bin", build_config))
  14. editor_src_dir = os.path.abspath(os.path.join(solution_path, os.pardir, "GodotSharpEditor", "bin", build_config))
  15. dst_dir = os.path.abspath(os.path.join(str(target[0]), os.pardir))
  16. if not os.path.isdir(dst_dir):
  17. assert not os.path.isfile(dst_dir)
  18. os.makedirs(dst_dir)
  19. def copy_target(target_path):
  20. from shutil import copy
  21. filename = os.path.basename(target_path)
  22. src_path = os.path.join(core_src_dir, filename)
  23. if not os.path.isfile(src_path):
  24. src_path = os.path.join(editor_src_dir, filename)
  25. copy(src_path, target_path)
  26. for scons_target in target:
  27. copy_target(str(scons_target))
  28. def build(env_mono):
  29. assert env_mono["tools"]
  30. target_filenames = [
  31. "GodotSharp.dll",
  32. "GodotSharp.pdb",
  33. "GodotSharp.xml",
  34. "GodotSharpEditor.dll",
  35. "GodotSharpEditor.pdb",
  36. "GodotSharpEditor.xml",
  37. ]
  38. depend_cmd = []
  39. for build_config in ["Debug", "Release"]:
  40. output_dir = Dir("#bin").abspath
  41. editor_api_dir = os.path.join(output_dir, "GodotSharp", "Api", build_config)
  42. targets = [os.path.join(editor_api_dir, filename) for filename in target_filenames]
  43. cmd = env_mono.CommandNoCache(
  44. targets, depend_cmd, build_api_solution, module_dir=os.getcwd(), solution_build_config=build_config
  45. )
  46. env_mono.AlwaysBuild(cmd)
  47. # Make the Release build of the API solution depend on the Debug build.
  48. # We do this in order to prevent SCons from building them in parallel,
  49. # which can freak out MSBuild. In many cases, one of the builds would
  50. # hang indefinitely requiring a key to be pressed for it to continue.
  51. depend_cmd = cmd
  52. return depend_cmd