@@ -53,7 +53,11 @@ sys.path.append(os.path.join(os.path.dirname(__file__), 'android'))
53
53
import adb .commands # noqa (E402)
54
54
55
55
56
- def call_without_sleeping (command , env = None , dry_run = False ):
56
+ build_script_impl = os .path .join (
57
+ SWIFT_SOURCE_ROOT , "swift" , "utils" , "build-script-impl" )
58
+
59
+
60
+ def call_without_sleeping (command , env = None , dry_run = False , echo = False ):
57
61
"""
58
62
Execute a command during which system sleep is disabled.
59
63
@@ -65,7 +69,7 @@ def call_without_sleeping(command, env=None, dry_run=False):
65
69
# Don't mutate the caller's copy of the arguments.
66
70
command = ["caffeinate" ] + list (command )
67
71
68
- shell .call (command , env = env , dry_run = dry_run )
72
+ shell .call (command , env = env , dry_run = dry_run , echo = echo )
69
73
70
74
71
75
class HostSpecificConfiguration (object ):
@@ -798,6 +802,115 @@ class BuildScriptInvocation(object):
798
802
799
803
return options
800
804
805
+ def compute_product_classes (self ):
806
+ """compute_product_classes() -> list
807
+
808
+ Compute the list of all Product classes used in this build. This list
809
+ is constructed in dependency order.
810
+ """
811
+
812
+ # FIXME: This is a weird division (returning a list of class objects),
813
+ # but it matches the existing structure of the `build-script-impl`.
814
+
815
+ product_classes = []
816
+ product_classes .append (products .CMark )
817
+ product_classes .append (products .LLVM )
818
+ product_classes .append (products .Swift )
819
+ if self .args .build_lldb :
820
+ product_classes .append (products .LLDB )
821
+ if self .args .build_llbuild :
822
+ product_classes .append (products .LLBuild )
823
+ if self .args .build_libdispatch :
824
+ product_classes .append (products .LibDispatch )
825
+ if self .args .build_foundation :
826
+ product_classes .append (products .Foundation )
827
+ if self .args .build_xctest :
828
+ product_classes .append (products .XCTest )
829
+ if self .args .build_swiftpm :
830
+ product_classes .append (products .SwiftPM )
831
+ return product_classes
832
+
833
+ def execute (self ):
834
+ """Execute the invocation with the configured arguments."""
835
+
836
+ # Convert to a build-script-impl invocation.
837
+ (impl_env , impl_args ) = self .convert_to_impl_arguments ()
838
+
839
+ # If using the legacy implementation, delegate all behavior to
840
+ # `build-script-impl`.
841
+ if self .args .legacy_impl :
842
+ # Execute the underlying build script implementation.
843
+ call_without_sleeping ([build_script_impl ] + impl_args ,
844
+ env = impl_env , echo = True )
845
+ return
846
+
847
+ # Otherwise, we compute and execute the individual actions ourselves.
848
+
849
+ def execute_one_impl_action (host = None , product_class = None , name = None ):
850
+ if host is None :
851
+ assert (product_class is None and
852
+ name == "merged-hosts-lipo" ), "invalid action"
853
+ action_name = name
854
+ elif product_class is None :
855
+ assert name == "package" , "invalid action"
856
+ action_name = "{}-{}" .format (host .name , name )
857
+ else :
858
+ assert name is not None , "invalid action"
859
+ action_name = "{}-{}-{}" .format (
860
+ host .name , product_class .product_name (), name )
861
+ call_without_sleeping (
862
+ [build_script_impl ] + impl_args + [
863
+ "--only-execute" , action_name ],
864
+ env = impl_env , echo = self .args .verbose_build )
865
+
866
+ # Compute the list of hosts to operate on.
867
+ all_host_names = [
868
+ self .args .host_target ] + self .args .cross_compile_hosts
869
+ all_hosts = [StdlibDeploymentTarget .get_target_for_name (name )
870
+ for name in all_host_names ]
871
+
872
+ # Compute the list of product classes to operate on.
873
+ #
874
+ # FIXME: This should really be per-host, but the current structure
875
+ # matches that of `build-script-impl`.
876
+ product_classes = self .compute_product_classes ()
877
+
878
+ # Execute each "pass".
879
+
880
+ # Build...
881
+ for host_target in all_hosts :
882
+ # FIXME: We should only compute these once.
883
+ config = HostSpecificConfiguration (host_target .name , self )
884
+ print ("Building the standard library for: {}" .format (
885
+ " " .join (config .swift_stdlib_build_targets )))
886
+ if config .swift_test_run_targets and (
887
+ self .args .test or self .args .long_test ):
888
+ print ("Running Swift tests for: {}" .format (
889
+ " " .join (config .swift_test_run_targets )))
890
+ if config .swift_benchmark_run_targets and self .args .benchmark :
891
+ print ("Running Swift benchmarks for: {}" .format (
892
+ " " .join (config .swift_benchmark_run_targets )))
893
+
894
+ for product_class in product_classes :
895
+ execute_one_impl_action (host_target , product_class , "build" )
896
+
897
+ # Test...
898
+ for host_target in all_hosts :
899
+ for product_class in product_classes :
900
+ execute_one_impl_action (host_target , product_class , "test" )
901
+
902
+ # Install...
903
+ for host_target in all_hosts :
904
+ for product_class in product_classes :
905
+ execute_one_impl_action (host_target , product_class , "install" )
906
+
907
+ # Package...
908
+ for host_target in all_hosts :
909
+ execute_one_impl_action (host_target , name = "package" )
910
+
911
+ # Lipo...
912
+ execute_one_impl_action (name = "merged-hosts-lipo" )
913
+
801
914
802
915
# Main entry point for the preset mode.
803
916
def main_preset ():
@@ -1073,6 +1186,11 @@ details of the setups of other systems or automated environments.""")
1073
1186
"them" ,
1074
1187
action = "store_true" ,
1075
1188
default = False )
1189
+ parser .add_argument (
1190
+ "--no-legacy-impl" , dest = "legacy_impl" ,
1191
+ help = "avoid legacy implementation" ,
1192
+ action = "store_false" ,
1193
+ default = True )
1076
1194
1077
1195
targets_group = parser .add_argument_group (
1078
1196
title = "Host and cross-compilation targets" )
@@ -1764,9 +1882,6 @@ details of the setups of other systems or automated environments.""")
1764
1882
1765
1883
args = migration .parse_args (parser , sys .argv [1 :])
1766
1884
1767
- build_script_impl = os .path .join (
1768
- SWIFT_SOURCE_ROOT , "swift" , "utils" , "build-script-impl" )
1769
-
1770
1885
if args .build_script_impl_args :
1771
1886
# If we received any impl args, check if `build-script-impl` would
1772
1887
# accept them or not before any further processing.
@@ -1820,13 +1935,8 @@ details of the setups of other systems or automated environments.""")
1820
1935
if args .build_ninja :
1821
1936
invocation .build_ninja ()
1822
1937
1823
- # Convert to a build-script-impl invocation.
1824
- (build_script_impl_env , build_script_impl_args ) = \
1825
- invocation .convert_to_impl_arguments ()
1826
-
1827
1938
# Execute the underlying build script implementation.
1828
- call_without_sleeping ([build_script_impl ] + build_script_impl_args ,
1829
- env = build_script_impl_env )
1939
+ invocation .execute ()
1830
1940
1831
1941
if args .symbols_package :
1832
1942
print ('--- Creating symbols package ---' )
0 commit comments