Skip to content

Instantly share code, notes, and snippets.

@CosineP
Created July 9, 2018 00:00
Show Gist options
  • Save CosineP/d6131e7b33b7c8689ae3697013db8ce7 to your computer and use it in GitHub Desktop.
Save CosineP/d6131e7b33b7c8689ae3697013db8ce7 to your computer and use it in GitHub Desktop.
#!python
import os
target = ARGUMENTS.get("target", "debug")
platform = ARGUMENTS.get("platform", "windows")
bits = ARGUMENTS.get("bits", 64)
final_lib_path = 'bin/'
# 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
env = Environment()
if platform == "windows":
env = Environment(ENV = os.environ)
def add_sources(sources, directory):
for file in os.listdir(directory):
if file.endswith('.cpp'):
sources.append(directory + '/' + file)
if platform == "osx":
env.Append(CCFLAGS = ['-g','-O3', '-arch', 'x86_64', '-std=c++14'])
env.Append(LINKFLAGS = ['-arch', 'x86_64'])
final_lib_path = final_lib_path + 'osx/'
elif platform == "linux":
env.Append(CCFLAGS = ['-fPIC', '-g','-O3', '-std=c++14'])
final_lib_path = final_lib_path + 'x11/'
elif platform == "windows":
if target == "debug":
env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '-MDd'])
else:
env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '-MD'])
final_lib_path = final_lib_path + 'win' + str(bits) + '/'
env.Append(CPPPATH=['.', 'cpp/', "godot_headers/", 'godot-cpp/include/', 'godot-cpp/include/core/', "/home/luna/src/mumlib/include"])
env.Append(LIBPATH=["/home/luna/src/mumlib/build", "godot-cpp/bin"])
env.Append(LIBS=["mumlib", "godot-cpp" + "." + platform + "." + str(bits)])
sources = []
add_sources(sources, "cpp")
library = env.SharedLibrary(target=final_lib_path + 'libgdexample', source=sources)
Default(library)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment