api_solution_build.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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', 'GodotSharp.pdb', 'GodotSharp.xml',
  32. 'GodotSharpEditor.dll', 'GodotSharpEditor.pdb', 'GodotSharpEditor.xml'
  33. ]
  34. depend_cmd = []
  35. for build_config in ['Debug', 'Release']:
  36. output_dir = Dir('#bin').abspath
  37. editor_api_dir = os.path.join(output_dir, 'GodotSharp', 'Api', build_config)
  38. targets = [os.path.join(editor_api_dir, filename) for filename in target_filenames]
  39. cmd = env_mono.CommandNoCache(targets, depend_cmd, build_api_solution,
  40. module_dir=os.getcwd(), solution_build_config=build_config)
  41. env_mono.AlwaysBuild(cmd)
  42. # Make the Release build of the API solution depend on the Debug build.
  43. # We do this in order to prevent SCons from building them in parallel,
  44. # which can freak out MSBuild. In many cases, one of the builds would
  45. # hang indefinitely requiring a key to be pressed for it to continue.
  46. depend_cmd = cmd
  47. return depend_cmd