Skip to content

Commit

Permalink
Adăugat SFML
Browse files Browse the repository at this point in the history
- Shallow clone, ignore errors
- Try to install less dependencies on Linux
- Try 2.6.x branch

Eliminare nume fereastră hardcodat în scripts

Run xvfb-run directly

Remove job running MSan

We do not run MSan with SFML, so this job is not needed at all
because we now run cppcheck in a different job.

Install linux deps due to cmake config

Add missing external dep

This might be preinstalled on GitHub Actions VMs, but it
simplifies local setup.

Make it compile on gcc-12

Use ninja-build

Skip linking sanitizers on gcc

Disable C++20 modules explicitly for MSVC

Skip MSVC modules

Just because MSVC insists on compiling modules
despite being explicitly disabled

Disable building STL modules on MSVC

Add workaround source

Comment explicit C++23

For now, we set it globally

Patch pentru a folosi SFML cu threads

CMake build flag as option, comment unused step

Link deps privately

Copy all missing framework dylibs

Copy OpenAL DLL on Windows

SFML requires C runtime linked against MSVCRT (for 2.6.1).
GitHub decided to switch to UCRT based builds of MinGW
See actions/runner-images#8372
and SFML/SFML#2700

Add missing shell param, fix label

Fix deprecation

Bump SFML to 2.6.1, refactor out quirks

Instrucțiuni pentru compilare pe Linux
  • Loading branch information
mcmarius committed Oct 2, 2024
1 parent 8122ce9 commit 1e0c65c
Show file tree
Hide file tree
Showing 17 changed files with 349 additions and 133 deletions.
5 changes: 4 additions & 1 deletion .github/actions/clang-tidy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ description: 'Install and run clang-tidy'
runs:
using: "composite"
steps:
- name: Install Linux Dependencies
if: runner.os == 'Linux'
uses: ./.github/actions/install-linux-deps

- name: Setup compiler env vars
shell: bash
run: |
Expand All @@ -21,7 +25,6 @@ runs:
- name: Install clang-tidy
shell: bash
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends clang-tidy-${{ env.CLANG_VER }} libc++-${{ env.CLANG_VER }}-dev libc++abi-${{ env.CLANG_VER }}-dev ninja-build
- name: Configure CMake
Expand Down
16 changes: 8 additions & 8 deletions .github/actions/configure-cmake/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ runs:
using: "composite"
steps:
# Uncomment when using external dependencies, so they will be cached
# - name: Cache deps
# uses: actions/cache@v4
# id: cache-deps
# # make the key depend on the dependency version
# with:
# path: |
# ${{ env.BUILD_DIR }}/_deps
# key: cache-${{ matrix.cmake_generator }}-${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.asan_name }}-${{ env.BUILD_TYPE }}
- name: Cache deps
uses: actions/cache@v4
id: cache-deps
# make the key depend on the dependency version
with:
path: |
${{ env.BUILD_DIR }}/_deps
key: cache-${{ matrix.cmake_generator }}-${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.asan_name }}-${{ env.BUILD_TYPE }}-${{ env.SFML_VERSION }}

# NOTE: GH Actions does not allow updating the cache yet
# Using the workaround found here: https://github.com/actions/cache/issues/171
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/cppcheck/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ description: 'Install and run cppcheck'
runs:
using: "composite"
steps:
- name: Install Linux Dependencies
if: runner.os == 'Linux'
uses: ./.github/actions/install-linux-deps

- name: Cache cppcheck
uses: actions/cache/restore@v4
id: cache-cppcheck
Expand Down
21 changes: 21 additions & 0 deletions .github/actions/install-linux-deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 'Install common Linux dependencies'
description: 'Common logic for Linux dependencies installation'
runs:
using: "composite"
steps:
- run: |
sudo apt-get update
sudo apt-get install --no-install-recommends \
libxrandr-dev \
libxcursor-dev \
libudev-dev \
libopenal-dev \
libflac-dev \
libvorbis-dev \
libgl1-mesa-dev \
libegl1-mesa-dev \
libdrm-dev \
libgbm-dev \
libfreetype6-dev \
xorg
shell: bash
39 changes: 23 additions & 16 deletions .github/actions/install-packages/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,37 @@ runs:
using: "composite"
steps:
# Common Linux dependencies
- name: Install Linux Dependencies
- name: Install common Linux Dependencies
if: runner.os == 'Linux'
uses: ./.github/actions/install-linux-deps

