diff --git a/.gitignore b/.gitignore index d12d506b1d..7cddd073f0 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,7 @@ callgrind.out.* deps/curl-7.54.1/**/*.o deps/curl-7.54.1/**/.dirstamp config.log +deps-build/** +.idea +cmake-build-debug/** +cmake-build/** diff --git a/CMakeLists.txt b/CMakeLists.txt index 94077811c3..033bff93a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -183,7 +183,7 @@ if (LINUX) find_library(CRYPTO_LIB libcrypto.a PATHS deps-build/${PLATFORM}/openssl/lib/ REQUIRED) find_library(AWS_CORE_LIB libaws-cpp-sdk-core.a PATHS deps-build/${PLATFORM}/aws/lib64/ REQUIRED) find_library(AWS_S3_LIB libaws-cpp-sdk-s3.a PATHS deps-build/${PLATFORM}/aws/lib64/ REQUIRED) - find_library(AZURE_STORAGE_LITE_LIB libazure-storage-lite.a PATHS deps-build/${PLATFORM}/azure/lib64/ REQUIRED) + find_library(AZURE_STORAGE_LITE_LIB libazure-storage-lite.a PATHS deps-build/${PLATFORM}/azure/lib/ REQUIRED) find_library(UUID_LIB libuuid.a PATHS deps-build/${PLATFORM}/uuid/lib/ REQUIRED) endif () diff --git a/deps/openssl-1.1.1b.tar.gz b/deps/openssl-1.1.1b.tar.gz new file mode 100644 index 0000000000..242316d4ae Binary files /dev/null and b/deps/openssl-1.1.1b.tar.gz differ diff --git a/deps/util-linux.tar.gz b/deps/util-linux.tar.gz new file mode 100644 index 0000000000..e0e49443a7 Binary files /dev/null and b/deps/util-linux.tar.gz differ diff --git a/scripts/build_azuresdk.sh b/scripts/build_azuresdk.sh new file mode 100755 index 0000000000..2d139223ca --- /dev/null +++ b/scripts/build_azuresdk.sh @@ -0,0 +1,101 @@ +#!/bin/bash -e +# +# build azure-cpp-lite +# +function usage() { + echo "Usage: `basename $0` [-t ]" + echo "Build AZURE SDK" + echo "-t : Release or Debug builds" + exit 2 +} +set -o pipefail + +export CC="/usr/lib64/ccache/gcc52 -g" +export CXX="/usr/lib64/ccache/g++52 -g" + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $DIR/_init.sh $@ +AZURE_SOURCE_DIR=$DEPS_DIR/azure-storage-cpplite +AZURE_BUILD_DIR=$DEPENDENCY_DIR/azure +AZURE_CMAKE_BUILD_DIR=$AZURE_SOURCE_DIR/cmake-build + +GIT_REPO="https://github.com/snowflakedb/azure-storage-cpplite.git" +CLONE_CMD="git clone -b master $GIT_REPO $AZURE_SOURCE_DIR" +VERSION="v0.1.1" + +if [ ! -d $AZURE_SOURCE_DIR ]; then + n=0 + # retry 5 times on cloning + until [ $n -ge 5 ] + do + if $CLONE_CMD ; then + break + fi + n=$[$n+1] + done + + if [ ! -d $AZURE_SOURCE_DIR ]; then + echo "[Error] failed to clone repo from $GIT_REPO" + exit 1 + fi + + cd $AZURE_SOURCE_DIR + git checkout tags/$VERSION -b $VERSION +else + cd $AZURE_SOURCE_DIR + git fetch + git checkout tags/$VERSION -b $VERSION || true +fi + + +azure_configure_opts=() +if [[ "$target" != "Release" ]]; then + azure_configure_opts+=("-DCMAKE_BUILD_TYPE=Debug") + AZURE_CMAKE_BUILD_DIR=$AZURE_SOURCE_DIR/cmake-build-debug +else + azure_configure_opts+=("-DCMAKE_BUILD_TYPE=Release") +fi +azure_configure_opts+=( + "-DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF" + "-DCMAKE_C_COMPILER=$GCC" + "-DCMAKE_CXX_COMPILER=$GXX" + "-DCMAKE_INSTALL_PREFIX=$AZURE_BUILD_DIR" + "-DBUILD_SHARED_LIBS=OFF" + "-DUSE_OPENSSL=true" + "-DOPENSSL_VERSION_NUMBER=0x11100000L" + "-DBUILD_SAMPLES=true" + "-DBUILD_TESTS=false" + "-DOPENSSL_INCLUDE_DIR=$DEPENDENCY_DIR/openssl/include" + "-DOPENSSL_CRYPTO_LIBRARY=$DEPENDENCY_DIR/openssl/lib/libcrypto.a" + "-DOPENSSL_SSL_LIBRARY=$DEPENDENCY_DIR/openssl/lib/libssl.a" + "-DUUID_INCLUDE_DIR=$DEPENDENCY_DIR/uuid/include" + "-DUUID_LIBRARIES=$DEPENDENCY_DIR/uuid/lib/libuuid.a" + "-DCURL_INCLUDE_DIRS=$DEPENDENCY_DIR/curl/include" + "-DCURL_LIBRARIES=$DEPENDENCY_DIR/curl/lib/libcurl.a" + "-DEXTRA_INCLUDE=$DEPENDENCY_DIR/zlib/include" +) + + +ADDITIONAL_CXXFLAGS= +if [[ "$PLATFORM" == "darwin" ]]; then + azure_configure_opts+=("-DCMAKE_OSX_ARCHITECTURES=x86_64;i386") + ADDITIONAL_CXXFLAGS="-mmacosx-version-min=10.11" +fi + +rm -rf $AZURE_BUILD_DIR +rm -rf $AZURE_CMAKE_BUILD_DIR +mkdir $AZURE_BUILD_DIR +mkdir $AZURE_CMAKE_BUILD_DIR + +export GIT_DIR=/tmp + +cd $AZURE_CMAKE_BUILD_DIR +$CMAKE -E env CXXFLAGS=$ADDITIONAL_CXXFLAGS $CMAKE ${azure_configure_opts[@]} -DEXTRA_LIBRARIES="-lrt -ldl -pthread $DEPENDENCY_DIR/zlib/lib/libz.a" ../ + +make +make install + +#make install does not do much here +cp -dfr $AZURE_SOURCE_DIR/include $DEPENDENCY_DIR/azure/ +mkdir -p $DEPENDENCY_DIR/azure/lib +cp -dfr $AZURE_CMAKE_BUILD_DIR/libazure-storage-lite.a $DEPENDENCY_DIR/azure/lib/ diff --git a/scripts/build_dependencies.sh b/scripts/build_dependencies.sh index 116ed47d75..a51234f176 100755 --- a/scripts/build_dependencies.sh +++ b/scripts/build_dependencies.sh @@ -11,8 +11,10 @@ function usage() { set -o pipefail DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" target=Debug -source $DIR/_init.sh +source $DIR/_init.sh $@ source $DIR/build_openssl.sh -t $target source $DIR/build_curl.sh -t $target source $DIR/build_awssdk.sh -t $target source $DIR/build_cmocka.sh -t Debug +source $DIR/build_uuid.sh -t $target +$DIR/build_azuresdk.sh -t $target diff --git a/scripts/build_libsnowflakeclient.sh b/scripts/build_libsnowflakeclient.sh index a6d6325769..efe6ea7f82 100755 --- a/scripts/build_libsnowflakeclient.sh +++ b/scripts/build_libsnowflakeclient.sh @@ -12,7 +12,7 @@ function usage() { set -o pipefail DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $DIR/_init.sh +source $DIR/_init.sh $@ cd $DIR/.. rm -rf cmake-build diff --git a/scripts/build_openssl.sh b/scripts/build_openssl.sh index 76c1a7188e..f8e3453938 100755 --- a/scripts/build_openssl.sh +++ b/scripts/build_openssl.sh @@ -11,8 +11,12 @@ function usage() { set -o pipefail DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $DIR/_init.sh -OPENSSL_SOURCE_DIR=$DEPS_DIR/openssl-1.1.1a/ +source $DIR/_init.sh $@ + +OPENSSL_TAR_GZ=$DEPS_DIR/openssl-1.1.1b.tar.gz +OPENSSL_SOURCE_DIR=$DEPS_DIR/openssl-1.1.1b/ + +tar -xzf $OPENSSL_TAR_GZ -C $DEPS_DIR # build openssl OPENSSL_BUILD_DIR=$DEPENDENCY_DIR/openssl diff --git a/scripts/build_uuid.sh b/scripts/build_uuid.sh new file mode 100755 index 0000000000..3c8e67dd43 --- /dev/null +++ b/scripts/build_uuid.sh @@ -0,0 +1,35 @@ +#!/bin/bash -e +# +# Build libuuid +# + +set -o pipefail + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $DIR/_init.sh $@ + +UTIL_LINUX_TAR_GZ=$DEPS_DIR/util-linux.tar.gz +SOURCE_DIR=$DEPS_DIR/util-linux + +tar -xzf $UTIL_LINUX_TAR_GZ -C $DEPS_DIR + +if [ ! -d "$SOURCE_DIR" ] ; then + echo "Could not extract $UTIL_LINUX_TAR_GZ" + exit 1 +fi + +cd $SOURCE_DIR + +if [[ "$PLATFORM" == "linux" ]]; then + echo "Generating UUID build system" + ./autogen.sh || true +# Make sure the compiled binary is position independent as ODBC is a shared library + export CFLAGS="-fPIC" + export AL_OPTS="-I/usr/share/aclocal" + ./configure --disable-all-programs --enable-libuuid --prefix=$DEPENDENCY_DIR/uuid || true + echo "Compiling UUID source" + make install || true +else + echo "[ERROR] Unknown platform: $PLATFORM" + exit 1 +fi diff --git a/scripts/build_zlib.sh b/scripts/build_zlib.sh new file mode 100755 index 0000000000..d0cc119d1b --- /dev/null +++ b/scripts/build_zlib.sh @@ -0,0 +1,42 @@ +#!/bin/bash -e +# +# Build zlib +# +function usage() { + echo "Usage: `basename $0` [-t ]" + echo "Builds zlib" + echo "-t : Release or Debug builds" + exit 2 +} +set -o pipefail + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +SOURCE_DIR=$DIR/../deps/zlib-1.2.11 +source $DIR/_init.sh $@ + +# init environment +#init_environment $DIR + +# build +BUILD_DIR=../deps-build/linux/zlib +rm -rf $BUILD_DIR +mkdir -p $BUILD_DIR + +zlib_config_opts=() +zlib_config_opts+=( + "--static" + "--prefix=$BUILD_DIR" +) +cd $SOURCE_DIR +if [[ "$PLATFORM" == "linux" ]]; then + # Linux 64 bit + export CC=gcc52 + if [ -e "Makefile" ] ; then + make distclean clean > /dev/null || true + fi + ./configure ${zlib_config_opts[@]} > /dev/null || true + make install > /dev/null || true +else + echo "[ERROR] Unknown platform: $PLATFORM" + exit 1 +fi