TextEditor: Allow using KSyntaxHighlighting from system

Set KSYNTAXHIGHLIGHTING_LIB_DIR to the directory that
contains the KSyntaxHighlighting library file
(e.g. libKF5SyntaxHighlighting.{dll,dylib,so}).
This will use the respective files from there and its
related include files instead of the files provided by QC.

If deducing the include directory depending on the library
does not work you can additionally specify
KSYNTAXHIGHLIGHTING_INCLUDE_DIR as well.

Both variables can be set either as qmake variable or
environment variable.

Task-number: QTCREATORBUG-21980
Change-Id: Ie021489d930dfc46ad3e37f9fa02d09fa146ac87
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Christian Stenger
2019-02-14 14:58:27 +01:00
parent 495f98b256
commit f670e80c88
5 changed files with 72 additions and 5 deletions

View File

@@ -49,6 +49,10 @@ You can build Qt Creator with
export QBS_INSTALL_DIR=/path/to/qbs
# Optional, needed for the Python enabled dumper on Windows
set PYTHON_INSTALL_DIR=C:\path\to\python
# Optional, needed to use system KSyntaxHighlighting:
set KSYNTAXHIGHLIGHTING_LIB_DIR to folder holding the KSyntaxHighlighting library
# if automatic deducing of include folder fails set KSYNTAXHIGHLIGHTING_INCLUDE_DIR as well
# both variables can also be passed as qmake variables
cd $SOURCE_DIRECTORY
qmake -r

View File

@@ -31,10 +31,28 @@ for(l, SUBDIRS) {
}
SUBDIRS += \
utils/process_stub.pro \
utils/process_stub.pro
isEmpty(KSYNTAXHIGHLIGHTING_LIB_DIR): KSYNTAXHIGHLIGHTING_LIB_DIR=$$(KSYNTAXHIGHLIGHTING_LIB_DIR)
!isEmpty(KSYNTAXHIGHLIGHTING_LIB_DIR) {
# enable short information message
KSYNTAX_WARN_ON = 1
}
include(../shared/syntax/syntax_shared.pri)
isEmpty(KSYNTAXHIGHLIGHTING_LIB_DIR) {
SUBDIRS += \
3rdparty/syntax-highlighting \
3rdparty/syntax-highlighting/data
equals(KSYNTAX_WARN_ON, 1) {
message("Either KSYNTAXHIGHLIGHTING_LIB_DIR does not exist or include path could not be deduced.")
unset(KSYNTAX_WARN_ON)
}
} else {
message("Using KSyntaxHighlighting provided at $${KSYNTAXHIGHLIGHTING_LIB_DIR}.")
}
win32:SUBDIRS += utils/process_ctrlc_stub.pro
# Windows: Compile Qt Creator CDB extension if Debugging tools can be detected.

View File

@@ -2,7 +2,19 @@ DEFINES += TEXTEDITOR_LIBRARY
QT += gui-private network printsupport xml
CONFIG += exceptions
CONFIG += include_source_dir # For the highlighter autotest.
include(../../shared/syntax/syntax_shared.pri)
isEmpty(KSYNTAXHIGHLIGHTING_LIB_DIR) | isEmpty(KSYNTAXHIGHLIGHTING_INCLUDE_DIR) {
QTC_LIB_DEPENDS += syntax-highlighting
} else {
unix:!disable_external_rpath {
!macos: QMAKE_LFLAGS += -Wl,-z,origin
QMAKE_LFLAGS += -Wl,-rpath,$$shell_quote($${KSYNTAXHIGHLIGHTING_LIB_DIR})
}
}
include(../../qtcreatorplugin.pri)
SOURCES += texteditorplugin.cpp \
plaintexteditorfactory.cpp \
textdocument.cpp \

View File

@@ -2,7 +2,21 @@ QTC_PLUGIN_NAME = TextEditor
QTC_LIB_DEPENDS += \
aggregation \
extensionsystem \
utils \
syntax-highlighting
utils
QTC_PLUGIN_DEPENDS += \
coreplugin
# needed for plugins that depend on TextEditor plugin
include(../../shared/syntax/syntax_shared.pri)
!isEmpty(KSYNTAXHIGHLIGHTING_INCLUDE_DIR) {
INCLUDEPATH *= $${KSYNTAXHIGHLIGHTING_INCLUDE_DIR}
LIBS *= -L$$KSYNTAXHIGHLIGHTING_LIB_DIR -lKF5SyntaxHighlighting
linux {
QMAKE_LFLAGS += -Wl,-z,origin
QMAKE_LFLAGS += -Wl,-rpath,$$shell_quote($${KSYNTAXHIGHLIGHTING_LIB_DIR})
}
} else {
QTC_LIB_DEPENDS += syntax-highlighting
}

View File

@@ -0,0 +1,19 @@
# KSyntaxHighlighting uses a special folder structure (may contain target arch triple for the lib),
# so expect lib folder to be specified by the user - generate include path based on this
isEmpty(KSYNTAXHIGHLIGHTING_LIB_DIR): KSYNTAXHIGHLIGHTING_LIB_DIR=$$(KSYNTAXHIGHLIGHTING_LIB_DIR)
isEmpty(KSYNTAXHIGHLIGHTING_INCLUDE_DIR): KSYNTAXHIGHLIGHTING_INCLUDE_DIR=$$(KSYNTAXHIGHLIGHTING_INCLUDE_DIR)
!exists($$KSYNTAXHIGHLIGHTING_LIB_DIR) {
unset(KSYNTAXHIGHLIGHTING_LIB_DIR)
unset(KSYNTAXHIGHLIGHTING_INCLUDE_DIR)
} else {
isEmpty(KSYNTAXHIGHLIGHTING_INCLUDE_DIR) {
!linux: KSYNTAXHIGHLIGHTING_INCLUDE_DIR=$$absolute_path('../include/KF5/KSyntaxHighlighting/', $$KSYNTAXHIGHLIGHTING_LIB_DIR)
else: KSYNTAXHIGHLIGHTING_INCLUDE_DIR=$$absolute_path('../../include/KF5/KSyntaxHighlighting/', $$KSYNTAXHIGHLIGHTING_LIB_DIR)
}
!exists($$KSYNTAXHIGHLIGHTING_INCLUDE_DIR) {
unset(KSYNTAXHIGHLIGHTING_INCLUDE_DIR)
unset(KSYNTAXHIGHLIGHTING_LIB_DIR)
}
}