- name: More Linux Dependencies
shell: bash
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install ninja-build
sudo apt-get install ninja-build xdotool \
openbox \
libxkbcommon-x11-0 \
libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0
# https://github.com/llvm/llvm-project/issues/78354
sudo sysctl vm.mmap_rnd_bits=28
# Also see https://github.com/actions/runner-images/discussions/9446#discussioncomment-8668538
- name: Install Clang ${{ matrix.clang_ver }}
shell: bash
if: runner.os == 'Linux' && matrix.runs_msan == true
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
sudo ./llvm.sh ${{ matrix.clang_ver }}
# - name: Install Clang ${{ matrix.clang_ver }}
# shell: bash
# if: runner.os == 'Linux' && matrix.runs_msan == true
# run: |
# wget https://apt.llvm.org/llvm.sh
# chmod +x ./llvm.sh
# sudo ./llvm.sh ${{ matrix.clang_ver }}

- name: Install libc++ (Linux Clang ${{ matrix.clang_ver }})
shell: bash
if: runner.os == 'Linux' && matrix.runs_msan == true
run: |
# sudo apt-get update
sudo apt-get install --no-install-recommends libc++-${{ matrix.clang_ver }}-dev libc++abi-${{ matrix.clang_ver }}-dev
# - name: Install libc++ (Linux Clang ${{ matrix.clang_ver }})
# shell: bash
# if: runner.os == 'Linux' && matrix.runs_msan == true
# run: |
# # sudo apt-get update
# sudo apt-get install --no-install-recommends libc++-${{ matrix.clang_ver }}-dev libc++abi-${{ matrix.clang_ver }}-dev

