Skip to content

Commit a14f464

Browse files
committed
feat: pull qt and libclang prebuilts instead of building from source
1 parent 46dec77 commit a14f464

8 files changed

Lines changed: 234 additions & 161 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ThirdParty/Lib
1717
ThirdParty/ConanRecipes/**/src
1818
ThirdParty/ConanRecipes/**/build
1919
ThirdParty/ConanRecipes/**/CMakeUserPresets.json
20+
aqtinstall.log
2021

2122
# Test Project
2223
TestProject/.idea

ThirdParty/ConanRecipes/README.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,3 @@ conan export-pkg qt/conanfile.py --version="6.10.1-exp"
2525
# test stage
2626
conan test qt/test_package qt/6.10.1-exp
2727
```
28-
29-
# Windows User Notice
30-
On the Windows platform, we consider some Visual Studio components as part of the system toolchain. These components are not automatically configured in the conan script, so you will need to install them manually:
31-
32-
* ATL
33-
* Windows SDK
34-
* Windows Driver Kit
35-
36-
And some lib may build failed with long build tree path in development mode (like qt-webengine), in this case, you can use the commands to map conan recipes working directory as a driver and execute all conan commands in the driver root:
37-
38-
```shell
39-
# map
40-
subst z: path/to/engine/ThirdParty/ConanRecipes
41-
42-
# unmap
43-
subst z: /d
44-
```

ThirdParty/ConanRecipes/dxc/conanfile.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,22 @@ def build(self):
4848
predefined_params_file = os.path.join(self.source_folder, "cmake", "caches", "PredefinedParams.cmake")
4949

5050
cmake = CMake(self)
51-
cmake.configure(cli_args=["-C", predefined_params_file, f"-DCMAKE_INSTALL_PREFIX={install_folder}"])
51+
# Disable every test sub-tree:
52+
# * HLSL_INCLUDE_TESTS=ON (set by PredefinedParams.cmake) drags in TAEF
53+
# via projects/dxilconv/unittests, which isn't shipped with the SDK.
54+
# * SPIRV_BUILD_TESTS=ON (also from PredefinedParams) builds GoogleTest.
55+
# * LLVM/CLANG_INCLUDE_TESTS=ON (CMake default) wires `check-all` up to
56+
# `ExecHLSLTests`/`dxc_batch`, which only exist when HLSL tests are on
57+
# and break configure once we turn them off.
58+
# Command line -D values take precedence over the -C cache file.
59+
cmake.configure(cli_args=[
60+
"-C", predefined_params_file,
61+
f"-DCMAKE_INSTALL_PREFIX={install_folder}",
62+
"-DHLSL_INCLUDE_TESTS=OFF",
63+
"-DSPIRV_BUILD_TESTS=OFF",
64+
"-DLLVM_INCLUDE_TESTS=OFF",
65+
"-DCLANG_INCLUDE_TESTS=OFF",
66+
])
5267
cmake.build()
5368
cmake.build(target="install-distribution")
5469

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
sources:
2-
"21.1.7-exp":
3-
url: "https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-21.1.7.tar.gz"
2+
"22.1.6-exp":
3+
Windows-x86_64:
4+
url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-22.1.6/clang%2Bllvm-22.1.6-x86_64-pc-windows-msvc.tar.xz"
5+
sha256: "657343edf361ca463bd642e39c74b251c6338b96cdbd55ff277555298b027696"
6+
Linux-x86_64:
7+
url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-22.1.6/LLVM-22.1.6-Linux-X64.tar.xz"
8+
sha256: "c5ac8ef89ca39d30cb32e9b83772f995dd891c685ebc188d593c943a64d5f8b5"
9+
Macos-armv8:
10+
url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-22.1.6/LLVM-22.1.6-macOS-ARM64.tar.xz"
11+
sha256: "8059d9d9eeb059c30d812b4a37291888f8dcba04d2b5ace61fd12d2904eaa0e9"
Lines changed: 63 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,71 @@
11
from conan import ConanFile
2-
from conan.tools.build import check_min_cppstd
3-
from conan.tools.build import can_run
4-
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
5-
from conan.tools.files import apply_conandata_patches, get, copy
2+
from conan.errors import ConanInvalidConfiguration
3+
from conan.tools.files import copy, get
64
import os
75

86
required_conan_version = ">=2.0.9"
97

8+
109
class LibclangConan(ConanFile):
1110
name = "libclang"
12-
description = "llvm - libclang"
13-
license = "https://github.com/llvm/llvm-project/blob/main/LICENSE.TXT"
14-
url = "https://github.com/conan-io/conan-center-index"
11+
description = "LLVM libclang (prebuilt, repackaged from llvm-project release artifacts)"
12+
license = "Apache-2.0 WITH LLVM-exception"
13+
url = "https://github.com/llvm/llvm-project"
1514
homepage = "https://github.com/llvm/llvm-project"
16-
topics = ("llvm", "tool")
15+
topics = ("llvm", "clang", "tool", "prebuilt")
1716
package_type = "shared-library"
1817
settings = "os", "arch", "compiler", "build_type"
18+
no_copy_source = True
1919

20-
def layout(self):
21-
cmake_layout(self, src_folder="src")
20+
def _source_entry(self):
21+
sources = self.conan_data.get("sources", {}).get(str(self.version), {})
22+
return sources.get(f"{self.settings.os}-{self.settings.arch}")
2223

2324
def validate(self):
24-
check_min_cppstd(self, 17)
25-
26-
def build_requirements(self):
27-
self.tool_requires("ninja/[>=1.12]")
28-
self.tool_requires("cmake/[>=3.16]")
29-
30-
def source(self):
31-
get(self, **self.conan_data["sources"][self.version], strip_root=True)
32-
apply_conandata_patches(self)
33-
34-
def generate(self):
35-
cmake_toolchain = CMakeToolchain(self, generator="Ninja")
36-
cmake_toolchain.cache_variables["LLVM_ENABLE_PROJECTS"] = "clang"
37-
cmake_toolchain.generate()
38-
39-
deps = CMakeDeps(self)
40-
deps.generate()
25+
if self._source_entry() is None:
26+
available = sorted(
27+
self.conan_data.get("sources", {}).get(str(self.version), {})
28+
)
29+
raise ConanInvalidConfiguration(
30+
f"libclang/{self.version} prebuilt is not available for "
31+
f"{self.settings.os}/{self.settings.arch}. Supported: {available}"
32+
)
4133

4234
def build(self):
43-
cmake = CMake(self)
44-
install_folder = os.path.join(self.build_folder, "installed")
45-
cmake.configure(build_script_folder=os.path.join(self.source_folder, "llvm"), cli_args=[f"-DCMAKE_INSTALL_PREFIX={install_folder}"])
46-
cmake.build(target="libclang")
47-
cmake.build(target="install-libclang")
48-
cmake.build(target="install-libclang-headers")
35+
get(self, **self._source_entry(), strip_root=True, destination=self.build_folder)
4936

5037
def package(self):
51-
copy(self, "*", os.path.join(self.build_folder, "installed"), self.package_folder)
38+
src = self.build_folder
39+
# Public C API headers; skip the multi-GB clang/llvm internal headers.
40+
copy(self, "clang-c/*",
41+
os.path.join(src, "include"),
42+
os.path.join(self.package_folder, "include"))
43+
if self.settings.os == "Windows":
44+
copy(self, "libclang.dll", os.path.join(src, "bin"),
45+
os.path.join(self.package_folder, "bin"))
46+
copy(self, "libclang.lib", os.path.join(src, "lib"),
47+
os.path.join(self.package_folder, "lib"))
48+
elif self.settings.os == "Linux":
49+
copy(self, "libclang.so*", os.path.join(src, "lib"),
50+
os.path.join(self.package_folder, "lib"))
51+
self._ensure_unversioned_symlink("libclang.so")
52+
elif self.settings.os == "Macos":
53+
copy(self, "libclang*.dylib", os.path.join(src, "lib"),
54+
os.path.join(self.package_folder, "lib"))
55+
self._ensure_unversioned_symlink("libclang.dylib")
56+
# License: Linux/macOS CPack tarballs put it at the root, the Windows
57+
# tarball nests it under include/llvm/Support/.
58+
for rel in ("LICENSE.TXT", "include/llvm/Support/LICENSE.TXT"):
59+
full = os.path.join(src, rel)
60+
if os.path.isfile(full):
61+
copy(self, os.path.basename(rel), os.path.dirname(full),
62+
os.path.join(self.package_folder, "licenses"))
63+
break
64+
65+
def package_id(self):
66+
# libclang is C ABI; the same prebuilt serves any compiler/build_type.
67+
del self.info.settings.compiler
68+
del self.info.settings.build_type
5269

5370
def package_info(self):
5471
self.cpp_info.includedirs = ["include"]
@@ -58,8 +75,16 @@ def package_info(self):
5875
self.cpp_info.bindirs = ["bin"]
5976
else:
6077
self.cpp_info.libs = ["clang"]
78+
self.cpp_info.bindirs = ["lib"]
6179

62-
def test(self):
63-
if can_run(self):
64-
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
65-
self.run(bin_path, env="conanrun")
80+
def _ensure_unversioned_symlink(self, base):
81+
"""LLVM CPack tarballs ship libclang.so.X / libclang.X.dylib but may
82+
omit the unversioned symlink CMakeDeps needs to resolve `-lclang`."""
83+
pkg_lib = os.path.join(self.package_folder, "lib")
84+
target = os.path.join(pkg_lib, base)
85+
if not os.path.isdir(pkg_lib) or os.path.lexists(target):
86+
return
87+
candidates = sorted(f for f in os.listdir(pkg_lib)
88+
if f.startswith(base) and f != base)
89+
if candidates:
90+
os.symlink(candidates[-1], target)
Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,2 @@
1-
sources:
2-
"6.10.1-exp":
3-
url:
4-
- "https://mirrors.cloud.tencent.com/qt/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
5-
- "https://download.qt.io/official_releases/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
6-
- "https://download.qt.io/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
7-
- "https://mirrors.ukfast.co.uk/sites/qt.io/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
8-
- "https://mirrors.20i.com/pub/qt.io/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
9-
- "https://ftp.nluug.nl/languages/qt/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
10-
- "https://mirror.netcologne.de/qtproject/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
11-
- "https://qt-mirror.dannhauer.de/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
12-
- "https://ftp.fau.de/qtproject/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
13-
- "https://mirrors.dotsrc.org/qtproject/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
14-
- "https://ftp.icm.edu.pl/packages/qt/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
15-
- "https://ftp.acc.umu.se/mirror/qt.io/qtproject/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
16-
- "https://www.nic.funet.fi/pub/mirrors/download.qt-project.org/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
17-
- "https://qt.mirror.constant.com/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
18-
- "https://mirrors.sau.edu.cn/qt/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
19-
- "https://mirror.bjtu.edu.cn/qt/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
20-
- "https://mirrors.sjtug.sjtu.edu.cn/qt/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
21-
- "https://ftp.jaist.ac.jp/pub/qtproject/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
22-
- "https://ftp.yz.yamagata-u.ac.jp/pub/qtproject/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz"
23-
sha256: "0ed08b079719394303cd2054b66b2dc0c5895ceeb88fb6131c18991c980bf00f"
1+
versions:
2+
- "6.10.3-exp"

0 commit comments

Comments
 (0)