Skip to content

Commit 7311b3b

Browse files
committed
Switch back to CMAKE_PREFIX_PATH
1 parent 72b91fb commit 7311b3b

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

pkg_swift_llvm.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,31 +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-
6456
def 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-
]
80-
run(cmd, cwd=tgt)
68+
run(["cmake", f"-DCMAKE_PREFIX_PATH={llvm};{swift};{swift_syntax}/cmake/modules", "-DBUILD_SHARED_LIBS=OFF", ".."], cwd=tgt)
8169
return tgt
8270

8371

@@ -203,13 +191,14 @@ def main(opts):
203191
if os.path.exists(tmp):
204192
shutil.rmtree(tmp)
205193
os.mkdir(tmp)
206-
configured = configure_dummy_project(tmp, get_cmake_package_locations(opts.build_tree))
194+
llvm_build_tree = next(pathlib.Path(opts.build_tree).glob("llvm-*"))
195+
swift_build_tree = next(pathlib.Path(opts.build_tree).glob("swift-*"))
196+
earlyswiftsyntax_build_tree = next(pathlib.Path(opts.build_tree).glob("earlyswiftsyntax-*"))
197+
configured = configure_dummy_project(tmp, llvm_build_tree, swift_build_tree, earlyswiftsyntax_build_tree)
207198
libs = get_libs(configured)
208199

209200
exported = tmp / "exported"
210201
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-*"))
213202
export_libs(exported, libs, swift_build_tree)
214203
export_headers(exported, opts.swift_source_tree, llvm_build_tree, swift_build_tree)
215204
export_sdk(exported / "sdk", opts.swift_source_tree, swift_build_tree)

0 commit comments

Comments
 (0)