1818from . import product
1919from . import swift
2020from . import swift_testing_macros
21+ from .. import shell
2122
2223
2324class SwiftTesting (product .Product ):
@@ -38,6 +39,10 @@ def get_dependencies(cls):
3839 return [swift .Swift ,
3940 swift_testing_macros .SwiftTestingMacros ]
4041
42+ def should_clean (self , host_target ):
43+ # Workaround for 'swift-testing' not detecting compiler/stdlib changes.
44+ return True
45+
4146 def should_build (self , host_target ):
4247 return True
4348
@@ -59,35 +64,38 @@ def _cmake_product(self, host_target):
5964 source_dir = self .source_dir ,
6065 build_dir = build_dir )
6166
62- def _build_with_cmake (self , host_target ):
63- self ._cmake_product (host_target ).build (host_target )
64-
65- def build (self , host_target ):
66- self ._build_with_cmake (host_target )
67+ def _for_each_host_target (self , base_target , body ):
68+ body (base_target )
6769
6870 # For Darwin host, 'build' is only called for the builder.
6971 # Manually iterate the cross compile hosts.
70- if self .has_cross_compile_hosts () and self .is_darwin_host (host_target ):
72+ if self .has_cross_compile_hosts () and self .is_darwin_host (base_target ):
7173 for target in self .args .cross_compile_hosts :
72- self ._build_with_cmake (target )
74+ body (target )
75+
76+ def _clean_with_cmake (self , host_target ):
77+ self ._cmake_product (host_target ).clean (host_target )
78+
79+ def clean (self , host_target ):
80+ self ._for_each_host_target (host_target , self ._clean_with_cmake )
7381
74- # FIXME: build testing library for 'stdlib_deployment_targets'?
75- pass
82+ def _build_with_cmake (self , host_target ):
83+ self ._cmake_product (host_target ).build (host_target )
84+
85+ def build (self , host_target ):
86+ self ._for_each_host_target (host_target , self ._build_with_cmake )
7687
7788 def _install_with_cmake (self , host_target ):
7889 self ._cmake_product (host_target ).install (host_target )
7990
8091 def install (self , host_target ):
81- self ._install_with_cmake (host_target )
82-
83- # For Darwin host, 'install' is only called for the builder.
84- # Manually iterate the cross compile hosts.
85- if self .has_cross_compile_hosts () and self .is_darwin_host (host_target ):
86- for target in self .args .cross_compile_hosts :
87- self ._install_with_cmake (target )
92+ self ._for_each_host_target (host_target , self ._install_with_cmake )
8893
8994
9095class SwiftTestingCMakeShim (cmake_product .CMakeProduct ):
96+ def clean (self , host_target ):
97+ shell .rmtree (self .build_dir )
98+
9199 def build (self , host_target ):
92100 override_deployment_version = None
93101 if host_target .startswith ('macosx' ):
0 commit comments