Skip to content

Commit

Permalink
Merge branch 'main' into pr/5493
Browse files Browse the repository at this point in the history
  • Loading branch information
chaosvolt committed Oct 17, 2024
2 parents e0b203b + 7351264 commit 2e3b2e4
Show file tree
Hide file tree
Showing 559 changed files with 38,241 additions and 14,785 deletions.
26 changes: 25 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Checks: >
-modernize-concat-nested-namespaces,
-modernize-loop-convert,
-modernize-unary-static-assert,
-modernize-use-nullptr,
-performance-no-automatic-move,
-performance-trivially-destructible,
-performance-for-range-copy,
Expand Down Expand Up @@ -86,12 +87,35 @@ Checks: >
-readability-redundant-access-specifiers,
-readability-use-anyofallof,
WarningsAsErrors: '*'
-bugprone-throw-keyword-missing,
-readability-identifier-naming,
-readability-avoid-nested-conditional-operator,
-bugprone-unchecked-optional-access,
-bugprone-chained-comparison,
-bugprone-easily-swappable-parameters,
-bugprone-switch-missing-default-case,
-misc-const-correctness,
-misc-include-cleaner,
-misc-use-anonymous-namespace,
-clang-diagnostic-unused-macros,
-clang-analyzer-optin.*,
-performance-enum-size,
-cert-dcl58-cpp,
# https://github.com/llvm/llvm-project/issues/59572
# https://github.com/llvm/llvm-project/issues/111003
# performance-enum-size: no automatic fix available
# cert-dcl58-cpp: too many issues with LUNA

# Turn back on when all the fixes are applied
# WarningsAsErrors: '*'
HeaderFilterRegex: "(src|(test(?!.*catch.*catch.h))|tools).*"
FormatStyle: none
CheckOptions:
- key: readability-uppercase-literal-suffix.NewSuffixes
value: "L;UL;LL;ULL"
- key: cata-text-style.EscapeUnicode
value: 0
- key: readability-simplify-boolean-expr.SimplifyDeMorgan
value: false
# vim:tw=0
4 changes: 1 addition & 3 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ jobs:

- run: sudo apt-get install astyle

- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: denoland/setup-deno@v2

- name: cache deno dependencies
uses: actions/cache@v4
Expand Down
82 changes: 63 additions & 19 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Clang-tidy (clang-12, tiles)
name: Clang-tidy (tiles)

on:
push:
branches: [main]
paths: [ "**.cpp", "**.h", "**.c", "**/CMakeLists.txt", "**/Makefile", "**.hpp", "**.cmake", "build-scripts/**","tools/clang-tidy-plugin/**", ".github/workflows/clang-tidy.yml", "**/.clang-tidy" ]
# push:
# branches: [main]
# paths: [ "**.cpp", "**.h", "**.c", "**/CMakeLists.txt", "**/Makefile", "**.hpp", "**.cmake", "build-scripts/**","tools/clang-tidy-plugin/**", ".github/workflows/clang-tidy.yml", "**/.clang-tidy" ]
pull_request:
branches: [main]
paths: [ "**.cpp", "**.h", "**.c", "**/CMakeLists.txt", "**/Makefile", "**.hpp", "**.cmake", "build-scripts/**", "tools/clang-tidy-plugin/**", ".github/workflows/clang-tidy.yml", "**/.clang-tidy" ]
Expand All @@ -16,7 +16,7 @@ concurrency:
jobs:
skip-duplicates:
continue-on-error: true
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
Expand All @@ -30,28 +30,48 @@ jobs:
needs: skip-duplicates
if: ${{ needs.skip-duplicates.outputs.should_skip != 'true' }}

runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
env:
CMAKE: 1
CLANG: clang++-12
COMPILER: clang++-12
CATA_CLANG_TIDY: plugin
CLANG: /usr/bin/clang++-18
COMPILER: /usr/bin/clang++-18
TILES: 1
SOUND: 1
BUILD_PATH: "build"
AFFECTED_FILES: "affected_files.txt"