- name: Install valgrind
shell: bash
Expand Down
33 changes: 19 additions & 14 deletions .github/actions/process-artifacts/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,29 @@ runs:
shell: bash
if: runner.os == 'macOS' && matrix.cxx == 'clang++'
# FIXME: temp disable asan for macOS due to github issues
run: |
if [[ "${BUILD_TYPE}" =~ "Deb" ]]; then
mkdir lib
# cp /Library/Developer/CommandLineTools/usr/lib/clang/16/lib/darwin/libclang_rt.asan_osx_dynamic.dylib lib
# install_name_tool -change @rpath/libclang_rt.asan_osx_dynamic.dylib @executable_path/lib/libclang_rt.asan_osx_dynamic.dylib ${{ env.ZIP_NAME }}/${{ env.EXECUTABLE_NAME }}
mv lib ${{ env.ZIP_NAME }}/
fi
- name: Copy missing dylibs (g++)
shell: bash
if: runner.os == 'macOS' && startsWith(matrix.cxx, 'g++')
run: |
mkdir lib
cp /opt/homebrew/lib/gcc/13/libstdc++.6.dylib /opt/homebrew/lib/gcc/13/libgcc_s.1.1.dylib lib
install_name_tool -change /opt/homebrew/lib/gcc/13/libstdc++.6.dylib @executable_path/lib/libstdc++.6.dylib ${{ env.ZIP_NAME }}/${{ env.EXECUTABLE_NAME }}
install_name_tool -change /opt/homebrew/lib/gcc/13/libgcc_s.1.1.dylib @executable_path/lib/libgcc_s.1.1.dylib ${{ env.ZIP_NAME }}/${{ env.EXECUTABLE_NAME }}
# if [[ "${BUILD_TYPE}" =~ "Deb" ]]; then
# # cp /Library/Developer/CommandLineTools/usr/lib/clang/16/lib/darwin/libclang_rt.asan_osx_dynamic.dylib lib
# # install_name_tool -change @rpath/libclang_rt.asan_osx_dynamic.dylib @executable_path/lib/libclang_rt.asan_osx_dynamic.dylib ${{ env.ZIP_NAME }}/${{ env.EXECUTABLE_NAME }}
# fi
ls -1 artifacts/lib | grep framework | xargs -I% ls artifacts/lib/%/Versions/A | grep -v "Resources" | xargs -I% cp artifacts/lib/%.framework/% lib
ls -1 artifacts/lib | grep framework | xargs -I% ls artifacts/lib/%/Versions/A | grep -v "Resources" | xargs -I% install_name_tool -change @rpath/../Frameworks/%.framework/Versions/A/% @executable_path/lib/% ${{ env.ZIP_NAME }}/${{ env.EXECUTABLE_NAME }}
mv lib ${{ env.ZIP_NAME }}/
# - name: Copy missing dylibs (g++)
# shell: bash
# if: runner.os == 'macOS' && startsWith(matrix.cxx, 'g++')
# run: |
# mkdir lib
# cp /opt/homebrew/lib/gcc/13/libstdc++.6.dylib /opt/homebrew/lib/gcc/13/libgcc_s.1.1.dylib lib
# install_name_tool -change /opt/homebrew/lib/gcc/13/libstdc++.6.dylib @executable_path/lib/libstdc++.6.dylib ${{ env.ZIP_NAME }}/${{ env.EXECUTABLE_NAME }}
# install_name_tool -change /opt/homebrew/lib/gcc/13/libgcc_s.1.1.dylib @executable_path/lib/libgcc_s.1.1.dylib ${{ env.ZIP_NAME }}/${{ env.EXECUTABLE_NAME }}
# # not sure about these - SFML might not support GCC on macOS
# ls -1 artifacts/lib | grep framework | xargs -I% ls artifacts/lib/%/Versions/A | grep -v "Resources" | xargs -I% cp artifacts/lib/%.framework/% lib
# ls -1 artifacts/lib | grep framework | xargs -I% ls artifacts/lib/%/Versions/A | grep -v "Resources" | xargs -I% install_name_tool -change @rpath/../Frameworks/%.framework/Versions/A/% @executable_path/lib/% ${{ env.ZIP_NAME }}/${{ env.EXECUTABLE_NAME }}
# mv lib ${{ env.ZIP_NAME }}/

- name: Copy missing dlls
shell: bash
if: runner.os == 'Windows' && matrix.cxx == 'cl'
Expand Down
99 changes: 49 additions & 50 deletions .github/actions/runtime-checks/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,66 @@ description: 'Run dynamic analysis tools'
runs:
using: "composite"
steps:
- name: Cache restore tools
uses: actions/cache/restore@v4
if: runner.os == 'Linux' && matrix.runs_msan == true
id: cache-tools
with:
path: tools
key: tools-clang-${{ matrix.clang_ver }}-stdlib-msan
# - name: Cache restore tools
# uses: actions/cache/restore@v4
# if: runner.os == 'Linux' && matrix.runs_msan == true
# id: cache-tools
# with:
# path: tools
# key: tools-clang-${{ matrix.clang_ver }}-stdlib-msan

- name: Setup memory sanitizer
shell: bash
if: runner.os == 'Linux' && matrix.runs_msan == true && steps.cache-tools.outputs.cache-hit != 'true'
run: |
mkdir -p tools
cd tools
git clone --depth=1 --branch=llvmorg-${{ matrix.clang_ver_full }} https://github.com/llvm/llvm-project
cd llvm-project
# mkdir build; cd build
sudo ln -s -f /usr/bin/$CC /usr/bin/clang
sudo ln -s -f /usr/bin/$CXX /usr/bin/clang++
# https://github.com/llvm/llvm-project/issues/78354
sudo sysctl vm.mmap_rnd_bits=28
cmake -G Ninja -S runtimes -B build \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DLLVM_USE_SANITIZER=MemoryWithOrigins \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=true
cmake --build build -j6 -- cxx cxxabi
# - name: Setup memory sanitizer
# shell: bash
# if: runner.os == 'Linux' && matrix.runs_msan == true && steps.cache-tools.outputs.cache-hit != 'true'
# run: |
# mkdir -p tools
# cd tools
# git clone --depth=1 --branch=llvmorg-${{ matrix.clang_ver_full }} https://github.com/llvm/llvm-project
# cd llvm-project
# # mkdir build; cd build
# sudo ln -s -f /usr/bin/$CC /usr/bin/clang
# sudo ln -s -f /usr/bin/$CXX /usr/bin/clang++
# # https://github.com/llvm/llvm-project/issues/78354
# sudo sysctl vm.mmap_rnd_bits=28
# cmake -G Ninja -S runtimes -B build \
# -DCMAKE_BUILD_TYPE=Release \
# -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
# -DCMAKE_C_COMPILER=clang \
# -DCMAKE_CXX_COMPILER=clang++ \
# -DLLVM_USE_SANITIZER=MemoryWithOrigins \
# -DCMAKE_BUILD_WITH_INSTALL_RPATH=true
# cmake --build build -j6 -- cxx cxxabi

- name: Cache save tools
uses: actions/cache/save@v4
if: runner.os == 'Linux' && matrix.runs_msan == true && steps.cache-tools.outputs.cache-hit != 'true'
with:
path: tools
key: tools-clang-${{ matrix.clang_ver }}-stdlib-msan
# - name: Cache save tools
# uses: actions/cache/save@v4
# if: runner.os == 'Linux' && matrix.runs_msan == true && steps.cache-tools.outputs.cache-hit != 'true'
# with:
# path: tools
# key: tools-clang-${{ matrix.clang_ver }}-stdlib-msan

- name: Sanitizers
- name: Make scripts executable
shell: bash
# run one sanitizer for each env to avoid building extra binaries on one env
if: (matrix.runs_asan == true || matrix.runs_msan == true) && runner.os != 'Windows'
# detect_leaks is not supported on macOS
# env:
# ASAN_OPTIONS: detect_leaks=1
if: runner.os == 'Linux'
run: |
cat "${INPUT_FILENAME}" | tr -d '\r' | ./${{ env.ZIP_NAME }}/"${EXECUTABLE_NAME}"
chmod +x scripts/*
- name: Sanitizers (Windows MSVC)
- name: Sanitizers
shell: bash
# run one sanitizer for each OS to avoid building extra binaries
if: matrix.cxx == 'cl' && matrix.runs_asan == true
if: runner.os == 'Linux' && matrix.runs_asan == true
continue-on-error: true
env:
ASAN_OPTIONS: halt_on_error=0
EXECUTABLE_NAME: ${{ env.EXECUTABLE_NAME }}
run: |
cat "${INPUT_FILENAME}" | ./${{ env.ZIP_NAME }}/"${EXECUTABLE_NAME}".exe
xvfb-run ./scripts/run_sanitizers.sh || true
working-directory: ${{github.workspace}}

- name: Valgrind
shell: bash
if: runner.os == 'Linux' && matrix.runs_valgrind == true
continue-on-error: true
env:
EXECUTABLE_NAME: ${{ env.EXECUTABLE_NAME }}
run: |
# remove --show-leak-kinds=all (and --track-origins=yes) if there are many leaks in external libs
cat "${INPUT_FILENAME}" | tr -d '\r' | valgrind \
--leak-check=full --show-leak-kinds=all --track-origins=yes \
--error-exitcode=1 \
./${{ env.ZIP_NAME }}/"${EXECUTABLE_NAME}"
xvfb-run ./scripts/run_valgrind.sh || true
working-directory: ${{github.workspace}}
50 changes: 27 additions & 23 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ env:
BUILD_DIR: "build"
EXT_DIR: "ext"
GEN_DIR: "generated"
APP_WINDOW: "My Window"

defaults:
run:
Expand Down Expand Up @@ -86,6 +87,9 @@ jobs:
CXX: ${{ matrix.cxx }}
VSCMD_SKIP_SENDTELEMETRY: 1

# NOTE: also update in CMakeLists FetchContent
SFML_VERSION: "2023-11-04-2.6.1"

# NOTE: replace with another version if this one does not work
# For more versions, see https://winlibs.com or
# https://github.com/brechtsanders/winlibs_mingw/releases/
Expand All @@ -100,22 +104,22 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
c: clang-18
cxx: clang++-18
clang_ver: "18"
clang_ver_full: "18.1.8"
name: "MSan: Ubuntu 22.04 Clang 18"
cmake_flags: "-DUSE_MSAN=ON"
cmake_generator: Ninja
# This env runs memory sanitizers
runs_msan: true
# - os: ubuntu-22.04
# c: clang-18
# cxx: clang++-18
# clang_ver: "18"
# clang_ver_full: "18.1.8"
# name: "MSan: Ubuntu 22.04 Clang 18"
# cmake_flags: "-DUSE_MSAN=ON -DBUILD_SHARED_LIBS=FALSE"
# cmake_generator: Ninja
# # This env runs memory sanitizers
# runs_msan: true

- os: ubuntu-22.04
c: gcc-12
cxx: g++-12
name: "ASan: Ubuntu 22.04 GCC 12"
cmake_flags: "-DUSE_ASAN=ON"
cmake_flags: "-DUSE_ASAN=ON -DBUILD_SHARED_LIBS=FALSE"
cmake_generator: Ninja
# This env runs address sanitizers
runs_asan: true
Expand All @@ -126,7 +130,7 @@ jobs:
c: gcc-12
cxx: g++-12
name: "Valgrind: Ubuntu 22.04 GCC 12"
# cmake_flags:
cmake_flags: -DBUILD_SHARED_LIBS=FALSE
cmake_generator: Ninja
# This env runs valgrind
runs_valgrind: true
Expand All @@ -135,34 +139,34 @@ jobs:
c: clang
cxx: clang++
name: "macOS 14 Apple Clang 15"
cmake_flags: "-DUSE_ASAN=OFF"
cmake_flags: "-DUSE_ASAN=OFF -DSFML_BUILD_FRAMEWORKS=FALSE -DSFML_DEPENDENCIES_INSTALL_PREFIX=$GITHUB_WORKSPACE/artifacts -DBUILD_SHARED_LIBS=FALSE"
# cmake_generator:
# This env runs address sanitizers
runs_asan: false
# runs_asan: false

- os: macos-14
c: gcc-13
cxx: g++-13
name: "macOS 14 GCC 13"
# cmake_flags:
# cmake_generator: Ninja
# - os: macos-14
# c: gcc-13
# cxx: g++-13
# name: "macOS 14 GCC 13"
# cmake_flags:
# cmake_generator: Ninja

- os: windows-2022
c: cl
cxx: cl
name: "ASan: Windows 2022 MSVC 19.41"
cmake_flags: "-DUSE_ASAN=ON"
cmake_flags: "-DUSE_ASAN=ON -DBUILD_SHARED_LIBS=TRUE"
# Ninja is not faster on MSVC because... MSVC
# cmake_generator: "Ninja"
# cmake_generator: "Ninja Multi-Config"
# This env runs address sanitizers
runs_asan: true
# runs_asan: true

- os: windows-2022
c: gcc
cxx: g++
name: "Windows 2022 MinGW GCC 13"
# cmake_flags:
cmake_flags: -DBUILD_SHARED_LIBS=TRUE
cmake_generator: Ninja

steps:
Expand Down
Loading

0 comments on commit 1e0c65c

Please sign in to comment.