SConstruct 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!python
  2. import os, subprocess
  3. # Local dependency paths, adapt them to your setup
  4. godot_headers_path = "../godot_headers/"
  5. godot_bin_path = "../godot_fork/bin/"
  6. # for windows
  7. godot_lib_path = "../godot_fork/bin/"
  8. env = Environment()
  9. if ARGUMENTS.get("use_llvm", "no") == "yes":
  10. env["CXX"] = "clang++"
  11. target = ARGUMENTS.get("target", "core")
  12. platform = ARGUMENTS.get("p", "linux")
  13. godot_name = "godot." + ("x11" if platform == "linux" else platform) + ".tools.64"
  14. def add_sources(sources, directory):
  15. for file in os.listdir(directory):
  16. if file.endswith('.cpp'):
  17. sources.append(directory + '/' + file)
  18. if platform == "osx":
  19. env.Append(CCFLAGS = ['-g','-O3', '-std=c++14', '-arch', 'x86_64'])
  20. env.Append(LINKFLAGS = ['-arch', 'x86_64', '-framework', 'Cocoa', '-Wl,-undefined,dynamic_lookup'])
  21. if target == "core":
  22. if platform == "linux":
  23. env.Append(CCFLAGS = ['-g','-O3', '-std=c++14'])
  24. env.Append(CPPPATH=['include/core', godot_headers_path])
  25. if platform == "windows":
  26. env.Append(LIBS=[godot_name + '.lib'])
  27. env.Append(LIBPATH=[godot_lib_path])
  28. env.Append(CPPFLAGS=['-D_GD_CPP_CORE_API_IMPL'])
  29. sources = []
  30. add_sources(sources, "src/core")
  31. library = env.SharedLibrary(target='bin/godot_cpp_core', source=sources)
  32. Default(library)
  33. elif target == "bindings":
  34. if ARGUMENTS.get("generate_bindings", "no") == "yes":
  35. godot_executable = godot_bin_path + godot_name
  36. if env["CXX"] == "clang++":
  37. godot_executable += ".llvm"
  38. if platform == "windows":
  39. godot_executable += ".exe"
  40. # TODO Generating the API should be done only if the Godot build is more recent than the JSON file
  41. json_api_file = 'godot_api.json'
  42. subprocess.call([godot_executable, '--gdnative-generate-json-api', json_api_file])
  43. # actually create the bindings here
  44. import binding_generator
  45. binding_generator.generate_bindings(json_api_file)
  46. if platform == "linux":
  47. if env["CXX"] == "clang++":
  48. env.Append(CCFLAGS = ['-Wno-writable-strings'])
  49. else:
  50. env.Append(CCFLAGS = ['-Wno-write-strings', '-Wno-return-local-addr'])
  51. env.Append(CCFLAGS = ['-g','-O3', '-std=c++14'])
  52. env.Append(LINKFLAGS = ['-Wl,-R,\'$$ORIGIN\''])
  53. env.Append(CPPPATH=['.', godot_headers_path, 'include', 'include/core'])
  54. if platform == "windows":
  55. env.Append(LIBS=[godot_name])
  56. env.Append(LIBPATH=[godot_lib_path])
  57. env.Append(LIBS=['godot_cpp_core'])
  58. env.Append(LIBPATH=['bin'])
  59. env.Append(CPPFLAGS=['-D_GD_CPP_BINDING_IMPL'])
  60. sources = []
  61. add_sources(sources, "src")
  62. library = env.SharedLibrary(target='bin/godot_cpp_bindings', source=sources)
  63. Default(library)