Advertisement
Guest User

Untitled

a guest
Feb 18th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.18 KB | None | 0 0
  1. #!python
  2.  
  3. import os, subprocess, platform
  4.  
  5.  
  6. env = Environment()
  7. host_platform = platform.system()
  8. target_platform = ARGUMENTS.get("p", "linux")
  9. target_arch = ARGUMENTS.get("a", "64")
  10. # default to debug build, must be same setting as used for cpp_bindings
  11. target = ARGUMENTS.get("target", "debug")
  12. # Local dependency paths, adapt them to your setup
  13. godot_headers = ARGUMENTS.get("headers", "../godot_headers/")
  14. godot_bin_path = ARGUMENTS.get("godotbinpath", os.getenv("GODOT_BIN_PATH", "../godot_fork/bin/godot.x11.tools.64.llvm"))
  15. result_path = 'bin/'
  16. result_name = 'libgodot_cpp_bindings'
  17.  
  18.  
  19. # This makes sure to keep the session environment variables on windows,
  20. # that way you can run scons in a vs 2017 prompt and it will find all the required tools
  21. env = Environment()
  22. if target_platform == "windows":
  23.     env = Environment(ENV = os.environ)
  24.  
  25. if ARGUMENTS.get("use_llvm", "no") == "yes":
  26.     env["CXX"] = "clang++"
  27.  
  28. def add_sources(sources, directory):
  29.     for file in os.listdir(directory):
  30.         if file.endswith('.cpp'):
  31.             sources.append(directory + '/' + file)
  32.  
  33.  
  34.  
  35. if target_platform == "linux":
  36.     result_name += '.linux.' + target_arch
  37.  
  38.     env['CXX']='gcc-5'
  39.     env.Append(CCFLAGS = [ '-fPIC', '-g', '-O3', '-std=c++14', '-Wwrite-strings' ])
  40.     env.Append(LINKFLAGS = [ '-Wl,-R,\'$$ORIGIN\'' ])
  41.  
  42.     if target_arch == "32":
  43.         env.Append(CCFLAGS = [ '-m32' ])
  44.         env.Append(LINKFLAGS = [ '-m32' ])
  45.     elif target_arch == "64":
  46.         env.Append(CCFLAGS = [ '-m64' ])
  47.         env.Append(LINKFLAGS = [ '-m64' ])
  48.  
  49. elif target_platform == "windows":
  50.     result_name += '.windows.' + target_arch
  51.  
  52.     if host_platform == "Windows":
  53.         result_name += '.dll'
  54.  
  55.         env.Append(LINKFLAGS = [ '/WX' ])
  56.         if target == "debug":
  57.             env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '/MDd' ])
  58.         else:
  59.             env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '/MD' ])
  60.     else:
  61.         if target_arch == "32":
  62.             env['CXX']='i686-w64-mingw32-g++'
  63.         elif target_arch == "64":
  64.             env['CXX']='x86_64-w64-mingw32-g++'
  65.  
  66.         env.Append(CCFLAGS = [ '-g', '-O3', '-std=c++14', '-Wwrite-strings' ])
  67.         env.Append(LINKFLAGS = [ '--static', '-Wl,--no-undefined', '-static-libgcc', '-static-libstdc++' ])
  68.  
  69. elif platform == "osx":
  70.     env.Append(CCFLAGS = [ '-g','-O3', '-std=c++14', '-arch', 'x86_64' ])
  71.     env.Append(LINKFLAGS = [ '-arch', 'x86_64', '-framework', 'Cocoa', '-Wl,-undefined,dynamic_lookup' ])
  72.  
  73.  
  74. env.Append(CPPPATH=['.', godot_headers, 'include', 'include/core'])
  75.  
  76.  
  77. if ARGUMENTS.get("generate_bindings", "no") == "yes":
  78.     # TODO Generating the API should be done only if the Godot build is more recent than the JSON file
  79.     json_api_file = 'godot_api.json'
  80.  
  81.     subprocess.call([os.path.expanduser(godot_bin_path), '--gdnative-generate-json-api', json_api_file])
  82.  
  83.     # actually create the bindings here
  84.    
  85.     import binding_generator
  86.  
  87.     binding_generator.generate_bindings(json_api_file)
  88.  
  89.  
  90. sources = []
  91. add_sources(sources, "src/core")
  92. add_sources(sources, "src")
  93.  
  94.  
  95. library = env.StaticLibrary(target=result_path + '/' + result_name, source=sources)
  96. Default(library)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement