Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #7218 from EOSIO/hello_mongo
Browse files Browse the repository at this point in the history
reenable building of mongo c/cxx drivers
  • Loading branch information
spoonincode authored Apr 26, 2019
2 parents 7d9ebb9 + f2208a9 commit cdde673
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 248 deletions.
20 changes: 10 additions & 10 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ steps:
ln -s "$(pwd)" /data/job
cd /data/job
echo "+++ Building :hammer:"
./scripts/eosio_build.sh -y -P
./scripts/eosio_build.sh -y -P -m
echo "--- Compressing build directory :compression:"
tar -pczf build.tar.gz build
if [[ ! -f build.tar.gz ]]; then echo 'ERROR: No build.tar.gz artifact found!' && exit 1; fi
Expand All @@ -60,7 +60,7 @@ steps:
- command: | # Amazon Linux 2 Build
echo "+++ :hammer: Building"
./scripts/eosio_build.sh -y -P
./scripts/eosio_build.sh -y -P -m
echo "--- :compression: Compressing build directory"
tar -pczf build.tar.gz build
if [[ ! -f build.tar.gz ]]; then echo 'ERROR: No build.tar.gz artifact found!' && exit 1; fi
Expand All @@ -83,7 +83,7 @@ steps:
- command: | # CentOS 7 Build
echo "+++ :hammer: Building"
./scripts/eosio_build.sh -y -P
./scripts/eosio_build.sh -y -P -m
echo "--- :compression: Compressing build directory"
tar -pczf build.tar.gz build
if [[ ! -f build.tar.gz ]]; then echo 'ERROR: No build.tar.gz artifact found!' && exit 1; fi
Expand All @@ -106,7 +106,7 @@ steps:
- command: | # Ubuntu 16.04 Build
echo "+++ :hammer: Building"
./scripts/eosio_build.sh -y -P
./scripts/eosio_build.sh -y -P -m
echo "--- :compression: Compressing build directory"
tar -pczf build.tar.gz build
if [[ ! -f build.tar.gz ]]; then echo 'ERROR: No build.tar.gz artifact found!' && exit 1; fi
Expand All @@ -129,7 +129,7 @@ steps:
- command: | # Ubuntu 18.04 Build
echo "+++ :hammer: Building"
./scripts/eosio_build.sh -y -P
./scripts/eosio_build.sh -y -P -m
echo "--- :compression: Compressing build directory"
tar -pczf build.tar.gz build
if [[ ! -f build.tar.gz ]]; then echo 'ERROR: No build.tar.gz artifact found!' && exit 1; fi
Expand Down Expand Up @@ -190,7 +190,7 @@ steps:
region: "us-west-2"
docker#v2.1.0:
debug: true
image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:amazonlinux2_2-3"
image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:amazonlinux2_2-2"
propagate-environment: true
workdir: /data/job
timeout: 60
Expand Down Expand Up @@ -233,7 +233,7 @@ steps:
region: "us-west-2"
docker#v2.1.0:
debug: true
image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:centos7_2-3"
image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:centos7_2-2"
propagate-environment: true
workdir: /data/job
timeout: 60
Expand Down Expand Up @@ -276,7 +276,7 @@ steps:
region: "us-west-2"
docker#v2.1.0:
debug: true
image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:ubuntu16_2-3"
image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:ubuntu16_2-2"
propagate-environment: true
workdir: /data/job
timeout: 60
Expand Down Expand Up @@ -319,7 +319,7 @@ steps:
region: "us-west-2"
docker#v2.1.0:
debug: true
image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:ubuntu18_2-3"
image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:ubuntu18_2-2"
propagate-environment: true
workdir: /data/job
timeout: 60
Expand Down Expand Up @@ -382,7 +382,7 @@ steps:
./scripts/serial-test.sh
label: ":darwin: Mojave NP Tests"
agents:
- "role=tester-v2-2"
- "role=tester-v2-1"
- "os=mojave"
timeout: 60
Expand Down
41 changes: 5 additions & 36 deletions plugins/mongo_db_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,11 @@ if(BUILD_MONGO_DB_PLUGIN)

if (libmongoc-1.0_FOUND)

