SConstruct 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. # This makes sure to keep the session environment variables on windows,
  9. # that way you can run scons in a vs 2017 prompt and it will find all the required tools
  10. env = Environment()
  11. if platform == "windows":
  12. env = Environment(ENV = os.environ)
  13. if ARGUMENTS.get("use_llvm", "no") == "yes":
  14. env["CXX"] = "clang++"
  15. target = ARGUMENTS.get("target", "debug")
  16. platform = ARGUMENTS.get("p", "linux")
  17. godot_name = "godot." + ("x11" if platform == "linux" else platform) + ".tools.64"
  18. def add_sources(sources, directory):
  19. for file in os.listdir(directory):
  20. if file.endswith('.cpp'):
  21. sources.append(directory + '/' + file)
  22. if platform == "osx":
  23. env.Append(CCFLAGS = ['-g','-O3', '-std=c++14', '-arch', 'x86_64'])
  24. env.Append(LINKFLAGS = ['-arch', 'x86_64', '-framework', 'Cocoa', '-Wl,-undefined,dynamic_lookup'])
  25. if platform == "linux":
  26. env.Append(CCFLAGS = ['-fPIC', '-g','-O3', '-std=c++14'])
  27. env.Append(CPPPATH=['.', godot_headers_path, 'include', 'include/core'])
  28. if platform == "windows":
  29. env.Append(LIBS=[godot_name])
  30. env.Append(LIBPATH=[godot_lib_path])
  31. sources = []
  32. add_sources(sources, "src/core")
  33. if ARGUMENTS.get("generate_bindings", "no") == "yes":
  34. godot_executable = godot_bin_path + godot_name
  35. if env["CXX"] == "clang++":
  36. godot_executable += ".llvm"
  37. if platform == "windows":
  38. godot_executable += ".exe"
  39. # TODO Generating the API should be done only if the Godot build is more recent than the JSON file
  40. json_api_file = 'godot_api.json'
  41. subprocess.call([godot_executable, '--gdnative-generate-json-api', json_api_file])
  42. # actually create the bindings here
  43. import binding_generator
  44. binding_generator.generate_bindings(json_api_file)
  45. add_sources(sources, "src")
  46. library = env.StaticLibrary(target='bin/godot_cpp_bindings', source=sources)
  47. Default(library)