From e7f61dabea2d78012cc39e7186ef8c14f4dada67 Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Fri, 17 Feb 2017 18:14:27 +0000 Subject: [PATCH] refs #213 Added precompiled header for MSVC in blackmisc, blackcore, blackgui. --- .gitignore | 3 + mkspecs/features/common_post.prf | 10 +++ mkspecs/features/warnings.pri | 1 + src/blackcore/blackcore.pro | 7 +- src/blackcore/pch/pch.h | 46 +++++++++++ src/blackgui/blackgui.pro | 7 +- src/blackgui/pch/pch.h | 70 +++++++++++++++++ src/blackmisc/blackmisc.pro | 8 +- src/blackmisc/metaclass.h | 14 +++- src/blackmisc/pch/pch.h | 128 +++++++++++++++++++++++++++++++ 10 files changed, 278 insertions(+), 16 deletions(-) create mode 100644 src/blackcore/pch/pch.h create mode 100644 src/blackgui/pch/pch.h create mode 100644 src/blackmisc/pch/pch.h diff --git a/.gitignore b/.gitignore index f767aad94..db24c7d99 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,9 @@ moc_*.cpp qrc_*.cpp ui_*.h +# MSVC generated precompiled source +pch.h.cpp + # QtCreator project files *.pro.user* diff --git a/mkspecs/features/common_post.prf b/mkspecs/features/common_post.prf index fec69d283..4bc937035 100644 --- a/mkspecs/features/common_post.prf +++ b/mkspecs/features/common_post.prf @@ -42,6 +42,16 @@ macx:staticlib:isEmpty(SOURCES) { QMAKE_MAC_SDK.$$basename(QMAKESPEC).$${QMAKE_MAC_SDK}.QMAKE_RANLIB = $$QMAKE_RANLIB } +################################ +# Precompiled header +################################ + +# only MSVC gains any build time improvement +!msvc: CONFIG -= precompile_header + +# not supported by clang_cl +clang_cl: CONFIG -= precompile_header + ################################ # Black libs ################################ diff --git a/mkspecs/features/warnings.pri b/mkspecs/features/warnings.pri index 7a868ae25..92dcf018f 100644 --- a/mkspecs/features/warnings.pri +++ b/mkspecs/features/warnings.pri @@ -4,6 +4,7 @@ msvc:DEFINES *= _SCL_SECURE_NO_WARNINGS msvc:QMAKE_CXXFLAGS_WARN_ON *= /wd4351 /wd4661 clang_cl:QMAKE_CXXFLAGS_WARN_ON *= -Wall -Wextra -Wno-unknown-pragmas gcc:QMAKE_CXXFLAGS_WARN_ON *= -Woverloaded-virtual +gcc:QMAKE_CXXFLAGS_USE_PRECOMPILE = -Winvalid-pch $$QMAKE_CXXFLAGS_USE_PRECOMPILE # elevated warnings contains(BLACK_CONFIG, AllowNoisyWarnings) { diff --git a/src/blackcore/blackcore.pro b/src/blackcore/blackcore.pro index 9efabce67..7f9a1d3a5 100644 --- a/src/blackcore/blackcore.pro +++ b/src/blackcore/blackcore.pro @@ -6,7 +6,7 @@ QT += network dbus xml multimedia TARGET = blackcore TEMPLATE = lib -CONFIG += blackconfig blackmisc blackinput blacksound +CONFIG += blackconfig blackmisc blackinput blacksound precompile_header contains(BLACK_CONFIG, Static) { CONFIG += staticlib @@ -15,10 +15,7 @@ contains(BLACK_CONFIG, Static) { INCLUDEPATH += .. DEPENDPATH += . .. -# PRECOMPILED_HEADER = stdpch.h -precompile_header:!isEmpty(PRECOMPILED_HEADER) { - DEFINES += USING_PCH -} +PRECOMPILED_HEADER = pch/pch.h DEFINES += LOG_IN_FILE BUILD_BLACKCORE_LIB diff --git a/src/blackcore/pch/pch.h b/src/blackcore/pch/pch.h new file mode 100644 index 000000000..e6847f239 --- /dev/null +++ b/src/blackcore/pch/pch.h @@ -0,0 +1,46 @@ +/* Copyright (C) 2017 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +/* --------- + * ! WARNING ! + * --------------------------------------------------------------------------------- + * >>>> CHANGES IN ANY HEADERS INCLUDED HEREIN WILL TRIGGER A FULL REBUILD OF EVERYTHING! <<<< + * --------------------------------------------------------------------------------- + */ + +#ifdef BLACKCORE_PCH_H +#error "Don't #include this file" +#else +#define BLACKCORE_PCH_H + +#include "blackmisc/pch/pch.h" + +#ifdef __cplusplus + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // __cplusplus +#endif // guard diff --git a/src/blackgui/blackgui.pro b/src/blackgui/blackgui.pro index b3d81d20d..5e4d1f4cb 100644 --- a/src/blackgui/blackgui.pro +++ b/src/blackgui/blackgui.pro @@ -4,7 +4,7 @@ QT += network dbus gui svg widgets TARGET = blackgui TEMPLATE = lib -CONFIG += blackconfig blackmisc blackcore +CONFIG += blackconfig blackmisc blackcore precompile_header contains(BLACK_CONFIG, Static) { CONFIG += staticlib @@ -13,10 +13,7 @@ contains(BLACK_CONFIG, Static) { INCLUDEPATH += .. DEPENDPATH += . .. -# PRECOMPILED_HEADER = stdpch.h -precompile_header:!isEmpty(PRECOMPILED_HEADER) { - DEFINES += USING_PCH -} +PRECOMPILED_HEADER = pch/pch.h DEFINES += LOG_IN_FILE BUILD_BLACKGUI_LIB diff --git a/src/blackgui/pch/pch.h b/src/blackgui/pch/pch.h new file mode 100644 index 000000000..862929733 --- /dev/null +++ b/src/blackgui/pch/pch.h @@ -0,0 +1,70 @@ +/* Copyright (C) 2017 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +/* --------- + * ! WARNING ! + * --------------------------------------------------------------------------------- + * >>>> CHANGES IN ANY HEADERS INCLUDED HEREIN WILL TRIGGER A FULL REBUILD OF EVERYTHING! <<<< + * --------------------------------------------------------------------------------- + */ + +#ifdef BLACKGUI_PCH_H +#error "Don't #include this file" +#else +#define BLACKGUI_PCH_H + +#include "blackcore/pch/pch.h" + +#ifdef __cplusplus + +#include "blackcore/context/contextallinterfaces.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // __cplusplus +#endif // guard diff --git a/src/blackmisc/blackmisc.pro b/src/blackmisc/blackmisc.pro index 473562ac4..f7fe0dcfd 100644 --- a/src/blackmisc/blackmisc.pro +++ b/src/blackmisc/blackmisc.pro @@ -4,7 +4,7 @@ QT += network dbus xml TARGET = blackmisc TEMPLATE = lib -CONFIG += blackconfig +CONFIG += blackconfig precompile_header contains(BLACK_CONFIG, Static) { CONFIG += staticlib @@ -12,10 +12,8 @@ contains(BLACK_CONFIG, Static) { INCLUDEPATH += .. # DEPENDPATH += . .. // BlackMisc should be independent -# PRECOMPILED_HEADER = stdpch.h -precompile_header:!isEmpty(PRECOMPILED_HEADER) { - DEFINES += USING_PCH -} + +PRECOMPILED_HEADER = pch/pch.h DEFINES += LOG_IN_FILE BUILD_BLACKMISC_LIB RESOURCES += blackmisc.qrc diff --git a/src/blackmisc/metaclass.h b/src/blackmisc/metaclass.h index 11e10965d..8dd0b0bd0 100644 --- a/src/blackmisc/metaclass.h +++ b/src/blackmisc/metaclass.h @@ -78,10 +78,22 @@ namespace BlackMisc * \ingroup MetaClass */ template - struct MetaFlags : public std::integral_constant + struct MetaFlags /* : public std::integral_constant */ { //! Implicit conversion to std::false_type (if F is zero) or std::true_type (if F is non-zero). constexpr operator std::integral_constant(F)>() const { return {}; } + +#if defined(Q_CC_MSVC) && ! defined(Q_CC_CLANG) // gymnastics to workaround an MSVC 2017 precompiled header ICE + int m_dummy = 0; +#if _MSC_FULL_VER < 191000000 + constexpr MetaFlags() {} +#endif +#endif + constexpr operator quint64() const { return F; } //!< Implicit conversion to integer. + constexpr quint64 operator ()() const { return F; } //!< Call operator. + constexpr static quint64 value = F; //!< Value. + using value_type = quint64; //!< Value type. + using type = MetaFlags; //!< Own type. }; /*! diff --git a/src/blackmisc/pch/pch.h b/src/blackmisc/pch/pch.h new file mode 100644 index 000000000..814cd5a09 --- /dev/null +++ b/src/blackmisc/pch/pch.h @@ -0,0 +1,128 @@ +/* Copyright (C) 2017 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +/* --------- + * ! WARNING ! + * --------------------------------------------------------------------------------- + * >>>> CHANGES IN ANY HEADERS INCLUDED HEREIN WILL TRIGGER A FULL REBUILD OF EVERYTHING! <<<< + * --------------------------------------------------------------------------------- + */ + +#ifdef BLACKMISC_PCH_H +#error "Don't #include this file" +#else +#define BLACKMISC_PCH_H + +#ifdef __cplusplus + +#if defined(_MSC_FULL_VER) && _MSC_FULL_VER < 191000000 +#pragma warning(disable:4503) +#endif + +#include "blackmisc/collection.h" +#include "blackmisc/compare.h" +#include "blackmisc/containerbase.h" +#include "blackmisc/dbus.h" +#include "blackmisc/dictionary.h" +#include "blackmisc/iterator.h" +#include "blackmisc/json.h" +#include "blackmisc/metaclass.h" +#include "blackmisc/range.h" +#include "blackmisc/sequence.h" +#include "blackmisc/valueobject.h" +#include "blackmisc/verify.h" +#include "blackmisc/worker.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // __cplusplus +#endif // guard