steps:
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: install dependencies
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main"
sudo apt-get update
sudo apt-get install libncursesw5-dev clang-12 libclang-12-dev llvm-12-dev llvm-12-tools \
libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libpulse-dev ccache \
libflac-dev gettext
sudo apt-get install \
cmake gettext ninja-build mold ccache jq \
clang-18 libclang-18-dev llvm-18 llvm-18-dev clang-tidy-18 \
libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libpulse-dev libflac-dev
- name: ensure clang 18 is installed
run: |
if [ -z "$(command -v clang++-18)" ]; then
echo "clang 18 not found"
exit 1
fi
ls -al /usr/lib/llvm-18/lib
if [ ! -d /usr/lib/llvm-18/lib ]; then
echo "llvm-18 not found"
exit 1
fi
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100
sudo update-alternatives --install /usr/bin/FileCheck FileCheck /usr/bin/FileCheck-18 100
- name: Setup ccache
uses: Chocobo1/setup-ccache-action@v1
with:
install_ccache: false
update_packager_index: false

- name: add problem matcher
run: |
Expand All @@ -60,8 +80,32 @@ jobs:
echo "::add-matcher::build-scripts/problem-matchers/catch2.json"
echo "::add-matcher::build-scripts/problem-matchers/debugmsg.json"
- name: prepare
run: bash ./build-scripts/requirements.sh
- uses: ammaraskar/gcc-problem-matcher@master

- uses: denoland/setup-deno@v2

- name: build clang-tidy plugin
run: |
pip install --break-system-packages lit
bash ./build-scripts/build-clang-tidy-plugin.sh
# - name: test clang-tidy plugin
# run: |
# lit -v $BUILD_PATH/tools/clang-tidy-plugin/test
# clang-tidy --version

- name: gather affected files
run: deno task affected-files ${{ github.event.pull_request.number }} --output "$AFFECTED_FILES"

- name: run clang-tidy
run: bash ./build-scripts/build.sh
run: bash ./build-scripts/run-clang-tidy-plugin.sh

