Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test CI with clang-format #354

Merged
merged 25 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ for:

build_script:
# Build MMapper within a Docker container using the current working path as a volume
- sh: sudo docker run --rm -v "$(pwd)":/root/mmapper --cap-add SYS_ADMIN --cap-add MKNOD --device /dev/fuse:mrw --security-opt apparmor:unconfined ubuntu:18.04 bash -c 'apt update -qq && apt install -y wget software-properties-common && add-apt-repository ppa:ecal/cmake-3.25 && add-apt-repository ppa:beineri/opt-qt-5.15.2-bionic -y && apt install -y qt515base libgl1-mesa-dev build-essential git zlib1g-dev libssl-dev wget zsync fuse cmake libminiupnpc-dev && source /opt/qt*/bin/qt*-env.sh && cd /root/mmapper && mkdir -p build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr && make -j$(getconf _NPROCESSORS_ONLN) DESTDIR=appdir install && QT_QPA_PLATFORM=offscreen ctest -V --no-compress-output -T test && export VERSION=$(grep -i "SET(CPACK_PACKAGE_VERSION " CPackConfig.cmake | cut -d\" -f 2) && wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage && chmod a+x linuxdeployqt-continuous-x86_64.AppImage && ./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/share/applications/org.mume.MMapper.desktop -updateinformation="gh-releases-zsync|MUME|MMapper|latest|MMapper-*-x86_64.AppImage.zsync" -appimage'
- sh: sudo docker run --rm -v "$(pwd)":/root/mmapper --cap-add SYS_ADMIN --cap-add MKNOD --device /dev/fuse:mrw --security-opt apparmor:unconfined ubuntu:18.04 bash -c 'apt update -qq && apt install -y wget software-properties-common && add-apt-repository ppa:ecal/cmake-3.25 && add-apt-repository ppa:beineri/opt-qt-5.15.2-bionic -y && apt install -y qt515base libgl1-mesa-dev build-essential git zlib1g-dev libssl-dev wget zsync fuse cmake libminiupnpc-dev && source /opt/qt*/bin/qt*-env.sh && cd /root/mmapper && mkdir -p build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_UNITY_BUILD=ON -DCMAKE_INSTALL_PREFIX=/usr && make -j$(getconf _NPROCESSORS_ONLN) DESTDIR=appdir install && QT_QPA_PLATFORM=offscreen ctest -V --no-compress-output -T test && export VERSION=$(grep -i "SET(CPACK_PACKAGE_VERSION " CPackConfig.cmake | cut -d\" -f 2) && wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage && chmod a+x linuxdeployqt-continuous-x86_64.AppImage && ./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/share/applications/org.mume.MMapper.desktop -updateinformation="gh-releases-zsync|MUME|MMapper|latest|MMapper-*-x86_64.AppImage.zsync" -appimage'
- sh: sudo mv build/*.AppImage* .
- sh: export FILE=$(find . -type f -name MMapper*.AppImage | sed 's#./##')
- sh: sha256sum $FILE > $FILE.sha256
Expand Down Expand Up @@ -153,7 +153,7 @@ for:
build_script:
- sh: mkdir build
- sh: cd build
- sh: cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DTARGET_ARCHITECTURE=$TARGET_ARCHITECTURE
- sh: cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DTARGET_ARCHITECTURE=$TARGET_ARCHITECTURE -DUSE_UNITY_BUILD=ON
- sh: cmake --build . -j$(getconf _NPROCESSORS_ONLN)
- sh: cpack
- sh: mv *.deb* ../
Expand Down Expand Up @@ -254,7 +254,7 @@ for:
- cmd: cd c:\Build\MMapper
- cmd: md winbuild
- cmd: cd winbuild
- cmd: cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G %CMAKE_GENERATOR% "-DCMAKE_PREFIX_PATH=%QTDIR%" "-DOPENSSL_ROOT_DIR=%OPENSSLDIR%"
- cmd: cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G %CMAKE_GENERATOR% "-DCMAKE_PREFIX_PATH=%QTDIR%" "-DOPENSSL_ROOT_DIR=%OPENSSLDIR%" -DUSE_UNITY_BUILD=ON
- cmd: cmake --build . -j %NUMBER_OF_PROCESSORS%
- cmd: cpack
- ps: move *.exe* ../
Expand Down Expand Up @@ -308,7 +308,7 @@ for:
- cmd: cd c:\Build\MMapper
- cmd: md winbuild
- cmd: cd winbuild
- cmd: cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G %CMAKE_GENERATOR% "-DCMAKE_PREFIX_PATH=%QTDIR%" "-DOPENSSL_ROOT_DIR=%OPENSSLDIR%"
- cmd: cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G %CMAKE_GENERATOR% "-DCMAKE_PREFIX_PATH=%QTDIR%" "-DOPENSSL_ROOT_DIR=%OPENSSLDIR%" -DUSE_UNITY_BUILD=ON
- cmd: cmake --build . -j %NUMBER_OF_PROCESSORS%
- cmd: cpack
- ps: move *.exe* ../
Expand Down
21 changes: 18 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,24 @@ ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<Q.*'
Priority: 200
# Headers in ""
- Regex: '^"'
Priority: 1
SortPriority: 1
# Headers in <>
- Regex: '^<[^Q][^/]*>$'
Priority: 2
SortPriority: 2
# Headers in <>
- Regex: '^<[^Q].*[/]'
Priority: 3
SortPriority: 3
# Qt headers
- Regex: '^<Q[^>]'
Priority: 4
SortPriority: 4
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentWidth: 4
Expand All @@ -97,7 +112,7 @@ PenaltyExcessCharacter: 50
PenaltyReturnTypeOnItsOwnLine: 300
PointerAlignment: Right
ReflowComments: false
SortIncludes: true
SortIncludes: CaseSensitive
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: false
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Run clang-format style check
uses: jidicula/clang-format-action@v4.12.0
uses: jidicula/clang-format-action@v4.13.0
with:
clang-format-version: '11'
clang-format-version: '14'
check-path: ${{ matrix.path['check'] }}
exclude-regex: ${{ matrix.path['exclude'] }}
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ option(WITH_OPENSSL "Use OpenSSL for TLS encryption" ON)
option(WITH_MINIUPNPC "Use MiniUPnPc for group manager port forwarding" ON)
option(WITH_MAP "Download the default map" ON)
option(WITH_TESTS "Compile unit tests" ON)
option(USE_UNITY_BUILD "Run unity build to speed up compilation" ON)
option(USE_UNITY_BUILD "Run unity build to speed up compilation" OFF)
option(USE_TIDY "Run clang-tidy with the compiler" OFF)
option(USE_IWYU "Run include-what-you-use with the compiler" OFF)
option(USE_DISTCC "Use distcc for distributed builds" OFF)
option(USE_CODE_COVERAGE "Run code coverage reporting" OFF)
if(WIN32 AND MINGW)
option(WITH_DRMINGW "Include Dr. Mingw crash dumping (Windows only)" ON)
Expand Down Expand Up @@ -273,7 +272,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()

if(MMAPPER_IS_DEBUG)
if(TRUE)
if(NOT WIN32)
# segfaults in ASAN initializer on 32-bit Ubuntu 18.04.1 with clang 6.0
# note: apparently -fsanitize=address can't be used with gnu libc 2.25+
# Ubuntu 18.04.1 has libc 2.27.
Expand Down
112 changes: 56 additions & 56 deletions external/zlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
if(ZLIB_FOUND)
message(STATUS "zlib found: ${ZLIB_LIBRARIES} ${ZLIB_INCLUDE_DIRS}")
# Ensure that we package zlib DLLs with MMapper for Windows
if(WIN32)
set(ZLIB_SHARED_LIBRARY_NAME "zlib1.dll")
# Find zlib root directory
list(GET ZLIB_LIBRARIES -1 ZLIB_DIRECTORY)
get_filename_component(ZLIB_ROOT_DIR ${ZLIB_DIRECTORY} DIRECTORY)
string(REGEX REPLACE "(.:[\\/]+[^\\/]+).*" "\\1" ZLIB_ROOT_DIR ${ZLIB_ROOT_DIR})
find_file(ZLIB_BIN
NAMES
${ZLIB_SHARED_LIBRARY_NAME}
HINTS
${ZLIB_ROOT_DIR}
${ZLIB_ROOT}
PATH_SUFFIXES
bin)
if(NOT ZLIB_BIN)
message(FATAL_ERROR "zlib dependency ${ZLIB_SHARED_LIBRARY_NAME} was NOT found")
else()
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/src/bin)
configure_file(${ZLIB_BIN} ${CMAKE_BINARY_DIR}/src/bin/${ZLIB_SHARED_LIBRARY_NAME} COPYONLY)
message(STATUS " Copied ${ZLIB_BIN} to src/bin/")
endif()
endif()
else()
if(WIN32)
set(ZLIB_STATIC_LIBRARY_NAME zlibstatic)
else()
set(ZLIB_STATIC_LIBRARY_NAME z)
message(FATAL_ERROR "zlib NOT found: use `-DWITH_ZLIB=OFF` to build without old map backwards compatability")
endif()
message(STATUS "Could not find system zlib; building as a static library")
include(ExternalProject)
ExternalProject_Add(zlib
URL "https://www.zlib.net/zlib-1.3.1.tar.gz"
URL_HASH SHA256=9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/zlib-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/zlib-build"
INSTALL_COMMAND ""
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release"
CMAKE_CACHE_ARGS -DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
-DBUILD_SHARED_LIBS:BOOL==OFF
UPDATE_COMMAND ""
ALWAYS 0
BUILD_BYPRODUCTS "<BINARY_DIR>/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_STATIC_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
ExternalProject_Get_Property(zlib SOURCE_DIR)
ExternalProject_Get_Property(zlib BINARY_DIR)
set(ZLIB_STATIC_LIBRARY ${BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_STATIC_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
set(ZLIB_LIBRARIES ${ZLIB_STATIC_LIBRARY} PARENT_SCOPE)
set(ZLIB_INCLUDE_DIRS ${SOURCE_DIR} ${BINARY_DIR} PARENT_SCOPE)
endif()
if(ZLIB_FOUND)
message(STATUS "zlib found: ${ZLIB_LIBRARIES} ${ZLIB_INCLUDE_DIRS}")
# Ensure that we package zlib DLLs with MMapper for Windows
if(WIN32)
set(ZLIB_SHARED_LIBRARY_NAME "zlib1.dll")
# Find zlib root directory
list(GET ZLIB_LIBRARIES -1 ZLIB_DIRECTORY)
get_filename_component(ZLIB_ROOT_DIR ${ZLIB_DIRECTORY} DIRECTORY)
string(REGEX REPLACE "(.:[\\/]+[^\\/]+).*" "\\1" ZLIB_ROOT_DIR ${ZLIB_ROOT_DIR})
find_file(ZLIB_BIN
NAMES
${ZLIB_SHARED_LIBRARY_NAME}
HINTS
${ZLIB_ROOT_DIR}
${ZLIB_ROOT}
PATH_SUFFIXES
bin)
if(NOT ZLIB_BIN)
message(FATAL_ERROR "zlib dependency ${ZLIB_SHARED_LIBRARY_NAME} was NOT found")
else()
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/src/bin)
configure_file(${ZLIB_BIN} ${CMAKE_BINARY_DIR}/src/bin/${ZLIB_SHARED_LIBRARY_NAME} COPYONLY)
message(STATUS " Copied ${ZLIB_BIN} to src/bin/")
endif()
endif()
else()
if(WIN32)
set(ZLIB_STATIC_LIBRARY_NAME zlibstatic)
else()
set(ZLIB_STATIC_LIBRARY_NAME z)
message(FATAL_ERROR "zlib NOT found: use `-DWITH_ZLIB=OFF` to build without old map backwards compatability")
endif()
message(STATUS "Could not find system zlib; building as a static library")
include(ExternalProject)
ExternalProject_Add(zlib
URL "https://www.zlib.net/zlib-1.3.1.tar.gz"
URL_HASH SHA256=9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23

SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/zlib-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/zlib-build"
INSTALL_COMMAND ""
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release"
CMAKE_CACHE_ARGS -DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
-DBUILD_SHARED_LIBS:BOOL==OFF

UPDATE_COMMAND ""
ALWAYS 0

BUILD_BYPRODUCTS "<BINARY_DIR>/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_STATIC_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
ExternalProject_Get_Property(zlib SOURCE_DIR)
ExternalProject_Get_Property(zlib BINARY_DIR)
set(ZLIB_STATIC_LIBRARY ${BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_STATIC_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
set(ZLIB_LIBRARIES ${ZLIB_STATIC_LIBRARY} PARENT_SCOPE)
set(ZLIB_INCLUDE_DIRS ${SOURCE_DIR} ${BINARY_DIR} PARENT_SCOPE)
endif()
26 changes: 6 additions & 20 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ set(mmapper_SRCS
adventure/adventuretracker.h
adventure/adventurewidget.cpp
adventure/adventurewidget.h
adventure/lineparsers.h
adventure/lineparsers.cpp
adventure/lineparsers.h
adventure/xpstatuswidget.cpp
adventure/xpstatuswidget.h
client/ClientTelnet.cpp
Expand All @@ -27,9 +27,9 @@ set(mmapper_SRCS
clock/mumemoment.cpp
clock/mumemoment.h
configuration/NamedConfig.h
configuration/configobserver.h
configuration/configuration.cpp
configuration/configuration.h
configuration/configobserver.h
display/CanvasMouseModeEnum.h
display/Characters.cpp
display/Characters.h
Expand Down Expand Up @@ -185,6 +185,8 @@ set(mmapper_SRCS
mapstorage/PandoraMapStorage.h
mapstorage/StorageUtils.cpp
mapstorage/StorageUtils.h
mapstorage/XmlMapStorage.cpp
mapstorage/XmlMapStorage.h
mapstorage/abstractmapstorage.cpp
mapstorage/abstractmapstorage.h
mapstorage/basemapsavefilter.cpp
Expand All @@ -199,8 +201,6 @@ set(mmapper_SRCS
mapstorage/progresscounter.h
mapstorage/roomsaver.cpp
mapstorage/roomsaver.h
mapstorage/XmlMapStorage.cpp
mapstorage/XmlMapStorage.h
mpi/mpifilter.cpp
mpi/mpifilter.h
mpi/remoteedit.cpp
Expand Down Expand Up @@ -277,9 +277,9 @@ set(mmapper_SRCS
parser/AbstractParser-Group.cpp
parser/AbstractParser-Mark.cpp
parser/AbstractParser-Room.cpp
parser/AbstractParser-Timer.cpp
parser/AbstractParser-Utils.cpp
parser/AbstractParser-Utils.h
parser/AbstractParser-Timer.cpp
parser/Action.cpp
parser/Action.h
parser/CommandId.cpp
Expand Down Expand Up @@ -473,6 +473,7 @@ if(CHECK_MISSING_INCLUDES)
set(FNAME "${CMAKE_CURRENT_BINARY_DIR}/gen/${header_path}.gen.cpp")
file(WRITE ${FNAME} "#include \"${header_path}\"\n")
list(APPEND DUMMY_FILES ${FNAME})
set_property(SOURCE ${FNAME} APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${header_path})
set(FNAME "")
endforeach()
# REVISIT: Find a way to avoid adding this to mmapper_SRCS?
Expand Down Expand Up @@ -585,21 +586,6 @@ if(USE_IWYU)
endif()
endif()

if(USE_DISTCC)
find_program(
DISTCC_EXE
NAMES distcc
DOC "Path to distcc executable"
)
if(NOT DISTCC_EXE)
message(FATAL_ERROR "distcc not found: use `-DUSE_DISTCC=OFF` to disable")
else()
message(STATUS "distcc found: ${DISTCC_EXE}")
set(CMAKE_C_COMPILER_LAUNCHER "${DISTCC_EXE}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${DISTCC_EXE}")
endif()
endif()


# Begin CPack Settings
if(GIT_TAG_NAME)
Expand Down
5 changes: 3 additions & 2 deletions src/adventure/adventuresession.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
// Copyright (C) 2023 The MMapper Authors
// Author: Mike Repass <[email protected]> (Taryn)

#include "../../tests/testadventure.h"

#include <chrono>
#include <QString>

#include "../../tests/testadventure.h"
#include <QString>

class AdventureSession
{
Expand Down
8 changes: 4 additions & 4 deletions src/adventure/adventuretracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
// Copyright (C) 2023 The MMapper Authors
// Author: Mike Repass <[email protected]> (Taryn)

#include <QObject>
#include "../observer/gameobserver.h"
#include "adventuresession.h"
#include "lineparsers.h"

#include "adventure/adventuresession.h"
#include "adventure/lineparsers.h"
#include "observer/gameobserver.h"
#include <QObject>

class AdventureTracker final : public QObject
{
Expand Down
6 changes: 3 additions & 3 deletions src/adventure/adventurewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

#include "adventurewidget.h"

#include <QtCore>
#include <QtWidgets>

#include "../configuration/configuration.h"
#include "adventuresession.h"

#include <QtCore>
#include <QtWidgets>

AdventureWidget::AdventureWidget(AdventureTracker &at, QWidget *const parent)
: QWidget{parent}
, m_adventureTracker{at}
Expand Down
4 changes: 2 additions & 2 deletions src/adventure/adventurewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// Copyright (C) 2023 The MMapper Authors
// Author: Mike Repass <[email protected]> (Taryn)

#include "adventuretracker.h"

#include <QString>
#include <QWidget>
#include <QtCore>
#include <QtWidgets>

#include "adventure/adventuretracker.h"

class AdventureWidget : public QWidget
{
Q_OBJECT
Expand Down
4 changes: 2 additions & 2 deletions src/adventure/xpstatuswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
// Copyright (C) 2023 The MMapper Authors
// Author: Mike Repass <[email protected]> (Taryn)

#include "adventuretracker.h"

#include <QLabel>
#include <QPushButton>
#include <QStatusBar>

#include "adventure/adventuretracker.h"

class XPStatusWidget : public QPushButton
{
Q_OBJECT
Expand Down
Loading
Loading