This is an automated email from the ASF dual-hosted git repository. colinlee pushed a commit to branch rc/2.2.0_bak in repository https://gitbox.apache.org/repos/asf/tsfile.git
commit 5d50d32f9114450d042fdeb9c849f7e5e24e6550 Author: Colin Lee <[email protected]> AuthorDate: Wed Dec 3 16:55:47 2025 +0800 Colin toolchain (#653) * add test for confg modify. * fix compile with toolchain. --- .github/workflows/unit-test-cpp.yml | 4 +++- .github/workflows/unit-test-python.yml | 16 ++++++++++++++++ cpp/CMakeLists.txt | 8 ++++++++ cpp/README.md | 34 ++++++++++++++++------------------ cpp/pom.xml | 24 ------------------------ 5 files changed, 43 insertions(+), 43 deletions(-) diff --git a/.github/workflows/unit-test-cpp.yml b/.github/workflows/unit-test-cpp.yml index 08c13801..d4172f8b 100644 --- a/.github/workflows/unit-test-cpp.yml +++ b/.github/workflows/unit-test-cpp.yml @@ -104,12 +104,14 @@ jobs: core.setOutput('platform_suffix', ``) } - - name: Install clang-format + # Install dependencies + - name: Install dependencies shell: bash run: | if [[ "$RUNNER_OS" == "Linux" ]]; then sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-17 100 sudo update-alternatives --set clang-format /usr/bin/clang-format-17 + sudo apt-get install -y uuid-dev elif [[ "$RUNNER_OS" == "Windows" ]]; then choco install llvm --version 17.0.6 --force else diff --git a/.github/workflows/unit-test-python.yml b/.github/workflows/unit-test-python.yml index c9993597..72be3236 100644 --- a/.github/workflows/unit-test-python.yml +++ b/.github/workflows/unit-test-python.yml @@ -75,6 +75,22 @@ jobs: core.setOutput('platform_suffix', ``) } + # Install dependencies + - name: Install dependencies + shell: bash + run: | + if [[ "$RUNNER_OS" == "Linux" ]]; then + sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-17 100 + sudo update-alternatives --set clang-format /usr/bin/clang-format-17 + sudo apt-get install -y uuid-dev + elif [[ "$RUNNER_OS" == "Windows" ]]; then + choco install llvm --version 17.0.6 --force + else + brew install llvm@17 + ln -sf $(brew --prefix llvm@17)/bin/clang-format /opt/homebrew/bin/clang-format + fi + + # Run the actual maven build including all tests. - name: Build and test with Maven shell: bash diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 60f5dc86..3128c996 100755 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -19,9 +19,17 @@ under the License. cmake_minimum_required(VERSION 3.11) project(TsFile_CPP) +if (DEFINED ToolChain) + include(${CMAKE_SOURCE_DIR}/cmake/ToolChain.cmake) + message(STATUS "Using ToolChain: ${CMAKE_TOOLCHAIN_FILE}") +else() + message(STATUS "Not using ToolChain") +endif () + cmake_policy(SET CMP0079 NEW) set(TsFile_CPP_VERSION 2.2.0.dev) set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -Wall") + if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused -Wuninitialized -D__STDC_FORMAT_MACROS") endif () diff --git a/cpp/README.md b/cpp/README.md index 9e13cdd1..dced6c8c 100644 --- a/cpp/README.md +++ b/cpp/README.md @@ -42,23 +42,6 @@ The source code can be found in the `./src` directory. C/C++ examples are locate We use `clang-format` to ensure that our C++ code adheres to a consistent set of rules defined in `./clang-format`. This is similar to the Google style. -**Feature List**: - -- [ ] Add unit tests for the reader, writer, compression, etc. -- [ ] Add unit tests for the C wrapper. -- [ ] Support multiple data flushes. -- [ ] Support aligned timeseries. -- [ ] Support table description in tsfile. -- [ ] Retrieve all table schemas/names. -- [ ] Implement automatic flush. -- [ ] Support out-of-order data writing. -- [ ] Support TsFile V4. Note: TsFile CPP does not implement support for the table model, therefore there are differences in file output compared to the Java version. - -**Bug List**: - -- [ ] Flushing without writing after registering a timeseries will cause a core dump. -- [ ] Misalignment in memory may lead to a bus error. - We welcome any bug reports. You can open an issue with a title starting with [CPP] to describe the bug, like: https://github.com/apache/tsfile/issues/94 ## Build @@ -67,7 +50,7 @@ We welcome any bug reports. You can open an issue with a title starting with [CP ```bash sudo apt-get update -sudo apt-get install -y cmake make g++ clang-format +sudo apt-get install -y cmake make g++ clang-format libuuid-dev ``` To build tsfile, you can run: `bash build.sh`. If you have Maven tools, you can run: `mvn package -P with-cpp clean verify`. Then, you can find the shared object at `./build`. @@ -81,6 +64,21 @@ If you compile using MinGW on windows and encounter an error, you can try replac * GCC 12.2.0 + LLVM/Clang/LLD/LLDB 16.0.0 + MinGW-w64 10.0.0 (MSVCRT) - release 5 * GCC 11.2.0 + MinGW-w64 10.0.0 (MSVCRT) - release 1 +### configure the cross-compilation toolchain + +Modify the Toolchain File `cmake/ToolChain.cmake`, define the following variables: + +- `CMAKE_C_COMPILER`: Specify the path to the C compiler. +- `CMAKE_CXX_COMPILER`: Specify the path to the C++ compiler. +- `CMAKE_FIND_ROOT_PATH`: Set the root path for the cross-compilation environment (e.g., the directory of the cross-compilation toolchain). + +In the `cpp/` directory, run the following commands to create the build directory and start the compilation: +``` +mkdir build && cd build +cmake .. -DToolChian=ON +make +``` + ## Use TsFile You can find examples on how to read and write data in `demo_read.cpp` and `demo_write.cpp` located under `./examples/cpp_examples`. There are also examples under `./examples/c_examples`on how to use a C-style API to read and write data in a C environment. You can run `bash build.sh` under `./examples` to generate an executable output under `./examples/build`. \ No newline at end of file diff --git a/cpp/pom.xml b/cpp/pom.xml index 8efae178..0619193f 100644 --- a/cpp/pom.xml +++ b/cpp/pom.xml @@ -171,30 +171,6 @@ <name>Linux</name> </os> </activation> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <executions> - <execution> - <id>install-uuid-dev</id> - <phase>validate</phase> - <goals> - <goal>exec</goal> - </goals> - </execution> - </executions> - <configuration> - <executable>bash</executable> - <arguments> - <argument>-c</argument> - <argument>sudo apt-get update && sudo apt-get install -y uuid-dev</argument> - </arguments> - </configuration> - </plugin> - </plugins> - </build> </profile> <!-- When running on jenkins, download the sonar build-wrapper, so we can do a code analysis --> <profile>
