summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-12-10 14:06:21 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2018-12-12 09:50:12 +0000
commite181ec2c20ede6b878187f3123d190e8b952deb1 (patch)
tree387823ff25aed7a7b4bf1012be1d5a23a22b95ce
parentdbe2b941313b8dcd24d3ceec3860ae9ff0da58a1 (diff)
downloadqttools-e181ec2c20ede6b878187f3123d190e8b952deb1.tar.gz
Port qdoc's libclang detection to the configure system
This is just an initial rough port with a custom config detection. More things can be refined in the future, for example turning libclang into a library to be used with QMAKE_USE. Fixes: QTBUG-72259 Change-Id: Iaf3c42f76b79bdfd07476173c2fd0f4060c11fea Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Martin Smith <martin.smith@qt.io>
-rw-r--r--configure.json5
-rw-r--r--qttools.pro1
-rw-r--r--src/qdoc/configure.json43
-rw-r--r--src/qdoc/configure.pri (renamed from mkspecs/features/qt_find_clang.prf)48
-rw-r--r--src/qdoc/qdoc.pro2
-rw-r--r--src/src.pro4
6 files changed, 82 insertions, 21 deletions
diff --git a/configure.json b/configure.json
new file mode 100644
index 000000000..cd111df83
--- /dev/null
+++ b/configure.json
@@ -0,0 +1,5 @@
+{
+ "subconfigs": [
+ "src/qdoc"
+ ]
+}
diff --git a/qttools.pro b/qttools.pro
index b87dcea59..58c33f27c 100644
--- a/qttools.pro
+++ b/qttools.pro
@@ -1,2 +1 @@
-load(qt_find_clang)
load(qt_parts)
diff --git a/src/qdoc/configure.json b/src/qdoc/configure.json
new file mode 100644
index 000000000..6b757737c
--- /dev/null
+++ b/src/qdoc/configure.json
@@ -0,0 +1,43 @@
+{
+ "module": "qdoc",
+ "tests": {
+ "libclang": {
+ "label": "libclang",
+ "test": "libclang",
+ "type": "libclang"
+ }
+ },
+ "features": {
+ "qdoc": {
+ "label": "QDoc",
+ "condition": "tests.libclang",
+ "output": [
+ "privateFeature",
+ { "type": "varAssign", "name": "CLANG_LIBS", "value": "tests.libclang.libs" },
+ { "type": "varAssign", "name": "CLANG_INCLUDEPATH", "value": "tests.libclang.includepath" },
+ { "type": "varAssign", "name": "CLANG_LIBDIR", "value": "tests.libclang.libdir" },
+ { "type": "varAssign", "name": "CLANG_DEFINES", "value": "tests.libclang.defines" },
+ { "type": "varAssign", "name": "CLANG_VERSION", "value": "tests.libclang.version" }
+ ]
+ }
+ },
+ "report": [
+ {
+ "type": "warning",
+ "condition": "!features.qdoc",
+ "message": "QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation.
+
+Either ensure that llvm-config is in your PATH environment variable, or set LLVM_INSTALL_DIR to the location of your llvm installation.
+On Linux systems you may be able to install libclang from a package. On macOS you could use Homebrew's llvm package.
+On Windows you need to set LLVM_INSTALL_DIR to the installation path."
+ }
+ ],
+ "summary": [
+ {
+ "section": "Qt Tools",
+ "entries": [
+ "qdoc"
+ ]
+ }
+ ]
+}
diff --git a/mkspecs/features/qt_find_clang.prf b/src/qdoc/configure.pri
index 5f9775126..859bd3731 100644
--- a/mkspecs/features/qt_find_clang.prf
+++ b/src/qdoc/configure.pri
@@ -1,5 +1,3 @@
-config_clang_done: return()
-
defineReplace(extractVersion) { return($$replace(1, ^(\\d+\\.\\d+\\.\\d+)(svn)?$, \\1)) }
defineReplace(extractMajorVersion) { return($$replace(1, ^(\\d+)\\.\\d+\\.\\d+(svn)?$, \\1)) }
defineReplace(extractMinorVersion) { return($$replace(1, ^\\d+\\.(\\d+)\\.\\d+(svn)?$, \\1)) }
@@ -39,10 +37,9 @@ defineReplace(findLLVMVersionFromLibDir) {
return($$candidateVersion)
}
-isEmpty(QDOC_USE_STATIC_LIBCLANG): QDOC_USE_STATIC_LIBCLANG = $$(QDOC_USE_STATIC_LIBCLANG)
-cache(QDOC_USE_STATIC_LIBCLANG)
+defineTest(qtConfTest_libclang) {
+ isEmpty(QDOC_USE_STATIC_LIBCLANG): QDOC_USE_STATIC_LIBCLANG = $$(QDOC_USE_STATIC_LIBCLANG)
-for(_, $$list(_)) { # just a way to break easily
equals(QMAKE_HOST.os, Windows) {
# on Windows we have only two host compilers, MSVC or mingw. The former we never
# use for cross-compilation where it isn't also the target compiler. The latter
@@ -66,8 +63,7 @@ for(_, $$list(_)) { # just a way to break easily
clangInstallDir = $$replace(LLVM_INSTALL_DIR, _ARCH_, 32)
isEmpty(LLVM_INSTALL_DIR) {
win32 {
- log("Set the LLVM_INSTALL_DIR environment variable to configure clang location (required to build qdoc).$$escape_expand(\\n)")
- break()
+ return(false)
}
macos {
# Default to homebrew llvm on macOS. The CLANG_VERSION test below will complain if missing.
@@ -92,16 +88,14 @@ for(_, $$list(_)) { # just a way to break easily
isEmpty(CLANG_VERSION) {
!isEmpty(LLVM_INSTALL_DIR): \
error("Cannot determine clang version at $${clangInstallDir}.")
- log("Set the LLVM_INSTALL_DIR environment variable to configure clang location.$$escape_expand(\\n)")
- break()
+ return(false)
}
LIBCLANG_MAIN_HEADER = $$CLANG_INCLUDEPATH/clang-c/Index.h
!exists($$LIBCLANG_MAIN_HEADER) {
!isEmpty(LLVM_INSTALL_DIR): \
error("Cannot find libclang's main header file, candidate: $${LIBCLANG_MAIN_HEADER}.")
- log("Set the LLVM_INSTALL_DIR environment variable to configure clang location.$$escape_expand(\\n)")
- break()
+ return(false)
}
!contains(QMAKE_DEFAULT_LIBDIRS, $$CLANG_LIBDIR): CLANG_LIBS = -L$${CLANG_LIBDIR}
@@ -319,15 +313,31 @@ for(_, $$list(_)) { # just a way to break easily
!versionIsAtLeast($$CLANG_VERSION, "3.9.0") {
log("LLVM/Clang version >= 3.9.0 required, version provided: $${CLANG_VERSION}.$$escape_expand(\\n)")
log("Clang was found in $${clangInstallDir}. Set the LLVM_INSTALL_DIR environment variable to override.$$escape_expand(\\n)")
- break()
+ return(false)
}
- cache(CLANG_LIBS)
- cache(CLANG_INCLUDEPATH)
- cache(CLANG_LIBDIR)
- cache(CLANG_DEFINES)
- cache(CLANG_VERSION)
- cache(CONFIG, add, $$list(config_clang))
+ $${1}.libs = $$CLANG_LIBS
+ export($${1}.libs)
+ $${1}.cache += libs
+
+ $${1}.includepath = $$CLANG_INCLUDEPATH
+ export($${1}.includepath)
+ $${1}.cache += includepath
+
+ $${1}.libdir = $$CLANG_LIBDIR
+ export($${1}.libdir)
+ $${1}.cache += libdir
+
+ $${1}.defines = $$CLANG_DEFINES
+ export($${1}.defines)
+ $${1}.cache += defines
+
+ $${1}.version = $$CLANG_VERSION
+ export($${1}.version)
+ $${1}.cache += version
+
+ export($${1}.cache)
+
+ return(true)
}
-cache(CONFIG, add, $$list(config_clang_done))
diff --git a/src/qdoc/qdoc.pro b/src/qdoc/qdoc.pro
index bc543c1e8..3c88e2643 100644
--- a/src/qdoc/qdoc.pro
+++ b/src/qdoc/qdoc.pro
@@ -11,6 +11,8 @@ qtHaveModule(qmldevtools-private) {
DEFINES += QT_NO_DECLARATIVE
}
+include($$OUT_PWD/qtqdoc-config.pri)
+
LIBS += $$CLANG_LIBS
!contains(QMAKE_DEFAULT_INCDIRS, $$CLANG_INCLUDEPATH): INCLUDEPATH += $$CLANG_INCLUDEPATH
DEFINES += $$CLANG_DEFINES
diff --git a/src/src.pro b/src/src.pro
index 7a1af0078..c954cf98a 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -23,7 +23,9 @@ qtConfig(library) {
!android|android_app: SUBDIRS += qtplugininfo
}
-config_clang: qtConfig(thread): SUBDIRS += qdoc
+include($$OUT_PWD/qdoc/qtqdoc-config.pri)
+QT_FOR_CONFIG += qdoc-private
+qtConfig(qdoc): qtConfig(thread): SUBDIRS += qdoc
!android|android_app: SUBDIRS += qtpaths