From d3ac43db36c78948b44f18d0760c03257a9cbb08 Mon Sep 17 00:00:00 2001 From: msclock Date: Sun, 17 Mar 2024 17:19:21 +0800 Subject: [PATCH 1/5] ci: simplify checks with the automated installation of vcpkg --- .github/workflows/ci.yml | 17 +++++++---------- .../workflows/ci.yml | 17 +++++++---------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89d46a87..dc415fc2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -105,20 +105,17 @@ jobs: - OFF include: - - presets: - os: - name: windows-latest - type: windows - compiler: - name: msvc - type: msvc - arch: - name: x64 - type: x64 + - presets: {os: {name: windows-latest, type: windows}, compiler: {name: msvc, type: msvc}} + arch: {name: x64, type: x64} vcpkg: true export_mode: ON + - presets: {os: {name: windows-latest, type: windows}, compiler: {name: msvc, type: msvc}} + arch: {name: x64, type: x64} + vcpkg: false + export_mode: OFF exclude: - export_mode: ON + - vcpkg: false steps: - uses: actions/checkout@v4 diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml index 89d46a87..dc415fc2 100644 --- a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml +++ b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml @@ -105,20 +105,17 @@ jobs: - OFF include: - - presets: - os: - name: windows-latest - type: windows - compiler: - name: msvc - type: msvc - arch: - name: x64 - type: x64 + - presets: {os: {name: windows-latest, type: windows}, compiler: {name: msvc, type: msvc}} + arch: {name: x64, type: x64} vcpkg: true export_mode: ON + - presets: {os: {name: windows-latest, type: windows}, compiler: {name: msvc, type: msvc}} + arch: {name: x64, type: x64} + vcpkg: false + export_mode: OFF exclude: - export_mode: ON + - vcpkg: false steps: - uses: actions/checkout@v4 From 23e532f3067112c09e3622b00a3eec83103266d5 Mon Sep 17 00:00:00 2001 From: msclock Date: Sun, 17 Mar 2024 17:24:49 +0800 Subject: [PATCH 2/5] ci: configure coverage flags and names --- .github/workflows/ci.yml | 4 ++-- .../workflows/ci.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc415fc2..efe09e6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -187,8 +187,8 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} directory: out/build/${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }}/code_coverage files: ./coverage.xml, ./coverage.info, ./coverage.json - flags: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}-${{ matrix.vcpkg }}${{ matrix.export_mode == 'ON' && '-export' || '' }} - name: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}-${{ matrix.vcpkg }}${{ matrix.export_mode == 'ON' && '-export' || '' }}-coverage + flags: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}${{ matrix.vcpkg == 'true' && '-vcpkg' || '' }}${{ matrix.export_mode == 'ON' && '-export' || '' }} + name: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}${{ matrix.vcpkg == 'true' && '-vcpkg' || '' }}${{ matrix.export_mode == 'ON' && '-export' || '' }}-coverage pass: if: always() diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml index dc415fc2..efe09e6d 100644 --- a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml +++ b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml @@ -187,8 +187,8 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} directory: out/build/${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }}/code_coverage files: ./coverage.xml, ./coverage.info, ./coverage.json - flags: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}-${{ matrix.vcpkg }}${{ matrix.export_mode == 'ON' && '-export' || '' }} - name: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}-${{ matrix.vcpkg }}${{ matrix.export_mode == 'ON' && '-export' || '' }}-coverage + flags: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}${{ matrix.vcpkg == 'true' && '-vcpkg' || '' }}${{ matrix.export_mode == 'ON' && '-export' || '' }} + name: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}${{ matrix.vcpkg == 'true' && '-vcpkg' || '' }}${{ matrix.export_mode == 'ON' && '-export' || '' }}-coverage pass: if: always() From fa92bedbb85a8e21142c807d1ff7b1187855a8a8 Mon Sep 17 00:00:00 2001 From: msclock Date: Sun, 17 Mar 2024 17:34:34 +0800 Subject: [PATCH 3/5] ci: change the vcpkg automatic installation check to ubuntu because the platform windows-latest always having a vcpkg installation in the directory of msvc sdk. --- .github/workflows/ci.yml | 6 +++--- .../workflows/ci.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index efe09e6d..6554e6cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,7 +109,7 @@ jobs: arch: {name: x64, type: x64} vcpkg: true export_mode: ON - - presets: {os: {name: windows-latest, type: windows}, compiler: {name: msvc, type: msvc}} + - presets: {os: {name: ubuntu-latest, type: linux}, compiler: {name: gcc-11, type: gcc}} arch: {name: x64, type: x64} vcpkg: false export_mode: OFF @@ -187,8 +187,8 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} directory: out/build/${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }}/code_coverage files: ./coverage.xml, ./coverage.info, ./coverage.json - flags: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}${{ matrix.vcpkg == 'true' && '-vcpkg' || '' }}${{ matrix.export_mode == 'ON' && '-export' || '' }} - name: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}${{ matrix.vcpkg == 'true' && '-vcpkg' || '' }}${{ matrix.export_mode == 'ON' && '-export' || '' }}-coverage + flags: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}${{ matrix.vcpkg == true && '-vcpkg' || '' }}${{ matrix.export_mode == 'ON' && '-export' || '' }} + name: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}${{ matrix.vcpkg == true && '-vcpkg' || '' }}${{ matrix.export_mode == 'ON' && '-export' || '' }}-coverage pass: if: always() diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml index efe09e6d..6554e6cf 100644 --- a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml +++ b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml @@ -109,7 +109,7 @@ jobs: arch: {name: x64, type: x64} vcpkg: true export_mode: ON - - presets: {os: {name: windows-latest, type: windows}, compiler: {name: msvc, type: msvc}} + - presets: {os: {name: ubuntu-latest, type: linux}, compiler: {name: gcc-11, type: gcc}} arch: {name: x64, type: x64} vcpkg: false export_mode: OFF @@ -187,8 +187,8 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} directory: out/build/${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }}/code_coverage files: ./coverage.xml, ./coverage.info, ./coverage.json - flags: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}${{ matrix.vcpkg == 'true' && '-vcpkg' || '' }}${{ matrix.export_mode == 'ON' && '-export' || '' }} - name: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}${{ matrix.vcpkg == 'true' && '-vcpkg' || '' }}${{ matrix.export_mode == 'ON' && '-export' || '' }}-coverage + flags: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}${{ matrix.vcpkg == true && '-vcpkg' || '' }}${{ matrix.export_mode == 'ON' && '-export' || '' }} + name: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}${{ matrix.vcpkg == true && '-vcpkg' || '' }}${{ matrix.export_mode == 'ON' && '-export' || '' }}-coverage pass: if: always() From 66e43215bdd53fe183a310a031bde32bdb600617 Mon Sep 17 00:00:00 2001 From: msclock Date: Sun, 17 Mar 2024 18:24:04 +0800 Subject: [PATCH 4/5] ci: disable pre-installed vcpkg for testing automatic vcpkg installation --- .github/workflows/ci.yml | 6 +++++- .../workflows/ci.yml | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6554e6cf..b199d9da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -146,6 +146,11 @@ jobs: python: true opencppcoverage: ${{ contains(matrix.presets.os.type, 'windows' )}} + - name: Disable pre-installedd vcpkg for testing automaical vcpkg installation + if: ${{ matrix.vcpkg == false }} + run: | + echo "VCPKG_INSTALLATION_ROOT=" >> $GITHUB_ENV + - name: Lcov for coverage if: contains(matrix.presets.compiler.type, 'gcc') && contains(matrix.presets.os.type, 'linux') run: | @@ -168,7 +173,6 @@ jobs: timeout 10s bash -c "while [ ! -f ~/.wine/system.reg ] ; do echo 'waiting for wine registry to be created' ; sleep 1 ; done" && echo "wine registry created" sed -i '/"PATH"/ s|"$|;Z:/usr/lib/gcc/x86_64-w64-mingw32/10-posix;Z:/usr/x86_64-w64-mingw32/lib"|g' ~/.wine/system.reg && echo "wine registry updated" - - name: Configure CMake run: | cmake -S . --preset=${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }} -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE=ON -DBUILD_TESTING=ON ${{ matrix.presets.os.type == 'linux' && '-DUSE_SANITIZER=OFF' || '' }} ${{ matrix.export_mode == 'ON' && '-DVCPKG_EXPORT_MODE=ON' || '' }} diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml index 6554e6cf..b199d9da 100644 --- a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml +++ b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml @@ -146,6 +146,11 @@ jobs: python: true opencppcoverage: ${{ contains(matrix.presets.os.type, 'windows' )}} + - name: Disable pre-installedd vcpkg for testing automaical vcpkg installation + if: ${{ matrix.vcpkg == false }} + run: | + echo "VCPKG_INSTALLATION_ROOT=" >> $GITHUB_ENV + - name: Lcov for coverage if: contains(matrix.presets.compiler.type, 'gcc') && contains(matrix.presets.os.type, 'linux') run: | @@ -168,7 +173,6 @@ jobs: timeout 10s bash -c "while [ ! -f ~/.wine/system.reg ] ; do echo 'waiting for wine registry to be created' ; sleep 1 ; done" && echo "wine registry created" sed -i '/"PATH"/ s|"$|;Z:/usr/lib/gcc/x86_64-w64-mingw32/10-posix;Z:/usr/x86_64-w64-mingw32/lib"|g' ~/.wine/system.reg && echo "wine registry updated" - - name: Configure CMake run: | cmake -S . --preset=${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }} -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE=ON -DBUILD_TESTING=ON ${{ matrix.presets.os.type == 'linux' && '-DUSE_SANITIZER=OFF' || '' }} ${{ matrix.export_mode == 'ON' && '-DVCPKG_EXPORT_MODE=ON' || '' }} From 7e2a29abbabf37746e5047d879fea55cc232077a Mon Sep 17 00:00:00 2001 From: msclock Date: Sun, 17 Mar 2024 19:00:37 +0800 Subject: [PATCH 5/5] perf: skip empty VCPKG_INSTALLATION_ROOT --- cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake | 3 ++- template/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake b/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake index f8988e62..e5a138f6 100644 --- a/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake +++ b/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake @@ -134,7 +134,8 @@ endfunction() # find root function(_vcpkg_find_root cache_dir_name out_vcpkg_root) - if(DEFINED ENV{VCPKG_INSTALLATION_ROOT}) + if(DEFINED ENV{VCPKG_INSTALLATION_ROOT} + AND NOT "$ENV{VCPKG_INSTALLATION_ROOT}" STREQUAL "") set(root "$ENV{VCPKG_INSTALLATION_ROOT}") elseif("${__vcpkg_bootstrap_host}" STREQUAL "Windows") set(root "$ENV{LOCALAPPDATA}/vcpkg/projects/${cache_dir_name}/cache") diff --git a/template/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake b/template/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake index f8988e62..e5a138f6 100644 --- a/template/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake +++ b/template/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake @@ -134,7 +134,8 @@ endfunction() # find root function(_vcpkg_find_root cache_dir_name out_vcpkg_root) - if(DEFINED ENV{VCPKG_INSTALLATION_ROOT}) + if(DEFINED ENV{VCPKG_INSTALLATION_ROOT} + AND NOT "$ENV{VCPKG_INSTALLATION_ROOT}" STREQUAL "") set(root "$ENV{VCPKG_INSTALLATION_ROOT}") elseif("${__vcpkg_bootstrap_host}" STREQUAL "Windows") set(root "$ENV{LOCALAPPDATA}/vcpkg/projects/${cache_dir_name}/cache")