@@ -8,13 +8,18 @@ from typing import List, Union
88
99import 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
1216from build .option_handler import OptionsClass
1317from build .glob_recursive import GlobRecursive
1418from build .git_info import get_git_info , git_builder
1519from build .license_info import license_builder
1620from build .author_info import author_builder
1721from build .cache import show_progress
22+ from build .pch import setup_pch
1823
1924def normalize_path (val , env ):
2025 return val if os .path .isabs (val ) else os .path .join (env .Dir ("#" ).abspath , val )
@@ -167,9 +172,14 @@ def SetupOptions():
167172 )
168173 )
169174
170- # Add platform options
175+ # Add platform options. Iterate deterministically with the current platform
176+ # registered last so its defaults win
171177 tools = {}
172- for pl in set (platforms ) - set (unsupported_known_platforms ):
178+ current_platform = env .get ("platform" , default_platform )
179+ supported = sorted (set (platforms ) - set (unsupported_known_platforms ))
180+ if current_platform in supported :
181+ supported = [pl for pl in supported if pl != current_platform ] + [current_platform ]
182+ for pl in supported :
173183 tool = Tool (pl , toolpath = env .TOOLPATH )
174184 if hasattr (tool , "options" ):
175185 tool .options (opts )
@@ -205,6 +215,7 @@ def SetupOptions():
205215 opts .Add (BoolVariable ("verbose" , "Enable verbose output for the compilation" , False ))
206216 opts .Add (BoolVariable ("intermediate_delete" , "Enables automatically deleting unassociated intermediate binary files." , True ))
207217 opts .Add (BoolVariable ("progress" , "Show a progress indicator during compilation" , True ))
218+ opts .Add (BoolVariable ("use_pch" , "Enable precompiled headers when the toolchain supports it" , True ))
208219
209220 # Targets flags tool (optimizations, debug symbols)
210221 target_tool = Tool ("targets" , toolpath = env .TOOLPATH )
@@ -261,10 +272,11 @@ def FinalizeOptions():
261272 target_tool .generate (env )
262273 tool .generate (env )
263274
275+ Decider ("MD5-timestamp" )
276+
264277 scons_cache_path = os .environ .get ("SCONS_CACHE" )
265278 if scons_cache_path != None :
266279 CacheDir (scons_cache_path )
267- Decider ("MD5" )
268280 print ("Scons cache enabled... (path: '" + scons_cache_path + "')" )
269281
270282 if env ["compiledb" ] and is_standalone :
@@ -279,6 +291,7 @@ env.get_git_info = get_git_info
279291env .license_builder = license_builder
280292env .git_builder = git_builder
281293env .author_builder = author_builder
294+ env .SetupPCH = lambda header , source : setup_pch (env , header , source )
282295
283296
284297def to_raw_cstring (value : Union [str , List [str ]]) -> str :
0 commit comments