Skip to content

Commit

Permalink
Add default INSTALL_PREFIX and DEPENDENCY_DIR
Browse files Browse the repository at this point in the history
  • Loading branch information
majetideepak committed Sep 4, 2024
1 parent 5bafa2f commit 2609922
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ projects/*
!projects/*.*
!projects/Makefile
.venv
deps-install
deps-download

#==============================================================================#
# Autotools artifacts
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,20 @@ 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

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
```
Expand Down
12 changes: 11 additions & 1 deletion scripts/setup-helper-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}" \
Expand All @@ -194,5 +203,6 @@ function cmake_install {
cmake --build "${BINARY_DIR}" || { echo 'build failed' ; exit 1; }
${SUDO} cmake --install "${BINARY_DIR}"
popd
popd
}

4 changes: 2 additions & 2 deletions scripts/setup-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion scripts/setup-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"}"
Expand Down

0 comments on commit 2609922

Please sign in to comment.