Skip to content

Commit

Permalink
Support for precompiled headers (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
awawa-dev committed Sep 27, 2022
1 parent 785fc77 commit eec1fb6
Show file tree
Hide file tree
Showing 63 changed files with 229 additions and 47 deletions.
1 change: 1 addition & 0 deletions .ci/ci_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ elif [[ "$CI_NAME" == 'linux' ]]; then
make -j $(nproc) package || exit 3 &&
cp /hyperhdr/build/bin/h* /deploy/ 2>/dev/null || : &&
cp /hyperhdr/build/Hyper* /deploy/ 2>/dev/null || : &&
ccache -s &&
exit 0;
exit 1 " || { echo "---> HyperHDR compilation failed! Abort"; exit 5; }
ls -a .ccache
Expand Down
61 changes: 33 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,36 @@ set(CMAKE_AUTORCC ON)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Set build variables
SET ( DEFAULT_PROTOBUF ON )
SET ( DEFAULT_BOBLIGHT ON )
SET ( DEFAULT_WS281XPWM OFF )
SET ( DEFAULT_USE_SYSTEM_FLATBUFFERS_LIBS OFF )
SET ( DEFAULT_USE_SYSTEM_MBEDTLS_LIBS OFF )
SET ( DEFAULT_MF OFF )
SET ( DEFAULT_DX OFF )
SET ( DEFAULT_AVF OFF )
SET ( DEFAULT_MAC_SYSTEM OFF )
SET ( DEFAULT_V4L2 OFF )
SET ( DEFAULT_X11 OFF )
SET ( DEFAULT_PIPEWIRE OFF )
SET ( DEFAULT_FRAMEBUFFER OFF )
SET ( DEFAULT_SOUNDCAPWINDOWS OFF )
SET ( DEFAULT_SOUNDCAPMACOS OFF )
SET ( DEFAULT_CEC OFF )
SET ( DEFAULT_BONJOUR ON )
SET ( DEFAULT_MQTT ON )
SET ( DEFAULT_STATIC_QT_PLUGINS OFF )
SET ( DEFAULT_PRECOMPILED_HEADERS ON )

# Configure CCache if available
find_program(CCACHE_FOUND ccache)
if ( CCACHE_FOUND )
if (DEFINED ENV{CCACHE_DIR})
message ( STATUS "Found CCache and its env settings: $ENV{CCACHE_DIR}. Will try to use it." )
message ( STATUS "Found CCache and its env settings: $ENV{CCACHE_DIR}. Will try to use it. Disabling precompiled headers." )
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
SET ( DEFAULT_PRECOMPILED_HEADERS OFF )
else()
message ( WARNING "Found CCache but env settings: CCACHE_DIR is not set. Skipping." )
endif()
Expand Down Expand Up @@ -52,29 +75,6 @@ ELSE()
SET( Qt_VERSION 5 )
ENDIF()


# Set build variables
SET ( DO_NOT_USE_QT_VERSION_6_LIBS OFF )
SET ( DEFAULT_PROTOBUF ON )
SET ( DEFAULT_BOBLIGHT ON )
SET ( DEFAULT_WS281XPWM OFF )
SET ( DEFAULT_USE_SYSTEM_FLATBUFFERS_LIBS OFF )
SET ( DEFAULT_USE_SYSTEM_MBEDTLS_LIBS OFF )
SET ( DEFAULT_MF OFF )
SET ( DEFAULT_DX OFF )
SET ( DEFAULT_AVF OFF )
SET ( DEFAULT_MAC_SYSTEM OFF )
SET ( DEFAULT_V4L2 OFF )
SET ( DEFAULT_X11 OFF )
SET ( DEFAULT_PIPEWIRE OFF )
SET ( DEFAULT_FRAMEBUFFER OFF )
SET ( DEFAULT_SOUNDCAPWINDOWS OFF )
SET ( DEFAULT_SOUNDCAPMACOS OFF )
SET ( DEFAULT_CEC OFF )
SET ( DEFAULT_BONJOUR ON )
SET ( DEFAULT_MQTT ON )
SET ( DEFAULT_STATIC_QT_PLUGINS OFF )

IF ( ${CMAKE_SYSTEM} MATCHES "Linux" )
SET ( DEFAULT_SOUNDCAPLINUX ON )
SET ( DEFAULT_V4L2 ON )
Expand Down Expand Up @@ -149,8 +149,9 @@ if ( "${PLATFORM}" MATCHES "osx" )
list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/qt5")
endif()

SET ( DEFAULT_AVF ON )
SET ( DEFAULT_MAC_SYSTEM ON )
SET ( DEFAULT_AVF ON )
SET ( DEFAULT_MAC_SYSTEM ON )
SET ( DEFAULT_PRECOMPILED_HEADERS OFF )
elseif ( "${PLATFORM}" MATCHES "rpi" )
SET ( DEFAULT_WS281XPWM ON )
SET ( DEFAULT_CEC ON )
Expand Down Expand Up @@ -357,6 +358,9 @@ message(STATUS "ENABLE_MQTT = ${ENABLE_MQTT}")
option(USE_STATIC_QT_PLUGINS "Enable static QT plugins" ${DEFAULT_STATIC_QT_PLUGINS})
message(STATUS "USE_STATIC_QT_PLUGINS = ${USE_STATIC_QT_PLUGINS}")

option(USE_PRECOMPILED_HEADERS "Enable precompiled headers (PCH)" ${DEFAULT_PRECOMPILED_HEADERS})
message(STATUS "USE_PRECOMPILED_HEADERS = ${USE_PRECOMPILED_HEADERS}")

SET ( FLATBUFFERS_INSTALL_BIN_DIR ${CMAKE_BINARY_DIR}/flatbuf )
SET ( FLATBUFFERS_INSTALL_LIB_DIR ${CMAKE_BINARY_DIR}/flatbuf )

Expand Down Expand Up @@ -453,6 +457,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
endif()

set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT hyperhdr)
add_definitions(/MP)
endif()

