diff --git a/.appveyor.yml b/.appveyor.yml index 4a557df..6ade23e 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -13,6 +13,7 @@ environment: LLVM_LOC: '"C:\Program Files\LLVM\bin\"' PYTHON_LOC: '"C:\Python37\"' BUILD_PACKAGE: "1" + OVRAS_WARNINGS_AS_ERRORS: "1" - QT_LOC: '"C:\Qt\5.12\msvc2017_64\bin\"' VS_LOC: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat"' @@ -23,6 +24,7 @@ environment: PYTHON_LOC: '"C:\Python37\"' BUILD_PACKAGE: "1" BUILD_CLANG: '"1"' + OVRAS_WARNINGS_AS_ERRORS: "1" clone_depth: 1 @@ -46,4 +48,4 @@ branches: - /docs-*/ - /do-not-run-ci-*/ - /only-travis-ci-*/ - - /only-circle-ci-*/ \ No newline at end of file + - /only-circle-ci-*/ diff --git a/advancedSettings.pro b/advancedSettings.pro index c6a216f..e7db78b 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -123,3 +123,7 @@ debugSymbolsAndLogs { CONFIG += force_debug_info DEFINES += ENABLE_DEBUG_LOGGING } + +warnings_as_errors { + message(Warnings as errors enabled.) +} diff --git a/build_scripts/linux/build_linux.sh b/build_scripts/linux/build_linux.sh index 6c765e0..442e680 100755 --- a/build_scripts/linux/build_linux.sh +++ b/build_scripts/linux/build_linux.sh @@ -1,15 +1,30 @@ #!/usr/bin/env bash set -e + +QMAKE_SPEC='linux-g++' + SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" PROJECT_DIR=$SCRIPT_DIR/../../ BUILD_DIR=$PROJECT_DIR/build/ -. $SCRIPT_DIR/configure.sh + +if [[ -z $USE_TIDY ]]; then + MAKE_COMMAND="make --jobs ${MAKE_JOBS}" + CLANG_TIDY= +else + # Bear replaces the compile database, it does not update it. + # If you run 'bear make' and there is nothing to compile, you + # will get an empty database. + # Clean up the artifacts and run everything together in that case. + MAKE_COMMAND='bear make --jobs' + QMAKE_SPEC='linux-clang' + CLANG_TIDY="$SCRIPT_DIR/run-clang-tidy.sh" +fi echo $MAKE_COMMAND mkdir -p $BUILD_DIR cd $BUILD_DIR qmake --version -qmake -spec $QMAKE_SPEC $PROJECT_DIR $QMAKE_EXTRAS +qmake -spec $QMAKE_SPEC $PROJECT_DIR CONFIG+=warnings_as_errors $MAKE_COMMAND $CLANG_TIDY diff --git a/build_scripts/linux/configure.sh b/build_scripts/linux/configure.sh deleted file mode 100644 index f375113..0000000 --- a/build_scripts/linux/configure.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -set -e - -if [[ -z $QMAKE_SPEC ]]; then - QMAKE_SPEC='linux-g++' -fi - -if [[ -z $USE_TIDY ]]; then - MAKE_COMMAND="make --jobs ${MAKE_JOBS}" - CLANG_TIDY= -else - # Bear replaces the compile database, it does not update it. - # If you run 'bear make' and there is nothing to compile, you - # will get an empty database. - # Clean up the artifacts and run everything together in that case. - MAKE_COMMAND='bear make --jobs' - QMAKE_SPEC='linux-clang' - CLANG_TIDY="$SCRIPT_DIR/run-clang-tidy.sh" -fi - -if [[ -n $NO_X11 ]]; then - QMAKE_EXTRAS='CONFIG+=noX11' -fi -if [[ -n $NO_DBUS ]]; then - QMAKE_EXTRAS='CONFIG+=noDBUS' -fi diff --git a/build_scripts/qt/compilers/clang.pri b/build_scripts/qt/compilers/clang.pri index 8d33a00..e938c5b 100644 --- a/build_scripts/qt/compilers/clang.pri +++ b/build_scripts/qt/compilers/clang.pri @@ -48,7 +48,10 @@ QMAKE_CXXFLAGS += -Wmost QMAKE_CXXFLAGS += -Wpedantic -QMAKE_CXXFLAGS += -Werror +warnings_as_errors { + QMAKE_CXXFLAGS += -Werror +} + #All includes from the third-party directory will not warn. QMAKE_CXXFLAGS += --system-header-prefix=third-party QMAKE_CXXFLAGS += --system-header-prefix=qt diff --git a/build_scripts/qt/compilers/gcc.pri b/build_scripts/qt/compilers/gcc.pri index 7898983..dc86954 100644 --- a/build_scripts/qt/compilers/gcc.pri +++ b/build_scripts/qt/compilers/gcc.pri @@ -27,7 +27,9 @@ include(clang-gcc-common-switches.pri) QMAKE_CXXFLAGS += -Wpedantic -QMAKE_CXXFLAGS += -Werror +warnings_as_errors { + QMAKE_CXXFLAGS += -Werror +} # GCC only switches QMAKE_CXXFLAGS += -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Wrestrict -Wnull-dereference diff --git a/build_scripts/qt/compilers/msvc.pri b/build_scripts/qt/compilers/msvc.pri index 6679151..4ff8b44 100644 --- a/build_scripts/qt/compilers/msvc.pri +++ b/build_scripts/qt/compilers/msvc.pri @@ -1,7 +1,9 @@ include(common-msvc.pri) -# Warnings as errors -QMAKE_CXXFLAGS += /WX +warnings_as_errors { + # Warnings as errors + QMAKE_CXXFLAGS += /WX +} # Enables Link Time Optimization QMAKE_CXXFLAGS += /GL diff --git a/build_scripts/win/build.py b/build_scripts/win/build.py index ec6b22b..7bf92c7 100644 --- a/build_scripts/win/build.py +++ b/build_scripts/win/build.py @@ -139,7 +139,10 @@ def build(): say(f"{BUILD_DEBUG_VAR_NAME} not defined. Building '{COMPILE_MODE}' version.") add_line_to_run_bat_file("@ECHO Running qmake:") - add_line_to_run_bat_file('"' + QMAKE_LOC + '"' + " -spec " + COMPILER + " CONFIG+=X86_64 " + "CONFIG+=" + COMPILE_MODE) + if is_env_var_set("OVRAS_WARNINGS_AS_ERRORS"): + add_line_to_run_bat_file('"' + QMAKE_LOC + '"' + " -spec " + COMPILER + " CONFIG+=X86_64 " + "CONFIG+=" + COMPILE_MODE + " CONFIG+=warnings_as_errors") + else: + add_line_to_run_bat_file('"' + QMAKE_LOC + '"' + " -spec " + COMPILER + " CONFIG+=X86_64 " + "CONFIG+=" + COMPILE_MODE) add_error_handling_line_to_bat_file() add_line_to_run_bat_file("@ECHO qmake done.") diff --git a/docs/building_for_linux.md b/docs/building_for_linux.md index 707c223..c2c059d 100644 --- a/docs/building_for_linux.md +++ b/docs/building_for_linux.md @@ -343,6 +343,7 @@ The following values can be appended to the `CONFIG` internal variable in order | `noDBUS` | Disables DBUS specific features (control media players). | | `noPulse` | Disables PulseAudio specific features (change audio devices). | | `debugSymbolsAndLogs` | Enables debug symbols and debug logging calls (while still having release optimizations). | +| `warnings_as_errors` | Makes compiler warnings failing errors (not needed unless you're changing the source). | The values are case sensitive. @@ -361,6 +362,11 @@ If you want to disable X11, DBUS and PulseAudio features you would type qmake CONFIG+=noX11 CONFIG+=noDBUS CONFIG+=noPulse ``` +If you want to compile with warnings as errors you would type +```bash +qmake CONFIG+=warnings_as_errors +``` + The location for `make install` can be configured in the `qmake` step. This is done by setting the `PREFIX` variable. ```bash