- name: show most time consuming checks
if: always()
run: | # the folder may not exist if there is no file to analyze
if [ -d clang-tidy-trace ]
then
jq -n 'reduce(inputs.profile | to_entries[]) as {$key,$value} ({}; .[$key] += $value) | with_entries(select(.key|contains(".wall"))) | to_entries | sort_by(.value) | reverse | .[0:10] | from_entries' clang-tidy-trace/*.json
else
echo "clang-tidy-trace folder not found."
fi
11 changes: 3 additions & 8 deletions .github/workflows/pull-translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@ jobs:
- name: "Checkout"
uses: actions/checkout@v4
with:
filter: blob:none
sparse-checkout: |
.tx
lang
# https://github.com/stefanzweifel/git-auto-commit-action?tab=readme-ov-file#push-to-protected-branches
token: ${{ secrets.AUTO_COMMIT_PAT }}

- name: "Get current date"
uses: nanzm/[email protected]
id: get-timestamp
with:
timeZone: 0
format: "YYYY-MM-DD"
run: echo "time=$(date -u "+%F")" >> $GITHUB_OUTPUT

- name: "Pull translations"
run: tx pull --force
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,10 @@ Xcode/
VERSION.txt

changelog.md

tidy-analyze-target

test/Output
test/.lit_test_times.txt
affected_files.txt
clang-tidy-trace
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ if (NOT MSVC)
-Wpedantic \
-Wsuggest-override \
-Wunused-macros \
-Wzero-as-null-pointer-constant \
-Wno-zero-as-null-pointer-constant \
-Wno-unknown-warning-option \
-Wno-dangling-reference \
-Wno-range-loop-analysis")
Expand All @@ -255,7 +255,7 @@ if (NOT MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g2")
endif ()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ WARNINGS = \
-Wpedantic \
-Wsuggest-override \
-Wunused-macros \
-Wzero-as-null-pointer-constant \
-Wno-zero-as-null-pointer-constant \
-Wno-unknown-warning-option \
-Wno-dangling-reference \
-Wno-range-loop-analysis # TODO: Fix warnings instead of disabling
Expand Down Expand Up @@ -432,9 +432,9 @@ ifndef RELEASE
endif

ifeq ($(shell sh -c 'uname -o 2>/dev/null || echo not'),Cygwin)
OTHERS += -std=gnu++17
OTHERS += -std=gnu++20
else
OTHERS += -std=c++17
OTHERS += -std=c++20
endif

ifeq ($(CYGWIN),1)
Expand Down
4 changes: 2 additions & 2 deletions android/app/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
APP_STL := c++_shared
APP_CPPFLAGS += -std=c++17
APP_CPPFLAGS += -std=c++20
ifneq ($(OS),Windows_NT)
APP_LDFLAGS += -fuse-ld=lld
endif
Expand All @@ -13,5 +13,5 @@ endif
#APP_OPTIM := release

# Min SDK level
APP_PLATFORM=android-16
APP_PLATFORM=android-21

30 changes: 11 additions & 19 deletions android/app/src/main/java/org/libsdl/app/SDL.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,42 +42,34 @@ public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError,
}

try {
// Let's see if we have ReLinker available in the project. This is necessary for
// some projects that have huge numbers of local libraries bundled, and thus may
// Let's see if we have ReLinker available in the project. This is necessary for
// some projects that have huge numbers of local libraries bundled, and thus may
// trip a bug in Android's native library loader which ReLinker works around. (If
// loadLibrary works properly, ReLinker will simply use the normal Android method
// internally.)
//
// To use ReLinker, just add it as a dependency. For more information, see
// To use ReLinker, just add it as a dependency. For more information, see
// https://github.com/KeepSafe/ReLinker for ReLinker's repository.
//
Class relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
Class relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
Class contextClass = mContext.getClassLoader().loadClass("android.content.Context");
Class stringClass = mContext.getClassLoader().loadClass("java.lang.String");
Class<?> relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
Class<?> relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
Class<?> contextClass = mContext.getClassLoader().loadClass("android.content.Context");
Class<?> stringClass = mContext.getClassLoader().loadClass("java.lang.String");

// Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if
// Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if
// they've changed during updates.
Method forceMethod = relinkClass.getDeclaredMethod("force");
Object relinkInstance = forceMethod.invoke(null);
Class relinkInstanceClass = relinkInstance.getClass();
Class<?> relinkInstanceClass = relinkInstance.getClass();

// Actually load the library!
Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass);
loadMethod.invoke(relinkInstance, mContext, libraryName, null, null);
}
catch (final Throwable e) {
// Fall back
try {
System.loadLibrary(libraryName);
}
catch (final UnsatisfiedLinkError ule) {
throw ule;
}
catch (final SecurityException se) {
throw se;
}
}
System.loadLibrary(libraryName);
}
}

protected static Context mContext;
Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ override_ndkBuildAppPlatform=android-21

# This property controls which ndkVersion should be used
# You can override this from the command line by passing "-Poverride_ndkVersion=#"
override_ndkVersion=25.2.9519653
override_ndkVersion=26.3.11579264
32 changes: 32 additions & 0 deletions build-scripts/build-clang-tidy-plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -exo pipefail

BUILD_TYPE=${BUILD_TYPE:-"RelWithDeb"}

NUM_JOBS=${NUM_JOBS:-$(nproc)}
BUILD_PATH=${BUILD_PATH:-"build"}

echo "Using bash version $BASH_VERSION with $NUM_JOBS jobs"
echo "Creating build files at $BUILD_PATH"

# We might need binaries installed via pip, so ensure that our personal bin dir is on the PATH
export PATH=$HOME/.local/bin:$PATH

cmake \
-B "$BUILD_PATH" \
-G Ninja \
-DBACKTRACE=ON \
-DCMAKE_C_COMPILER=/usr/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DTILES="$TILES" \
-DSOUND="$SOUND" \
-DLIBBACKTRACE="${LIBBACKTRACE:-0}" \
-DLINKER=mold \
-DLUA=ON \
-DCATA_CLANG_TIDY_PLUGIN=ON

ninja -C "$BUILD_PATH" -j"$NUM_JOBS" CataAnalyzerPlugin
ln -s "$BUILD_PATH/compile_commands.json" compile_commands.json
Loading

0 comments on commit 2e3b2e4

Please sign in to comment.