From a0f032c28bdf4950fb7fd9b98099fe1414a770a2 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Tue, 3 Feb 2026 15:03:30 +0800 Subject: [PATCH] chore: update yycc gh action build script --- .github/scripts/README.md | 4 ++ .github/scripts/gbenchmark/linux.sh | 17 ++++++++ .github/scripts/gbenchmark/macos.sh | 17 ++++++++ .github/scripts/gbenchmark/windows.bat | 17 ++++++++ .github/scripts/gtest/linux.sh | 17 ++++++++ .github/scripts/gtest/macos.sh | 17 ++++++++ .github/scripts/gtest/windows.bat | 17 ++++++++ .github/{linux_build.sh => scripts/linux.sh} | 7 +--- .github/{macos_build.sh => scripts/macos.sh} | 7 +--- .../windows.bat} | 4 +- .github/workflows/linux.yml | 31 +++++--------- .github/workflows/macos.yml | 31 +++++--------- .github/workflows/windows.yml | 40 ++++++------------- 13 files changed, 142 insertions(+), 84 deletions(-) create mode 100644 .github/scripts/README.md create mode 100644 .github/scripts/gbenchmark/linux.sh create mode 100644 .github/scripts/gbenchmark/macos.sh create mode 100644 .github/scripts/gbenchmark/windows.bat create mode 100644 .github/scripts/gtest/linux.sh create mode 100644 .github/scripts/gtest/macos.sh create mode 100644 .github/scripts/gtest/windows.bat rename .github/{linux_build.sh => scripts/linux.sh} (79%) rename .github/{macos_build.sh => scripts/macos.sh} (79%) rename .github/{windows_build.bat => scripts/windows.bat} (100%) diff --git a/.github/scripts/README.md b/.github/scripts/README.md new file mode 100644 index 0000000..cda87c2 --- /dev/null +++ b/.github/scripts/README.md @@ -0,0 +1,4 @@ +# GitHub Action Scripts + +These script files are only used for GitHub Action. +These script files should only be executed in their root directory respectively. diff --git a/.github/scripts/gbenchmark/linux.sh b/.github/scripts/gbenchmark/linux.sh new file mode 100644 index 0000000..d80e030 --- /dev/null +++ b/.github/scripts/gbenchmark/linux.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -euo pipefail + +# Create build and install directory +mkdir build install + +# Build project +cd build +cmake -DCMAKE_CXX_STANDARD=23 -DBENCHMARK_ENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release .. +cmake --build . +cmake --install . --prefix=../install +cd .. + +# Record install directory +cd install +export benchmark_ROOT=$(pwd) +cd .. diff --git a/.github/scripts/gbenchmark/macos.sh b/.github/scripts/gbenchmark/macos.sh new file mode 100644 index 0000000..d80e030 --- /dev/null +++ b/.github/scripts/gbenchmark/macos.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -euo pipefail + +# Create build and install directory +mkdir build install + +# Build project +cd build +cmake -DCMAKE_CXX_STANDARD=23 -DBENCHMARK_ENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release .. +cmake --build . +cmake --install . --prefix=../install +cd .. + +# Record install directory +cd install +export benchmark_ROOT=$(pwd) +cd .. diff --git a/.github/scripts/gbenchmark/windows.bat b/.github/scripts/gbenchmark/windows.bat new file mode 100644 index 0000000..1c7658b --- /dev/null +++ b/.github/scripts/gbenchmark/windows.bat @@ -0,0 +1,17 @@ +@ECHO OFF + +:: Create build and install directory +MKDIR build +MKDIR install + +:: Build project +CD build +cmake -A x64 -DCMAKE_CXX_STANDARD=23 -DBENCHMARK_ENABLE_TESTING=OFF .. +cmake --build . --config Release +cmake --install . --prefix=../install --config Release +CD .. + +:: Record install directory +CD install +SET benchmark_ROOT=%CD% +CD .. diff --git a/.github/scripts/gtest/linux.sh b/.github/scripts/gtest/linux.sh new file mode 100644 index 0000000..494514c --- /dev/null +++ b/.github/scripts/gtest/linux.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -euo pipefail + +# Create build and install directory +mkdir build install + +# Build project +cd build +cmake -DCMAKE_CXX_STANDARD=23 -Dgtest_force_shared_crt=ON -DCMAKE_BUILD_TYPE=Release .. +cmake --build . +cmake --install . --prefix=../install +cd .. + +# Record install directory +cd install +export GTest_ROOT=$(pwd) +cd .. diff --git a/.github/scripts/gtest/macos.sh b/.github/scripts/gtest/macos.sh new file mode 100644 index 0000000..494514c --- /dev/null +++ b/.github/scripts/gtest/macos.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -euo pipefail + +# Create build and install directory +mkdir build install + +# Build project +cd build +cmake -DCMAKE_CXX_STANDARD=23 -Dgtest_force_shared_crt=ON -DCMAKE_BUILD_TYPE=Release .. +cmake --build . +cmake --install . --prefix=../install +cd .. + +# Record install directory +cd install +export GTest_ROOT=$(pwd) +cd .. diff --git a/.github/scripts/gtest/windows.bat b/.github/scripts/gtest/windows.bat new file mode 100644 index 0000000..38623b2 --- /dev/null +++ b/.github/scripts/gtest/windows.bat @@ -0,0 +1,17 @@ +@ECHO OFF + +:: Create build and install directory +MKDIR build +MKDIR install + +:: Build project +CD build +cmake -A x64 -DCMAKE_CXX_STANDARD=23 -Dgtest_force_shared_crt=ON .. +cmake --build . --config Release +cmake --install . --prefix=../install --config Release +CD .. + +:: Record install directory +CD install +SET GTest_ROOT=%CD% +CD .. diff --git a/.github/linux_build.sh b/.github/scripts/linux.sh similarity index 79% rename from .github/linux_build.sh rename to .github/scripts/linux.sh index 09562bd..b79a08f 100644 --- a/.github/linux_build.sh +++ b/.github/scripts/linux.sh @@ -1,22 +1,19 @@ #!/bin/bash set -euo pipefail -GTest_ROOT="${GTest_ROOT:?GTest_ROOT must be set}" -benchmark_ROOT="${benchmark_ROOT:?benchmark_ROOT must be set}" - # Create build directory and enter it mkdir bin cd bin # Create internal build and install directory, then enter it mkdir build mkdir install -cd build # Build in Release mode +cd build cmake -DCMAKE_BUILD_TYPE=Release -DYYCC_BUILD_TEST=ON -DGTest_ROOT=$GTest_ROOT -DYYCC_BUILD_BENCHMARK=ON -Dbenchmark_ROOT=$benchmark_ROOT ../.. cmake --build . cmake --install . --prefix=../install +cd .. # Back to root directory cd .. -cd .. diff --git a/.github/macos_build.sh b/.github/scripts/macos.sh similarity index 79% rename from .github/macos_build.sh rename to .github/scripts/macos.sh index 09562bd..b79a08f 100644 --- a/.github/macos_build.sh +++ b/.github/scripts/macos.sh @@ -1,22 +1,19 @@ #!/bin/bash set -euo pipefail -GTest_ROOT="${GTest_ROOT:?GTest_ROOT must be set}" -benchmark_ROOT="${benchmark_ROOT:?benchmark_ROOT must be set}" - # Create build directory and enter it mkdir bin cd bin # Create internal build and install directory, then enter it mkdir build mkdir install -cd build # Build in Release mode +cd build cmake -DCMAKE_BUILD_TYPE=Release -DYYCC_BUILD_TEST=ON -DGTest_ROOT=$GTest_ROOT -DYYCC_BUILD_BENCHMARK=ON -Dbenchmark_ROOT=$benchmark_ROOT ../.. cmake --build . cmake --install . --prefix=../install +cd .. # Back to root directory cd .. -cd .. diff --git a/.github/windows_build.bat b/.github/scripts/windows.bat similarity index 100% rename from .github/windows_build.bat rename to .github/scripts/windows.bat index e89058d..a466a8c 100644 --- a/.github/windows_build.bat +++ b/.github/scripts/windows.bat @@ -6,13 +6,13 @@ CD bin :: Create internal build and install directory, then enter it MKDIR build MKDIR install -CD build :: Build with x64 architecture in Release mode +CD build cmake -A x64 -DYYCC_BUILD_TEST=ON -DGTest_ROOT=%GTest_ROOT% -DYYCC_BUILD_BENCHMARK=ON -Dbenchmark_ROOT=%benchmark_ROOT% ../.. cmake --build . --config Release cmake --install . --prefix=../install --config Release +CD .. :: Back to root directory CD .. -CD .. diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 2f564c6..e024dcf 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -23,17 +23,11 @@ jobs: - name: Build Google Test shell: bash run: | - # Build Google Test cd extern/googletest - mkdir build install - cd build - cmake -DCMAKE_CXX_STANDARD=23 -Dgtest_force_shared_crt=ON -DCMAKE_BUILD_TYPE=Release .. - cmake --build . - cmake --install . --prefix=../install - cd .. - cd install - echo "GTest_ROOT=$(pwd)" >> "$GITHUB_ENV" - cd .. + # Build Google Test + source ../../.github/scripts/gtest/linux.sh + # Record environment variable + echo "GTest_ROOT=$GTest_ROOT" >> "$GITHUB_ENV" cd ../.. - name: Fetch Google Benchmark uses: actions/checkout@v4 @@ -44,25 +38,18 @@ jobs: - name: Build Google Benchmark shell: bash run: | - # Build Google Benchmark cd extern/benchmark # Create symlink to googletest as required by benchmark ln -s ../googletest googletest - mkdir build install - cd build - cmake -DCMAKE_CXX_STANDARD=23 -DBENCHMARK_ENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release .. - cmake --build . - cmake --install . --prefix=../install - cd .. - cd install - echo "benchmark_ROOT=$(pwd)" >> "$GITHUB_ENV" - cd .. + # Build Google Benchmark + source ../../.github/scripts/gbenchmark/linux.sh + # Record environment variable + echo "benchmark_ROOT=$benchmark_ROOT" >> "$GITHUB_ENV" cd ../.. - name: Build YYCC shell: bash run: | - chmod +x ./.github/linux_build.sh - ./.github/linux_build.sh + source ./.github/scripts/linux.sh - name: Run YYCC Test shell: bash run: | diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index f6d3dfd..609a812 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -18,17 +18,11 @@ jobs: - name: Build Google Test shell: bash run: | - # Build Google Test cd extern/googletest - mkdir build install - cd build - cmake -DCMAKE_CXX_STANDARD=23 -Dgtest_force_shared_crt=ON -DCMAKE_BUILD_TYPE=Release .. - cmake --build . - cmake --install . --prefix=../install - cd .. - cd install - echo "GTest_ROOT=$(pwd)" >> "$GITHUB_ENV" - cd .. + # Build Google Test + source ../../.github/scripts/gtest/macos.sh + # Record environment variable + echo "GTest_ROOT=$GTest_ROOT" >> "$GITHUB_ENV" cd ../.. - name: Fetch Google Benchmark uses: actions/checkout@v4 @@ -39,25 +33,18 @@ jobs: - name: Build Google Benchmark shell: bash run: | - # Build Google Benchmark cd extern/benchmark # Create symlink to googletest as required by benchmark ln -s ../googletest googletest - mkdir build install - cd build - cmake -DCMAKE_CXX_STANDARD=23 -DBENCHMARK_ENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release .. - cmake --build . - cmake --install . --prefix=../install - cd .. - cd install - echo "benchmark_ROOT=$(pwd)" >> "$GITHUB_ENV" - cd .. + # Build Google Benchmark + source ../../.github/scripts/gbenchmark/macos.sh + # Record environment variable + echo "benchmark_ROOT=$benchmark_ROOT" >> "$GITHUB_ENV" cd ../.. - name: Build YYCC shell: bash run: | - chmod +x ./.github/macos_build.sh - ./.github/macos_build.sh + source ./.github/scripts/macos.sh - name: Run YYCC Test shell: bash run: | diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index a8aae90..8eb04d3 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -25,21 +25,13 @@ jobs: - name: Build Google Test shell: cmd run: | + CD extern\googletest :: Build Google Test - cd extern/googletest - mkdir build - mkdir install - cd build - cmake -A x64 -DCMAKE_CXX_STANDARD=23 -Dgtest_force_shared_crt=ON .. - cmake --build . --config Release - cmake --install . --prefix=../install --config Release - cd .. - cd install + CALL ..\..\.github\scripts\gtest\windows.bat :: Idk why I can't use $GITHUB_ENV, so I use this stupid way to do this. :: This is first entry so we override it. - echo set GTest_ROOT=%CD% > ../../envs.bat - cd .. - cd ../.. + ECHO SET GTest_ROOT=%GTest_ROOT% > ..\envs.bat + CD ..\.. - name: Fetch Google Benchmark uses: actions/checkout@v4 with: @@ -49,22 +41,14 @@ jobs: - name: Build Google Benchmark shell: cmd run: | - :: Build Google Benchmark - cd extern/benchmark + CD extern\benchmark :: Create symlink to googletest as required by benchmark - mklink /D googletest ../googletest - mkdir build - mkdir install - cd build - cmake -A x64 -DCMAKE_CXX_STANDARD=23 -DBENCHMARK_ENABLE_TESTING=OFF .. - cmake --build . --config Release - cmake --install . --prefix=../install --config Release - cd .. - cd install + mklink /D googletest ..\googletest + :: Build Google Benchmark + CALL ..\..\.github\scripts\gbenchmark\windows.bat :: This is second entry so we append it. - echo set benchmark_ROOT=%CD% >> ../../envs.bat - cd .. - cd ../.. + ECHO SET benchmark_ROOT=%benchmark_ROOT% >> ..\envs.bat + CD ..\.. - name: Build YYCC shell: cmd run: | @@ -74,9 +58,9 @@ jobs: if not exist %VCVARS% set VCVARS="C:\Program Files\Microsoft Visual Studio\%VS%\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" call %VCVARS% ${{ matrix.msvc_arch }} :: Extract saved environment variables - call .\extern\envs.bat + CALL .\extern\envs.bat :: Build Project - .\.github\windows_build.bat + CALL .\.github\scripts\windows.bat - name: Run YYCC Test shell: cmd run: |