# EOS has no direct dependencies on libmongoc but its shared libraries
# will need to be present at runtime for the C++ libraries we use:
# libbsoncxx & libmongocxx (both from github.com/mongodb/mongo-cxx-driver)

# The *.cmake package files provided by mongo-cxx-driver don't give us the
# absolute path to the libraries, which is needed whenever they are not
# installed in system-known locations. CMake requires the absolute paths
# in target_link_libraries() since we are builiding an archive and the
# link step for all executables using this archive must include the
# mongo-cxx-driver libraries libmongocxx and libbsoncxx.

find_package(libbsoncxx-static REQUIRED)
message(STATUS "Found bsoncxx headers: ${LIBBSONCXX_STATIC_INCLUDE_DIRS}")

# mongo-cxx-driver 3.2 release altered LIBBSONCXX_LIBRARIES semantics. Instead of library names,
# it now hold library paths.
if((LIBBSONCXX_STATIC_VERSION_MAJOR LESS 3) OR ((LIBBSONCXX_STATIC_VERSION_MAJOR EQUAL 3) AND (LIBBSONCXX_STATIC_VERSION_MINOR LESS 2)))
find_library(EOS_LIBBSONCXX ${LIBBSONCXX_STATIC_LIBRARIES}
PATHS ${LIBBSONCXX_STATIC_LIBRARY_DIRS} NO_DEFAULT_PATH)
else()
set(EOS_LIBBSONCXX ${LIBBSONCXX_STATIC_LIBRARIES})
endif()

message(STATUS "Found bsoncxx library: ${EOS_LIBBSONCXX}")

find_package(libmongocxx-static REQUIRED)
message(STATUS "Found mongocxx headers: ${LIBMONGOCXX_STATIC_INCLUDE_DIRS}")

# mongo-cxx-driver 3.2 release altered LIBBSONCXX_LIBRARIES semantics. Instead of library names,
# it now hold library paths.
if((LIBMONGOCXX_STATIC_VERSION_MAJOR LESS 3) OR ((LIBMONGOCXX_STATIC_VERSION_MAJOR EQUAL 3) AND (LIBMONGOCXX_STATIC_VERSION_MINOR LESS 2)))
find_library(EOS_LIBMONGOCXX ${LIBMONGOCXX_STATIC_LIBRARIES}
PATHS ${LIBMONGOCXX_STATIC_LIBRARY_DIRS} NO_DEFAULT_PATH)
else()
set(EOS_LIBMONGOCXX ${LIBMONGOCXX_STATIC_LIBRARIES})
endif()
find_package(libmongoc-static-1.0 REQUIRED)
find_package(libbson-static-1.0 REQUIRED)

message(STATUS "Found mongocxx library: ${EOS_LIBMONGOCXX}")
else()
message("Could NOT find MongoDB. mongo_db_plugin with MongoDB support will not be included.")
return()
Expand All @@ -64,7 +31,9 @@ if(BUILD_MONGO_DB_PLUGIN)

target_link_libraries(mongo_db_plugin
PUBLIC chain_plugin eosio_chain appbase
${EOS_LIBMONGOCXX} ${EOS_LIBBSONCXX}
${LIBMONGOCXX_STATIC_LIBRARY_PATH} ${LIBBSONCXX_STATIC_LIBRARY_PATH}
${MONGOC_STATIC_LIBRARY} ${BSON_STATIC_LIBRARY}
resolv
)

else()
Expand Down
2 changes: 1 addition & 1 deletion scripts/eosio_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ if [ "$ARCH" == "Darwin" ]; then
export OS_NAME=MacOSX
# opt/gettext: cleos requires Intl, which requires gettext; it's keg only though and we don't want to force linking: https://github.com/EOSIO/eos/issues/2240#issuecomment-396309884
# HOME/lib/cmake: mongo_db_plugin.cpp:25:10: fatal error: 'bsoncxx/builder/basic/kvp.hpp' file not found
LOCAL_CMAKE_FLAGS="-DCMAKE_PREFIX_PATH=/usr/local/opt/gettext;$HOME/lib/cmake ${LOCAL_CMAKE_FLAGS}"
LOCAL_CMAKE_FLAGS="-DCMAKE_PREFIX_PATH=/usr/local/opt/gettext;$PREFIX ${LOCAL_CMAKE_FLAGS}"
FILE="${REPO_ROOT}/scripts/eosio_build_darwin.sh"
OPENSSL_ROOT_DIR=/usr/local/opt/openssl
fi
Expand Down
131 changes: 69 additions & 62 deletions scripts/eosio_build_amazon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ DISK_AVAIL_KB=$( df . | tail -1 | awk '{print $4}' )
DISK_TOTAL=$(( DISK_TOTAL_KB / 1048576 ))
DISK_AVAIL=$(( DISK_AVAIL_KB / 1048576 ))

if [ "$BUILD_CLANG8" = "true" ]; then
PINNED_TOOLCHAIN=-DCMAKE_TOOLCHAIN_FILE=$BUILD_DIR/pinned_toolchain.cmake
fi

DEP_ARRAY=(
git procps-ng util-linux gcc gcc-c++ autoconf automake libtool make bzip2 \
bzip2-devel openssl-devel gmp-devel libstdc++ libcurl-devel libusbx-devel \
Expand Down Expand Up @@ -142,8 +146,8 @@ fi
if [ $? -ne 0 ]; then exit -1; fi


printf "\\n"

printf "\\n"

if [ $PIN_COMPILER ]; then
printf "Checking Clang 8 support...\\n"
Expand Down Expand Up @@ -257,67 +261,6 @@ else

printf "\\n"

if [ $BUILD_MONGO ]; then
printf "Checking MongoDB installation...\\n"
if [ ! -d $MONGODB_ROOT ] || [ $FORCE_BUILD ]; then
printf "Installing MongoDB into ${MONGODB_ROOT}...\\n"
curl -OL https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \
&& tar -xzf mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \
&& mv $SRC_LOCATION/mongodb-linux-x86_64-amazon-$MONGODB_VERSION $MONGODB_ROOT \
&& touch $MONGODB_LOG_LOCATION/mongod.log \
&& rm -f mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \
&& cp -f $REPO_ROOT/scripts/mongod.conf $MONGODB_CONF \
&& mkdir -p $MONGODB_DATA_LOCATION \
&& rm -rf $MONGODB_LINK_LOCATION \
&& rm -rf $BIN_LOCATION/mongod \
&& ln -s $MONGODB_ROOT $MONGODB_LINK_LOCATION \
&& ln -s $MONGODB_LINK_LOCATION/bin/mongod $BIN_LOCATION/mongod \
|| exit 1
printf " - MongoDB successfully installed @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n"
else
printf " - MongoDB found with correct version @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi
printf "Checking MongoDB C driver installation...\\n"
if [ ! -d $MONGO_C_DRIVER_ROOT ] || [ $FORCE_BUILD ]; then
printf "Installing MongoDB C driver...\\n"
curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/$MONGO_C_DRIVER_VERSION/mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \
&& tar -xzf mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \
&& cd mongo-c-driver-$MONGO_C_DRIVER_VERSION \
&& mkdir -p cmake-build \
&& cd cmake-build \
&& $CMAKE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX -DENABLE_BSON=ON -DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON .. \
&& make -j"${JOBS}" \
&& make install \
&& cd ../.. \
&& rm mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \
|| exit 1
printf " - MongoDB C driver successfully installed @ ${MONGO_C_DRIVER_ROOT}.\\n"
else
printf " - MongoDB C driver found with correct version @ ${MONGO_C_DRIVER_ROOT}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi
printf "Checking MongoDB C++ driver installation...\\n"
if [ ! -d $MONGO_CXX_DRIVER_ROOT ] || [ $FORCE_BUILD ]; then
printf "Installing MongoDB C++ driver...\\n"
curl -L https://github.com/mongodb/mongo-cxx-driver/archive/r$MONGO_CXX_DRIVER_VERSION.tar.gz -o mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \
&& tar -xzf mongo-cxx-driver-r${MONGO_CXX_DRIVER_VERSION}.tar.gz \
&& cd mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION/build \
&& $CMAKE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX .. \
&& make -j"${JOBS}" VERBOSE=1 \
&& make install \
&& cd ../.. \
&& rm -f mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \
|| exit 1
printf " - MongoDB C++ driver successfully installed @ ${MONGO_CXX_DRIVER_ROOT}.\\n"
else
printf " - MongoDB C++ driver found with correct version @ ${MONGO_CXX_DRIVER_ROOT}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi

printf "\\n"
fi

printf "Checking LLVM 4 support...\\n"
if [ ! -d $LLVM_ROOT ] || [ $FORCE_BUILD ]; then
printf "Installing LLVM 4...\\n"
Expand All @@ -341,6 +284,70 @@ else
printf "\\n"
fi

if [ $BUILD_MONGO ]; then
printf "Checking MongoDB installation...\\n"
if [ ! -d $MONGODB_ROOT ] || [ $FORCE_BUILD ]; then
printf "Installing MongoDB into ${MONGODB_ROOT}...\\n"
curl -OL https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \
&& tar -xzf mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \
&& mv $SRC_LOCATION/mongodb-linux-x86_64-amazon-$MONGODB_VERSION $MONGODB_ROOT \
&& touch $MONGODB_LOG_LOCATION/mongod.log \
&& rm -f mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \
&& cp -f $REPO_ROOT/scripts/mongod.conf $MONGODB_CONF \
&& mkdir -p $MONGODB_DATA_LOCATION \
&& rm -rf $MONGODB_LINK_LOCATION \
&& rm -rf $BIN_LOCATION/mongod \
&& ln -s $MONGODB_ROOT $MONGODB_LINK_LOCATION \
&& ln -s $MONGODB_LINK_LOCATION/bin/mongod $BIN_LOCATION/mongod \
|| exit 1
printf " - MongoDB successfully installed @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n"
else
printf " - MongoDB found with correct version @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi
printf "Checking MongoDB C driver installation...\\n"
if [ ! -d $MONGO_C_DRIVER_ROOT ] || [ $FORCE_BUILD ]; then
printf "Installing MongoDB C driver...\\n"
curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/$MONGO_C_DRIVER_VERSION/mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \
&& tar -xzf mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \
&& cd mongo-c-driver-$MONGO_C_DRIVER_VERSION \
&& mkdir -p cmake-build \
&& cd cmake-build \
&& $CMAKE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX -DENABLE_BSON=ON -DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON -DENABLE_ICU=OFF $PINNED_TOOLCHAIN .. \
&& make -j"${JOBS}" \
&& make install \
&& cd ../.. \
&& rm mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \
|| exit 1
printf " - MongoDB C driver successfully installed @ ${MONGO_C_DRIVER_ROOT}.\\n"
else
printf " - MongoDB C driver found with correct version @ ${MONGO_C_DRIVER_ROOT}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi
printf "Checking MongoDB C++ driver installation...\\n"
if [ ! -d $MONGO_CXX_DRIVER_ROOT ] || [ $FORCE_BUILD ]; then
printf "Installing MongoDB C++ driver...\\n"
curl -L https://github.com/mongodb/mongo-cxx-driver/archive/r$MONGO_CXX_DRIVER_VERSION.tar.gz -o mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \
&& tar -xzf mongo-cxx-driver-r${MONGO_CXX_DRIVER_VERSION}.tar.gz \
&& cd mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION \
&& sed -i 's/"maxAwaitTimeMS", count/"maxAwaitTimeMS", static_cast<int64_t>(count)/' src/mongocxx/options/change_stream.cpp \
&& sed -i 's/add_subdirectory(test)//' src/mongocxx/CMakeLists.txt src/bsoncxx/CMakeLists.txt \
&& cd build \
&& $CMAKE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_PREFIX_PATH=$PREFIX $PINNED_TOOLCHAIN .. \
&& make -j"${JOBS}" VERBOSE=1 \
&& make install \
&& cd ../.. \
&& rm -f mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \
|| exit 1
printf " - MongoDB C++ driver successfully installed @ ${MONGO_CXX_DRIVER_ROOT}.\\n"
else
printf " - MongoDB C++ driver found with correct version @ ${MONGO_CXX_DRIVER_ROOT}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi

printf "\\n"
fi

function print_instructions() {
return 0
}
Loading

0 comments on commit cdde673

Please sign in to comment.