From 9d2e3fd2bbf85756bb0d8af07d5c92409eea9d3b Mon Sep 17 00:00:00 2001 From: Archit <45993519+Aviii06@users.noreply.github.com> Date: Sat, 31 Dec 2022 17:00:36 +0530 Subject: [PATCH 1/9] Add caching --- .github/workflows/cpp.yml | 185 ++++++++++++++++++++++++++++++++------ 1 file changed, 157 insertions(+), 28 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 1b3113349..0ab80978e 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -1,36 +1,165 @@ -name: C/C++ CI +name: C/C++ CI Windows on: [push] -jobs: - build-windows-22: - - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [windows-2022] - - steps: - - uses: actions/checkout@v2 - - - name: configure - run: ./generate_cache.bat /22 - - - name: build - run: ./build.bat +env: + CMAKE_VERSION: 3.24.3 + NINJA_VERSION: 1.11.1 + BUILD_TYPE: Release + CCACHE_VERSION: 4.7.3 - build-windows-19: - - runs-on: ${{ matrix.os }} +jobs: + build: + name: ${{ matrix.config.name }} + runs-on: ${{ matrix.config.os }} strategy: + fail-fast: false matrix: - os: [windows-2019] - + config: + - { + name: "Windows Latest MSVC", artifact: "Windows-MSVC.7z", + os: windows-2019, + cc: "cl", cxx: "cl", + environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat" + } + - { + name: "Windows Latest MSVC", artifact: "Windows-MSVC.7z", + os: windows-2022, + cc: "cl", cxx: "cl", + environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat" + } steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + with: + submodules: recursive - - name: configure - run: ./generate_cache.bat /19 - - - name: build - run: ./build.bat + - name: Download Ninja and CMake + shell: cmake -P {0} + run: | + set(cmake_version $ENV{CMAKE_VERSION}) + set(ninja_version $ENV{NINJA_VERSION}) + message(STATUS "Using host CMake version: ${CMAKE_VERSION}") + if ("${{ runner.os }}" STREQUAL "Windows") + set(ninja_suffix "win.zip") + set(cmake_suffix "windows-x86_64.zip") + set(cmake_dir "cmake-${cmake_version}-windows-x86_64/bin") + elseif ("${{ runner.os }}" STREQUAL "Linux") + set(ninja_suffix "linux.zip") + set(cmake_suffix "linux-x86_64.tar.gz") + set(cmake_dir "cmake-${cmake_version}-linux-x86_64/bin") + elseif ("${{ runner.os }}" STREQUAL "macOS") + set(ninja_suffix "mac.zip") + set(cmake_suffix "macos-universal.tar.gz") + set(cmake_dir "cmake-${cmake_version}-macos-universal/CMake.app/Contents/bin") + endif() + set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}") + file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip) + set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${cmake_suffix}") + file(DOWNLOAD "${cmake_url}" ./cmake.zip SHOW_PROGRESS) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./cmake.zip) + # Add to PATH environment variable + file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${cmake_dir}" cmake_dir) + set(path_separator ":") + if ("${{ runner.os }}" STREQUAL "Windows") + set(path_separator ";") + endif() + file(APPEND "$ENV{GITHUB_PATH}" "$ENV{GITHUB_WORKSPACE}${path_separator}${cmake_dir}") + if (NOT "${{ runner.os }}" STREQUAL "Windows") + execute_process( + COMMAND chmod +x ninja + COMMAND chmod +x ${cmake_dir}/cmake + ) + endif() + - name: Download ccache + id: ccache + shell: cmake -P {0} + run: | + set(ccache_url "https://github.com/cristianadam/ccache/releases/download/v$ENV{CCACHE_VERSION}/${{ runner.os }}.tar.xz") + file(DOWNLOAD "${ccache_url}" ./ccache.tar.xz SHOW_PROGRESS) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ccache.tar.xz) + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + file(APPEND "$ENV{GITHUB_OUTPUT}" "timestamp=${current_date}") + - name: ccache cache files + uses: actions/cache@v3 + with: + path: .ccache + key: ${{ matrix.config.name }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + restore-keys: | + ${{ matrix.config.name }}-ccache- + - name: Configure + shell: cmake -P {0} + run: | + set(ENV{CC} ${{ matrix.config.cc }}) + set(ENV{CXX} ${{ matrix.config.cxx }}) + if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") + execute_process( + COMMAND "${{ matrix.config.environment_script }}" && set + OUTPUT_FILE environment_script_output.txt + ) + file(STRINGS environment_script_output.txt output_lines) + foreach(line IN LISTS output_lines) + if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") + set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") + endif() + endforeach() + endif() + set(path_separator ":") + if ("${{ runner.os }}" STREQUAL "Windows") + set(path_separator ";") + endif() + set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}") + execute_process( + COMMAND cmake + -S . + -B build + -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE} + -G Ninja + -D CMAKE_MAKE_PROGRAM=ninja + -D CMAKE_C_COMPILER_LAUNCHER=ccache + -D CMAKE_CXX_COMPILER_LAUNCHER=ccache + RESULT_VARIABLE result + ) + if (NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + - name: Build + shell: cmake -P {0} + run: | + set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ") + if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") + file(STRINGS environment_script_output.txt output_lines) + foreach(line IN LISTS output_lines) + if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") + set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") + endif() + endforeach() + endif() + file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}" ccache_basedir) + set(ENV{CCACHE_BASEDIR} "${ccache_basedir}") + set(ENV{CCACHE_DIR} "${ccache_basedir}/.ccache") + set(ENV{CCACHE_COMPRESS} "true") + set(ENV{CCACHE_COMPRESSLEVEL} "6") + set(ENV{CCACHE_MAXSIZE} "400M") + if ("${{ matrix.config.cxx }}" STREQUAL "cl") + set(ENV{CCACHE_MAXSIZE} "600M") + endif() + execute_process(COMMAND ccache -p) + execute_process(COMMAND ccache -z) + execute_process( + COMMAND cmake --build build + RESULT_VARIABLE result + OUTPUT_VARIABLE output + ERROR_VARIABLE output + ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE + ) + if (NOT result EQUAL 0) + string(REGEX MATCH "FAILED:.*$" error_message "${output}") + string(REPLACE "\n" "%0A" error_message "${error_message}") + message("::error::${error_message}") + message(FATAL_ERROR "Build failed") + endif() From 36aeacb19bbb4060bc52c4535667575bee46daeb Mon Sep 17 00:00:00 2001 From: Archit <45993519+Aviii06@users.noreply.github.com> Date: Sat, 31 Dec 2022 17:03:48 +0530 Subject: [PATCH 2/9] fix recursive clone --- .github/workflows/cpp.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 0ab80978e..ceee72ec7 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -17,21 +17,19 @@ jobs: matrix: config: - { - name: "Windows Latest MSVC", artifact: "Windows-MSVC.7z", + name: "Windows 2019 MSVC", artifact: "Windows-MSVC.7z", os: windows-2019, cc: "cl", cxx: "cl", - environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat" + environment_script: "C:/Program Files/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" } - { - name: "Windows Latest MSVC", artifact: "Windows-MSVC.7z", + name: "Windows 2022 MSVC", artifact: "Windows-MSVC.7z", os: windows-2022, cc: "cl", cxx: "cl", environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat" } steps: - uses: actions/checkout@v3 - with: - submodules: recursive - name: Download Ninja and CMake shell: cmake -P {0} From 3b31cf7434d09810df761811c2cd487fa3a55c0d Mon Sep 17 00:00:00 2001 From: Archit <45993519+Aviii06@users.noreply.github.com> Date: Sat, 31 Dec 2022 17:09:54 +0530 Subject: [PATCH 3/9] change 2022 to windows-latest --- .github/workflows/cpp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index ceee72ec7..f1de98127 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -23,8 +23,8 @@ jobs: environment_script: "C:/Program Files/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" } - { - name: "Windows 2022 MSVC", artifact: "Windows-MSVC.7z", - os: windows-2022, + name: "Windows latest MSVC", artifact: "Windows-MSVC.7z", + os: windows-latest, cc: "cl", cxx: "cl", environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat" } From 5b3d1a3634d289f1872c403c78f4e4a5c9d4fc5b Mon Sep 17 00:00:00 2001 From: Archit <45993519+Aviii06@users.noreply.github.com> Date: Sat, 31 Dec 2022 17:46:35 +0530 Subject: [PATCH 4/9] Change from ninja --- .github/workflows/cpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index f1de98127..0216d9d13 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -117,7 +117,7 @@ jobs: -B build -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE} -G Ninja - -D CMAKE_MAKE_PROGRAM=ninja + -D CMAKE_MAKE_PROGRAM=Visual Studio 17 2022 -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache RESULT_VARIABLE result From 0a06e672d5e9f438389a4e044726b066878d9aa3 Mon Sep 17 00:00:00 2001 From: Archit <45993519+Aviii06@users.noreply.github.com> Date: Sat, 31 Dec 2022 17:55:18 +0530 Subject: [PATCH 5/9] change to VS 2022 --- .github/workflows/cpp.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 0216d9d13..be4e14d5d 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -116,8 +116,7 @@ jobs: -S . -B build -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE} - -G Ninja - -D CMAKE_MAKE_PROGRAM=Visual Studio 17 2022 + -G "Visual Studio 17 2022" -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache RESULT_VARIABLE result From 6acabbc0adce5ced9d1416ff61b4e617cfae0a4f Mon Sep 17 00:00:00 2001 From: Archit <45993519+Aviii06@users.noreply.github.com> Date: Sat, 31 Dec 2022 18:10:20 +0530 Subject: [PATCH 6/9] Make two jobs for 2019 and 2022 --- .github/workflows/cpp.yml | 149 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 144 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index be4e14d5d..7291cdd4d 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -17,13 +17,152 @@ jobs: matrix: config: - { - name: "Windows 2019 MSVC", artifact: "Windows-MSVC.7z", - os: windows-2019, + name: "Windows 2022 MSVC", artifact: "Windows-MSVC.7z", + os: windows-latest, cc: "cl", cxx: "cl", - environment_script: "C:/Program Files/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" + environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat" } + steps: + - uses: actions/checkout@v3 + + - name: Download Ninja and CMake + shell: cmake -P {0} + run: | + set(cmake_version $ENV{CMAKE_VERSION}) + set(ninja_version $ENV{NINJA_VERSION}) + message(STATUS "Using host CMake version: ${CMAKE_VERSION}") + if ("${{ runner.os }}" STREQUAL "Windows") + set(ninja_suffix "win.zip") + set(cmake_suffix "windows-x86_64.zip") + set(cmake_dir "cmake-${cmake_version}-windows-x86_64/bin") + elseif ("${{ runner.os }}" STREQUAL "Linux") + set(ninja_suffix "linux.zip") + set(cmake_suffix "linux-x86_64.tar.gz") + set(cmake_dir "cmake-${cmake_version}-linux-x86_64/bin") + elseif ("${{ runner.os }}" STREQUAL "macOS") + set(ninja_suffix "mac.zip") + set(cmake_suffix "macos-universal.tar.gz") + set(cmake_dir "cmake-${cmake_version}-macos-universal/CMake.app/Contents/bin") + endif() + set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}") + file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip) + set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${cmake_suffix}") + file(DOWNLOAD "${cmake_url}" ./cmake.zip SHOW_PROGRESS) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./cmake.zip) + # Add to PATH environment variable + file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${cmake_dir}" cmake_dir) + set(path_separator ":") + if ("${{ runner.os }}" STREQUAL "Windows") + set(path_separator ";") + endif() + file(APPEND "$ENV{GITHUB_PATH}" "$ENV{GITHUB_WORKSPACE}${path_separator}${cmake_dir}") + if (NOT "${{ runner.os }}" STREQUAL "Windows") + execute_process( + COMMAND chmod +x ninja + COMMAND chmod +x ${cmake_dir}/cmake + ) + endif() + - name: Download ccache + id: ccache + shell: cmake -P {0} + run: | + set(ccache_url "https://github.com/cristianadam/ccache/releases/download/v$ENV{CCACHE_VERSION}/${{ runner.os }}.tar.xz") + file(DOWNLOAD "${ccache_url}" ./ccache.tar.xz SHOW_PROGRESS) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ccache.tar.xz) + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + file(APPEND "$ENV{GITHUB_OUTPUT}" "timestamp=${current_date}") + - name: ccache cache files + uses: actions/cache@v3 + with: + path: .ccache + key: ${{ matrix.config.name }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + restore-keys: | + ${{ matrix.config.name }}-ccache- + - name: Configure + shell: cmake -P {0} + run: | + set(ENV{CC} ${{ matrix.config.cc }}) + set(ENV{CXX} ${{ matrix.config.cxx }}) + if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") + execute_process( + COMMAND "${{ matrix.config.environment_script }}" && set + OUTPUT_FILE environment_script_output.txt + ) + file(STRINGS environment_script_output.txt output_lines) + foreach(line IN LISTS output_lines) + if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") + set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") + endif() + endforeach() + endif() + set(path_separator ":") + if ("${{ runner.os }}" STREQUAL "Windows") + set(path_separator ";") + endif() + set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}") + execute_process( + COMMAND cmake + -S . + -B build + -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE} + -G "Visual Studio 17 2022" + -D CMAKE_C_COMPILER_LAUNCHER=ccache + -D CMAKE_CXX_COMPILER_LAUNCHER=ccache + RESULT_VARIABLE result + ) + if (NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + - name: Build + shell: cmake -P {0} + run: | + set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ") + if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") + file(STRINGS environment_script_output.txt output_lines) + foreach(line IN LISTS output_lines) + if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") + set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") + endif() + endforeach() + endif() + file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}" ccache_basedir) + set(ENV{CCACHE_BASEDIR} "${ccache_basedir}") + set(ENV{CCACHE_DIR} "${ccache_basedir}/.ccache") + set(ENV{CCACHE_COMPRESS} "true") + set(ENV{CCACHE_COMPRESSLEVEL} "6") + set(ENV{CCACHE_MAXSIZE} "400M") + if ("${{ matrix.config.cxx }}" STREQUAL "cl") + set(ENV{CCACHE_MAXSIZE} "600M") + endif() + execute_process(COMMAND ccache -p) + execute_process(COMMAND ccache -z) + execute_process( + COMMAND cmake --build build + RESULT_VARIABLE result + OUTPUT_VARIABLE output + ERROR_VARIABLE output + ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE + ) + if (NOT result EQUAL 0) + string(REGEX MATCH "FAILED:.*$" error_message "${output}") + string(REPLACE "\n" "%0A" error_message "${error_message}") + message("::error::${error_message}") + message(FATAL_ERROR "Build failed") + endif() + + name: ${{ matrix.config.name }} + runs-on: ${{ matrix.config.os }} + strategy: + fail-fast: false + matrix: + config: - { - name: "Windows latest MSVC", artifact: "Windows-MSVC.7z", + name: "Windows 2019 MSVC", artifact: "Windows-MSVC.7z", os: windows-latest, cc: "cl", cxx: "cl", environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat" @@ -116,7 +255,7 @@ jobs: -S . -B build -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE} - -G "Visual Studio 17 2022" + -G "Visual Studio 16 2019" -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache RESULT_VARIABLE result From df8f5afc9d3a6ace6b5323fe388d69dd2e12ec42 Mon Sep 17 00:00:00 2001 From: Archit <45993519+Aviii06@users.noreply.github.com> Date: Sat, 31 Dec 2022 18:11:32 +0530 Subject: [PATCH 7/9] Update cpp.yml --- .github/workflows/cpp.yml | 145 -------------------------------------- 1 file changed, 145 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 7291cdd4d..483ae22b2 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -154,148 +154,3 @@ jobs: message("::error::${error_message}") message(FATAL_ERROR "Build failed") endif() - - name: ${{ matrix.config.name }} - runs-on: ${{ matrix.config.os }} - strategy: - fail-fast: false - matrix: - config: - - { - name: "Windows 2019 MSVC", artifact: "Windows-MSVC.7z", - os: windows-latest, - cc: "cl", cxx: "cl", - environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat" - } - steps: - - uses: actions/checkout@v3 - - - name: Download Ninja and CMake - shell: cmake -P {0} - run: | - set(cmake_version $ENV{CMAKE_VERSION}) - set(ninja_version $ENV{NINJA_VERSION}) - message(STATUS "Using host CMake version: ${CMAKE_VERSION}") - if ("${{ runner.os }}" STREQUAL "Windows") - set(ninja_suffix "win.zip") - set(cmake_suffix "windows-x86_64.zip") - set(cmake_dir "cmake-${cmake_version}-windows-x86_64/bin") - elseif ("${{ runner.os }}" STREQUAL "Linux") - set(ninja_suffix "linux.zip") - set(cmake_suffix "linux-x86_64.tar.gz") - set(cmake_dir "cmake-${cmake_version}-linux-x86_64/bin") - elseif ("${{ runner.os }}" STREQUAL "macOS") - set(ninja_suffix "mac.zip") - set(cmake_suffix "macos-universal.tar.gz") - set(cmake_dir "cmake-${cmake_version}-macos-universal/CMake.app/Contents/bin") - endif() - set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}") - file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip) - set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${cmake_suffix}") - file(DOWNLOAD "${cmake_url}" ./cmake.zip SHOW_PROGRESS) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./cmake.zip) - # Add to PATH environment variable - file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${cmake_dir}" cmake_dir) - set(path_separator ":") - if ("${{ runner.os }}" STREQUAL "Windows") - set(path_separator ";") - endif() - file(APPEND "$ENV{GITHUB_PATH}" "$ENV{GITHUB_WORKSPACE}${path_separator}${cmake_dir}") - if (NOT "${{ runner.os }}" STREQUAL "Windows") - execute_process( - COMMAND chmod +x ninja - COMMAND chmod +x ${cmake_dir}/cmake - ) - endif() - - name: Download ccache - id: ccache - shell: cmake -P {0} - run: | - set(ccache_url "https://github.com/cristianadam/ccache/releases/download/v$ENV{CCACHE_VERSION}/${{ runner.os }}.tar.xz") - file(DOWNLOAD "${ccache_url}" ./ccache.tar.xz SHOW_PROGRESS) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ccache.tar.xz) - - name: Prepare ccache timestamp - id: ccache_cache_timestamp - shell: cmake -P {0} - run: | - string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) - file(APPEND "$ENV{GITHUB_OUTPUT}" "timestamp=${current_date}") - - name: ccache cache files - uses: actions/cache@v3 - with: - path: .ccache - key: ${{ matrix.config.name }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} - restore-keys: | - ${{ matrix.config.name }}-ccache- - - name: Configure - shell: cmake -P {0} - run: | - set(ENV{CC} ${{ matrix.config.cc }}) - set(ENV{CXX} ${{ matrix.config.cxx }}) - if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") - execute_process( - COMMAND "${{ matrix.config.environment_script }}" && set - OUTPUT_FILE environment_script_output.txt - ) - file(STRINGS environment_script_output.txt output_lines) - foreach(line IN LISTS output_lines) - if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") - set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") - endif() - endforeach() - endif() - set(path_separator ":") - if ("${{ runner.os }}" STREQUAL "Windows") - set(path_separator ";") - endif() - set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}") - execute_process( - COMMAND cmake - -S . - -B build - -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE} - -G "Visual Studio 16 2019" - -D CMAKE_C_COMPILER_LAUNCHER=ccache - -D CMAKE_CXX_COMPILER_LAUNCHER=ccache - RESULT_VARIABLE result - ) - if (NOT result EQUAL 0) - message(FATAL_ERROR "Bad exit status") - endif() - - name: Build - shell: cmake -P {0} - run: | - set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ") - if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") - file(STRINGS environment_script_output.txt output_lines) - foreach(line IN LISTS output_lines) - if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") - set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") - endif() - endforeach() - endif() - file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}" ccache_basedir) - set(ENV{CCACHE_BASEDIR} "${ccache_basedir}") - set(ENV{CCACHE_DIR} "${ccache_basedir}/.ccache") - set(ENV{CCACHE_COMPRESS} "true") - set(ENV{CCACHE_COMPRESSLEVEL} "6") - set(ENV{CCACHE_MAXSIZE} "400M") - if ("${{ matrix.config.cxx }}" STREQUAL "cl") - set(ENV{CCACHE_MAXSIZE} "600M") - endif() - execute_process(COMMAND ccache -p) - execute_process(COMMAND ccache -z) - execute_process( - COMMAND cmake --build build - RESULT_VARIABLE result - OUTPUT_VARIABLE output - ERROR_VARIABLE output - ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE - ) - if (NOT result EQUAL 0) - string(REGEX MATCH "FAILED:.*$" error_message "${output}") - string(REPLACE "\n" "%0A" error_message "${error_message}") - message("::error::${error_message}") - message(FATAL_ERROR "Build failed") - endif() From 81f84cee43560cdccecf7c350c88f12bc2fda2d8 Mon Sep 17 00:00:00 2001 From: Archit <45993519+Aviii06@users.noreply.github.com> Date: Sat, 31 Dec 2022 18:14:33 +0530 Subject: [PATCH 8/9] Create build-2019.yml --- .github/workflows/build-2019.yml | 156 +++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 .github/workflows/build-2019.yml diff --git a/.github/workflows/build-2019.yml b/.github/workflows/build-2019.yml new file mode 100644 index 000000000..d58d8d202 --- /dev/null +++ b/.github/workflows/build-2019.yml @@ -0,0 +1,156 @@ +name: C/C++ CI Windows + +on: [push] + +env: + CMAKE_VERSION: 3.24.3 + NINJA_VERSION: 1.11.1 + BUILD_TYPE: Release + CCACHE_VERSION: 4.7.3 + +jobs: + build: + name: ${{ matrix.config.name }} + runs-on: ${{ matrix.config.os }} + strategy: + fail-fast: false + matrix: + config: + - { + name: "Windows 2019 MSVC", artifact: "Windows-MSVC.7z", + os: windows-latest, + cc: "cl", cxx: "cl", + environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat" + } + steps: + - uses: actions/checkout@v3 + + - name: Download Ninja and CMake + shell: cmake -P {0} + run: | + set(cmake_version $ENV{CMAKE_VERSION}) + set(ninja_version $ENV{NINJA_VERSION}) + message(STATUS "Using host CMake version: ${CMAKE_VERSION}") + if ("${{ runner.os }}" STREQUAL "Windows") + set(ninja_suffix "win.zip") + set(cmake_suffix "windows-x86_64.zip") + set(cmake_dir "cmake-${cmake_version}-windows-x86_64/bin") + elseif ("${{ runner.os }}" STREQUAL "Linux") + set(ninja_suffix "linux.zip") + set(cmake_suffix "linux-x86_64.tar.gz") + set(cmake_dir "cmake-${cmake_version}-linux-x86_64/bin") + elseif ("${{ runner.os }}" STREQUAL "macOS") + set(ninja_suffix "mac.zip") + set(cmake_suffix "macos-universal.tar.gz") + set(cmake_dir "cmake-${cmake_version}-macos-universal/CMake.app/Contents/bin") + endif() + set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}") + file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip) + set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${cmake_suffix}") + file(DOWNLOAD "${cmake_url}" ./cmake.zip SHOW_PROGRESS) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./cmake.zip) + # Add to PATH environment variable + file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${cmake_dir}" cmake_dir) + set(path_separator ":") + if ("${{ runner.os }}" STREQUAL "Windows") + set(path_separator ";") + endif() + file(APPEND "$ENV{GITHUB_PATH}" "$ENV{GITHUB_WORKSPACE}${path_separator}${cmake_dir}") + if (NOT "${{ runner.os }}" STREQUAL "Windows") + execute_process( + COMMAND chmod +x ninja + COMMAND chmod +x ${cmake_dir}/cmake + ) + endif() + - name: Download ccache + id: ccache + shell: cmake -P {0} + run: | + set(ccache_url "https://github.com/cristianadam/ccache/releases/download/v$ENV{CCACHE_VERSION}/${{ runner.os }}.tar.xz") + file(DOWNLOAD "${ccache_url}" ./ccache.tar.xz SHOW_PROGRESS) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ccache.tar.xz) + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + file(APPEND "$ENV{GITHUB_OUTPUT}" "timestamp=${current_date}") + - name: ccache cache files + uses: actions/cache@v3 + with: + path: .ccache + key: ${{ matrix.config.name }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + restore-keys: | + ${{ matrix.config.name }}-ccache- + - name: Configure + shell: cmake -P {0} + run: | + set(ENV{CC} ${{ matrix.config.cc }}) + set(ENV{CXX} ${{ matrix.config.cxx }}) + if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") + execute_process( + COMMAND "${{ matrix.config.environment_script }}" && set + OUTPUT_FILE environment_script_output.txt + ) + file(STRINGS environment_script_output.txt output_lines) + foreach(line IN LISTS output_lines) + if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") + set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") + endif() + endforeach() + endif() + set(path_separator ":") + if ("${{ runner.os }}" STREQUAL "Windows") + set(path_separator ";") + endif() + set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}") + execute_process( + COMMAND cmake + -S . + -B build + -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE} + -G "Visual Studio 16 2019" + -D CMAKE_C_COMPILER_LAUNCHER=ccache + -D CMAKE_CXX_COMPILER_LAUNCHER=ccache + RESULT_VARIABLE result + ) + if (NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + - name: Build + shell: cmake -P {0} + run: | + set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ") + if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") + file(STRINGS environment_script_output.txt output_lines) + foreach(line IN LISTS output_lines) + if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") + set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") + endif() + endforeach() + endif() + file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}" ccache_basedir) + set(ENV{CCACHE_BASEDIR} "${ccache_basedir}") + set(ENV{CCACHE_DIR} "${ccache_basedir}/.ccache") + set(ENV{CCACHE_COMPRESS} "true") + set(ENV{CCACHE_COMPRESSLEVEL} "6") + set(ENV{CCACHE_MAXSIZE} "400M") + if ("${{ matrix.config.cxx }}" STREQUAL "cl") + set(ENV{CCACHE_MAXSIZE} "600M") + endif() + execute_process(COMMAND ccache -p) + execute_process(COMMAND ccache -z) + execute_process( + COMMAND cmake --build build + RESULT_VARIABLE result + OUTPUT_VARIABLE output + ERROR_VARIABLE output + ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE + ) + if (NOT result EQUAL 0) + string(REGEX MATCH "FAILED:.*$" error_message "${output}") + string(REPLACE "\n" "%0A" error_message "${error_message}") + message("::error::${error_message}") + message(FATAL_ERROR "Build failed") + endif() From 7f422d120d1f84bfbafec99da346a4277022a67d Mon Sep 17 00:00:00 2001 From: Archit <45993519+Aviii06@users.noreply.github.com> Date: Sat, 31 Dec 2022 18:14:53 +0530 Subject: [PATCH 9/9] Rename cpp.yml to build-2022.yml --- .github/workflows/{cpp.yml => build-2022.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{cpp.yml => build-2022.yml} (100%) diff --git a/.github/workflows/cpp.yml b/.github/workflows/build-2022.yml similarity index 100% rename from .github/workflows/cpp.yml rename to .github/workflows/build-2022.yml