18
18
from . import product
19
19
from . import swift
20
20
from . import swift_testing_macros
21
+ from .. import shell
21
22
22
23
23
24
class SwiftTesting (product .Product ):
@@ -38,6 +39,10 @@ def get_dependencies(cls):
38
39
return [swift .Swift ,
39
40
swift_testing_macros .SwiftTestingMacros ]
40
41
42
+ def should_clean (self , host_target ):
43
+ # Workaround for 'swift-testing' not detecting compiler/stdlib changes.
44
+ return True
45
+
41
46
def should_build (self , host_target ):
42
47
return True
43
48
@@ -59,35 +64,38 @@ def _cmake_product(self, host_target):
59
64
source_dir = self .source_dir ,
60
65
build_dir = build_dir )
61
66
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 )
67
69
68
70
# For Darwin host, 'build' is only called for the builder.
69
71
# 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 ):
71
73
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 )
73
81
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 )
76
87
77
88
def _install_with_cmake (self , host_target ):
78
89
self ._cmake_product (host_target ).install (host_target )
79
90
80
91
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 )
88
93
89
94
90
95
class SwiftTestingCMakeShim (cmake_product .CMakeProduct ):
96
+ def clean (self , host_target ):
97
+ shell .rmtree (self .build_dir )
98
+
91
99
def build (self , host_target ):
92
100
override_deployment_version = None
93
101
if host_target .startswith ('macosx' ):
0 commit comments