Skip to content

Instantly share code, notes, and snippets.

@RameshRavone
Created May 18, 2017 10:20
Show Gist options
  • Select an option

  • Save RameshRavone/406063be5cd02ef06fe073b78eeb3e47 to your computer and use it in GitHub Desktop.

Select an option

Save RameshRavone/406063be5cd02ef06fe073b78eeb3e47 to your computer and use it in GitHub Desktop.
SConstruct file to build GDNativie library
#!python
import os
# To compile your game code you need to run
# `scons p=linux` to compile for linux
# `scons p=windows` to compile for windows
# on linux you can optionally use `use_llvm=yes` to use clang instead of gcc
# Mac/Android will come soon as well. (help is appreciated :D)
# FILL ME
project_name = "test"
env = Environment()
if ARGUMENTS.get("use_llvm", "no") == "yes":
env["CXX"] = "clang++"
platform = ARGUMENTS.get("p", "linux")
def add_sources(sources, dir):
for f in os.listdir(dir):
if f.endswith(".cpp"):
sources.append(dir + "/" + f)
if platform == "linux":
env.Append(CCFLAGS = ['-g','-O3', '-std=c++14'])
env.Append(LINKFLAGS = ['-Wl,-R,\'$$ORIGIN\''])
env.Append(CPPPATH=['../cpp_bindings/include', '../godot_headers/', '../cpp_bindings/include/core'])
env.Append(LIBS=['godot_cpp_core', 'godot_cpp_bindings'])
env.Append(LIBPATH=["../lib"])
if platform == "windows":
# for 32 bit you need change this name here.
env.Append(LIBS=['godot.windows.opt.tools.64'])
# # sources has all the paths to files that should be compiled
# # I usually have one init.cpp at the top of the source tree.
# sources = ["init.cpp"]
sources = ["init.cpp"]
# # add_sources adds all files that have a .cpp extension from the path that is the second parameter
# # for example: to add all .cpp files in the folder "tower" you'd write
# add_sources(sources, "tower")
# # the same works for nested folders
# add_sources(sources, "stages/game")
library = env.SharedLibrary(target=('../lib/' + project_name), source=sources)
Default(library)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment