Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.21.x"
go-version: "1.24.x"

- name: Download dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-csharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.21.x"
go-version: "1.24.x"

- name: Download dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.21.x"
go-version: "1.24.x"

- name: Download dependencies
run: |
Expand Down
21 changes: 16 additions & 5 deletions .github/workflows/testing-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ jobs:
test:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
go-version: [ 1.24.x ]
protobuf-version: [ "32.0", "3.19.3" ]
include:
- os: ubuntu-latest
go-version: 1.21.x
init_script: bash init.sh
run_loader: ./bin/loader
- os: windows-latest
go-version: 1.21.x
init_script: cmd /c init.bat
run_loader: .\bin\loader.exe

name: test (${{ matrix.os }})
name: test (${{ matrix.os }}, protobuf ${{ matrix.protobuf-version }})
runs-on: ${{ matrix.os }}
timeout-minutes: 10
timeout-minutes: 20

steps:
- name: Checkout Code
Expand Down Expand Up @@ -56,11 +57,21 @@ jobs:

- name: Init submodules and build protobuf
run: ${{ matrix.init_script }}
env:
PROTOBUF_REF: v${{ matrix.protobuf-version }}

- name: Install Protoc
if: "!startsWith(matrix.protobuf-version, '3.')"
uses: arduino/setup-protoc@v3
with:
version: ${{ matrix.protobuf-version }}
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Protoc (legacy)
if: startsWith(matrix.protobuf-version, '3.')
uses: arduino/setup-protoc@v1
with:
version: "3.19.3"
version: ${{ matrix.protobuf-version }}
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Buf
Expand Down
20 changes: 13 additions & 7 deletions .github/workflows/testing-csharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ jobs:
test:
strategy:
matrix:
include:
- os: ubuntu-latest
go-version: 1.21.x
- os: windows-latest
go-version: 1.21.x
os: [ ubuntu-latest, windows-latest ]
go-version: [ 1.24.x ]
protobuf-version: [ "32.0", "3.19.3" ]

name: test (${{ matrix.os }})
name: test (${{ matrix.os }}, protobuf ${{ matrix.protobuf-version }})
runs-on: ${{ matrix.os }}
timeout-minutes: 10

Expand All @@ -44,9 +42,17 @@ jobs:
dotnet-version: "8.0.x"

- name: Install Protoc
if: "!startsWith(matrix.protobuf-version, '3.')"
uses: arduino/setup-protoc@v3
with:
version: ${{ matrix.protobuf-version }}
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Protoc (legacy)
if: startsWith(matrix.protobuf-version, '3.')
uses: arduino/setup-protoc@v1
with:
version: "3.19.3"
version: ${{ matrix.protobuf-version }}
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Buf
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/testing-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ jobs:
test:
strategy:
matrix:
include:
- os: ubuntu-latest
go-version: 1.21.x
- os: windows-latest
go-version: 1.21.x
os: [ ubuntu-latest, windows-latest ]
go-version: [ 1.24.x ]
protobuf-version: [ "32.0", "3.19.3" ]

name: test (${{ matrix.os }})
name: test (${{ matrix.os }}, protobuf ${{ matrix.protobuf-version }})
runs-on: ${{ matrix.os }}
timeout-minutes: 10

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The official config loader for [Tableau](https://github.com/tableauio/tableau).
### Dev at Linux

- Change dir: `cd test/cpp-tableau-loader`
- Generate protoconf: `PATH=../../third_party/_submodules/protobuf/cmake/build:$PATH buf generate ..`
- Generate protoconf: `PATH=../../third_party/_submodules/protobuf/.build/_install/bin:$PATH buf generate ..`
- CMake:
- C++17: `cmake -S . -B build`
- C++20: `cmake -S . -B build -DCMAKE_CXX_STANDARD=20`
Expand All @@ -53,7 +53,7 @@ The official config loader for [Tableau](https://github.com/tableauio/tableau).

- Initialize MSVC environment (from loader root): `.\prepare.bat`
- Change dir: `cd test\cpp-tableau-loader`, or change directory with Drive, e.g.: `cd /D D:\GitHub\loader\test\cpp-tableau-loader`
- Generate protoconf: `cmd /C "set PATH=..\..\third_party\_submodules\protobuf\cmake\build;%PATH% && buf generate .."`
- Generate protoconf: `cmd /C "set PATH=..\..\third_party\_submodules\protobuf\.build\_install\bin;%PATH% && buf generate .."`
- CMake:
- C++17: `cmake -S . -B build -G "Ninja"`
- C++20: `cmake -S . -B build -G "Ninja" -DCMAKE_CXX_STANDARD=20`
Expand Down Expand Up @@ -87,7 +87,7 @@ The official config loader for [Tableau](https://github.com/tableauio/tableau).

- Install: **dotnet-sdk-8.0**
- Change dir: `cd test/csharp-tableau-loader`
- Generate protoconf: `PATH=../third_party/_submodules/protobuf/cmake/build:$PATH buf generate .. `
- Generate protoconf: `PATH=../third_party/_submodules/protobuf/.build/_install/bin:$PATH buf generate ..`
- Test: `dotnet run`

## TypeScript
Expand Down
5 changes: 4 additions & 1 deletion cmd/protoc-gen-cpp-tableau-loader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/tableauio/loader/internal/options"
"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/types/descriptorpb"
"google.golang.org/protobuf/types/pluginpb"
)

Expand Down Expand Up @@ -50,7 +51,9 @@ func main() {
protogen.Options{
ParamFunc: flags.Set,
}.Run(func(gen *protogen.Plugin) error {
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL | pluginpb.CodeGeneratorResponse_FEATURE_SUPPORTS_EDITIONS)
gen.SupportedEditionsMinimum = descriptorpb.Edition_EDITION_PROTO2
gen.SupportedEditionsMaximum = descriptorpb.Edition_EDITION_2024
for _, f := range gen.Files {
if !options.NeedGenFile(f) {
continue
Expand Down
5 changes: 4 additions & 1 deletion cmd/protoc-gen-csharp-tableau-loader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/tableauio/loader/internal/options"
"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/types/descriptorpb"
"google.golang.org/protobuf/types/pluginpb"
)

Expand All @@ -24,7 +25,9 @@ func main() {
protogen.Options{
ParamFunc: flags.Set,
}.Run(func(gen *protogen.Plugin) error {
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL | pluginpb.CodeGeneratorResponse_FEATURE_SUPPORTS_EDITIONS)
gen.SupportedEditionsMinimum = descriptorpb.Edition_EDITION_PROTO2
gen.SupportedEditionsMaximum = descriptorpb.Edition_EDITION_2024
for _, f := range gen.Files {
if !options.NeedGenFile(f) {
continue
Expand Down
5 changes: 4 additions & 1 deletion cmd/protoc-gen-go-tableau-loader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/tableauio/loader/internal/options"
"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/types/descriptorpb"
"google.golang.org/protobuf/types/pluginpb"
)

Expand All @@ -27,7 +28,9 @@ func main() {
protogen.Options{
ParamFunc: flags.Set,
}.Run(func(gen *protogen.Plugin) error {
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL | pluginpb.CodeGeneratorResponse_FEATURE_SUPPORTS_EDITIONS)
gen.SupportedEditionsMinimum = descriptorpb.Edition_EDITION_PROTO2
gen.SupportedEditionsMaximum = descriptorpb.Edition_EDITION_2024
for _, f := range gen.Files {
if !options.NeedGenFile(f) {
continue
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/tableauio/loader

go 1.21
go 1.24.0

require (
github.com/aymanbagabas/go-udiff v0.2.0
github.com/iancoleman/strcase v0.3.0
github.com/stretchr/testify v1.10.0
github.com/tableauio/tableau v0.15.1
google.golang.org/protobuf v1.34.2
google.golang.org/protobuf v1.36.11
)

require (
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
Expand Down Expand Up @@ -66,8 +66,8 @@ golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
Expand Down
70 changes: 54 additions & 16 deletions init.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,61 @@ cd /d "%repoRoot%"
git submodule update --init --recursive

REM Build and install the C++ Protocol Buffer runtime and the Protocol Buffer compiler (protoc)
REM Refer: https://github.com/protocolbuffers/protobuf/blob/3.19.x/cmake/README.md#cmake-configuration
cd third_party\_submodules\protobuf\cmake
REM use Debug version
REM - protobuf_MSVC_STATIC_RUNTIME defaults to ON, which uses static CRT (/MTd for Debug).
REM Our project's CMakeLists.txt also sets static CRT to match.
REM - protobuf_WITH_ZLIB=OFF: disable ZLIB dependency to avoid ZLIB::ZLIB link requirement
REM in protobuf's exported CMake targets, which simplifies cross-platform builds.
REM - protobuf_BUILD_SHARED_LIBS=OFF: build static libraries explicitly.
cmake -S . -B build -G Ninja ^
-DCMAKE_BUILD_TYPE=Debug ^
-DCMAKE_CXX_STANDARD=17 ^
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 ^
-Dprotobuf_BUILD_TESTS=OFF ^
-Dprotobuf_WITH_ZLIB=OFF ^
-Dprotobuf_BUILD_SHARED_LIBS=OFF
cd third_party\_submodules\protobuf

REM If PROTOBUF_REF is set, switch submodule to the specified ref
if not "%PROTOBUF_REF%"=="" (
echo Switching protobuf submodule to %PROTOBUF_REF%...
git fetch --tags
git checkout %PROTOBUF_REF%
git submodule update --init --recursive
)

REM Detect protobuf major version to determine cmake source directory and arguments.
for /f "tokens=*" %%v in ('git describe --tags --abbrev^=0 2^>nul') do set PROTOBUF_VERSION=%%v
if not defined PROTOBUF_VERSION set PROTOBUF_VERSION=unknown
echo Detected protobuf version: %PROTOBUF_VERSION%

REM Extract major version number from tag (e.g., v3.19.3 -> 3, v32.0 -> 32)
set "VER_STR=%PROTOBUF_VERSION:~1%"
for /f "tokens=1 delims=." %%a in ("%VER_STR%") do set MAJOR_VERSION=%%a

if %MAJOR_VERSION% LEQ 3 (
REM Legacy protobuf (v3.x): CMakeLists.txt is in cmake/ subdirectory
echo Using legacy cmake\ subdirectory for protobuf %PROTOBUF_VERSION%
cmake -S cmake -B .build -G Ninja ^
-DCMAKE_BUILD_TYPE=Debug ^
-DCMAKE_CXX_STANDARD=17 ^
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 ^
-Dprotobuf_BUILD_TESTS=OFF ^
-Dprotobuf_WITH_ZLIB=OFF ^
-Dprotobuf_BUILD_SHARED_LIBS=OFF
) else (
REM Modern protobuf (v4+/v21+/v32+): CMakeLists.txt is in root directory
REM Refer: https://github.com/protocolbuffers/protobuf/blob/v32.0/cmake/README.md#cmake-configuration
echo Using root CMakeLists.txt for protobuf %PROTOBUF_VERSION%
REM - protobuf_MSVC_STATIC_RUNTIME defaults to ON, which uses static CRT (/MTd for Debug).
REM Our project's CMakeLists.txt also sets static CRT to match.
REM - protobuf_WITH_ZLIB=OFF: disable ZLIB dependency to avoid ZLIB::ZLIB link requirement
REM in protobuf's exported CMake targets, which simplifies cross-platform builds.
REM - protobuf_BUILD_SHARED_LIBS=OFF: build static libraries explicitly.
cmake -S . -B .build -G Ninja ^
-DCMAKE_BUILD_TYPE=Debug ^
-DCMAKE_CXX_STANDARD=17 ^
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 ^
-Dprotobuf_BUILD_TESTS=OFF ^
-Dprotobuf_WITH_ZLIB=OFF ^
-Dprotobuf_BUILD_SHARED_LIBS=OFF ^
-Dutf8_range_ENABLE_INSTALL=ON
)

REM Compile the code
cmake --build build --parallel
cmake --build .build --parallel

REM Install into .build/_install so that protobuf-config.cmake (along with
REM absl and utf8_range configs) is generated for find_package(Protobuf CONFIG)
REM used by downstream CMakeLists.txt.
REM NOTE: .build/ is already in protobuf's .gitignore, so _install stays clean.
cmake --install .build --prefix .build\_install

endlocal
Loading
Loading