Skip to content

Commit e99a055

Browse files
authored
Merge pull request #37 from Vertexwahn/mac-fix
Fix
2 parents 4d5a296 + b646092 commit e99a055

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

extension/qt/6.8.3/mac_aarch64.BUILD

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
load("@rules_cc//cc:cc_library.bzl", "cc_library")
22
load("@rules_qt//:qt_libraries.bzl", "QT_LIBRARIES")
33

4+
# Create a mapping of available frameworks by checking for header files in each framework
5+
# We look for any file in the Headers directory to determine if a framework exists
6+
_all_framework_headers = glob(["lib/*.framework/Headers/*"], allow_empty = True)
7+
# Extract unique framework names from the header paths
8+
_available_framework_names = {hdr.split("/")[1].replace(".framework", ""): True for hdr in _all_framework_headers}.keys()
9+
10+
# Convert Qt6XXX library names to QtXXX framework names (e.g., Qt6Core -> QtCore, Qt63DCore -> Qt3DCore)
11+
_framework_names = {library_name: ("Qt" + library_name[3:] if library_name.startswith("Qt6") else library_name) for _, _, library_name, _ in QT_LIBRARIES}
12+
413
[
514
cc_library(
615
name = "qt_%s_mac" % name,
@@ -10,7 +19,7 @@ load("@rules_qt//:qt_libraries.bzl", "QT_LIBRARIES")
1019
],
1120
additional_linker_inputs = [":lib"],
1221
linkopts = ["-F $(location :lib)"] + [
13-
"-framework %s" % library_name.replace("6", ""), # macOS qt libs do not contain a 6 - e.g. instead of Qt6Core the lib is called QtCore
22+
"-framework %s" % _framework_names[library_name], # macOS qt libs do not contain a 6 - e.g. instead of Qt6Core the lib is called QtCore
1423
"-rpath $(rootpath :lib)",
1524
],
1625
include_prefix = "%s" % include_folder,
@@ -19,6 +28,20 @@ load("@rules_qt//:qt_libraries.bzl", "QT_LIBRARIES")
1928
visibility = ["//visibility:public"],
2029
)
2130
for name, include_folder, library_name, _ in QT_LIBRARIES
31+
if _framework_names[library_name] in _available_framework_names
32+
]
33+
34+
# Create stub libraries for Qt modules that don't exist on macOS
35+
# This prevents build failures when code depends on `:qt` which includes all modules
36+
[
37+
cc_library(
38+
name = "qt_%s_mac" % name,
39+
target_compatible_with = ["@platforms//os:osx"],
40+
visibility = ["//visibility:public"],
41+
tags = ["manual"], # Don't build unless explicitly requested
42+
)
43+
for name, include_folder, library_name, _ in QT_LIBRARIES
44+
if _framework_names[library_name] not in _available_framework_names
2245
]
2346

2447
cc_library(

0 commit comments

Comments
 (0)