1
0

5 Commits

Author SHA1 Message Date
422aa152ff fix: fix libcxx patch error 2026-03-04 13:49:58 +08:00
92ce0e29cb fix: find iconv if we include it 2026-02-03 19:26:21 +08:00
a0f032c28b chore: update yycc gh action build script 2026-02-03 15:23:21 +08:00
b51ded2101 chore: add lost cd in CI script 2026-02-02 16:22:32 +08:00
09f07d99f7 fix: fix wrong value hint in clap test.
- remove the bracker (<bla>) in clap test because clap will automatically add it.
2026-02-02 16:21:39 +08:00
16 changed files with 153 additions and 84 deletions

4
.github/scripts/README.md vendored Normal file
View File

@@ -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.

17
.github/scripts/gbenchmark/linux.sh vendored Normal file
View File

@@ -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 ..

17
.github/scripts/gbenchmark/macos.sh vendored Normal file
View File

@@ -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 ..

17
.github/scripts/gbenchmark/windows.bat vendored Normal file
View File

@@ -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 ..

17
.github/scripts/gtest/linux.sh vendored Normal file
View File

@@ -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 ..

17
.github/scripts/gtest/macos.sh vendored Normal file
View File

@@ -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 ..

17
.github/scripts/gtest/windows.bat vendored Normal file
View File

@@ -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 ..

View File

@@ -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 ..

View File

@@ -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 ..

View File

@@ -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 ..

View File

@@ -23,16 +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"
# 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
@@ -43,24 +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"
# 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: |

View File

@@ -18,16 +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"
# 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
@@ -38,24 +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"
# 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: |

View File

@@ -25,20 +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 ../..
ECHO SET GTest_ROOT=%GTest_ROOT% > ..\envs.bat
CD ..\..
- name: Fetch Google Benchmark
uses: actions/checkout@v4
with:
@@ -48,21 +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 ../..
ECHO SET benchmark_ROOT=%benchmark_ROOT% >> ..\envs.bat
CD ..\..
- name: Build YYCC
shell: cmd
run: |
@@ -72,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: |

View File

@@ -1,7 +1,12 @@
@PACKAGE_INIT@
# Find Iconv if we have found it.
if ("@Iconv_FOUND@")
find_package(Iconv REQUIRED)
endif ()
# Include targets file
include("${CMAKE_CURRENT_LIST_DIR}/YYCCommonplaceTargets.cmake")
check_required_components(YYCCommonplace)
check_required_components(YYCCommonplace)

View File

@@ -270,7 +270,7 @@ namespace std {
// Float to_chars
template<typename T>
requires std::floating_point<T>
to_chars_result to_chars(char* first, char* last, T value, chars_format fmt, int precision = 0) {
to_chars_result to_chars(char* first, char* last, T value, chars_format fmt, int precision = 6) {
if (first >= last) {
return {first, std::errc::value_too_large};
}

View File

@@ -72,10 +72,10 @@ namespace yycctest::carton::clap {
// Add options
auto options = CLAP::option::OptionCollection();
int_option = options.add_option(CLAP::option::Option(u8"i", u8"int", u8"<integer>", u8"integral argument"));
float_option = options.add_option(CLAP::option::Option(u8"f", std::nullopt, u8"<float>", u8""));
string_option = options.add_option(CLAP::option::Option(std::nullopt, u8"string", u8"<string>", u8""));
clamped_float_option = options.add_option(CLAP::option::Option(std::nullopt, u8"clamped-float", u8"<float>", u8""));
int_option = options.add_option(CLAP::option::Option(u8"i", u8"int", u8"integer", u8"integral argument"));
float_option = options.add_option(CLAP::option::Option(u8"f", std::nullopt, u8"float", u8""));
string_option = options.add_option(CLAP::option::Option(std::nullopt, u8"string", u8"string", u8""));
clamped_float_option = options.add_option(CLAP::option::Option(std::nullopt, u8"clamped-float", u8"float", u8""));
novalue_option = options.add_option(CLAP::option::Option(u8"b", std::nullopt, std::nullopt, u8""));
// Add variables