Skip to content

Commit

Permalink
Migrate to C++17 (cataclysmbnteam#1953)
Browse files Browse the repository at this point in the history
* feat: migrate to c++17

* build: change vcprj option

* fix: make clang-tidy happy

* chore: make clang-tidy just warn about C++17 changes

* build: bump ubuntu version to 22.04

* build: bump GCC and macos to 11

* ci: update ubuntu GCC to 11,  clang to 14

* style: add end_of_line exception for vcxproj

because vcxproj is autogenerated, can't risk another 800 line diff

* build: update stdcpp14 to 17
  • Loading branch information
scarf005 authored Oct 31, 2022
1 parent a5cedb1 commit bde30fe
Show file tree
Hide file tree
Showing 21 changed files with 197 additions and 184 deletions.
10 changes: 9 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ Checks: >
-readability-redundant-control-flow,
-readability-identifier-length,
WarningsAsErrors: "*"
WarningsAsErrors: >
*,
-modernize-use-nodiscard,
-modernize-concat-nested-namespaces,
-modernize-loop-convert,
-modernize-unary-static-assert,
-readability-redundant-declaration,
# C++17 changes that clang-tidy does not likes

HeaderFilterRegex: "(src|(test(?!.*catch.*catch.h))|tools).*"
FormatStyle: none
CheckOptions:
Expand Down
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ indent_size = 2

[{.clang-tidy,.clang-format}]
indent_size = 2

[*.vcxproj]
end_of_line = crlf # Can't really use lf because it's autogenerated
30 changes: 15 additions & 15 deletions .github/workflows/astyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,36 @@ on: pull_request
jobs:
skip-duplicates:
continue-on-error: true
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
cancel_others: 'true'
cancel_others: "true"
paths: '[".github/workflows/astyle.yml", "Makefile", ".astylerc", "**.cpp", "**.h", "**.c"]'
astyle-code:
name: astyle check
needs: skip-duplicates
if: ${{ needs.skip-duplicates.outputs.should_skip != 'true' }}

runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: install dependencies
run: sudo apt-get install astyle
- name: install dependencies
run: sudo apt-get install astyle

- name: astyle check
run: make astyle-check
- name: astyle check
run: make astyle-check

- name: Display Corrections
if: failure()
run: |
make astyle
git diff
- name: Display Corrections
if: failure()
run: |
make astyle
git diff
40 changes: 20 additions & 20 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Clang-tidy (clang-8, tiles)
on:
push:
branches:
- upload
- upload
pull_request:
branches:
- upload
- upload

# We only care about the latest revision of a PR, so cancel all previous instances.
concurrency:
Expand All @@ -16,41 +16,41 @@ concurrency:
jobs:
skip-duplicates:
continue-on-error: true
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
cancel_others: 'true'
cancel_others: "true"
paths: '[ "**.cpp", "**.h", "**.c", "**/CMakeLists.txt", "**/Makefile", "**.hpp", "**.cmake" ]'
build:
needs: skip-duplicates
if: ${{ needs.skip-duplicates.outputs.should_skip != 'true' }}

runs-on: ubuntu-18.04
env:
CMAKE: 1
CLANG: clang++-8
COMPILER: clang++-8
CATA_CLANG_TIDY: plugin
TILES: 1
SOUND: 1
CMAKE: 1
CLANG: clang++-8
COMPILER: clang++-8
CATA_CLANG_TIDY: plugin
TILES: 1
SOUND: 1
steps:
- name: checkout repository
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: install dependencies
run: |
- name: checkout repository
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: install dependencies
run: |
#sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main"
sudo apt-get update
sudo apt-get install libncursesw5-dev clang-8 libclang-8-dev llvm-8-dev llvm-8-tools \
libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libpulse-dev ccache \
gettext
- name: prepare
run: bash ./build-scripts/requirements.sh
- name: run clang-tidy
run: bash ./build-scripts/build.sh
- name: prepare
run: bash ./build-scripts/requirements.sh
- name: run clang-tidy
run: bash ./build-scripts/build.sh
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
documentation:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- name: checkout repository
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ on: pull_request
jobs:
skip-duplicates:
continue-on-error: true
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
cancel_others: 'true'
cancel_others: "true"
paths: '["**.json"]'
style-json:
name: JSON style check

runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: skip-duplicates
if: ${{ needs.skip-duplicates.outputs.should_skip != 'true' }}

steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: JSON style check
run: make style-json
- name: Display Corrections
if: failure()
run: git diff
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: JSON style check
run: make style-json COMPILER=g++-11
- name: Display Corrections
if: failure()
run: git diff
32 changes: 16 additions & 16 deletions .github/workflows/manual-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ on:
workflow_dispatch:
inputs:
version:
description: 'Version string for the release'
required: true
description: "Version string for the release"
required: true
type: string
env:
VERSION: ${{ inputs.version }}
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_already_exists: ${{ steps.tag_check.outputs.exists }}
Expand All @@ -23,7 +23,7 @@ jobs:
uses: nanzm/get-time-action@v1.1
with:
timeZone: 0
format: 'YYYY-MM-DD-HHmm'
format: "YYYY-MM-DD-HHmm"
- name: Generate environmental variables
id: generate_env_vars
run: |
Expand Down Expand Up @@ -93,14 +93,14 @@ jobs:
mxe: x86_64
mxe_apt: x86-64
artifact: windows-tiles-x64
os: ubuntu-latest
os: ubuntu-22.04
ext: zip
content: application/zip
- name: Windows Tiles x32
mxe: i686
mxe_apt: i686
artifact: windows-tiles-x32
os: ubuntu-latest
os: ubuntu-22.04
ext: zip
content: application/zip
- name: Linux Tiles x64
Expand Down Expand Up @@ -134,21 +134,21 @@ jobs:
ext: dmg
content: application/x-apple-diskimage
- name: Android x64
os: ubuntu-latest
os: ubuntu-22.04
mxe: none
android: arm64
artifact: android-x64
ext: apk
content: application/apk
- name: Android x32
os: ubuntu-latest
os: ubuntu-22.04
mxe: none
android: arm32
artifact: android-x32
ext: apk
content: application/apk
- name: Android Bundle
os: ubuntu-latest
os: ubuntu-22.04
mxe: none
android: bundle
artifact: android-bundle
Expand All @@ -157,7 +157,7 @@ jobs:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
env:
ZSTD_CLEVEL: 17
ZSTD_CLEVEL: 17
steps:
- uses: actions/checkout@v2
- name: Create VERSION.TXT
Expand All @@ -177,15 +177,15 @@ jobs:
uses: lukka/run-vcpkg@main
id: runvcpkg
with:
additionalCachedPaths: '${{ runner.workspace }}/Cataclysm-BN/msvc-full-features/vcpkg_installed'
additionalCachedPaths: "${{ runner.workspace }}/Cataclysm-BN/msvc-full-features/vcpkg_installed"
appendedCacheKey: ${{ hashFiles( 'msvc-full-features/vcpkg.json', '.github/vcpkg_triplets/**' ) }}-${{ matrix.arch }}-1
setupOnly: true
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
# We have to use at least this version of vcpkg to include fixes for
vcpkgDirectory: "${{ runner.workspace }}/b/vcpkg"
# We have to use at least this version of vcpkg to include fixes for
# various issues we've encountered over time. Keep it in sync with the builtin-baseline
# field in vcpkg.json. Caching happens as a post-action which runs at the end of
# the whole workflow, after vcpkg install happens during msbuild run.
vcpkgGitCommitId: 'f4b262b259145adb2ab0116a390b08642489d32b'
vcpkgGitCommitId: "f4b262b259145adb2ab0116a390b08642489d32b"
- name: Install dependencies (windows msvc) (3/3)
if: runner.os == 'Windows'
run: |
Expand Down Expand Up @@ -256,8 +256,8 @@ jobs:
if: runner.os == 'Linux' && matrix.android != 'none' && matrix.mxe == 'none'
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
java-version: "8"
distribution: "adopt"
- name: Setup Build and Dependencies (android)
if: runner.os == 'Linux' && matrix.android != 'none' && matrix.mxe == 'none'
run: |
Expand Down
Loading

0 comments on commit bde30fe

Please sign in to comment.