From ac16f2031427f2dac7d44a661f420dcc5881019a Mon Sep 17 00:00:00 2001 From: freemine Date: Thu, 8 Oct 2020 15:47:55 +0800 Subject: [PATCH] 1. adjust CMakeLists.txt to enabling checking unixodbc existence 2. use install.sh to install odbcinst/odbc record in system 3. add packages (unixodbc/unixodbc-dev) to install in .travis.yml --- .travis.yml | 2 ++ src/CMakeLists.txt | 2 +- src/connector/odbc/CMakeLists.txt | 36 +++++++++++++++++++++-------- src/connector/odbc/src/install.sh | 25 ++++++++++++++++++++ src/connector/odbc/src/template.dsn | 5 ---- src/connector/odbc/src/template.ini | 4 ---- 6 files changed, 54 insertions(+), 20 deletions(-) create mode 100755 src/connector/odbc/src/install.sh delete mode 100644 src/connector/odbc/src/template.dsn delete mode 100644 src/connector/odbc/src/template.ini diff --git a/.travis.yml b/.travis.yml index 6e49709c85..3256710434 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,8 @@ matrix: - python3-setuptools - valgrind - psmisc + - unixodbc + - unixodbc-dev before_script: - export TZ=Asia/Harbin diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2ed56d4f81..f619edd221 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,5 +21,5 @@ ADD_SUBDIRECTORY(wal) ADD_SUBDIRECTORY(cq) ADD_SUBDIRECTORY(dnode) ADD_SUBDIRECTORY(connector/odbc) -# ADD_SUBDIRECTORY(connector/jdbc) +ADD_SUBDIRECTORY(connector/jdbc) diff --git a/src/connector/odbc/CMakeLists.txt b/src/connector/odbc/CMakeLists.txt index 32e5c7ed69..393a1bd50b 100644 --- a/src/connector/odbc/CMakeLists.txt +++ b/src/connector/odbc/CMakeLists.txt @@ -1,17 +1,33 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) -AUX_SOURCE_DIRECTORY(src SRC) +IF (TD_LINUX_64) + find_program(HAVE_ODBCINST NAMES odbcinst) -# generate dynamic library (*.so) -ADD_LIBRARY(todbc SHARED ${SRC}) -SET_TARGET_PROPERTIES(todbc PROPERTIES CLEAN_DIRECT_OUTPUT 1) -SET_TARGET_PROPERTIES(todbc PROPERTIES VERSION ${TD_VER_NUMBER} SOVERSION 1) -TARGET_LINK_LIBRARIES(todbc taos) + IF (HAVE_ODBCINST) + include(CheckSymbolExists) + # shall we revert CMAKE_REQUIRED_LIBRARIES and how? + set(CMAKE_REQUIRED_LIBRARIES odbc) + check_symbol_exists(SQLExecute "sql.h" HAVE_ODBC_DEV) + if(NOT (HAVE_ODBC_DEV)) + unset(HAVE_ODBC_DEV CACHE) + message(WARNING "unixodbc-dev is not installed yet, you may install it under ubuntu by typing: sudo apt install unixodbc-dev") + else () + message(STATUS "unixodbc/unixodbc-dev are installed, and odbc connector will be built") + AUX_SOURCE_DIRECTORY(src SRC) -install(CODE "execute_process(COMMAND sudo odbcinst -i -d -f ${CMAKE_CURRENT_SOURCE_DIR}/src/template.ini - COMMAND odbcinst -i -s -f ${CMAKE_CURRENT_SOURCE_DIR}/src/template.dsn - COMMAND echo odbc install done)") + # generate dynamic library (*.so) + ADD_LIBRARY(todbc SHARED ${SRC}) + SET_TARGET_PROPERTIES(todbc PROPERTIES CLEAN_DIRECT_OUTPUT 1) + SET_TARGET_PROPERTIES(todbc PROPERTIES VERSION ${TD_VER_NUMBER} SOVERSION 1) + TARGET_LINK_LIBRARIES(todbc taos) -ADD_SUBDIRECTORY(tests) + install(CODE "execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/src/install.sh ${CMAKE_BINARY_DIR})") + + ADD_SUBDIRECTORY(tests) + endif() + ELSE () + message(WARNING "unixodbc is not installed yet, you may install it under ubuntu by typing: sudo apt install unixodbc-dev") + ENDIF () +ENDIF () diff --git a/src/connector/odbc/src/install.sh b/src/connector/odbc/src/install.sh new file mode 100755 index 0000000000..b8c04677c7 --- /dev/null +++ b/src/connector/odbc/src/install.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -u + +BLD_DIR="$1" + +rm -f "${BLD_DIR}/template.ini" +rm -f "${BLD_DIR}/template.dsn" + +cat > "${BLD_DIR}/template.ini" < "${BLD_DIR}/template.dsn" <