Improve build usage
- Local dependency paths are now grouped in a few vars on top of SConstruct - Added an option to generate bindings as part of the buildpull/7/head
parent
ac51c7b141
commit
805ca9601f
|
@ -1,5 +1,12 @@
|
||||||
#!python
|
#!python
|
||||||
import os
|
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/"
|
||||||
|
|
||||||
|
|
||||||
env = Environment()
|
env = Environment()
|
||||||
|
|
||||||
|
@ -7,46 +14,59 @@ if ARGUMENTS.get("use_llvm", "no") == "yes":
|
||||||
env["CXX"] = "clang++"
|
env["CXX"] = "clang++"
|
||||||
|
|
||||||
target = ARGUMENTS.get("target", "core")
|
target = ARGUMENTS.get("target", "core")
|
||||||
|
|
||||||
platform = ARGUMENTS.get("p", "linux")
|
platform = ARGUMENTS.get("p", "linux")
|
||||||
|
|
||||||
if (target == "core"):
|
|
||||||
|
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":
|
||||||
if platform == "linux":
|
if platform == "linux":
|
||||||
env.Append(CCFLAGS = ['-g','-O3', '-std=c++14'])
|
env.Append(CCFLAGS = ['-g','-O3', '-std=c++14'])
|
||||||
|
|
||||||
env.Append(CPPPATH=['.', './godot'])
|
env.Append(CPPPATH=['.', godot_headers_path])
|
||||||
|
|
||||||
if platform == "windows":
|
if platform == "windows":
|
||||||
env.Append(LIBS=['godot.windows.tools.64.lib'])
|
env.Append(LIBS=[godot_name + '.lib'])
|
||||||
|
env.Append(LIBPATH=[godot_lib_path])
|
||||||
|
|
||||||
env.Append(CPPFLAGS=['-D_GD_CPP_CORE_API_IMPL'])
|
env.Append(CPPFLAGS=['-D_GD_CPP_CORE_API_IMPL'])
|
||||||
|
|
||||||
sources = [
|
sources = []
|
||||||
'godot_cpp/core/Array.cpp',
|
add_sources(sources, "godot_cpp/core")
|
||||||
'godot_cpp/core/Basis.cpp',
|
|
||||||
'godot_cpp/core/Color.cpp',
|
|
||||||
'godot_cpp/core/Dictionary.cpp',
|
|
||||||
'godot_cpp/core/Image.cpp',
|
|
||||||
'godot_cpp/core/InputEvent.cpp',
|
|
||||||
'godot_cpp/core/NodePath.cpp',
|
|
||||||
'godot_cpp/core/Plane.cpp',
|
|
||||||
'godot_cpp/core/PoolArrays.cpp',
|
|
||||||
'godot_cpp/core/Quat.cpp',
|
|
||||||
'godot_cpp/core/Rect2.cpp',
|
|
||||||
'godot_cpp/core/Rect3.cpp',
|
|
||||||
'godot_cpp/core/RID.cpp',
|
|
||||||
'godot_cpp/core/String.cpp',
|
|
||||||
'godot_cpp/core/Transform.cpp',
|
|
||||||
'godot_cpp/core/Transform2D.cpp',
|
|
||||||
'godot_cpp/core/Variant.cpp',
|
|
||||||
'godot_cpp/core/Vector2.cpp',
|
|
||||||
'godot_cpp/core/Vector3.cpp'
|
|
||||||
]
|
|
||||||
|
|
||||||
library = env.SharedLibrary(target='godot_cpp_core', source=sources)
|
library = env.SharedLibrary(target='godot_cpp_core', source=sources)
|
||||||
Default(library)
|
Default(library)
|
||||||
|
|
||||||
|
|
||||||
elif target == "bindings":
|
elif target == "bindings":
|
||||||
|
|
||||||
|
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/'])
|
||||||
|
|
||||||
if platform == "linux":
|
if platform == "linux":
|
||||||
if env["CXX"] == "clang++":
|
if env["CXX"] == "clang++":
|
||||||
env.Append(CCFLAGS = ['-Wno-writable-strings'])
|
env.Append(CCFLAGS = ['-Wno-writable-strings'])
|
||||||
|
@ -55,16 +75,19 @@ elif target == "bindings":
|
||||||
|
|
||||||
env.Append(CCFLAGS = ['-g','-O3', '-std=c++14'])
|
env.Append(CCFLAGS = ['-g','-O3', '-std=c++14'])
|
||||||
env.Append(LINKFLAGS = ['-Wl,-R,\'$$ORIGIN\''])
|
env.Append(LINKFLAGS = ['-Wl,-R,\'$$ORIGIN\''])
|
||||||
env.Append(CPPPATH=['.', './godot', './godot_cpp'])
|
env.Append(CPPPATH=['.', godot_headers_path, './godot_cpp'])
|
||||||
|
|
||||||
if platform == "windows":
|
if platform == "windows":
|
||||||
env.Append(LIBS=['godot.windows.tools.64'])
|
env.Append(LIBS=[godot_name])
|
||||||
|
env.Append(LIBPATH=[godot_lib_path])
|
||||||
|
|
||||||
env.Append(LIBS=['godot_cpp_core'])
|
env.Append(LIBS=['godot_cpp_core'])
|
||||||
env.Append(LIBPATH=["."])
|
env.Append(LIBPATH=['.'])
|
||||||
|
|
||||||
env.Append(CPPFLAGS=['-D_GD_CPP_BINDING_IMPL'])
|
env.Append(CPPFLAGS=['-D_GD_CPP_BINDING_IMPL'])
|
||||||
|
|
||||||
sources = [os.path.join("godot_cpp/impl/", f) for f in os.listdir("godot_cpp/impl/") if f.endswith('.cpp')]
|
sources = []
|
||||||
|
add_sources(sources, "godot_cpp/impl/")
|
||||||
|
|
||||||
library = env.SharedLibrary(target='godot_cpp_bindings', source=sources)
|
library = env.SharedLibrary(target='godot_cpp_bindings', source=sources)
|
||||||
Default(library)
|
Default(library)
|
||||||
|
|
Loading…
Reference in New Issue