Skip to content

Commit dfeadb6

Browse files
committed
fix(generator): normalize macOS framework includes to bare Qt headers
Follow-up of 19738be ("feat(generator): discover Qt include/framework paths dynamically; add PYTHONQT_FRAMEWORK", 2025-09-18). On macOS, headers parsed from framework paths like: .../QtCore.framework/Headers/qbytearray.h .../QtCore.framework/Versions/A/Headers/qbytearray.h were emitted as relative framework paths. Update `AbstractMetaBuilder::getRelativeInclude()` to detect both layouts and emit only the basename (e.g., `<qbytearray.h>`).
1 parent 3f119cb commit dfeadb6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

generator/abstractmetabuilder.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#include <QtCore/QTextStream>
6161
#include <QtCore/QVariant>
6262
#include <QtCore/QDir>
63+
#include <QtCore/QRegularExpression>
6364

6465
static QString strip_template_args(const QString &name)
6566
{
@@ -416,6 +417,22 @@ AbstractMetaClass* AbstractMetaBuilder::getGlobalNamespace(const TypeEntry* type
416417

417418
Include AbstractMetaBuilder::getRelativeInclude(const QString& path)
418419
{
420+
#ifdef Q_OS_MACOS
421+
// If the parsed header lives inside a macOS framework bundle, emit just the
422+
// bare header name (e.g., "qbytearray.h") so generators will produce <...>.
423+
//
424+
// Match both:
425+
// .../QtCore.framework/Headers/...
426+
// .../QtCore.framework/Versions/<X>/Headers/...
427+
static const QRegularExpression fwHeadersRe(
428+
QStringLiteral(R"(\.framework/(Versions/[^/]+/)?Headers/)")
429+
);
430+
if (fwHeadersRe.match(path).hasMatch()) {
431+
const QString base = QFileInfo(path).fileName(); // e.g., "qbytearray.h"
432+
return Include(Include::IncludePath, base); // choose <> style
433+
}
434+
#endif
435+
419436
QString bestRelativePath;
420437
int bestNumDirectories = 0;
421438
// find the shortest relative path relative to all given include directories

0 commit comments

Comments
 (0)