Skip to content

Commit

Permalink
Azure put get: Adding dependent libs and wrapper scripts.
Browse files Browse the repository at this point in the history
Added openssl 1.1.1b.tar.gz
Added util-linux.tar.gz (Azure sdk requires UUID and uuid is part of util-linux)
Added dependency uuid and Azure sdk to build_dependencies script
build_openssl.sh: Now untars the tar and builds the library.
build_uuid.sh: Untars the util-linux and only builds the UUID
build_zlib.sh: Builds the zlib.
CMakeLists.txt: Add findlibrary Azure
  • Loading branch information
rvishureddy committed Apr 8, 2019
1 parent 26f20d8 commit 0b3d66f
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/**
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()

Expand Down
Binary file added deps/openssl-1.1.1b.tar.gz
Binary file not shown.
Binary file added deps/util-linux.tar.gz
Binary file not shown.
101 changes: 101 additions & 0 deletions scripts/build_azuresdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/bin/bash -e
#
# build azure-cpp-lite
#
function usage() {
echo "Usage: `basename $0` [-t <Release|Debug>]"
echo "Build AZURE SDK"
echo "-t <Release/Debug> : 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/
4 changes: 3 additions & 1 deletion scripts/build_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion scripts/build_libsnowflakeclient.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions scripts/build_openssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions scripts/build_uuid.sh
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions scripts/build_zlib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash -e
#
# Build zlib
#
function usage() {
echo "Usage: `basename $0` [-t <Release|Debug>]"
echo "Builds zlib"
echo "-t <Release/Debug> : 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

0 comments on commit 0b3d66f

Please sign in to comment.