Skip to content

Commit

Permalink
Split off build environment configuration to a dedicated file
Browse files Browse the repository at this point in the history
  • Loading branch information
native-api committed Jan 24, 2018
1 parent b9071fc commit a414ba0
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 24 deletions.
11 changes: 7 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ functions and variables in earlier scripts:
* multibuild/common_utils.sh
* multibuild/osx_utils.sh
* env_vars.sh
* multibuild/configure_build.sh
* multibuild/library_builders.sh
* config.sh

Expand Down Expand Up @@ -80,6 +81,7 @@ following bash scripts:
* multibuild/common_utils.sh
* multibuild/manylinux_utils.sh
* env_vars.sh
* multibuild/configure_build.sh
* multibuild/library_builders.sh
* config.sh

Expand Down Expand Up @@ -321,10 +323,11 @@ To use these scripts
Optionally you can specify a different location for ``config.sh`` file with
the ``$CONFIG_PATH`` environment variable.

* Optionally, create an ``env_vars.sh`` file to set defaults for any build
environment variables used in ``library_builders.sh``. In Linux, they cannot
be just set in the global environment because the build runs in Docker, so
only the variables explicitly passed to ``docker run`` are propagated.
* Optionally, create an ``env_vars.sh`` file to override the defaults for any
environment variables used by ``configure_build.sh``/``library_builders.sh``.
In Linux, they cannot be just set in the initial environment because the
build runs in Docker, so only the variables explicitly passed to
``docker run`` are propagated.

Likewise, you can specify a different location for the file by setting the
the ``$ENV_VARS_PATH`` environment variable.
Expand Down
23 changes: 23 additions & 0 deletions configure_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Find, load common utilities
# Defines IS_OSX, fetch_unpack
MULTIBUILD_DIR=$(dirname "${BASH_SOURCE[0]}")
source $MULTIBUILD_DIR/common_utils.sh

PLAT="${PLAT:x86_64}"
BUILD_PREFIX="${BUILD_PREFIX:-/usr/local}"

# Default compilation flags for OSX
# IS_OSX is defined in common_utils.sh
if [ -n "$IS_OSX" ]; then
# Dual arch build by default
ARCH_FLAGS=${ARCH_FLAGS:-"-arch i386 -arch x86_64"}
# Only set CFLAGS, FFLAGS if they are not already defined. Build functions
# can override the arch flags by setting CFLAGS, FFLAGS
export CFLAGS="${CFLAGS:-$ARCH_FLAGS}"
export CXXFLAGS="${CXXFLAGS:-$ARCH_FLAGS}"
export FFLAGS="${FFLAGS:-$ARCH_FLAGS}"
fi

# Promote BUILD_PREFIX on search path to any newly built libs
export CPPFLAGS="-L$BUILD_PREFIX/include $CPPFLAGS"
export LIBRARY_PATH="$BUILD_PREFIX/lib:$LIBRARY_PATH"
1 change: 1 addition & 0 deletions docker_build_wrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ MULTIBUILD_DIR=$(dirname "${BASH_SOURCE[0]}")
# These routines also source common_utils.sh
source $MULTIBUILD_DIR/manylinux_utils.sh
if [ -r "$ENV_VARS_PATH" ]; then source "$ENV_VARS_PATH"; fi
source $MULTIBUILD_DIR/configure_build.sh
source $MULTIBUILD_DIR/library_builders.sh

if [ "$USE_CCACHE" == "1" ]; then
Expand Down
19 changes: 3 additions & 16 deletions library_builders.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Find, load common utilities
# Defines IS_OSX, fetch_unpack
#Functions and environment variables to build various
#native libraries commonly used as dependencies

MULTIBUILD_DIR=$(dirname "${BASH_SOURCE[0]}")
source $MULTIBUILD_DIR/common_utils.sh
source $MULTIBUILD_DIR/_gfortran_utils.sh

# For OpenBLAS
PLAT="${PLAT:x86_64}"
GF_LIB_URL="https://3f23b170c54c2533c070-1c8a9b3114517dc5fe17b7c3f8c63a43.ssl.cf2.rackcdn.com"

# Recipes for building some libraries
Expand Down Expand Up @@ -45,20 +44,8 @@ OPENSSL_HASH=ce07195b659e75f4e1db43552860070061f156a98bb37b672b101ba6e3ddf30c
OPENSSL_DOWNLOAD_URL=https://www.openssl.org/source


BUILD_PREFIX="${BUILD_PREFIX:-/usr/local}"
ARCHIVE_SDIR=${ARCHIVE_DIR:-archives}

# Set default library compilation flags for OSX
# IS_OSX defined in common_utils.sh
if [ -n "$IS_OSX" ]; then
# Dual arch build by default
ARCH_FLAGS=${ARCH_FLAGS:-"-arch i386 -arch x86_64"}
# Only set CFLAGS, FFLAGS if they are not already defined. Build functions
# can override the arch flags by setting CFLAGS, FFLAGS
export CFLAGS="${CFLAGS:-$ARCH_FLAGS}"
export CXXFLAGS="${CXXFLAGS:-$ARCH_FLAGS}"
export FFLAGS="${FFLAGS:-$ARCH_FLAGS}"
fi

function build_simple {
# Example: build_simple libpng $LIBPNG_VERSION \
Expand Down
1 change: 1 addition & 0 deletions tests/test_library_builders.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Smoke test
export BUILD_PREFIX="${PWD}/builds"
rm_mkdir $BUILD_PREFIX
source configure_build.sh
source library_builders.sh

# set -e -x
Expand Down
1 change: 1 addition & 0 deletions travis_osx_steps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ENV_VARS_PATH=${ENV_VARS_PATH:-env_vars.sh}
# These load common_utils.sh
source $MULTIBUILD_DIR/osx_utils.sh
if [ -r "$ENV_VARS_PATH" ]; then source "$ENV_VARS_PATH"; fi
source $MULTIBUILD_DIR/configure_build.sh
source $MULTIBUILD_DIR/library_builders.sh

# NB - config.sh sourced at end of this function.
Expand Down
4 changes: 0 additions & 4 deletions travis_steps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,3 @@ if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
else
source $MULTIBUILD_DIR/travis_linux_steps.sh
fi

# Promote BUILD_PREFIX on search path to any newly built libs
export CPPFLAGS="-L$BUILD_PREFIX/include $CPPFLAGS"
export LIBRARY_PATH="$BUILD_PREFIX/lib:$LIBRARY_PATH"

0 comments on commit a414ba0

Please sign in to comment.