add_definitions(${QT_DEFINITIONS})
Expand Down Expand Up @@ -542,8 +547,8 @@ add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_D
include (${CMAKE_CURRENT_SOURCE_DIR}/cmake/packages.cmake)

# external targets
if (WIN32 AND TARGET apidoc AND TARGET flatbuffers AND TARGET flatc AND TARGET mbedcrypto AND TARGET qmqtt)
set_target_properties(qmqtt apidoc flatbuffers flatc flathash lib mbedcrypto mbedtls mbedx509 resources uninstall PROPERTIES FOLDER ExternalLibsTargets)
if (WIN32 AND TARGET precompiled_hyperhdr_headers AND TARGET apidoc AND TARGET flatbuffers AND TARGET flatc AND TARGET mbedcrypto AND TARGET qmqtt)
set_target_properties(precompiled_hyperhdr_headers qmqtt apidoc flatbuffers flatc flathash lib mbedcrypto mbedtls mbedx509 resources uninstall PROPERTIES FOLDER ExternalLibsTargets)
else()
set_target_properties(resources uninstall PROPERTIES FOLDER ExternalLibsTargets)
endif()
Expand Down
6 changes: 3 additions & 3 deletions assets/webconfig/content/connection_lost.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h4 class="reconstop" data-i18n="info_conlost_label_autorecon">We reconnect agai
var connectionTimer;
var animationTimer;
var count = 1;
var reconnectInterval = 4000;
var reconnectInterval = 2000;
var connURL = window.location.protocol + "//" + window.location.hostname + ":" + window.jsonPort + window.location.pathname + window.location.hash;
var animation = -1;
var animation_value = 0;
Expand Down Expand Up @@ -91,7 +91,7 @@ <h4 class="reconstop" data-i18n="info_conlost_label_autorecon">We reconnect agai
$.ajax({ url: connURL })
.done(function (data) {
window.clearInterval(connectionTimer);
if (reconnectInterval <= 2000) {
if (reconnectInterval < 2000) {
let url = connURL;
if (window.connURL.includes("#")) url = window.connURL.slice(0, window.connURL.indexOf("#"));
window.location.replace(url);
Expand All @@ -110,7 +110,7 @@ <h4 class="reconstop" data-i18n="info_conlost_label_autorecon">We reconnect agai
// if we changed the webui port we connect faster
if (window.fastReconnect) {
window.fastReconnect = false;
reconnectInterval = 2000;
reconnectInterval = 1000;
}
connectionTimer = window.setInterval(tryReconnect, reconnectInterval);
animationTimer = window.setInterval(animate, 100);
Expand Down
82 changes: 82 additions & 0 deletions include/base/AllHeaders_pch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#ifndef ALLHEADERS_PCH_H_
#define ALLHEADERS_PCH_H_

#include <QAtomicInteger>
#include <QBuffer>
#include <QByteArray>
#include <QColor>
#include <QCoreApplication>
#include <QCryptographicHash>
#include <QDateTime>
#include <QExplicitlySharedDataPointer>
#include <QFile>
#include <QHostAddress>
#include <QHostInfo>
#include <QImage>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonValue>
#include <QList>
#include <QMap>
#include <QMultiMap>
#include <QMutex>
#include <QMutexLocker>
#include <QPair>
#include <QPainter>
#include <QRectF>
#include <QRegularExpression>
#include <QResource>
#include <QSet>
#include <QSize>
#include <QSocketNotifier>
#include <QStack>
#include <QString>
#include <QStringList>
#include <QSemaphore>
#include <QSharedData>
#include <QQueue>
#include <QTcpSocket>
#include <QTimer>
#include <QTextStream>
#include <QThread>
#include <QThreadStorage>
#include <QUdpSocket>
#include <QUuid>
#include <QVariant>
#include <QVector>

#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <QStringView>
#else
#include <QStringRef>
#endif

#include <algorithm>
#include <atomic>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <ctime>
#include <exception>
#include <functional>
#include <iterator>
#include <inttypes.h>
#include <iostream>
#include <limits>
#include <list>
#include <stdexcept>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <sstream>
#include <map>
#include <math.h>
#include <memory>
#include <type_traits>
#include <vector>


#endif // ALLHEADERS_PCH_H_
4 changes: 1 addition & 3 deletions include/base/SoundCapture.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#pragma once


#include <utils/Logger.h>
#include <utils/settings.h>
#include <QString>
#include <QSemaphore>
#include <QJsonObject>
#include <QJsonArray>
#include <QColor>
#include <effectengine/AnimationBaseMusic.h>
#include <utils/settings.h>

#define SOUNDCAP_N_WAVE 1024
#define SOUNDCAP_LOG2_N_WAVE 10
Expand Down
1 change: 0 additions & 1 deletion include/db/DBManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <QCryptographicHash>
#include <QDateTime>
#include <QUuid>
#include <QNetworkInterface>
#include <QJsonDocument>
#include <QThreadStorage>

Expand Down
6 changes: 0 additions & 6 deletions include/effectengine/AnimationBase.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#pragma once

#include <QDateTime>
#include <QSize>
#include <QImage>
#include <QPainter>
#include <QJsonObject>
#include <QList>

#include <utils/Image.h>
#include <effectengine/EffectDefinition.h>
#include <utils/ColorSys.h>
Expand Down
1 change: 0 additions & 1 deletion include/effectengine/AnimationBaseMusic.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ class AnimationBaseMusic : public AnimationBase

};

#include <base/SoundCapture.h>
7 changes: 7 additions & 0 deletions sources/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
if(USE_PRECOMPILED_HEADERS AND COMMAND target_precompile_headers)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/precompiled_hyperhdr_headers.cpp "void precompiledHeadersHyperHDR(){};")
add_library(precompiled_hyperhdr_headers ${CMAKE_CURRENT_BINARY_DIR}/precompiled_hyperhdr_headers.cpp)
target_link_libraries(precompiled_hyperhdr_headers Qt${Qt_VERSION}::Gui Qt${Qt_VERSION}::Network)

target_precompile_headers(precompiled_hyperhdr_headers PRIVATE ${CMAKE_SOURCE_DIR}/include/base/AllHeaders_pch.h)
endif()

# Define the current source locations
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include)
Expand Down
4 changes: 4 additions & 0 deletions sources/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ target_link_libraries(hyperhdr-api
Qt${Qt_VERSION}::Gui
Qt${Qt_VERSION}::Network
)

if(USE_PRECOMPILED_HEADERS AND COMMAND target_precompile_headers)
target_precompile_headers(hyperhdr-api REUSE_FROM precompiled_hyperhdr_headers)
endif()
4 changes: 4 additions & 0 deletions sources/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ endif()
if (ENABLE_BONJOUR)
target_link_libraries(hyperhdr-base bonjour)
endif ()

if(USE_PRECOMPILED_HEADERS AND COMMAND target_precompile_headers)
target_precompile_headers(hyperhdr-base REUSE_FROM precompiled_hyperhdr_headers)
endif()
1 change: 1 addition & 0 deletions sources/base/SoundCapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <utils/settings.h>
#include <utils/Logger.h>
#include <cmath>

uint32_t SoundCapture::_noSoundCounter = 0;
bool SoundCapture::_noSoundWarning = false;
bool SoundCapture::_soundDetectedInfo = false;
Expand Down
4 changes: 4 additions & 0 deletions sources/blackborder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ target_link_libraries(blackborder
hyperhdr-utils
hyperhdr-base
)

if(USE_PRECOMPILED_HEADERS AND COMMAND target_precompile_headers)
target_precompile_headers(blackborder REUSE_FROM precompiled_hyperhdr_headers)
endif()
5 changes: 5 additions & 0 deletions sources/boblightserver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ target_link_libraries(boblightserver
hyperhdr-utils
${QT_LIBRARIES}
)

if(USE_PRECOMPILED_HEADERS AND COMMAND target_precompile_headers)
target_precompile_headers(boblightserver REUSE_FROM precompiled_hyperhdr_headers)
endif()

4 changes: 4 additions & 0 deletions sources/bonjour/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ target_link_libraries(bonjour
hyperhdr-utils
Qt${Qt_VERSION}::Network
)

if(USE_PRECOMPILED_HEADERS AND COMMAND target_precompile_headers)
target_precompile_headers(bonjour REUSE_FROM precompiled_hyperhdr_headers)
endif()
4 changes: 4 additions & 0 deletions sources/commandline/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ target_link_libraries(commandline
hyperhdr-base
Qt${Qt_VERSION}::Gui
)

if(USE_PRECOMPILED_HEADERS AND COMMAND target_precompile_headers)
target_precompile_headers(commandline REUSE_FROM precompiled_hyperhdr_headers)
endif()
4 changes: 4 additions & 0 deletions sources/db/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ target_link_libraries(database
if (USE_STATIC_QT_PLUGINS)
target_link_libraries(database ${STATIC_QT_PLUGINS_LIBS})
endif()

if(USE_PRECOMPILED_HEADERS AND COMMAND target_precompile_headers)
target_precompile_headers(database REUSE_FROM precompiled_hyperhdr_headers)
endif()
1 change: 1 addition & 0 deletions sources/db/MetaTable.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <db/MetaTable.h>
#include <QNetworkInterface>


MetaTable::MetaTable(QObject* parent, bool readonlyMode)
Expand Down
1 change: 1 addition & 0 deletions sources/effectengine/Animation4Music_PulseBlue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#include <effectengine/Animation4Music_PulseBlue.h>
#include <base/SoundCapture.h>

Animation4Music_PulseBlue::Animation4Music_PulseBlue() :
AnimationBaseMusic(AMUSIC_PULSEBLUE),
Expand Down
1 change: 1 addition & 0 deletions sources/effectengine/Animation4Music_PulseGreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#include <effectengine/Animation4Music_PulseGreen.h>
#include <base/SoundCapture.h>

Animation4Music_PulseGreen::Animation4Music_PulseGreen() :
AnimationBaseMusic(AMUSIC_PULSEGREEN),
Expand Down
1 change: 1 addition & 0 deletions sources/effectengine/Animation4Music_PulseMulti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#include <effectengine/Animation4Music_PulseMulti.h>
#include <base/SoundCapture.h>

Animation4Music_PulseMulti::Animation4Music_PulseMulti() :
AnimationBaseMusic(AMUSIC_PULSEMULTI),
Expand Down
1 change: 1 addition & 0 deletions sources/effectengine/Animation4Music_PulseMultiFast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#include <effectengine/Animation4Music_PulseMultiFast.h>
#include <base/SoundCapture.h>

Animation4Music_PulseMultiFast::Animation4Music_PulseMultiFast() :
AnimationBaseMusic(AMUSIC_PULSEMULTIFAST),
Expand Down
1 change: 1 addition & 0 deletions sources/effectengine/Animation4Music_PulseMultiSlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#include <effectengine/Animation4Music_PulseMultiSlow.h>
#include <base/SoundCapture.h>

Animation4Music_PulseMultiSlow::Animation4Music_PulseMultiSlow() :
AnimationBaseMusic(AMUSIC_PULSEMULTISLOW),
Expand Down
1 change: 1 addition & 0 deletions sources/effectengine/Animation4Music_PulseRed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#include <effectengine/Animation4Music_PulseRed.h>
#include <base/SoundCapture.h>

Animation4Music_PulseRed::Animation4Music_PulseRed() :
AnimationBaseMusic(AMUSIC_PULSERED),
Expand Down

0 comments on commit eec1fb6

Please sign in to comment.