12
12
13
13
import os
14
14
15
+ from build_swift .build_swift .versions import Version
16
+
15
17
from . import cmake_product
18
+ from . import product
16
19
from . import swift
17
20
18
21
19
- class SwiftTesting (cmake_product . CMakeProduct ):
22
+ class SwiftTesting (product . Product ):
20
23
@classmethod
21
24
def is_build_script_impl_product (cls ):
22
25
return False
@@ -36,7 +39,59 @@ def get_dependencies(cls):
36
39
def should_build (self , host_target ):
37
40
return True
38
41
42
+ def should_test (self , host_target ):
43
+ # TODO: Implement.
44
+ return False
45
+
46
+ def should_install (self , host_target ):
47
+ return self .args .install_swift_testing_macros
48
+
49
+ def _cmake_product (self , host_target ):
50
+ build_root = os .path .dirname (self .build_dir )
51
+ build_dir = os .path .join (
52
+ build_root , '%s-%s' % (self .product_name (), host_target ))
53
+
54
+ return SwiftTestingCMakeShim (
55
+ args = self .args ,
56
+ toolchain = self .toolchain ,
57
+ source_dir = self .source_dir ,
58
+ build_dir = build_dir )
59
+
60
+ def _build_with_cmake (self , host_target ):
61
+ self ._cmake_product (host_target ).build (host_target )
62
+
63
+ def build (self , host_target ):
64
+ self ._build_with_cmake (host_target )
65
+
66
+ # For Darwin host, 'build' is only called for the builder.
67
+ # Manually iterate the cross compile hosts.
68
+ if self .has_cross_compile_hosts () and self .is_darwin_host (host_target ):
69
+ for target in self .args .cross_compile_hosts :
70
+ self ._build_with_cmake (target )
71
+
72
+ # FIXME: build testing library for 'stdlib_deployment_targets'?
73
+ pass
74
+
75
+ def _install_with_cmake (self , host_target ):
76
+ self ._cmake_product (host_target ).install (host_target )
77
+
78
+ def install (self , host_target ):
79
+ self ._install_with_cmake (host_target )
80
+
81
+ # For Darwin host, 'install' is only called for the builder.
82
+ # Manually iterate the cross compile hosts.
83
+ if self .has_cross_compile_hosts () and self .is_darwin_host (host_target ):
84
+ for target in self .args .cross_compile_hosts :
85
+ self ._install_with_cmake (target )
86
+
87
+
88
+ class SwiftTestingCMakeShim (cmake_product .CMakeProduct ):
39
89
def build (self , host_target ):
90
+ override_deployment_version = None
91
+ if host_target .startswith ('macosx' ):
92
+ if Version (self .args .darwin_deployment_version_osx ) < Version ('10.15' ):
93
+ override_deployment_version = '10.15'
94
+
40
95
self .cmake_options .define ('BUILD_SHARED_LIBS' , 'YES' )
41
96
42
97
# Use empty CMake install prefix, since the `DESTDIR` env var is set by
@@ -45,22 +100,14 @@ def build(self, host_target):
45
100
46
101
self .cmake_options .define ('CMAKE_BUILD_TYPE' , self .args .build_variant )
47
102
48
- build_root = os .path .dirname (self .build_dir )
49
- swift_build_dir = os .path .join (
50
- '..' , build_root , '%s-%s' % ('swift' , host_target ))
51
- swift_cmake_dir = os .path .join (swift_build_dir , 'cmake' , 'modules' )
52
- self .cmake_options .define ('SwiftSyntax_DIR:PATH' , swift_cmake_dir )
103
+ # FIXME: If we build macros for the builder, specify the path.
104
+ self .cmake_options .define ('SwiftTesting_MACRO' , 'NO' )
53
105
106
+ self .generate_toolchain_file_for_darwin_or_linux (
107
+ host_target , override_macos_deployment_version = override_deployment_version )
54
108
self .build_with_cmake ([], self .args .build_variant , [],
55
109
prefer_native_toolchain = True )
56
110
57
- def should_test (self , host_target ):
58
- # TODO
59
- return False
60
-
61
- def should_install (self , host_target ):
62
- return self .args .install_swift_testing
63
-
64
111
def install (self , host_target ):
65
112
install_destdir = self .host_install_destdir (host_target )
66
113
install_prefix = install_destdir + self .args .install_prefix
0 commit comments