@@ -53,30 +53,19 @@ def run(prog, *, cwd, env=None, input=None):
53
53
subprocess .run (prog , cwd = cwd , env = runenv , input = input , text = True , check = True )
54
54
55
55
56
- def get_cmake_package_locations (build_tree ):
57
- build_tree = pathlib .Path (build_tree )
58
- return {
59
- package : next (build_tree .rglob (f"{ package } Config.cmake" ))
60
- for package in REQUIRED_CMAKE_PACKAGES
61
- }
62
-
63
-
64
56
def get_platform ():
65
57
return "linux" if platform .system () == "Linux" else "macos"
66
58
67
59
68
- def configure_dummy_project (tmp , package_locations ):
60
+ def configure_dummy_project (tmp , llvm , swift , swift_syntax ):
69
61
print ("configuring dummy cmake project" )
70
62
script_dir = pathlib .Path (os .path .realpath (__file__ )).parent
71
63
print (script_dir )
72
64
shutil .copy (script_dir / "CMakeLists.txt" , tmp / "CMakeLists.txt" )
73
65
shutil .copy (script_dir / "empty.cpp" , tmp / "empty.cpp" )
74
66
tgt = tmp / "build"
75
67
tgt .mkdir ()
76
- cmd = ["cmake" , ".." , "-DBUILD_SHARED_LIBS=OFF" ]
77
- cmd += [
78
- f"-D{ package } _DIR={ location .parent } " for package , location in package_locations .items ()
79
- ]
68
+ run (["cmake" , f"-DCMAKE_PREFIX_PATH={ llvm } ;{ swift } ;{ swift_syntax } /cmake/modules" , "-DBUILD_SHARED_LIBS=OFF" , ".." ], cwd = tgt )
80
69
run (cmd , cwd = tgt )
81
70
return tgt
82
71
@@ -203,13 +192,14 @@ def main(opts):
203
192
if os .path .exists (tmp ):
204
193
shutil .rmtree (tmp )
205
194
os .mkdir (tmp )
206
- configured = configure_dummy_project (tmp , get_cmake_package_locations (opts .build_tree ))
195
+ llvm_build_tree = next (pathlib .Path (opts .build_tree ).glob ("llvm-*" ))
196
+ swift_build_tree = next (pathlib .Path (opts .build_tree ).glob ("swift-*" ))
197
+ earlyswiftsyntax_build_tree = next (pathlib .Path (opts .build_tree ).glob ("earlyswiftsyntax-*" ))
198
+ configured = configure_dummy_project (tmp , llvm_build_tree , swift_build_tree , earlyswiftsyntax_build_tree )
207
199
libs = get_libs (configured )
208
200
209
201
exported = tmp / "exported"
210
202
exported .mkdir ()
211
- llvm_build_tree = next (pathlib .Path (opts .build_tree ).glob ("llvm-*" ))
212
- swift_build_tree = next (pathlib .Path (opts .build_tree ).glob ("swift-*" ))
213
203
export_libs (exported , libs , swift_build_tree )
214
204
export_headers (exported , opts .swift_source_tree , llvm_build_tree , swift_build_tree )
215
205
export_sdk (exported / "sdk" , opts .swift_source_tree , swift_build_tree )
0 commit comments