@@ -50,7 +50,7 @@ from swift_build_support.cmake import CMake # noqa (E402)
50
50
import swift_build_support .workspace # noqa (E402)
51
51
52
52
53
- def call_without_sleeping (command , dry_run = False ):
53
+ def call_without_sleeping (command , env = None , dry_run = False ):
54
54
"""
55
55
Execute a command during which system sleep is disabled.
56
56
@@ -62,7 +62,7 @@ def call_without_sleeping(command, dry_run=False):
62
62
# Don't mutate the caller's copy of the arguments.
63
63
command = ["caffeinate" ] + list (command )
64
64
65
- shell .call (command , dry_run = dry_run , echo = False )
65
+ shell .call (command , env = env , dry_run = dry_run )
66
66
67
67
68
68
class BuildScriptInvocation (object ):
@@ -322,10 +322,10 @@ class BuildScriptInvocation(object):
322
322
self .toolchain .ninja = ninja_build .ninja_bin_path
323
323
324
324
def convert_to_impl_arguments (self ):
325
- """convert_to_impl_arguments() -> args
325
+ """convert_to_impl_arguments() -> (env, args)
326
326
327
- Convert the invocation to a list of arguments suitable for invoking
328
- `build-script-impl`.
327
+ Convert the invocation to an environment and list of arguments suitable
328
+ for invoking `build-script-impl`.
329
329
"""
330
330
331
331
# Create local shadows, for convenience.
@@ -540,7 +540,26 @@ class BuildScriptInvocation(object):
540
540
if args .dry_run :
541
541
impl_args += ["--dry-run" ]
542
542
543
- return impl_args
543
+ # Compute the set of host-specific variables, which we pass through to
544
+ # the build script via environment variables.
545
+ host_specific_variables = self .compute_host_specific_variables ()
546
+ impl_env = {}
547
+ for (host_target , options ) in host_specific_variables .items ():
548
+ for (name , value ) in options .items ():
549
+ # We mangle into an environment variable we can easily evaluate
550
+ # from the `build-script-impl`.
551
+ impl_env ["HOST_VARIABLE_{}__{}" .format (
552
+ host_target .replace ("-" , "_" ), name )] = value
553
+
554
+ return (impl_env , impl_args )
555
+
556
+ def compute_host_specific_variables (self ):
557
+ """compute_host_specific_variables(args) -> dict
558
+
559
+ Compute the host-specific options, organized as a dictionary keyed by
560
+ host of options.
561
+ """
562
+ return {}
544
563
545
564
546
565
# Main entry point for the preset mode.
@@ -1551,10 +1570,12 @@ details of the setups of other systems or automated environments.""")
1551
1570
invocation .build_ninja ()
1552
1571
1553
1572
# Convert to a build-script-impl invocation.
1554
- build_script_impl_args = invocation .convert_to_impl_arguments ()
1573
+ (build_script_impl_env ,build_script_impl_args ) = \
1574
+ invocation .convert_to_impl_arguments ()
1555
1575
1556
1576
# Execute the underlying build script implementation.
1557
- call_without_sleeping ([build_script_impl ] + build_script_impl_args )
1577
+ call_without_sleeping ([build_script_impl ] + build_script_impl_args ,
1578
+ env = build_script_impl_env )
1558
1579
1559
1580
if args .symbols_package :
1560
1581
print ('--- Creating symbols package ---' )
0 commit comments