aboutsummaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2023-07-13 08:01:02 +0200
committer GitHub <noreply@github.com>2023-07-13 08:01:02 +0200
commit1cb52daa06968aef519b66402ba6a3f4005000ee (patch)
treea1746f7ad78b4e1190d9e5521cacf2a21e46a92a /SConstruct
parent1d8accc1ca6b30120732c56233e5d74e860de1bb (diff)
parent449f7f33c231c0284cc2da53197db84e137d26a0 (diff)
Merge pull request #138 from Spartan322/add/compiledb-support
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct15
1 files changed, 15 insertions, 0 deletions
diff --git a/SConstruct b/SConstruct
index 426682c..65d741d 100644
--- a/SConstruct
+++ b/SConstruct
@@ -9,6 +9,7 @@ SAVED_ARGUMENTS = ARGUMENTS.copy()
ARGUMENTS.pop('intermediate_delete', True)
ARGUMENTS.pop('progress', True)
ARGUMENTS.pop('verbose', True)
+ARGUMENTS.pop('compiledb', True)
env = SConscript("godot-cpp/SConstruct")
@@ -30,6 +31,7 @@ if profile:
customs.append(profile + ".py")
opts = Variables(customs, ARGUMENTS)
+opts.Add(BoolVariable("compiledb", "Generate compilation DB (`compile_commands.json`) for external tools", False))
opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False))
opts.Add(
BoolVariable("intermediate_delete", "Enables automatically deleting unassociated intermediate binary files.", True)
@@ -183,6 +185,19 @@ if scons_cache_path != None:
CacheDir(scons_cache_path)
print("Scons cache enabled... (path: '" + scons_cache_path + "')")
+if env["compiledb"]:
+ # Generating the compilation DB (`compile_commands.json`) requires SCons 4.0.0 or later.
+ from SCons import __version__ as scons_raw_version
+
+ scons_ver = env._get_major_minor_revision(scons_raw_version)
+
+ if scons_ver < (4, 0, 0):
+ print("The `compiledb=yes` option requires SCons 4.0 or later, but your version is %s." % scons_raw_version)
+ Exit(255)
+
+ env.Tool("compilation_db")
+ env.Alias("compiledb", env.CompilationDatabase())
+
# For the reference:
# - CCFLAGS are compilation flags shared between C and C++
# - CFLAGS are for C-specific compilation flags