Skip to content

Instantly share code, notes, and snippets.

@NangiDev
Created November 16, 2023 10:35
Show Gist options
  • Save NangiDev/d6804c34c19db91144b9b389acf548e8 to your computer and use it in GitHub Desktop.
Save NangiDev/d6804c34c19db91144b9b389acf548e8 to your computer and use it in GitHub Desktop.
GDExtension SCons compilation database
#!/usr/bin/env python
import os
import sys
env = SConscript("godot-cpp/SConstruct")
# For reference:
# - CCFLAGS are compilation flags shared between C and C++
# - CFLAGS are for C-specific compilation flags
# - CXXFLAGS are for C++-specific compilation flags
# - CPPFLAGS are for pre-processor flags
# - CPPDEFINES are for pre-processor defines
# - LINKFLAGS are for linking flags
# tweak this if you want to use different folders, or more folders, to store your source code in.
env.Tool('compilation_db')
env.Append(CPPPATH=["src/"])
env['CXXFLAGS'].remove('/std:c++17')
env.Append(CXXFLAGS=['/std:c++20'])
sources = [Glob("src/*.cpp"), Glob("src/CharacterController/*.cpp")]
if env["platform"] == "macos":
library = env.SharedLibrary(
"demo/bin/libgdexample.{}.{}.framework/libgdexample.{}.{}".format(
env["platform"], env["target"], env["platform"], env["target"]
),
source=sources,
)
else:
library = env.SharedLibrary(
"demo/bin/libgdexample{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
source=sources,
)
cc = env.CompilationDatabase('compile_commands.json')
Default(cc,library)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment