From 8122ce9b3a322f0d02d7c7a22160287fba4155ff Mon Sep 17 00:00:00 2001 From: mcmarius <23401453+mcmarius@users.noreply.github.com> Date: Wed, 2 Oct 2024 15:51:12 +0300 Subject: [PATCH] Fixes 2024 partea 3 (#24) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Modificări cache, sincronizare cu sfml * Dezactivează ASan pe macOS * Actualizează etichete --- .github/actions/clang-tidy/action.yml | 2 +- .github/actions/configure-cmake/action.yml | 10 +++++----- .github/actions/cppcheck/action.yml | 9 ++++++++- .github/actions/process-artifacts/action.yml | 5 +++-- .github/actions/runtime-checks/action.yml | 11 +++++++++-- .github/workflows/cmake.yml | 19 +++++++++++++------ CMakeLists.txt | 12 ++++++++++-- cmake/CompilerFlags.cmake | 2 +- cmake/CopyHelper.cmake | 12 ++++++------ scripts/build_cppcheck.sh | 0 scripts/cmake.sh | 0 scripts/run_cppcheck.sh | 0 12 files changed, 56 insertions(+), 26 deletions(-) mode change 100644 => 100755 scripts/build_cppcheck.sh mode change 100644 => 100755 scripts/cmake.sh mode change 100644 => 100755 scripts/run_cppcheck.sh diff --git a/.github/actions/clang-tidy/action.yml b/.github/actions/clang-tidy/action.yml index 770548a8..1097f34c 100644 --- a/.github/actions/clang-tidy/action.yml +++ b/.github/actions/clang-tidy/action.yml @@ -22,7 +22,7 @@ runs: 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 + 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 uses: ./.github/actions/configure-cmake diff --git a/.github/actions/configure-cmake/action.yml b/.github/actions/configure-cmake/action.yml index 9dd3a6e2..f7c92801 100644 --- a/.github/actions/configure-cmake/action.yml +++ b/.github/actions/configure-cmake/action.yml @@ -20,7 +20,7 @@ runs: # with: # path: | # ${{ env.BUILD_DIR }}/_deps - # key: cache-${{ matrix.cmake_generator }}-${{ matrix.os }}-${{ env.CXX }}-${{ env.BUILD_TYPE }} + # key: cache-${{ matrix.cmake_generator }}-${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.asan_name }}-${{ env.BUILD_TYPE }} # NOTE: GH Actions does not allow updating the cache yet # Using the workaround found here: https://github.com/actions/cache/issues/171 @@ -33,8 +33,8 @@ runs: path: | ${{ env.BUILD_DIR }}/.ninja_deps ${{ env.BUILD_DIR }}/.ninja_log - key: ${{ matrix.os }}-${{ matrix.cxx }}-ninja-cache-${{ hashFiles('CMakeLists.txt') }} - restore-keys: ${{ matrix.os }}-${{ matrix.cxx }}-ninja-cache- + key: ${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.asan_name }}-ninja-cache-${{ hashFiles('CMakeLists.txt') }} + restore-keys: ${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.asan_name }}-ninja-cache- - name: Cache MinGW uses: actions/cache@v4 @@ -68,7 +68,7 @@ runs: bash ./scripts/cmake.sh configure -s ${GITHUB_WORKSPACE} -b ${{ env.BUILD_DIR }} \ -t ${{ env.BUILD_TYPE }} \ -i ${GITHUB_WORKSPACE}/artifacts \ - -c "-DWARNINGS_AS_ERRORS=${{ inputs.warnings_as_errors }} -DGITHUB_ACTIONS=${GITHUB_ACTIONS} ${{ inputs.custom_flags }}" + -c "-DPROJECT_WARNINGS_AS_ERRORS=${{ inputs.warnings_as_errors }} -DGITHUB_ACTIONS=${GITHUB_ACTIONS} ${{ inputs.custom_flags }}" - name: Configure CMake shell: bash @@ -78,7 +78,7 @@ runs: bash ./scripts/cmake.sh configure -s ${GITHUB_WORKSPACE} -b ${{ env.BUILD_DIR }} \ -t ${{ env.BUILD_TYPE }} \ -i ${GITHUB_WORKSPACE}/artifacts \ - -c "-DWARNINGS_AS_ERRORS=${{ inputs.warnings_as_errors }} -DGITHUB_ACTIONS=${GITHUB_ACTIONS} ${{ inputs.custom_flags }}" + -c "-DPROJECT_WARNINGS_AS_ERRORS=${{ inputs.warnings_as_errors }} -DGITHUB_ACTIONS=${GITHUB_ACTIONS} ${{ inputs.custom_flags }}" # https://docs.github.com/en/actions/creating-actions/creating-a-composite-action # https://github.com/GuillaumeFalourd/poc-github-actions/blob/main/.github/workflows/36-local-action.yml diff --git a/.github/actions/cppcheck/action.yml b/.github/actions/cppcheck/action.yml index 6c0bedaa..fc488e42 100644 --- a/.github/actions/cppcheck/action.yml +++ b/.github/actions/cppcheck/action.yml @@ -5,7 +5,7 @@ runs: using: "composite" steps: - name: Cache cppcheck - uses: actions/cache@v4 + uses: actions/cache/restore@v4 id: cache-cppcheck with: path: cppcheck @@ -17,6 +17,13 @@ runs: run: | bash ./scripts/build_cppcheck.sh -v ${CPPCHECK_VER} + - name: Save cppcheck cache + uses: actions/cache/save@v4 + if: steps.cache-cppcheck.outputs.cache-hit != 'true' + with: + path: cppcheck + key: cppcheck-${{ env.CPPCHECK_VER }} + - name: Install cppcheck shell: bash # this step is fast, no need for caching diff --git a/.github/actions/process-artifacts/action.yml b/.github/actions/process-artifacts/action.yml index eaab271e..97df6a74 100644 --- a/.github/actions/process-artifacts/action.yml +++ b/.github/actions/process-artifacts/action.yml @@ -14,11 +14,12 @@ runs: - name: Copy missing dylibs 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/15.0.0/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 }} + # 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 diff --git a/.github/actions/runtime-checks/action.yml b/.github/actions/runtime-checks/action.yml index 2e451b3e..794e2ada 100644 --- a/.github/actions/runtime-checks/action.yml +++ b/.github/actions/runtime-checks/action.yml @@ -4,8 +4,8 @@ description: 'Run dynamic analysis tools' runs: using: "composite" steps: - - name: Cache tools - uses: actions/cache@v4 + - name: Cache restore tools + uses: actions/cache/restore@v4 if: runner.os == 'Linux' && matrix.runs_msan == true id: cache-tools with: @@ -34,6 +34,13 @@ runs: -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: Sanitizers shell: bash # run one sanitizer for each env to avoid building extra binaries on one env diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index dafb04dd..745c2d17 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -39,6 +39,8 @@ defaults: jobs: cppcheck: name: "Cppcheck" + # concurrency: + # group: "Cppcheck" runs-on: ubuntu-22.04 timeout-minutes: 5 env: @@ -54,6 +56,8 @@ jobs: clang-tidy: name: "Clang-Tidy" + # concurrency: + # group: "Clang-Tidy" runs-on: ubuntu-22.04 timeout-minutes: 5 env: @@ -68,6 +72,8 @@ jobs: build: name: ${{ matrix.name }} + # concurrency: + # group: ${{ matrix.name }} runs-on: ${{ matrix.os }} timeout-minutes: 8 permissions: @@ -128,11 +134,11 @@ jobs: - os: macos-14 c: clang cxx: clang++ - name: "ASan: macOS 14 Apple Clang 15" - cmake_flags: "-DUSE_ASAN=ON" + name: "macOS 14 Apple Clang 15" + cmake_flags: "-DUSE_ASAN=OFF" # cmake_generator: # This env runs address sanitizers - runs_asan: true + runs_asan: false - os: macos-14 c: gcc-13 @@ -144,7 +150,7 @@ jobs: - os: windows-2022 c: cl cxx: cl - name: "ASan: Windows 2022 MSVC 19.40" + name: "ASan: Windows 2022 MSVC 19.41" cmake_flags: "-DUSE_ASAN=ON" # Ninja is not faster on MSVC because... MSVC # cmake_generator: "Ninja" @@ -184,12 +190,13 @@ jobs: warnings_as_errors: 'ON' - name: Build - run: bash ./scripts/cmake.sh build + run: | + bash ./scripts/cmake.sh build -t ${{ env.BUILD_TYPE }} - name: Install # Use CMake to "install" build artifacts (only interested in CMake registered targets) to our custom artifacts directory run: | - bash ./scripts/cmake.sh install -i artifacts + bash ./scripts/cmake.sh install -i artifacts -t ${{ env.BUILD_TYPE }} - name: Move artifacts run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index fd126fda..3d05ceeb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 3.26) # NOTE: update executable name in .github/workflows/cmake.yml:25 when changing executable name in this file # for now, the project name is used as the executable name project(oop) +# set(CMAKE_PROJECT_VERSION_MAJOR 0) +# set(CMAKE_PROJECT_VERSION_MINOR 0) +# set(CMAKE_PROJECT_VERSION_PATCH 1) set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -15,6 +18,9 @@ include(cmake/Options.cmake) # external dependencies with FetchContent # include(FetchContent) # +# set(FETCHCONTENT_QUIET OFF) +# set(FETCHCONTENT_UPDATES_DISCONNECTED ON) +# # NOTE: Also update env vars used for caching in # - .github/actions/configure-cmake/action.yml # - .github/workflows/cmake.yml @@ -36,8 +42,10 @@ include(cmake/Options.cmake) ############################################################################### # NOTE: update executable name in .github/workflows/cmake.yml:25 when changing name here -add_executable(${PROJECT_NAME} main.cpp - generated/src/Helper.cpp) +add_executable(${PROJECT_NAME} + main.cpp + generated/src/Helper.cpp +) include(cmake/CompilerFlags.cmake) diff --git a/cmake/CompilerFlags.cmake b/cmake/CompilerFlags.cmake index bd874140..d7d346ef 100644 --- a/cmake/CompilerFlags.cmake +++ b/cmake/CompilerFlags.cmake @@ -7,7 +7,7 @@ endif() ############################################################################### -if(WARNINGS_AS_ERRORS) +if(PROJECT_WARNINGS_AS_ERRORS) set_property(TARGET ${PROJECT_NAME} PROPERTY COMPILE_WARNING_AS_ERROR ON) endif() diff --git a/cmake/CopyHelper.cmake b/cmake/CopyHelper.cmake index a7b6ed62..2ef52b8b 100644 --- a/cmake/CopyHelper.cmake +++ b/cmake/CopyHelper.cmake @@ -7,12 +7,12 @@ function(copy_files) # copy files to build dir foreach(file ${ARG_FILES}) - add_custom_command( - TARGET ${PROJECT_NAME} POST_BUILD - COMMENT "Copying ${file}..." - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${CMAKE_SOURCE_DIR}/${file} $) - # ${CMAKE_CURRENT_BINARY_DIR}) + add_custom_command( + TARGET ${PROJECT_NAME} POST_BUILD + COMMENT "Copying ${file}..." + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_SOURCE_DIR}/${file} $) + # ${CMAKE_CURRENT_BINARY_DIR}) endforeach() # copy folders to build dir diff --git a/scripts/build_cppcheck.sh b/scripts/build_cppcheck.sh old mode 100644 new mode 100755 diff --git a/scripts/cmake.sh b/scripts/cmake.sh old mode 100644 new mode 100755 diff --git a/scripts/run_cppcheck.sh b/scripts/run_cppcheck.sh old mode 100644 new mode 100755