2017-03-06 02:30:46 +00:00
|
|
|
#!python
|
2017-04-18 00:16:57 +00:00
|
|
|
import os, subprocess
|
|
|
|
|
|
|
|
|
|
|
|
# Local dependency paths, adapt them to your setup
|
2017-05-12 19:53:07 +00:00
|
|
|
godot_headers_path = "../godot_headers/"
|
|
|
|
godot_bin_path = "../godot_fork/bin/"
|
|
|
|
|
|
|
|
# for windows
|
|
|
|
godot_lib_path = "../godot_fork/bin/"
|
2017-04-18 00:16:57 +00:00
|
|
|
|
2017-07-29 12:25:57 +00:00
|
|
|
target = ARGUMENTS.get("target", "debug")
|
|
|
|
platform = ARGUMENTS.get("p", "linux")
|
|
|
|
|
2017-07-29 10:50:05 +00:00
|
|
|
# This makes sure to keep the session environment variables on windows,
|
|
|
|
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
|
2017-03-06 02:30:46 +00:00
|
|
|
env = Environment()
|
2017-07-29 10:50:05 +00:00
|
|
|
if platform == "windows":
|
|
|
|
env = Environment(ENV = os.environ)
|
2017-03-09 02:03:21 +00:00
|
|
|
|
2017-03-15 22:19:58 +00:00
|
|
|
if ARGUMENTS.get("use_llvm", "no") == "yes":
|
2017-03-09 02:03:21 +00:00
|
|
|
env["CXX"] = "clang++"
|
2017-03-06 07:49:24 +00:00
|
|
|
|
2017-04-18 00:41:39 +00:00
|
|
|
godot_name = "godot." + ("x11" if platform == "linux" else platform) + ".tools.64"
|
2017-04-18 00:16:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
def add_sources(sources, directory):
|
|
|
|
for file in os.listdir(directory):
|
|
|
|
if file.endswith('.cpp'):
|
|
|
|
sources.append(directory + '/' + file)
|
|
|
|
|
|
|
|
|
2017-06-16 13:50:48 +00:00
|
|
|
if platform == "osx":
|
|
|
|
env.Append(CCFLAGS = ['-g','-O3', '-std=c++14', '-arch', 'x86_64'])
|
|
|
|
env.Append(LINKFLAGS = ['-arch', 'x86_64', '-framework', 'Cocoa', '-Wl,-undefined,dynamic_lookup'])
|
|
|
|
|
2017-07-23 15:53:50 +00:00
|
|
|
if platform == "linux":
|
2017-07-24 12:23:09 +00:00
|
|
|
env.Append(CCFLAGS = ['-fPIC', '-g','-O3', '-std=c++14'])
|
2017-03-06 07:49:24 +00:00
|
|
|
|
2017-07-23 15:53:50 +00:00
|
|
|
env.Append(CPPPATH=['.', godot_headers_path, 'include', 'include/core'])
|
2017-04-18 00:16:57 +00:00
|
|
|
|
2017-07-23 15:53:50 +00:00
|
|
|
if platform == "windows":
|
2017-07-30 12:22:30 +00:00
|
|
|
if target == "debug":
|
|
|
|
env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '/MDd'])
|
|
|
|
else:
|
|
|
|
env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '/MD'])
|
2017-07-23 15:53:50 +00:00
|
|
|
env.Append(LIBS=[godot_name])
|
|
|
|
env.Append(LIBPATH=[godot_lib_path])
|
2017-04-18 00:16:57 +00:00
|
|
|
|
2017-07-23 15:53:50 +00:00
|
|
|
sources = []
|
|
|
|
add_sources(sources, "src/core")
|
2017-04-18 00:41:39 +00:00
|
|
|
|
|
|
|
|
2017-07-23 15:53:50 +00:00
|
|
|
if ARGUMENTS.get("generate_bindings", "no") == "yes":
|
|
|
|
godot_executable = godot_bin_path + godot_name
|
2017-04-18 00:41:39 +00:00
|
|
|
|
2017-07-23 15:53:50 +00:00
|
|
|
if env["CXX"] == "clang++":
|
|
|
|
godot_executable += ".llvm"
|
2017-04-18 00:16:57 +00:00
|
|
|
|
2017-07-23 15:53:50 +00:00
|
|
|
if platform == "windows":
|
|
|
|
godot_executable += ".exe"
|
|
|
|
|
|
|
|
# TODO Generating the API should be done only if the Godot build is more recent than the JSON file
|
|
|
|
json_api_file = 'godot_api.json'
|
2017-06-16 13:50:48 +00:00
|
|
|
|
2017-07-23 15:53:50 +00:00
|
|
|
subprocess.call([godot_executable, '--gdnative-generate-json-api', json_api_file])
|
2017-03-06 07:49:24 +00:00
|
|
|
|
2017-07-23 15:53:50 +00:00
|
|
|
# actually create the bindings here
|
|
|
|
|
|
|
|
import binding_generator
|
2017-04-18 00:16:57 +00:00
|
|
|
|
2017-07-23 15:53:50 +00:00
|
|
|
|
|
|
|
binding_generator.generate_bindings(json_api_file)
|
2017-03-06 07:49:24 +00:00
|
|
|
|
|
|
|
|
2017-07-23 15:53:50 +00:00
|
|
|
add_sources(sources, "src")
|
2017-03-06 07:49:24 +00:00
|
|
|
|
2017-07-23 15:53:50 +00:00
|
|
|
library = env.StaticLibrary(target='bin/godot_cpp_bindings', source=sources)
|
|
|
|
Default(library)
|
2017-03-06 02:30:46 +00:00
|
|
|
|