diff --git a/.gitignore b/.gitignore index 913a149b9eda..f2b64bee7a55 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,8 @@ projects/* !projects/*.* !projects/Makefile .venv +deps-install +deps-download #==============================================================================# # Autotools artifacts diff --git a/README.md b/README.md index 9bc7a46e0fe7..198766d6441e 100644 --- a/README.md +++ b/README.md @@ -85,11 +85,13 @@ dependencies for a given platform. ### Setting up dependencies The following setup scripts use the `DEPENDENCY_DIR` environment variable to set the -location of the build packages. If you do not set this variable, it will default to -the current working directory. +location to download and build packages. This defaults to `deps-download` in the current +working directory. Use `INSTALL_PREFIX` to set the install directory of the packages. +This defaults to `deps-install` in the current working directory on MacOS. ```shell $ export DEPENDENCY_DIR=/path/to/your/dependencies +$ export INSTALL_PREFIX=/Users/$USERNAME/velox/velox_dependency_install ``` ### Setting up on macOS @@ -97,7 +99,6 @@ $ export DEPENDENCY_DIR=/path/to/your/dependencies On a MacOS machine (either Intel or Apple silicon) you can setup and then build like so: ```shell -$ export INSTALL_PREFIX=/Users/$USERNAME/velox/velox_dependency_install $ ./scripts/setup-macos.sh $ make ``` diff --git a/scripts/setup-helper-functions.sh b/scripts/setup-helper-functions.sh index bf5e7d9c5c55..7d3802f5da42 100755 --- a/scripts/setup-helper-functions.sh +++ b/scripts/setup-helper-functions.sh @@ -16,6 +16,8 @@ # github_checkout $REPO $VERSION $GIT_CLONE_PARAMS clones or re-uses an existing clone of the # specified repo, checking out the requested version. +DEPENDENCY_DIR=${DEPENDENCY_DIR:-$(pwd)/deps-download} + function run_and_time { time "$@" || (echo "Failed to run $* ." ; exit 1 ) { echo "+ Finished running $*"; } 2> /dev/null @@ -156,29 +158,36 @@ function get_cxx_flags { function wget_and_untar { local URL=$1 local DIR=$2 + mkdir -p "${DEPENDENCY_DIR}" + pushd "${DEPENDENCY_DIR}" mkdir -p "${DIR}" pushd "${DIR}" curl -L "${URL}" > $2.tar.gz tar -xz --strip-components=1 -f $2.tar.gz popd + popd } function cmake_install { + local DWLD_DIR=$(pwd) + mkdir -p "${DEPENDENCY_DIR}" + pushd "${DEPENDENCY_DIR}" if [ -d "$1" ]; then DIR="$1" shift else DIR=$(pwd) fi + pushd "${DIR}" local NAME=$(basename "$(pwd)") local BINARY_DIR=_build SUDO="${SUDO:-""}" - pushd "${DIR}" if [ -d "${BINARY_DIR}" ] && prompt "Do you want to rebuild ${NAME}?"; then ${SUDO} rm -rf "${BINARY_DIR}" fi mkdir -p "${BINARY_DIR}" COMPILER_FLAGS=$(get_cxx_flags) + COMPILER_FLAGS+=${CXXFLAGS} # CMAKE_POSITION_INDEPENDENT_CODE is required so that Velox can be built into dynamic libraries \ cmake -Wno-dev -B"${BINARY_DIR}" \ @@ -194,5 +203,6 @@ function cmake_install { cmake --build "${BINARY_DIR}" || { echo 'build failed' ; exit 1; } ${SUDO} cmake --install "${BINARY_DIR}" popd + popd } diff --git a/scripts/setup-macos.sh b/scripts/setup-macos.sh index d4eb3315e573..e723545c7ca9 100755 --- a/scripts/setup-macos.sh +++ b/scripts/setup-macos.sh @@ -29,12 +29,12 @@ set -e # Exit on error. set -x # Print commands that are executed. SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}") +INSTALL_PREFIX=${INSTALL_PREFIX:-"$(pwd)/deps-install"} source $SCRIPTDIR/setup-helper-functions.sh PYTHON_VENV=${PYHTON_VENV:-"${SCRIPTDIR}/../.venv"} - +export CXXFLAGS=" -isystem $(brew --prefix)/include" NPROC=$(getconf _NPROCESSORS_ONLN) -DEPENDENCY_DIR=${DEPENDENCY_DIR:-$(pwd)} MACOS_VELOX_DEPS="bison flex gflags glog googletest icu4c libevent libsodium lz4 lzo openssl protobuf@21 snappy xz zstd" MACOS_BUILD_DEPS="ninja cmake ccache" FB_OS_VERSION="v2024.05.20.00" diff --git a/scripts/setup-ubuntu.sh b/scripts/setup-ubuntu.sh index e40bba1d9923..b3ec1a25cd28 100755 --- a/scripts/setup-ubuntu.sh +++ b/scripts/setup-ubuntu.sh @@ -35,7 +35,6 @@ source $SCRIPTDIR/setup-helper-functions.sh COMPILER_FLAGS=$(get_cxx_flags) export COMPILER_FLAGS NPROC=$(getconf _NPROCESSORS_ONLN) -DEPENDENCY_DIR=${DEPENDENCY_DIR:-$(pwd)} BUILD_DUCKDB="${BUILD_DUCKDB:-true}" export CMAKE_BUILD_TYPE=Release SUDO="${SUDO:-"sudo --preserve-env"}"