@@ -34,21 +34,35 @@ def build(self, host_target):
34
34
self .args .install_prefix )
35
35
swiftc = os .path .join (toolchain_path , 'usr' , 'bin' , 'swiftc' )
36
36
37
- shell .call ([
38
- self .toolchain .cmake ,
39
- '-G' , 'Ninja' ,
40
- '-D' , 'BUILD_SHARED_LIBS=YES' ,
41
- '-D' , 'CMAKE_INSTALL_PREFIX={}/usr' .format (
42
- self .args .install_destdir ),
43
- '-D' , 'CMAKE_MAKE_PROGRAM={}' .format (self .toolchain .ninja ),
44
- '-D' , 'CMAKE_Swift_COMPILER={}' .format (swiftc ),
45
- '-B' , self .build_dir ,
46
- '-S' , self .source_dir ,
47
- ])
48
- shell .call ([
49
- self .toolchain .cmake ,
50
- '--build' , self .build_dir ,
51
- ])
37
+ # FIXME: this is a workaround for CMake <3.16 which does not correctly
38
+ # generate the build rules if you are not in the build directory. As a
39
+ # result, we need to create the build tree before we can use it and
40
+ # change into it.
41
+ #
42
+ # NOTE: unfortunately, we do not know if the build is using Python
43
+ # 2.7 or Python 3.2+. In the latter, the `exist_ok` named parameter
44
+ # would alleviate some of this issue.
45
+ try :
46
+ os .makedirs (self .build_dir )
47
+ except OSError :
48
+ pass
49
+
50
+ with shell .pushd (self .build_dir ):
51
+ shell .call ([
52
+ self .toolchain .cmake ,
53
+ '-G' , 'Ninja' ,
54
+ '-D' , 'BUILD_SHARED_LIBS=YES' ,
55
+ '-D' , 'CMAKE_INSTALL_PREFIX={}/usr' .format (
56
+ self .args .install_destdir ),
57
+ '-D' , 'CMAKE_MAKE_PROGRAM={}' .format (self .toolchain .ninja ),
58
+ '-D' , 'CMAKE_Swift_COMPILER={}' .format (swiftc ),
59
+ '-B' , self .build_dir ,
60
+ '-S' , self .source_dir ,
61
+ ])
62
+ shell .call ([
63
+ self .toolchain .cmake ,
64
+ '--build' , self .build_dir ,
65
+ ])
52
66
53
67
def should_test (self , host_target ):
54
68
return self .args .test_pythonkit
0 commit comments