@@ -53,30 +53,19 @@ def run(prog, *, cwd, env=None, input=None):
5353 subprocess .run (prog , cwd = cwd , env = runenv , input = input , text = True , check = True )
5454
5555
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-
6456def get_platform ():
6557 return "linux" if platform .system () == "Linux" else "macos"
6658
6759
68- def configure_dummy_project (tmp , package_locations ):
60+ def configure_dummy_project (tmp , llvm , swift , swift_syntax ):
6961 print ("configuring dummy cmake project" )
7062 script_dir = pathlib .Path (os .path .realpath (__file__ )).parent
7163 print (script_dir )
7264 shutil .copy (script_dir / "CMakeLists.txt" , tmp / "CMakeLists.txt" )
7365 shutil .copy (script_dir / "empty.cpp" , tmp / "empty.cpp" )
7466 tgt = tmp / "build"
7567 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 )
8069 run (cmd , cwd = tgt )
8170 return tgt
8271
@@ -203,13 +192,14 @@ def main(opts):
203192 if os .path .exists (tmp ):
204193 shutil .rmtree (tmp )
205194 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 )
207199 libs = get_libs (configured )
208200
209201 exported = tmp / "exported"
210202 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-*" ))
213203 export_libs (exported , libs , swift_build_tree )
214204 export_headers (exported , opts .swift_source_tree , llvm_build_tree , swift_build_tree )
215205 export_sdk (exported / "sdk" , opts .swift_source_tree , swift_build_tree )
0 commit comments