Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 43d3b11

Browse files
Add compiledb, help and custom.py support
1 parent 948cf4b commit 43d3b11

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

‎.gitignore‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ demo/bin/*
66
!demo/bin/*.gdextension
77
.sconsign*.dblite
88

9+
# Ignore custom.py
10+
custom.py
11+
12+
# Ignore generated compile_commands.json
13+
compile_commands.json
14+
915
# Binaries
1016
*.o
1117
*.os

‎SConstruct‎

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,53 @@
11
#!/usr/bin/env python
2+
import os
3+
4+
5+
def normalize_path(val, env):
6+
return val if os.path.isabs(val) else os.path.join(env.Dir("#").abspath, val)
7+
8+
9+
def validate_parent_dir(key, val, env):
10+
if not os.path.isdir(normalize_path(os.path.dirname(val), env)):
11+
raise UserError("'%s' is not a directory: %s" % (key, os.path.dirname(val)))
12+
213

314
libname = "EXTENSION-NAME"
415

5-
env = SConscript("godot-cpp/SConstruct")
16+
localEnv = Environment(tools=["default"], PLATFORM="")
17+
18+
customs = ["custom.py"]
19+
customs = [os.path.abspath(path) for path in customs]
20+
21+
opts = Variables(customs, ARGUMENTS)
22+
opts.Add(
23+
BoolVariable(
24+
key="compiledb",
25+
help="Generate compilation DB (`compile_commands.json`) for external tools",
26+
default=localEnv.get("compiledb", False),
27+
)
28+
)
29+
opts.Add(
30+
PathVariable(
31+
key="compiledb_file",
32+
help="Path to a custom `compile_commands.json` file",
33+
default=localEnv.get("compiledb_file", "compile_commands.json"),
34+
validator=validate_parent_dir,
35+
)
36+
)
37+
opts.Update(localEnv)
38+
39+
Help(opts.GenerateHelpText(localEnv))
40+
41+
env = localEnv.Clone()
42+
env["compiledb"] = False
43+
44+
env.Tool("compilation_db")
45+
compilation_db = env.CompilationDatabase(
46+
normalize_path(localEnv["compiledb_file"], localEnv)
47+
)
48+
env.Alias("compiledb", compilation_db)
49+
50+
env = SConscript("godot-cpp/SConstruct", {"env": env, "customs": customs})
651

752
env.Append(CPPPATH=["src/"])
853
sources = Glob("src/*.cpp")
@@ -19,4 +64,7 @@ else:
1964
source=sources,
2065
)
2166

22-
Default(library)
67+
default_args = [library]
68+
if localEnv.get("compiledb", False):
69+
default_args += [compilation_db]
70+
Default(*default_args)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /