File tree Expand file tree Collapse file tree 18 files changed +199
-1528
lines changed
Expand file tree Collapse file tree 18 files changed +199
-1528
lines changed Original file line number Diff line number Diff line change 1+ name : c-test
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ - master
8+ tags :
9+ - ' *'
10+ pull_request :
11+ branches :
12+ - main
13+ paths :
14+ - " c/**"
15+ - " .github/workflows/c-test.yaml"
16+ workflow_dispatch :
17+
18+ concurrency :
19+ group : ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
20+ cancel-in-progress : true
21+
22+ permissions :
23+ contents : read
24+
25+ jobs :
26+ build-and-test :
27+ defaults :
28+ run :
29+ working-directory : " c"
30+ runs-on : ubuntu-latest
31+ steps :
32+ - uses : actions/checkout@v4
33+ - name : Install Rust
34+ uses : actions-rs/toolchain@v1
35+ with :
36+ toolchain : 1.79
37+ override : true
38+ components : clippy, rustfmt
39+ - name : Build
40+ run : |
41+ make
42+ make examples
43+ - name : Run Examples
44+ shell : bash
45+ run : |
46+ cd examples
47+ for file in ./*
48+ do
49+ if [[ -f "$file" && -x "$file" ]]; then
50+ echo "Executing: $file"
51+ if ! "$file"; then
52+ echo "Error occurred while executing $file. Exiting script."
53+ exit 1
54+ fi
55+ fi
56+ done
Original file line number Diff line number Diff line change 1+ name : cpp-test
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ - master
8+ tags :
9+ - ' *'
10+ pull_request :
11+ branches :
12+ - main
13+ paths :
14+ - " cpp/**"
15+ - " .github/workflows/cpp-test.yaml"
16+ workflow_dispatch :
17+
18+ concurrency :
19+ group : ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
20+ cancel-in-progress : true
21+
22+ permissions :
23+ contents : read
24+
25+ jobs :
26+ build-and-test :
27+ defaults :
28+ run :
29+ working-directory : " cpp"
30+ runs-on : ubuntu-latest
31+ steps :
32+ - uses : actions/checkout@v4
33+ - name : Install dependencies
34+ run : |
35+ sudo apt-get update
36+ sudo apt-get install libgtest-dev ninja-build
37+ - name : Install Rust
38+ uses : actions-rs/toolchain@v1
39+ with :
40+ toolchain : 1.79
41+ override : true
42+ components : clippy, rustfmt
43+ - name : Build
44+ run : |
45+ mkdir build
46+ cd build
47+ cmake ..
48+ make -j8
49+ - name : Run Examples
50+ shell : bash
51+ run : |
52+ cd build
53+ for file in ./*
54+ do
55+ if [[ -f "$file" && -x "$file" ]]; then
56+ echo "Executing: $file"
57+ if ! "$file"; then
58+ echo "Error occurred while executing $file. Exiting script."
59+ exit 1
60+ fi
61+ fi
62+ done
Original file line number Diff line number Diff line change 1212 - main
1313 paths :
1414 - " dotnet/**"
15+ - " .github/workflows/dotnet-test.yaml"
1516 workflow_dispatch :
1617
1718jobs :
6869 - name : Install Rust
6970 uses : actions-rs/toolchain@v1
7071 with :
71- toolchain : 1.77
72+ toolchain : 1.79
7273 override : true
7374 components : clippy, rustfmt
7475 - name : Setup linux-aarch_64 rust target
@@ -123,7 +124,7 @@ jobs:
123124 - name : Install Rust
124125 uses : actions-rs/toolchain@v1
125126 with :
126- toolchain : 1.77
127+ toolchain : 1.79
127128 override : true
128129 components : clippy, rustfmt
129130
Original file line number Diff line number Diff line change 1414 - " go/**"
1515 - " go.mod"
1616 - " go.sum"
17+ - " .github/workflows/go-test.yaml"
1718 workflow_dispatch :
1819
1920permissions :
Original file line number Diff line number Diff line change 1212 - main
1313 paths :
1414 - " java/**"
15+ - " .github/workflows/java-test.yaml"
1516 workflow_dispatch :
1617
1718jobs :
5960 - name : Install rust nightly toolchain
6061 uses : actions-rs/toolchain@v1
6162 with :
62- toolchain : 1.77
63+ toolchain : 1.79
6364 override : true
6465 components : clippy, rustfmt
6566
Original file line number Diff line number Diff line change 1515 - main
1616 paths :
1717 - " nodejs/**"
18+ - " .github/workflows/nodejs-test.yaml"
1819 workflow_dispatch :
1920
2021jobs :
Original file line number Diff line number Diff line change 1717 - main
1818 paths :
1919 - " python/**"
20+ - " .github/workflows/python-test.yaml"
2021 workflow_dispatch :
2122
2223permissions :
Original file line number Diff line number Diff line change 1313 paths :
1414 - " Cargo.toml"
1515 - " src/**"
16+ - " .github/workflows/rust-test.yaml"
1617 workflow_dispatch :
1718
1819permissions :
3031 - name : Install rust nightly toolchain
3132 uses : actions-rs/toolchain@v1
3233 with :
33- toolchain : 1.77
34+ toolchain : 1.79
3435 override : true
3536 components : clippy, rustfmt
3637 - name : Rust code test
Original file line number Diff line number Diff line change 1111 - main
1212 paths :
1313 - " wasm/**"
14+ - " .github/workflows/wasm-test.yaml"
1415 workflow_dispatch :
1516
1617jobs :
Original file line number Diff line number Diff line change @@ -161,6 +161,61 @@ function main() {
161161main ();
162162```
163163
164+ ### C++
165+
166+ For CMake, you can use FetchContent to add KCL C++ Lib to your project.
167+
168+ ``` shell
169+ FetchContent_Declare(
170+ kcl-lib
171+ GIT_REPOSITORY https://github.com/kcl-lang/lib.git
172+ GIT_TAG v0.9.3
173+ SOURCE_SUBDIR cpp
174+ )
175+ FetchContent_MakeAvailable(kcl-lib)
176+ ```
177+
178+ Or you can download the source code and add it to your project.
179+
180+ ``` shell
181+ mkdir third_party
182+ cd third_party
183+ git clone https://github.com/kcl-lang/lib.git
184+ ```
185+
186+ ``` shell
187+ add_subdirectory(third_party/lib/cpp)
188+ ```
189+
190+ ``` shell
191+ target_link_libraries(your_target kcl-lib-cpp)
192+ ```
193+
194+ Write the code
195+
196+ ``` cpp
197+ #include " kcl_lib.hpp"
198+ #include < iostream>
199+
200+ int main ()
201+ {
202+ auto args = kcl_lib::ExecProgramArgs();
203+ auto files = rust::Vec<rust::String>();
204+ files.push_back(rust::String("../test_data/schema.k"));
205+ args.k_filename_list = files;
206+ auto result = kcl_lib::exec_program(args);
207+ std::cout << result.yaml_result.c_str() << std::endl;
208+ }
209+ ```
210+
211+ ### C
212+
213+ See [ here] ( ./c/ )
214+
215+ ### WASM
216+
217+ See [ here] ( ./wasm/ )
218+
164219## Documents
165220
166221See [ here] ( https://www.kcl-lang.io/docs/reference/xlang-api/overview )
You can’t perform that action at this time.
0 commit comments