summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2023-02-27 20:53:57 +0100
committerPaul Wicking <paul.wicking@qt.io>2023-03-04 21:02:05 +0100
commitf1f4cad99a7097c8612ec1c5b05b1b5647e05251 (patch)
treeec1130e0c456178d71a72e44726820a8b78deac6
parentd4ca672f987916b0e05e014f0ba40d8facab871d (diff)
downloadqttools-f1f4cad99a7097c8612ec1c5b05b1b5647e05251.tar.gz
QDoc: Always depend on QmlPrivate
Make Qml a hard dependency for QDoc. - There are no known usecases for running QDoc without qml support. - We're not testing QDoc without qml support, as it's not officially supported. - There are known issues with parsing certain file types when qml support is missing. - Dropping feature checks makes the code easier to reason about and thus maintain. - Clean up some of the configure and CMake configuration that's affected by the change. [ChangeLog][QDoc] QDoc now requires the library QmlPrivate. Make sure the qtdeclarative module is available. Fixes: QTBUG-111673 Change-Id: I3a8aa20ace3c379c3896b9f59aa4e8113cd9a873 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r--configure.cmake20
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/qdoc/CMakeLists.txt11
-rw-r--r--src/qdoc/qmlcodemarker.cpp25
-rw-r--r--src/qdoc/qmlcodemarker.h6
-rw-r--r--src/qdoc/qmlcodeparser.cpp22
-rw-r--r--src/qdoc/qmlcodeparser.h12
-rw-r--r--src/qdoc/qmlmarkupvisitor.cpp9
-rw-r--r--src/qdoc/qmlmarkupvisitor.h7
-rw-r--r--src/qdoc/qmlvisitor.cpp9
-rw-r--r--src/qdoc/qmlvisitor.h8
11 files changed, 40 insertions, 91 deletions
diff --git a/configure.cmake b/configure.cmake
index 1cd61cde9..9fbbe2c9b 100644
--- a/configure.cmake
+++ b/configure.cmake
@@ -45,12 +45,17 @@ qt_feature("assistant" PRIVATE
CONDITION TARGET Qt::Widgets AND QT_FEATURE_png AND QT_FEATURE_pushbutton AND QT_FEATURE_toolbutton AND (sqlite_plugin_available OR QT_BUILD_SHARED_LIBS)
)
qt_feature("clang" PRIVATE
- LABEL "QDoc"
+ LABEL "libclang found"
CONDITION TEST_libclang
)
+qt_feature("qdoc" PRIVATE
+ LABEL "QDoc"
+ PURPOSE "QDoc is Qt's documentation generator for C++ and QML projects."
+ CONDITION TARGET Qt::QmlPrivate AND QT_FEATURE_clang AND QT_FEATURE_clangcpp AND QT_FEATURE_commandlineparser AND QT_FEATURE_thread
+)
qt_feature("clangcpp" PRIVATE
LABEL "Clang-based lupdate parser"
- CONDITION QT_FEATURE_clang AND TEST_libclang
+ CONDITION QT_FEATURE_clang
)
qt_feature("designer" PRIVATE
LABEL "Qt Designer"
@@ -109,6 +114,7 @@ qt_configure_add_summary_entry(ARGS "distancefieldgenerator")
qt_configure_add_summary_entry(ARGS "linguist")
qt_configure_add_summary_entry(ARGS "pixeltool")
qt_configure_add_summary_entry(ARGS "qdbus")
+qt_configure_add_summary_entry(ARGS "qdoc")
#qt_configure_add_summary_entry(ARGS "qev")
qt_configure_add_summary_entry(ARGS "qtattributionsscanner")
qt_configure_add_summary_entry(ARGS "qtdiag")
@@ -126,6 +132,16 @@ You will also need to set the FEATURE_clang CMake variable to ON to re-evaluate
)
qt_configure_add_report_entry(
TYPE WARNING
+ MESSAGE "QDoc will not be compiled because the QmlPrivate library wasn't found."
+ CONDITION NOT TARGET Qt::QmlPrivate
+)
+qt_configure_add_report_entry(
+ TYPE WARNING
+ MESSAGE "QDoc cannot be compiled without Qt's commandline parser or thread features."
+ CONDITION NOT QT_FEATURE_commandlineparser OR NOT QT_FEATURE_thread
+)
+qt_configure_add_report_entry(
+ TYPE WARNING
MESSAGE "Clang-based lupdate parser will not be available. LLVM and Clang C++ libraries have not been found.
You will need to set the FEATURE_clangcpp CMake variable to ON to re-evaluate this check."
CONDITION NOT QT_FEATURE_clangcpp
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6356cd7ad..466fca7a0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -45,7 +45,7 @@ endif()
if(QT_FEATURE_qtplugininfo)
add_subdirectory(qtplugininfo)
endif()
-if(QT_FEATURE_clang AND QT_FEATURE_clangcpp AND QT_FEATURE_commandlineparser AND QT_FEATURE_thread)
+if(QT_FEATURE_qdoc AND QT_FEATURE_clangcpp)
add_subdirectory(qdoc)
endif()
if(QT_FEATURE_qdbus)
diff --git a/src/qdoc/CMakeLists.txt b/src/qdoc/CMakeLists.txt
index 9d8682279..d774b70c1 100644
--- a/src/qdoc/CMakeLists.txt
+++ b/src/qdoc/CMakeLists.txt
@@ -85,6 +85,7 @@ qt_internal_add_tool(${target_name}
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}
LIBRARIES
+ Qt::QmlPrivate
WrapLibClang::WrapLibClang
DEFINES
#(CLANG_RESOURCE_DIR=\"/clang//include\") # special case remove
@@ -100,16 +101,6 @@ qt_internal_return_unless_building_tools()
# TODO: Re-enable PIE once clang is built with PIE in provisioning.
set_target_properties(${target_name} PROPERTIES POSITION_INDEPENDENT_CODE FALSE)
-qt_internal_extend_target(${target_name} CONDITION TARGET Qt::QmlPrivate
- LIBRARIES
- Qt::QmlPrivate
-)
-
-qt_internal_extend_target(${target_name} CONDITION NOT TARGET Qt::QmlPrivate
- DEFINES
- QT_NO_DECLARATIVE
-)
-
qt_internal_extend_target(${target_name} CONDITION (WIN32 AND ICC) OR MSVC
LINK_OPTIONS
"/STACK:4194304"
diff --git a/src/qdoc/qmlcodemarker.cpp b/src/qdoc/qmlcodemarker.cpp
index 20b2ccffc..30dec979e 100644
--- a/src/qdoc/qmlcodemarker.cpp
+++ b/src/qdoc/qmlcodemarker.cpp
@@ -10,13 +10,11 @@
#include "qmlmarkupvisitor.h"
#include "text.h"
-#ifndef QT_NO_DECLARATIVE
-# include <private/qqmljsast_p.h>
-# include <private/qqmljsastfwd_p.h>
-# include <private/qqmljsengine_p.h>
-# include <private/qqmljslexer_p.h>
-# include <private/qqmljsparser_p.h>
-#endif
+#include <private/qqmljsast_p.h>
+#include <private/qqmljsastfwd_p.h>
+#include <private/qqmljsengine_p.h>
+#include <private/qqmljslexer_p.h>
+#include <private/qqmljsparser_p.h>
QT_BEGIN_NAMESPACE
@@ -25,7 +23,6 @@ QT_BEGIN_NAMESPACE
*/
bool QmlCodeMarker::recognizeCode(const QString &code)
{
-#ifndef QT_NO_DECLARATIVE
// Naive pre-check; starts with an import statement or 'CamelCase {'
static const QRegularExpression regExp(QStringLiteral("^\\s*(import |([A-Z][a-z0-9]*)+\\s?{)"));
if (!regExp.match(code).hasMatch())
@@ -40,10 +37,6 @@ bool QmlCodeMarker::recognizeCode(const QString &code)
lexer.setCode(newCode, 1);
return parser.parse();
-#else
- Q_UNUSED(code);
- return false;
-#endif
}
/*!
@@ -99,7 +92,6 @@ QString QmlCodeMarker::markedUpInclude(const QString &include)
QString QmlCodeMarker::addMarkUp(const QString &code, const Node * /* relative */,
const Location &location)
{
-#ifndef QT_NO_DECLARATIVE
QQmlJS::Engine engine;
QQmlJS::Lexer lexer(&engine);
@@ -131,14 +123,8 @@ QString QmlCodeMarker::addMarkUp(const QString &code, const Node * /* relative *
}
return output;
-#else
- Q_UNUSED(code);
- location.warning("QtDeclarative not installed; cannot parse QML or JS.");
- return QString();
-#endif
}
-#ifndef QT_NO_DECLARATIVE
/*
Copied and pasted from
src/declarative/qml/qqmlscriptparser.cpp.
@@ -185,6 +171,5 @@ QList<QQmlJS::SourceLocation> QmlCodeMarker::extractPragmas(QString &script)
}
return removed;
}
-#endif
QT_END_NAMESPACE
diff --git a/src/qdoc/qmlcodemarker.h b/src/qdoc/qmlcodemarker.h
index dc5a79c27..64a1f7c9f 100644
--- a/src/qdoc/qmlcodemarker.h
+++ b/src/qdoc/qmlcodemarker.h
@@ -6,9 +6,7 @@
#include "cppcodemarker.h"
-#ifndef QT_NO_DECLARATIVE
-# include <private/qqmljsastfwd_p.h>
-#endif
+#include <private/qqmljsastfwd_p.h>
QT_BEGIN_NAMESPACE
@@ -29,9 +27,7 @@ public:
QString markedUpInclude(const QString &include) override;
/* Copied from src/declarative/qml/qdeclarativescriptparser.cpp */
-#ifndef QT_NO_DECLARATIVE
QList<QQmlJS::SourceLocation> extractPragmas(QString &script);
-#endif
private:
QString addMarkUp(const QString &code, const Node *relative, const Location &location);
diff --git a/src/qdoc/qmlcodeparser.cpp b/src/qdoc/qmlcodeparser.cpp
index 1e7edee59..4c0eaf150 100644
--- a/src/qdoc/qmlcodeparser.cpp
+++ b/src/qdoc/qmlcodeparser.cpp
@@ -7,9 +7,8 @@
#include "qmlvisitor.h"
#include "utilities.h"
-#ifndef QT_NO_DECLARATIVE
-# include <private/qqmljsast_p.h>
-#endif
+#include <private/qqmljsast_p.h>
+
#include <qdebug.h>
QT_BEGIN_NAMESPACE
@@ -17,12 +16,7 @@ QT_BEGIN_NAMESPACE
/*!
Constructs the QML code parser.
*/
-QmlCodeParser::QmlCodeParser()
-#ifndef QT_NO_DECLARATIVE
- : m_lexer(nullptr), m_parser(nullptr)
-#endif
-{
-}
+QmlCodeParser::QmlCodeParser() : m_lexer(nullptr), m_parser(nullptr) { }
/*!
Initializes the code parser base class.
@@ -32,10 +26,8 @@ void QmlCodeParser::initializeParser()
{
CodeParser::initializeParser();
-#ifndef QT_NO_DECLARATIVE
m_lexer = new QQmlJS::Lexer(&m_engine);
m_parser = new QQmlJS::Parser(&m_engine);
-#endif
}
/*!
@@ -44,10 +36,8 @@ void QmlCodeParser::initializeParser()
*/
void QmlCodeParser::terminateParser()
{
-#ifndef QT_NO_DECLARATIVE
delete m_lexer;
delete m_parser;
-#endif
}
/*!
@@ -84,7 +74,6 @@ void QmlCodeParser::parseSourceFile(const Location &location, const QString &fil
return;
}
-#ifndef QT_NO_DECLARATIVE
QString document = in.readAll();
in.close();
@@ -106,9 +95,6 @@ void QmlCodeParser::parseSourceFile(const Location &location, const QString &fil
msg.loc.startLine, msg.loc.startColumn, qUtf8Printable(msg.message));
}
m_currentFile.clear();
-#else
- location.warning("QtDeclarative not installed; cannot parse QML or JS.");
-#endif
}
static QSet<QString> topicCommands_;
@@ -127,7 +113,6 @@ const QSet<QString> &QmlCodeParser::topicCommands()
return topicCommands_;
}
-#ifndef QT_NO_DECLARATIVE
/*!
Copy and paste from src/declarative/qml/qdeclarativescriptparser.cpp.
This function blanks out the section of the \a str beginning at \a idx
@@ -188,6 +173,5 @@ void QmlCodeParser::extractPragmas(QString &script)
return;
}
}
-#endif
QT_END_NAMESPACE
diff --git a/src/qdoc/qmlcodeparser.h b/src/qdoc/qmlcodeparser.h
index 206c541fb..243c552fb 100644
--- a/src/qdoc/qmlcodeparser.h
+++ b/src/qdoc/qmlcodeparser.h
@@ -8,11 +8,9 @@
#include <QtCore/qset.h>
-#ifndef QT_NO_DECLARATIVE
-# include <private/qqmljsengine_p.h>
-# include <private/qqmljslexer_p.h>
-# include <private/qqmljsparser_p.h>
-#endif
+#include <private/qqmljsengine_p.h>
+#include <private/qqmljslexer_p.h>
+#include <private/qqmljsparser_p.h>
QT_BEGIN_NAMESPACE
@@ -31,20 +29,16 @@ public:
QStringList sourceFileNameFilter() override;
void parseSourceFile(const Location &location, const QString &filePath) override;
-#ifndef QT_NO_DECLARATIVE
/* Copied from src/declarative/qml/qdeclarativescriptparser.cpp */
void extractPragmas(QString &script);
-#endif
protected:
const QSet<QString> &topicCommands();
private:
-#ifndef QT_NO_DECLARATIVE
QQmlJS::Engine m_engine {};
QQmlJS::Lexer *m_lexer { nullptr };
QQmlJS::Parser *m_parser { nullptr };
-#endif
};
QT_END_NAMESPACE
diff --git a/src/qdoc/qmlmarkupvisitor.cpp b/src/qdoc/qmlmarkupvisitor.cpp
index c46c60f8e..31adb838d 100644
--- a/src/qdoc/qmlmarkupvisitor.cpp
+++ b/src/qdoc/qmlmarkupvisitor.cpp
@@ -6,14 +6,11 @@
#include <QtCore/qglobal.h>
#include <QtCore/qstringlist.h>
-#ifndef QT_NO_DECLARATIVE
-# include <private/qqmljsast_p.h>
-# include <private/qqmljsengine_p.h>
-#endif
+#include <private/qqmljsast_p.h>
+#include <private/qqmljsengine_p.h>
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_DECLARATIVE
QmlMarkupVisitor::QmlMarkupVisitor(const QString &source,
const QList<QQmlJS::SourceLocation> &pragmas,
QQmlJS::Engine *engine)
@@ -794,6 +791,4 @@ void QmlMarkupVisitor::throwRecursionDepthError()
m_hasRecursionDepthError = true;
}
-#endif
-
QT_END_NAMESPACE
diff --git a/src/qdoc/qmlmarkupvisitor.h b/src/qdoc/qmlmarkupvisitor.h
index 9c05d4e7f..a19636a67 100644
--- a/src/qdoc/qmlmarkupvisitor.h
+++ b/src/qdoc/qmlmarkupvisitor.h
@@ -9,9 +9,8 @@
#include <QtCore/qstring.h>
-#ifndef QT_NO_DECLARATIVE
-# include <private/qqmljsastvisitor_p.h>
-# include <private/qqmljsengine_p.h>
+#include <private/qqmljsastvisitor_p.h>
+#include <private/qqmljsengine_p.h>
QT_BEGIN_NAMESPACE
@@ -138,5 +137,3 @@ Q_DECLARE_TYPEINFO(QmlMarkupVisitor::ExtraType, Q_PRIMITIVE_TYPE);
QT_END_NAMESPACE
#endif
-
-#endif
diff --git a/src/qdoc/qmlvisitor.cpp b/src/qdoc/qmlvisitor.cpp
index 9e70a356a..04e60e427 100644
--- a/src/qdoc/qmlvisitor.cpp
+++ b/src/qdoc/qmlvisitor.cpp
@@ -17,14 +17,11 @@
#include <QtCore/qfileinfo.h>
#include <QtCore/qglobal.h>
-#ifndef QT_NO_DECLARATIVE
-# include <private/qqmljsast_p.h>
-# include <private/qqmljsengine_p.h>
-#endif
+#include <private/qqmljsast_p.h>
+#include <private/qqmljsengine_p.h>
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_DECLARATIVE
/*!
The constructor stores all the parameters in local data members.
*/
@@ -709,6 +706,4 @@ bool QmlDocVisitor::hasError() const
return hasRecursionDepthError;
}
-#endif
-
QT_END_NAMESPACE
diff --git a/src/qdoc/qmlvisitor.h b/src/qdoc/qmlvisitor.h
index e1de6650c..9482c8bbf 100644
--- a/src/qdoc/qmlvisitor.h
+++ b/src/qdoc/qmlvisitor.h
@@ -9,10 +9,8 @@
#include <QtCore/qstring.h>
-#ifndef QT_NO_DECLARATIVE
-# include <private/qqmljsastvisitor_p.h>
-# include <private/qqmljsengine_p.h>
-#endif
+#include <private/qqmljsastvisitor_p.h>
+#include <private/qqmljsengine_p.h>
QT_BEGIN_NAMESPACE
@@ -34,7 +32,6 @@ struct QmlPropArgs
}
};
-#ifndef QT_NO_DECLARATIVE
class QmlDocVisitor : public QQmlJS::AST::Visitor
{
public:
@@ -90,7 +87,6 @@ private:
Aggregate *m_current { nullptr };
bool hasRecursionDepthError { false };
};
-#endif
QT_END_NAMESPACE