This is an automated email from the ASF dual-hosted git repository.
hxd pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 9d88a8e [C++ Client] remove compiling boost for compling client-cpp
module (#2509)
9d88a8e is described below
commit 9d88a8e25b0fa02922093ba08499b1b8efaad5dc
Author: wshao08 <[email protected]>
AuthorDate: Fri Jan 29 10:21:54 2021 +0800
[C++ Client] remove compiling boost for compling client-cpp module (#2509)
---
.github/workflows/client.yml | 100 ++++++++++++++
.github/workflows/main-ci.yml | 16 +--
client-cpp/README.md | 31 +++++
client-cpp/pom.xml | 41 ++++--
client-cpp/src/assembly/client-cpp.xml | 16 +--
client-cpp/src/main/CMakeLists.txt | 22 +++-
client-cpp/src/main/Session.h | 1 +
client-cpp/src/test/CMakeLists.txt | 40 ++++--
compile-tools/README.md | 85 +++++++-----
compile-tools/boost/pom.xml | 145 ---------------------
compile-tools/boost/src/assembly/bundle.xml | 35 -----
compile-tools/pom.xml | 7 +-
compile-tools/thrift/pom.xml | 51 ++------
.../client-cpp-example}/README.md | 28 +++-
{client-cpp => example}/client-cpp-example/pom.xml | 12 +-
.../client-cpp-example/src/CMakeLists.txt | 19 ++-
.../client-cpp-example/src/SessionExample.cpp | 0
pom.xml | 9 +-
18 files changed, 340 insertions(+), 318 deletions(-)
diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml
new file mode 100644
index 0000000..033eb5b
--- /dev/null
+++ b/.github/workflows/client.yml
@@ -0,0 +1,100 @@
+# This workflow will build a Java project with Maven
+# For more information see:
https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
+
+# CPP compiling is too slow, so let's do it in parallel with testing other
modules.
+# As there is no Java client, we just use one JDK.
+name: Clients_except_Java CI with Maven
+
+on:
+ push:
+ branches:
+ - master
+ - 'rel/*'
+ paths:
+ - 'client-*/**'
+ - 'compile-tools/**'
+ - 'thrift/**'
+ - 'service-rpc/**'
+ pull_request:
+ branches:
+ - master
+ - 'rel/*'
+ paths:
+ - 'client-*/**'
+ - 'compile-tools/**'
+ - 'thrift/**'
+ - 'service-rpc/**'
+
+jobs:
+ build:
+ strategy:
+ fail-fast: false
+ max-parallel: 20
+ matrix:
+ java: [11.0.x]
+ os: [ubuntu-latest, macos-latest]
+ runs-on: ${{ matrix.os}}
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up JDK ${{ matrix.java }}
+ uses: actions/setup-java@v1
+ with:
+ java-version: ${{ matrix.java }}
+ - name: Install CPP Dependencies (Ubuntu)
+ if: matrix.os == 'ubuntu-latest'
+ shell: bash
+ run: sudo apt-get install libboost-all-dev
+ - name: Install CPP Dependencies (Mac)
+ if: matrix.os == 'macos-latest'
+ shell: bash
+ run: |
+ brew install boost
+ brew install bison
+ echo 'export PATH=/usr/local/opt/bison/bin:$PATH' >> ~/.bash_profile
+ source ~/.bash_profile && export LDFLAGS="-L/usr/local/opt/bison/lib"
+ - name: Cache Maven packages
+ uses: actions/cache@v2
+ with:
+ path: ~/.m2
+ key: client-${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
+ restore-keys: ${{ runner.os }}-m2-
+ - name: Test with Maven
+ run: mvn -B clean integration-test -Pclient-cpp
-Dtsfile.test.skip=true -Djdbc.test.skip=true -Diotdb.test.skip=true
-Dtest.port.closed=true -Denforcer.skip=true -pl
server,client-cpp,example/client-cpp-example -am
+
+ build-win:
+ strategy:
+ fail-fast: false
+ max-parallel: 20
+ matrix:
+ java: [11.0.x]
+ os: [windows-latest]
+ runs-on: ${{ matrix.os}}
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up JDK ${{ matrix.java }}
+ uses: actions/setup-java@v1
+ with:
+ java-version: ${{ matrix.java }}
+ - name: Cache Maven packages
+ uses: actions/cache@v2
+ with:
+ path: ~/.m2
+ key: client-${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
+ restore-keys: ${{ runner.os }}-m2-
+ - name: Install Boost and Win_Flex_Bison
+ run: mkdir D:\a\cpp ; `
+ Invoke-WebRequest
https://github.com/lexxmark/winflexbison/releases/download/v2.5.24/win_flex_bison-2.5.24.zip
-OutFile D:\a\cpp\win_flex_bison.zip ; `
+ [Environment]::SetEnvironmentVariable("Path", $env:Path +
";D:\a\cpp", "User") ; `
+ Invoke-WebRequest
https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.zip -OutFile
D:\a\cpp\boost_1_72_0.zip ; `
+ Expand-Archive D:\a\cpp\boost_1_72_0.zip -DestinationPath D:\a\cpp ;
`
+ cd D:\a\cpp\boost_1_72_0 ; `
+ .\bootstrap.bat ; `
+ .\b2.exe
+ - name: Add Flex and Bison Path
+ shell: bash
+ run: cd /d/a/cpp && unzip win_flex_bison.zip && mv win_flex.exe
flex.exe && mv win_bison.exe bison.exe && echo 'export PATH=/d/a/cpp:$PATH' >>
~/.bash_profile && source ~/.bash_profile
+ - name: Test with Maven
+ shell: bash
+ run: source ~/.bash_profile && mvn -B clean integration-test
-Pclient-cpp -Dboost.include.dir=/d/a/cpp/boost_1_72_0
-Dboost.library.dir=/d/a/cpp/boost_1_72_0/stage/lib -Dtsfile.test.skip=true
-Djdbc.test.skip=true -Diotdb.test.skip=true -Dtest.port.closed=true
-Denforcer.skip=true -pl server,client-cpp,example/client-cpp-example -am
\ No newline at end of file
diff --git a/.github/workflows/main-ci.yml b/.github/workflows/main-ci.yml
index a7aec89..3c7250d 100644
--- a/.github/workflows/main-ci.yml
+++ b/.github/workflows/main-ci.yml
@@ -5,19 +5,19 @@ name: Java CI with Maven
on:
push:
- branches:
+ branches:
- master
- 'rel/*'
paths-ignore:
- 'docs/**'
pull_request:
- branches:
+ branches:
- master
- 'rel/*'
- cluster_new
paths-ignore:
- 'docs/**'
-
+
jobs:
build:
strategy:
@@ -39,11 +39,11 @@ jobs:
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
- restore-keys: ${{ runner.os }}-m2
+ restore-keys: ${{ runner.os }}-m2-
- name: Check Apache Rat
- run: mvn -B apache-rat:check
+ run: mvn -B apache-rat:check -P client-cpp
- name: Test with Maven
- run: mvn -B clean integration-test -Dtest.port.closed=true
+ run: mvn -B clean integration-test -Dtest.port.closed=true
-Denforcer.skip=true
build-win:
strategy:
@@ -65,7 +65,7 @@ jobs:
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
- restore-keys: ${{ runner.os }}-m2
+ restore-keys: ${{ runner.os }}-m2-
- name: Check Apache Rat
run: mvn -B apache-rat:check
- name: Download Hadoop Tools if Needed
@@ -109,4 +109,4 @@ jobs:
restore-keys: ${{ runner.os }}-hadoop-files
- name: Test with Maven
shell: bash
- run: source ~/.bash_profile && mvn -B clean integration-test
-Dtest.port.closed=true
+ run: source ~/.bash_profile && mvn -B clean integration-test
-Dtest.port.closed=true -Denforcer.skip=true
\ No newline at end of file
diff --git a/client-cpp/README.md b/client-cpp/README.md
index 675b6d1..3556c54 100644
--- a/client-cpp/README.md
+++ b/client-cpp/README.md
@@ -30,3 +30,34 @@ For more information, please refer to
"compile-tools/README.md".
`mvn integration-test -P client-cpp -pl client-cpp,server -am
-Diotdb.test.skip=true -Dtsfile.test.skip=true -Djdbc.test.skip=true`
+To compile on Windows, please install Boost first and add following Maven
settings:
+```
+-Dboost.include.dir=${your boost header folder} -Dboost.library.dir=${your
boost lib (stage) folder}`
+```
+
+e.g.,
+```
+mvn integration-test -P client-cpp -pl
client-cpp,server,example/client-cpp-example -am
+-D"iotdb.test.skip"=true -D"tsfile.test.skip"=true -D"jdbc.test.skip"=true
+-D"boost.include.dir"="D:\boost_1_75_0"
-D"boost.library.dir"="D:\boost_1_75_0\stage\lib"
+```
+
+##
+
+If the compilation finishes successfully, the packaged zip file will be placed
under
+"client-cpp/target/client-cpp-${project.version}-cpp-${os}.zip".
+
+On Mac machines, the hierarchy of the package should look like this:
+```
+.
++-- client
+| +-- include
+| +-- Session.h
+| +-- TSIService.h
+| +-- rpc_types.h
+| +-- rpc_constants.h
+| +-- thrift
+| +-- thrift_headers...
+| +-- lib
+| +-- libiotdb_session.dylib
+```
diff --git a/client-cpp/pom.xml b/client-cpp/pom.xml
index 7b505b1..e5762d7 100644
--- a/client-cpp/pom.xml
+++ b/client-cpp/pom.xml
@@ -27,9 +27,7 @@
<version>0.12.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <groupId>org.apache.iotdb</groupId>
<artifactId>client-cpp</artifactId>
- <version>0.12.0-SNAPSHOT</version>
<name>Client for cpp</name>
<description>C++ client</description>
<packaging>pom</packaging>
@@ -44,8 +42,15 @@
<catch2.url>https://github.com/catchorg/Catch2/releases/download/v2.13.0/catch.hpp</catch2.url>
</properties>
<modules>
- <module>client-cpp-example</module>
+ <module>../example/client-cpp-example</module>
</modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.iotdb</groupId>
+ <artifactId>client-cpp-tools-thrift</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
<profiles>
<profile>
<id>os-unix</id>
@@ -61,7 +66,6 @@
<cmake.root.dir>${project.parent.basedir}/compile-tools/thrift/target/cmake-${cmake-version}-Linux-x86_64/</cmake.root.dir>
<thrift.exec.absolute.path>${project.parent.basedir}/compile-tools/thrift/target/build/compiler/cpp/bin/thrift</thrift.exec.absolute.path>
<iotdb.server.script>start-server.sh</iotdb.server.script>
- <dev.null.path>/dev/null</dev.null.path>
</properties>
</profile>
<profile>
@@ -78,7 +82,6 @@
<cmake.root.dir>${project.parent.basedir}/compile-tools/thrift/target/cmake-${cmake-version}-Darwin-x86_64/CMake.app/Contents</cmake.root.dir>
<thrift.exec.absolute.path>${project.parent.basedir}/compile-tools/thrift/target/build/compiler/cpp/bin/thrift</thrift.exec.absolute.path>
<iotdb.server.script>start-server.sh</iotdb.server.script>
- <dev.null.path>/dev/null</dev.null.path>
</properties>
</profile>
<profile>
@@ -95,7 +98,8 @@
<cmake.root.dir>${project.parent.basedir}/compile-tools/thrift/target/cmake-${cmake-version}-win64-x64/</cmake.root.dir>
<thrift.exec.absolute.path>${project.parent.basedir}/compile-tools/thrift/target/build/compiler/cpp/bin/${cmake.build.type}/thrift.exe</thrift.exec.absolute.path>
<iotdb.server.script>start-server.bat</iotdb.server.script>
- <dev.null.path>NUL</dev.null.path>
+ <boost.include.dir/>
+ <boost.library.dir/>
</properties>
</profile>
<profile>
@@ -113,6 +117,7 @@
<version>1.0</version>
<executions>
<execution>
+ <!-- Copy rpc.thrift into target directory -->
<id>copy-thrift-source</id>
<goals>
<goal>copy</goal>
@@ -127,6 +132,7 @@
</configuration>
</execution>
<execution>
+ <!-- Copy source file and CmakeLists.txt into
target directory -->
<id>copy-cmakelist-file</id>
<phase>compile</phase>
<goals>
@@ -158,7 +164,7 @@
<executions>
<execution>
<id>generate-thrift-sources-cpp</id>
- <!-- Move from generate-sources to
generate-resources to avoid executing twice -->
+ <!-- Move from generate-sources to
generate-resources to avoid double executions -->
<phase>generate-resources</phase>
<goals>
<goal>compile</goal>
@@ -198,6 +204,10 @@
-->
<targetPath>${project.build.directory}/build/main</targetPath>
<generator>${cmake.generator}</generator>
+ <options>
+
<option>-DBOOST_INCLUDEDIR=${boost.include.dir}</option>
+
<option>-DBOOST_LIBRARYDIR=${boost.library.dir}</option>
+ </options>
</configuration>
</execution>
<!-- Actually executes the build -->
@@ -219,6 +229,7 @@
<projectDirectory>${project.build.directory}/build/main</projectDirectory>
</configuration>
</execution>
+ <!-- Generate Cmake build directory to compile
testing program -->
<execution>
<id>cmake-generate-test</id>
<phase>test-compile</phase>
@@ -231,8 +242,13 @@
<sourcePath>${project.build.directory}/build/test</sourcePath>
<targetPath>${project.build.directory}/build/test</targetPath>
<generator>${cmake.generator}</generator>
+ <options>
+
<option>-DBOOST_INCLUDEDIR=${boost.include.dir}</option>
+
<option>-DBOOST_LIBRARYDIR=${boost.library.dir}</option>
+ </options>
</configuration>
</execution>
+ <!-- Actually executes the testing compilation -->
<execution>
<id>cmake-compile-test</id>
<phase>test-compile</phase>
@@ -246,6 +262,7 @@
<projectDirectory>${project.build.directory}/build/test</projectDirectory>
</configuration>
</execution>
+ <!-- Run the integration test cases -->
<execution>
<id>cmake-run-test</id>
<phase>test</phase>
@@ -319,7 +336,7 @@
<outputDirectory>${project.build.directory}/build/test/catch2</outputDirectory>
<skipCache>false</skipCache>
<!-- must be true to avoid the local
Catch2 has incorrect vesion.-->
- <overwrite>true</overwrite>
+ <overwrite>false</overwrite>
</configuration>
</execution>
</executions>
@@ -327,8 +344,9 @@
<plugin>
<groupId>com.bazaarvoice.maven.plugins</groupId>
<artifactId>process-exec-maven-plugin</artifactId>
- <version>0.7</version>
+ <version>0.9</version>
<executions>
+ <!-- Start a local IoTDB server to run integration
test cases -->
<execution>
<id>iotdb-process</id>
<phase>generate-test-resources</phase>
@@ -341,12 +359,13 @@
<!-- Maximum time in seconds to wait after
launching IoTDB -->
<waitAfterLaunch>5</waitAfterLaunch>
<!-- Redirect IoTDB server log to
/dev/null -->
-
<processLogFile>${dev.null.path}</processLogFile>
+
<processLogFile>${project.build.directory}/build/test/test.log</processLogFile>
<arguments>
-
<argument>../../server/target/iotdb-server-${project.version}/sbin/${iotdb.server.script}</argument>
+
<argument>${project.basedir}/../server/target/iotdb-server-${project.version}/sbin/${iotdb.server.script}</argument>
</arguments>
</configuration>
</execution>
+ <!-- Stop the IoTDB server when integration test
finishes -->
<execution>
<id>stop-all</id>
<phase>post-integration-test</phase>
diff --git a/client-cpp/src/assembly/client-cpp.xml
b/client-cpp/src/assembly/client-cpp.xml
index 5b96467..c602b60 100644
--- a/client-cpp/src/assembly/client-cpp.xml
+++ b/client-cpp/src/assembly/client-cpp.xml
@@ -40,19 +40,19 @@
<outputDirectory>include</outputDirectory>
</fileSet>
<fileSet>
-
<directory>${project.basedir}/../compile-tools/boost/target/lib/boost/include</directory>
- <includes>
- <include>**/*.h</include>
- <include>**/*.hpp</include>
- </includes>
- <outputDirectory>include</outputDirectory>
- </fileSet>
- <fileSet>
<directory>${project.build.directory}/build/main</directory>
<includes>
<include>*.so</include>
<include>*.dylib</include>
<include>**/*.dll</include>
+ <include>**/*.lib</include>
+ </includes>
+ <outputDirectory>lib</outputDirectory>
+ </fileSet>
+ <fileSet>
+
<directory>${project.basedir}/../compile-tools/thrift/target/build/lib/Release</directory>
+ <includes>
+ <include>**/*.lib</include>
</includes>
<outputDirectory>lib</outputDirectory>
</fileSet>
diff --git a/client-cpp/src/main/CMakeLists.txt
b/client-cpp/src/main/CMakeLists.txt
index 294171e..27c359a 100644
--- a/client-cpp/src/main/CMakeLists.txt
+++ b/client-cpp/src/main/CMakeLists.txt
@@ -21,22 +21,32 @@ PROJECT(iotdb_session CXX)
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wall")
SET(TOOLS_DIR "${CMAKE_SOURCE_DIR}/../../../../compile-tools")
-# TODO May use FIND_PACKAGE instead
+FIND_PACKAGE(Boost REQUIRED)
+IF (DEFINED BOOST_INCLUDEDIR)
+ include_directories(SYSTEM "${BOOST_INCLUDEDIR}")
+ENDIF()
+
IF(MSVC)
SET(THRIFT_STATIC_LIB
"${TOOLS_DIR}/thrift/target/build/lib/Release/thriftmd.lib")
- INCLUDE_DIRECTORIES(${TOOLS_DIR}/boost/target/lib/boost/include/boost-1_72)
ELSE()
SET(THRIFT_STATIC_LIB "${TOOLS_DIR}/thrift/target/build/lib/libthrift.a")
- INCLUDE_DIRECTORIES(${TOOLS_DIR}/boost/target/lib/boost/include)
ENDIF()
+# Add Boost include path for MacOS
+INCLUDE_DIRECTORIES(/usr/local/include)
+# Add Thrift include directory
INCLUDE_DIRECTORIES(${TOOLS_DIR}/thrift/target/thrift-0.13.0/lib/cpp/src)
-#ADD_SUBDIRECTORY(generated-sources-cpp)
+# Add ./generated-sources-cpp as a Cmake subdirectory
AUX_SOURCE_DIRECTORY(./generated-sources-cpp SESSION_SRCS)
-ADD_LIBRARY(iotdb_session SHARED ${SESSION_SRCS})
+IF(MSVC)
+ ADD_LIBRARY(iotdb_session ${SESSION_SRCS})
+ELSE()
+ ADD_LIBRARY(iotdb_session SHARED ${SESSION_SRCS})
+ENDIF()
+
+# Link with Thrift static library
TARGET_LINK_LIBRARIES(iotdb_session ${THRIFT_STATIC_LIB})
diff --git a/client-cpp/src/main/Session.h b/client-cpp/src/main/Session.h
index 256035c..41a72f0 100644
--- a/client-cpp/src/main/Session.h
+++ b/client-cpp/src/main/Session.h
@@ -25,6 +25,7 @@
#include <map>
#include <utility>
#include <memory>
+#include <new>
#include <thread>
#include <mutex>
#include <stdexcept>
diff --git a/client-cpp/src/test/CMakeLists.txt
b/client-cpp/src/test/CMakeLists.txt
index 4514d75..ba4ddfc 100644
--- a/client-cpp/src/test/CMakeLists.txt
+++ b/client-cpp/src/test/CMakeLists.txt
@@ -20,23 +20,43 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.7)
INCLUDE( CTest )
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
-SET(TARGET_NAME tests)
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall")
+SET(TARGET_NAME session_tests)
SET(TOOLS_DIR "${CMAKE_SOURCE_DIR}/../../../../compile-tools")
ENABLE_TESTING()
+# Add Boost include path for MacOS
+INCLUDE_DIRECTORIES(/usr/local/include)
+# Add Session related include files
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/../main/generated-sources-cpp)
+# Add Thrift include directory
+INCLUDE_DIRECTORIES(${TOOLS_DIR}/thrift/target/thrift-0.13.0/lib/cpp/src)
+
+find_package(Boost REQUIRED)
+IF (DEFINED BOOST_INCLUDEDIR)
+ include_directories(SYSTEM "${BOOST_INCLUDEDIR}")
+ENDIF()
+
+# Link directories are different for Windows and Linux/Mac
IF(MSVC)
- INCLUDE_DIRECTORIES(${TOOLS_DIR}/boost/target/lib/boost/include/boost-1_72)
+ LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/../main/Release)
+ SET(THRIFT_STATIC_LIB
"${TOOLS_DIR}/thrift/target/build/lib/Release/thriftmd.lib")
ELSE()
- INCLUDE_DIRECTORIES(${TOOLS_DIR}/boost/target/lib/boost/include)
+ LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/../main)
ENDIF()
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/../main/generated-sources-cpp)
-INCLUDE_DIRECTORIES(${TOOLS_DIR}/thrift/target/thrift-0.13.0/lib/cpp/src)
-LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/../main)
-
ADD_EXECUTABLE(${TARGET_NAME} main.cpp cpp/sessionIT.cpp)
-TARGET_LINK_LIBRARIES(${TARGET_NAME} PUBLIC iotdb_session)
+
+# Link with shared library iotdb_session and pthread
+IF(MSVC)
+ TARGET_LINK_LIBRARIES(${TARGET_NAME} iotdb_session ${THRIFT_STATIC_LIB})
+ELSE()
+ TARGET_LINK_LIBRARIES(${TARGET_NAME} iotdb_session pthread)
+ENDIF()
TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME} PUBLIC ./catch2/)
-ADD_TEST(NAME test1 COMMAND ${TARGET_NAME})
\ No newline at end of file
+# Add 'sessionIT' to the project to be run by ctest
+IF(MSVC)
+ ADD_TEST(NAME sessionIT CONFIGURATIONS Release COMMAND ${TARGET_NAME})
+ELSE()
+ ADD_TEST(NAME sessionIT COMMAND ${TARGET_NAME})
+ENDIF()
diff --git a/compile-tools/README.md b/compile-tools/README.md
index c232a40..fb19922 100644
--- a/compile-tools/README.md
+++ b/compile-tools/README.md
@@ -26,49 +26,52 @@
* Maven 3.5+
* Flex
* Bison 2.7+
+* Boost
* OpenSSL 1.0+
Make sure a complete C++ building environment is prepared on your machine.
### Mac
-1. Bison
+- Bison
-Bison 2.3 is preinstalled on OSX, but this version is too low.
-When building Thrift with Bison 2.3, the following error would pop out:
+ Bison 2.3 is preinstalled on OSX, but this version is too low.
+ When building Thrift with Bison 2.3, the following error would pop out:
-```invalid directive: '%code'```
-
-For such case, please update `Bison`:
-
-```
- brew install bison
- brew link bison --force
+
+ ```invalid directive: '%code'```
+
+ For such case, please update `Bison`:
+
+```
+ brew install bison
+ brew link bison --force
```
+
+ Then, you need to tell the OS where the new bison is.
+
+ For Bash users:
+ ```
+ echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile
+ ```
+
+ For zsh users:
+ ```
+ echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.zshrc
+ ```
+
+- Boost
+
+Please make sure a relative new version of Boost is ready on your machine.
+If no Boost available, install the latest version of Boost:
-Then, you need to tell the OS where the new bison is.
-
-For Bash users:
-```
- echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile
```
-
-For zsh users:
-```
- echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.zshrc
+ brew install boost
+ brew link boost
```
-Then,
-```
-mv
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bison
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bison2.3
-
-ln -s /usr/local/opt/bison/bin/bison
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bison
-```
-
-
-
-2. OpenSSL
+- OpenSSL
Make sure the Openssl libraries has been install on your Mac.
The default Openssl include file search path is
"/usr/local/opt/openssl/include".
@@ -86,16 +89,14 @@ To install all dependencies, run:
Debian/Ubuntu:
```
-sudo apt install gcc g++ bison flex -y
+sudo apt-get install gcc g++ bison flex libboost-all-dev
```
CentOS:
```
-yum install gcc g++ bison flex
+yum install gcc g++ bison flex boost-devel
```
-
-
### Windows
#### Flex and Bison
@@ -103,6 +104,10 @@ For Flex and Bison, they could be downloaded from
SourceForge: https://sourcefor
After downloaded, please rename the executables to flex.exe and bison.exe and
add them to "PATH" environment variables.
+#### Boost
+For Boost, please download from the official website:
https://www.boost.org/users/download/
+
+
#### Cmake generator on Windows
@@ -144,4 +149,16 @@ There is a long list of supported Cmake generators on
Windows environment.
(the list is gotten by `cmake --help`.)
When building client-cpp project, use -Dcmake.generator="" option to specify a
Cmake generator.
-E.g., `mvn package -Dcmake.generator="Visual Studio 15 2017 [arch]"`
\ No newline at end of file
+E.g., `mvn package -Dcmake.generator="Visual Studio 15 2017 [arch]"`
+
+on windows, you should set `-Dboost.include.dir=${your boost header folder}
-Dboost.library.dir=${your boost lib (stage) folder}`
+
+
+### FAQ
+
+#### on Mac
+
+if you occur some errors when compiling thrift source code, try to downgrade
your xcode-commandline from 12 to 11.5
+
+see
https://stackoverflow.com/questions/63592445/ld-unsupported-tapi-file-type-tapi-tbd-in-yaml-file/65518087#65518087
+
diff --git a/compile-tools/boost/pom.xml b/compile-tools/boost/pom.xml
deleted file mode 100644
index ea7625b..0000000
--- a/compile-tools/boost/pom.xml
+++ /dev/null
@@ -1,145 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.iotdb</groupId>
- <artifactId>client-cpp-tools</artifactId>
- <version>0.12.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <artifactId>client-cpp-tools-boost</artifactId>
- <packaging>jar</packaging>
- <name>Tools: Boost</name>
- <description>Building of the Boost library.</description>
- <!-- Disabled for now as C++ support is currently not installed in Apache
SonarQube -->
- <!--properties>
- <sonar.language>c++</sonar.language>
- </properties-->
- <profiles>
- <profile>
- <id>build-boost</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <build>
- <plugins>
- <!-- First download the cmake binaries and sources for
building the boost library -->
- <plugin>
- <groupId>com.googlecode.maven-download-plugin</groupId>
- <artifactId>download-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>get-boost</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>wget</goal>
- </goals>
- <configuration>
- <url>${boost.url}</url>
- <unpack>true</unpack>
-
<outputDirectory>${project.build.directory}</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <!--
- Then execute two boost build phases:
-
- 1) bootstrap the boost build
- 2) Perform the actual boost build and install
- -->
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <configuration>
- <quietLogs>true</quietLogs>
- <useMavenLogger>true</useMavenLogger>
- </configuration>
- <executions>
- <execution>
- <id>bootstrap-boost</id>
- <phase>process-sources</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
-
<executable>${boost.bootstrap.executable}</executable>
- <arguments>
- <!-- Use clang instead of gcc as this
requires far less memory -->
- <argument>--with-toolset=gcc</argument>
- </arguments>
-
<workingDirectory>${project.build.directory}/boost_${boost.version.underline}</workingDirectory>
- </configuration>
- </execution>
- <execution>
- <id>compile-boost</id>
- <phase>process-sources</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
-
<executable>${boost.build.executable}</executable>
- <arguments>
- <!-- Have the build install the built
libraries -->
- <argument>install</argument>
- <!-- Tell it where to install the
libraries and header files -->
-
<argument>--prefix=${project.build.directory}/lib/boost</argument>
- <!-- List of modules to build -->
- <argument>--with-system</argument>
- <argument>--with-thread</argument>
- <argument>--with-date_time</argument>
- <argument>--with-regex</argument>
- <argument>--with-log</argument>
- <!-- On Windows machines the build
failed, if this was not explicitly set -->
- <argument>address-model=64</argument>
- <!-- On Linux machines the build
failed, if this is not set -->
- <argument>cxxflags=-fPIC</argument>
- </arguments>
-
<workingDirectory>${project.build.directory}/boost_${boost.version.underline}</workingDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <!-- Build a zip artifact containing the boost library -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>package-boost-library</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
-
<finalName>${project.artifactId}-${project.version}</finalName>
- <descriptors>
-
<descriptor>src/assembly/bundle.xml</descriptor>
- </descriptors>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
diff --git a/compile-tools/boost/src/assembly/bundle.xml
b/compile-tools/boost/src/assembly/bundle.xml
deleted file mode 100644
index 1a7ac15..0000000
--- a/compile-tools/boost/src/assembly/bundle.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<assembly>
- <id>lib-${os.classifier}</id>
- <formats>
- <format>zip</format>
- </formats>
- <includeBaseDirectory>false</includeBaseDirectory>
- <fileSets>
- <fileSet>
- <directory>${project.build.directory}/lib/boost</directory>
- <includes>
- <include>**</include>
- </includes>
- <outputDirectory/>
- </fileSet>
- </fileSets>
-</assembly>
diff --git a/compile-tools/pom.xml b/compile-tools/pom.xml
index a7f30d0..e99532b 100644
--- a/compile-tools/pom.xml
+++ b/compile-tools/pom.xml
@@ -26,8 +26,6 @@
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>client-cpp-tools</artifactId>
- <groupId>org.apache.iotdb</groupId>
- <version>0.12.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Compile Tools</name>
<properties>
@@ -36,10 +34,10 @@
<boost.version.underline>${boost.version.underline-short}_0</boost.version.underline>
<cmake-version>3.17.3</cmake-version>
<openssl.include.dir>-Dtrue1=true1</openssl.include.dir>
+ <bison.executable.dir>-Dtrue1=true1</bison.executable.dir>
<cmake.build.type/>
</properties>
<modules>
- <module>boost</module>
<module>thrift</module>
</modules>
<profiles>
@@ -89,6 +87,7 @@
<gradlew.executable>./gradlew</gradlew.executable>
<openssl.include.default.path>/usr/local/opt/openssl/include</openssl.include.default.path>
<openssl.include.dir>-DCMAKE_CXX_FLAGS="-I${openssl.include.default.path}"</openssl.include.dir>
+
<bison.executable.dir>-DBISON_EXECUTABLE=/usr/local/opt/bison/bin/bison</bison.executable.dir>
</properties>
</profile>
<profile>
@@ -115,6 +114,8 @@
<thrift.make.executable>make</thrift.make.executable>
<thrift.compiler.executable>thrift.exe</thrift.compiler.executable>
<gradlew.executable>gradlew.bat</gradlew.executable>
+ <boost.include.dir/>
+ <boost.library.dir/>
</properties>
</profile>
</profiles>
diff --git a/compile-tools/thrift/pom.xml b/compile-tools/thrift/pom.xml
index 28fb46b..b314655 100644
--- a/compile-tools/thrift/pom.xml
+++ b/compile-tools/thrift/pom.xml
@@ -225,36 +225,10 @@
<goal>wget</goal>
</goals>
<configuration>
-
<url>http://www.apache.org/dyn/closer.lua?action=download&filename=/thrift/${thrift.version}/thrift-${thrift.version}.tar.gz</url>
+
<url>https://archive.apache.org/dist/thrift/${thrift.version}/thrift-${thrift.version}.zip</url>
<unpack>true</unpack>
<outputDirectory>${project.build.directory}</outputDirectory>
- <overwrite>true</overwrite>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>unpack-boost</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>unpack</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.apache.iotdb</groupId>
-
<artifactId>client-cpp-tools-boost</artifactId>
- <version>${project.version}</version>
- <type>zip</type>
-
<classifier>lib-${os.classifier}</classifier>
- <overWrite>true</overWrite>
- </artifactItem>
- </artifactItems>
-
<outputDirectory>${project.build.directory}/boost</outputDirectory>
+ <overwrite>false</overwrite>
</configuration>
</execution>
</executions>
@@ -325,13 +299,16 @@
<option>-DBUILD_JAVA=OFF</option>
<option>-DBUILD_PYTHON=${thrift.with.python}</option>
<option>-DBUILD_HASKELL=OFF</option>
- <!-- Tell CMake where our boost includes and
libs are located -->
-
<option>-DBOOST_INCLUDEDIR=${project.build.directory}/boost/include</option>
-
<option>-DBOOST_LIBRARYDIR=${project.build.directory}/boost/lib</option>
<option>-DWITH_SHARED_LIB=OFF</option>
+ <!-- Generate libthrift.a to compile IoTDB
Session -->
<option>-DWITH_STATIC_LIB=ON</option>
<option>-DCMAKE_POSITION_INDEPENDENT_CODE=ON</option>
+ <!-- Specify openssl include path for Mac OS
-->
<option>${openssl.include.dir}</option>
+ <!-- Specify new version Bison path for Mac OS
-->
+ <option>${bison.executable.dir}</option>
+
<option>-DBOOST_INCLUDEDIR=${boost.include.dir}</option>
+
<option>-DBOOST_LIBRARYDIR=${boost.library.dir}</option>
</options>
</configuration>
</execution>
@@ -382,6 +359,7 @@
</execution>
</executions>
</plugin>
+ <!-- Copy the config.h file into thrift include directory -->
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
@@ -406,15 +384,4 @@
</plugin>
</plugins>
</build>
- <dependencies>
- <!-- Make sure Boost is built first -->
- <dependency>
- <groupId>org.apache.iotdb</groupId>
- <artifactId>client-cpp-tools-boost</artifactId>
- <version>${project.version}</version>
- <type>zip</type>
- <classifier>lib-${os.classifier}</classifier>
- <scope>provided</scope>
- </dependency>
- </dependencies>
</project>
diff --git a/client-cpp/README.md b/example/client-cpp-example/README.md
similarity index 58%
copy from client-cpp/README.md
copy to example/client-cpp-example/README.md
index 675b6d1..07d16b7 100644
--- a/client-cpp/README.md
+++ b/example/client-cpp-example/README.md
@@ -18,15 +18,31 @@
under the License.
-->
-# Building C++ Client
-To compile cpp client, add "-P client-cpp" option to maven build command.
+# How to get a complete CPP client demo project
-The compiling requires the module "compile-tools" to be built first.
-For more information, please refer to "compile-tools/README.md".
+## get a project
+using maven to build this example project:
-## Compile and Test:
+* cd the root path of the whole project
+* run `mvn package -DskipTests -P client-cpp -pl example/client-cpp-example
-am`
+* cd example/client-cpp-example/target
+
+You can find some files to form a complete project:
+```
++-- client
+| +-- include
+| +-- Session.h
+| +-- TSIService.h
+| +-- rpc_types.h
+| +-- rpc_constants.h
+| +-- thrift
+| +-- thrift_headers...
+| +-- lib
+| +-- libiotdb_session.dylib
++-- CMakeLists.txt
++-- SessionExample.cpp
+```
-`mvn integration-test -P client-cpp -pl client-cpp,server -am
-Diotdb.test.skip=true -Dtsfile.test.skip=true -Djdbc.test.skip=true`
diff --git a/client-cpp/client-cpp-example/pom.xml
b/example/client-cpp-example/pom.xml
similarity index 95%
rename from client-cpp/client-cpp-example/pom.xml
rename to example/client-cpp-example/pom.xml
index a6286ca..10a2734 100644
--- a/client-cpp/client-cpp-example/pom.xml
+++ b/example/client-cpp-example/pom.xml
@@ -22,14 +22,13 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>client-cpp</artifactId>
<groupId>org.apache.iotdb</groupId>
+ <artifactId>client-cpp</artifactId>
<version>0.12.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
+ <relativePath>../../client-cpp/pom.xml</relativePath>
</parent>
- <groupId>org.apache.iotdb</groupId>
<artifactId>client-cpp-example</artifactId>
- <version>0.12.0-SNAPSHOT</version>
+ <name>IoTDB-Client CPP Examples</name>
<profiles>
<profile>
<id>os-unix</id>
@@ -51,6 +50,7 @@
</activation>
<properties>
<cmake.root.dir>${project.parent.basedir}/../compile-tools/thrift/target/cmake-${cmake-version}-Darwin-x86_64/CMake.app/Contents</cmake.root.dir>
+ <boost.include.dir>/usr/local/include</boost.include.dir>
</properties>
</profile>
<profile>
@@ -62,6 +62,7 @@
</activation>
<properties>
<cmake.root.dir>${project.parent.basedir}/../compile-tools/thrift/target/cmake-${cmake-version}-win64-x64/</cmake.root.dir>
+ <boost.include.dir/>
</properties>
</profile>
</profiles>
@@ -138,6 +139,9 @@
<sourcePath>${project.build.directory}</sourcePath>
<targetPath>${project.build.directory}</targetPath>
<generator>${cmake.generator}</generator>
+ <options>
+
<option>-DBOOST_INCLUDEDIR=${boost.include.dir}</option>
+ </options>
</configuration>
</execution>
<execution>
diff --git a/client-cpp/client-cpp-example/src/CMakeLists.txt
b/example/client-cpp-example/src/CMakeLists.txt
similarity index 67%
rename from client-cpp/client-cpp-example/src/CMakeLists.txt
rename to example/client-cpp-example/src/CMakeLists.txt
index 7fd15ef..f3b36ba 100644
--- a/client-cpp/client-cpp-example/src/CMakeLists.txt
+++ b/example/client-cpp-example/src/CMakeLists.txt
@@ -23,8 +23,21 @@ SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
-INCLUDE_DIRECTORIES(client/include)
-LINK_DIRECTORIES(client/lib)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/../target/client/include)
+
+find_package(Boost REQUIRED)
+IF (DEFINED BOOST_INCLUDEDIR)
+ include_directories(SYSTEM "${BOOST_INCLUDEDIR}")
+ENDIF()
+
+IF(MSVC)
+ LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/../target/client/lib/Release)
+ENDIF()
+LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/../target/client/lib)
ADD_EXECUTABLE(SessionExample SessionExample.cpp)
-TARGET_LINK_LIBRARIES(SessionExample iotdb_session)
+IF(MSVC)
+ TARGET_LINK_LIBRARIES(SessionExample iotdb_session thriftmd)
+ELSE()
+ TARGET_LINK_LIBRARIES(SessionExample iotdb_session pthread)
+ENDIF()
diff --git a/client-cpp/client-cpp-example/src/SessionExample.cpp
b/example/client-cpp-example/src/SessionExample.cpp
similarity index 100%
rename from client-cpp/client-cpp-example/src/SessionExample.cpp
rename to example/client-cpp-example/src/SessionExample.cpp
diff --git a/pom.xml b/pom.xml
index 05b82bd..edfe2a8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -144,6 +144,8 @@
<!-- By default, the argLine is empty-->
<gson.version>2.8.6</gson.version>
<argLine/>
+ <!-- whether enable compiling the cpp client-->
+ <client-cpp>false</client-cpp>
</properties>
<!--
if we claim dependencies in dependencyManagement, then we do not claim
@@ -1271,10 +1273,11 @@
</modules>
</profile>
<profile>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
<id>client-cpp</id>
+ <!-- we set client-cpp as true to enable the client-cpp-example-->
+ <properties>
+ <client-cpp>true</client-cpp>
+ </properties>
<modules>
<module>compile-tools</module>
<module>client-cpp</module>