From db692461ef36a8212341f46aae3fe8f57d925fed Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Mon, 20 Feb 2017 21:03:03 +0000 Subject: [PATCH] Qmake directives to help using Templight to analyse our template usage. --- mkspecs/features/common_post.prf | 6 ++++++ mkspecs/features/copyfiles.pri | 3 +-- mkspecs/features/templight.pri | 30 ++++++++++++++++++++++++++++ mkspecs/features/templight_blacklist | 14 +++++++++++++ mkspecs/features/touch.prf | 6 ++++++ 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 mkspecs/features/templight.pri create mode 100644 mkspecs/features/templight_blacklist create mode 100644 mkspecs/features/touch.prf diff --git a/mkspecs/features/common_post.prf b/mkspecs/features/common_post.prf index 4bc937035..ba1971697 100644 --- a/mkspecs/features/common_post.prf +++ b/mkspecs/features/common_post.prf @@ -52,6 +52,12 @@ macx:staticlib:isEmpty(SOURCES) { # not supported by clang_cl clang_cl: CONFIG -= precompile_header +################################ +# Templight (template analysis tool) +################################ + +include(templight.pri) + ################################ # Black libs ################################ diff --git a/mkspecs/features/copyfiles.pri b/mkspecs/features/copyfiles.pri index 67fa813b0..d830e116c 100644 --- a/mkspecs/features/copyfiles.pri +++ b/mkspecs/features/copyfiles.pri @@ -9,12 +9,10 @@ defineReplace(fileCopyDestination) { win32:isEmpty(MINGW_IN_SHELL) { copy_files.commands = copy /y ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} - TOUCH = copy /y nul } else { copy_files.commands = mkdir -p `dirname ${QMAKE_FILE_OUT}` && \ cp ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} - TOUCH = touch } QMAKE_EXTRA_COMPILERS += copy_files @@ -25,6 +23,7 @@ QMAKE_EXTRA_COMPILERS += copy_files # with PRE_TARGETDEPS instead. #copy_files.CONFIG += target_predeps +load(touch) copy_files_cookie.depends = compiler_copy_files_make_all copy_files_cookie.target = copy_files.cookie win32:!mingw: copy_files_cookie.commands = $$TOUCH $** && $$TOUCH $@ diff --git a/mkspecs/features/templight.pri b/mkspecs/features/templight.pri new file mode 100644 index 000000000..61cf72754 --- /dev/null +++ b/mkspecs/features/templight.pri @@ -0,0 +1,30 @@ +contains(BLACK_CONFIG, Templight) { + QMAKE_CXXFLAGS += -Xtemplight -profiler -Xtemplight -ignore-system + QMAKE_CXXFLAGS += -Xtemplight -blacklist -Xtemplight $$PWD/templight_blacklist + clang_cl { + QMAKE_CC = clang-cl + QMAKE_CXX = templight-cl + moc_predefs.commands = clang-cl -Bx$$shell_quote($$shell_path($$QMAKE_QMAKE)) $$QMAKE_CXXFLAGS \ + -E -Za ${QMAKE_FILE_IN} 2>NUL >${QMAKE_FILE_OUT} $$escape_expand(\n)$$LITERAL_HASH + } + else:clang { + QMAKE_CC = clang + QMAKE_CXX = templight++ + moc_predefs.commands = clang++ $$QMAKE_CXXFLAGS -dM -E -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} + } + else:error(Templight requires a clang mkspec) + + templight-convert.commands = templight-convert -f callgrind -i ${QMAKE_FILE_IN}.trace.pbf -o ${QMAKE_FILE_OUT} + templight-convert.CONFIG = no_link + templight-convert.input = OBJECTS + templight-convert.output = ${QMAKE_FILE_IN_PATH}/callgrind.${QMAKE_FILE_IN_BASE} + QMAKE_EXTRA_COMPILERS += templight-convert + + load(touch) + win32:!mingw: templight-convert-cookie.commands = $$TOUCH $** && $$TOUCH $@ + else: templight-convert-cookie.commands = $$TOUCH $< && $$TOUCH $@ + templight-convert-cookie.depends = compiler_templight-convert_make_all + templight-convert-cookie.target = templight-convert.cookie + QMAKE_EXTRA_TARGETS += templight-convert-cookie + !isEmpty(SOURCES): PRE_TARGETDEPS += templight-convert.cookie +} diff --git a/mkspecs/features/templight_blacklist b/mkspecs/features/templight_blacklist new file mode 100644 index 000000000..25dd68f16 --- /dev/null +++ b/mkspecs/features/templight_blacklist @@ -0,0 +1,14 @@ +# +# Identifiers matching the regular expressions below +# will be omitted from templight traces. +# + +# standard library templates +identifier ^std(::|$) + +# standard library implementation templates +identifier __ +identifier ^_[A-Z] + +# assume templates starting with 'Q' are Qt templates +identifier ^[qQ] diff --git a/mkspecs/features/touch.prf b/mkspecs/features/touch.prf new file mode 100644 index 000000000..fe6adf32e --- /dev/null +++ b/mkspecs/features/touch.prf @@ -0,0 +1,6 @@ +win32:isEmpty(MINGW_IN_SHELL) { + TOUCH = copy /y nul +} +else { + TOUCH = touch +}