Skip to content

Commit abc94ab

Browse files
author
Justin Nolan
committed
Out of source build support
1 parent 4ddc9a1 commit abc94ab

3 files changed

Lines changed: 26 additions & 13 deletions

File tree

SConstruct

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ from typing import List, Union
88

99
import SCons
1010

11+
_SCRIPTS_DIR = Dir(".").abspath
12+
if _SCRIPTS_DIR not in sys.path:
13+
sys.path.insert(0, _SCRIPTS_DIR)
14+
1115
# Local
1216
from build.option_handler import OptionsClass
1317
from build.glob_recursive import GlobRecursive
@@ -167,9 +171,14 @@ def SetupOptions():
167171
)
168172
)
169173

170-
# Add platform options
174+
# Add platform options. Iterate deterministically with the current platform
175+
# registered last so its defaults win
171176
tools = {}
172-
for pl in set(platforms) - set(unsupported_known_platforms):
177+
current_platform = env.get("platform", default_platform)
178+
supported = sorted(set(platforms) - set(unsupported_known_platforms))
179+
if current_platform in supported:
180+
supported = [pl for pl in supported if pl != current_platform] + [current_platform]
181+
for pl in supported:
173182
tool = Tool(pl, toolpath=env.TOOLPATH)
174183
if hasattr(tool, "options"):
175184
tool.options(opts)
@@ -261,10 +270,11 @@ def FinalizeOptions():
261270
target_tool.generate(env)
262271
tool.generate(env)
263272

273+
Decider("MD5-timestamp")
274+
264275
scons_cache_path = os.environ.get("SCONS_CACHE")
265276
if scons_cache_path != None:
266277
CacheDir(scons_cache_path)
267-
Decider("MD5")
268278
print("Scons cache enabled... (path: '" + scons_cache_path + "')")
269279

270280
if env["compiledb"] and is_standalone:

build/__init__.py

Whitespace-only changes.

build/glob_recursive.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
def GlobRecursive(pattern, nodes=["."], exclude=None):
22
import fnmatch
3+
import os
34

45
import SCons
56

@@ -11,15 +12,17 @@ def GlobRecursive(pattern, nodes=["."], exclude=None):
1112

1213
results = []
1314
for node in nodes:
14-
nnodes = []
15-
for f in Glob(str(node) + "/*", source=True):
15+
node_str = str(node)
16+
17+
for f in Glob(node_str + "/*", source=True):
1618
if type(f) is SCons.Node.FS.Dir:
17-
nnodes.append(f)
18-
results += GlobRecursive(pattern, nnodes)
19-
results += Glob(str(node) + "/" + pattern, source=True)
20-
if isinstance(exclude, list):
21-
for val in results:
22-
for pat in exclude:
23-
if fnmatch.fnmatch(str(val), pat):
24-
results.remove(val)
19+
child = node_str + "/" + os.path.basename(str(f))
20+
results += GlobRecursive(pattern, [child])
21+
22+
results += Glob(node_str + "/" + pattern)
23+
24+
if isinstance(exclude, list):
25+
norm = lambda s: str(s).replace("\\", "/")
26+
norm_exclude = [norm(p) for p in exclude]
27+
results = [r for r in results if not any(fnmatch.fnmatch(norm(r), p) for p in norm_exclude)]
2528
return results

0 commit comments

Comments
 (0)