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
|
|
|
|
godot_headers_path = "../../godot_headers/"
|
|
|
|
godot_bin_path = "../../godot_fork/bin/"
|
|
|
|
godot_lib_path = "../../godot_fork/bin/"
|
|
|
|
|
2017-03-06 07:49:24 +00:00
|
|
|
|
2017-03-06 02:30:46 +00:00
|
|
|
env = Environment()
|
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
|
|
|
|
|
|
|
target = ARGUMENTS.get("target", "core")
|
2017-03-15 22:19:58 +00:00
|
|
|
platform = ARGUMENTS.get("p", "linux")
|
|
|
|
|
2017-04-18 00:16:57 +00:00
|
|
|
|
|
|
|
godot_name = "godot." + platform + ".tools.64"
|
|
|
|
|
|
|
|
|
|
|
|
def add_sources(sources, directory):
|
|
|
|
for file in os.listdir(directory):
|
|
|
|
if file.endswith('.cpp'):
|
|
|
|
sources.append(directory + '/' + file)
|
|
|
|
|
|
|
|
|
|
|
|
if target == "core":
|
2017-03-15 22:19:58 +00:00
|
|
|
if platform == "linux":
|
|
|
|
env.Append(CCFLAGS = ['-g','-O3', '-std=c++14'])
|
|
|
|
|
2017-04-18 00:16:57 +00:00
|
|
|
env.Append(CPPPATH=['.', godot_headers_path])
|
|
|
|
|
2017-03-15 22:19:58 +00:00
|
|
|
if platform == "windows":
|
2017-04-18 00:16:57 +00:00
|
|
|
env.Append(LIBS=[godot_name + '.lib'])
|
|
|
|
env.Append(LIBPATH=[godot_lib_path])
|
|
|
|
|
2017-03-15 22:19:58 +00:00
|
|
|
env.Append(CPPFLAGS=['-D_GD_CPP_CORE_API_IMPL'])
|
2017-03-06 07:49:24 +00:00
|
|
|
|
2017-04-18 00:16:57 +00:00
|
|
|
sources = []
|
|
|
|
add_sources(sources, "godot_cpp/core")
|
2017-03-06 07:49:24 +00:00
|
|
|
|
|
|
|
library = env.SharedLibrary(target='godot_cpp_core', source=sources)
|
|
|
|
Default(library)
|
|
|
|
|
2017-04-18 00:16:57 +00:00
|
|
|
|
2017-03-09 02:03:21 +00:00
|
|
|
elif target == "bindings":
|
2017-04-18 00:16:57 +00:00
|
|
|
|
|
|
|
if ARGUMENTS.get("generate_bindings", "no") == "yes":
|
|
|
|
godot_executable = godot_bin_path + godot_name
|
|
|
|
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'
|
|
|
|
subprocess.call([godot_executable, '--gdnative-generate-json-api', json_api_file])
|
|
|
|
|
|
|
|
binding_generator_executable = '../binding_generator/target/debug/binding_generator'
|
|
|
|
if platform == "windows":
|
|
|
|
binding_generator_executable += ".exe"
|
|
|
|
|
|
|
|
# TODO Should that be the job of the generator?
|
|
|
|
if not os.path.isdir('godot_cpp/impl'):
|
|
|
|
os.mkdir('godot_cpp/impl')
|
|
|
|
|
|
|
|
# Note: the binding generator should have been built before
|
|
|
|
subprocess.call([binding_generator_executable, json_api_file, 'godot_cpp/'])
|
|
|
|
|
2017-03-15 22:19:58 +00:00
|
|
|
if platform == "linux":
|
|
|
|
if env["CXX"] == "clang++":
|
|
|
|
env.Append(CCFLAGS = ['-Wno-writable-strings'])
|
|
|
|
else:
|
|
|
|
env.Append(CCFLAGS = ['-Wno-write-strings', '-Wno-return-local-addr'])
|
2017-03-09 02:03:21 +00:00
|
|
|
|
2017-03-15 22:19:58 +00:00
|
|
|
env.Append(CCFLAGS = ['-g','-O3', '-std=c++14'])
|
2017-04-04 19:02:44 +00:00
|
|
|
env.Append(LINKFLAGS = ['-Wl,-R,\'$$ORIGIN\''])
|
2017-04-18 00:16:57 +00:00
|
|
|
env.Append(CPPPATH=['.', godot_headers_path, './godot_cpp'])
|
2017-03-06 07:49:24 +00:00
|
|
|
|
2017-03-18 14:23:28 +00:00
|
|
|
if platform == "windows":
|
2017-04-18 00:16:57 +00:00
|
|
|
env.Append(LIBS=[godot_name])
|
|
|
|
env.Append(LIBPATH=[godot_lib_path])
|
|
|
|
|
2017-03-18 14:23:28 +00:00
|
|
|
env.Append(LIBS=['godot_cpp_core'])
|
2017-04-18 00:16:57 +00:00
|
|
|
env.Append(LIBPATH=['.'])
|
2017-03-06 07:49:24 +00:00
|
|
|
|
2017-03-15 22:19:58 +00:00
|
|
|
env.Append(CPPFLAGS=['-D_GD_CPP_BINDING_IMPL'])
|
2017-03-06 07:49:24 +00:00
|
|
|
|
2017-04-18 00:16:57 +00:00
|
|
|
sources = []
|
|
|
|
add_sources(sources, "godot_cpp/impl/")
|
2017-03-06 07:49:24 +00:00
|
|
|
|
|
|
|
library = env.SharedLibrary(target='godot_cpp_bindings', source=sources)
|
|
|
|
Default(library)
|
2017-03-06 02:30:46 +00:00
|
|
|
|