Skip to content

Commit e36462b

Browse files
committed
Merge branch 'use-conda-toolchain'
Build and test conda package with Anaconda C++ compiler. Adhere to compiler flags environment variables.
2 parents 2a1042f + 7707cb2 commit e36462b

File tree

5 files changed

+27
-9
lines changed

5 files changed

+27
-9
lines changed

.travis.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,13 @@ before_install:
4444
- MYMCREPO=https://repo.continuum.io/miniconda
4545
- case ${TRAVIS_OS_NAME} in
4646
linux)
47-
MYMCBUNDLE=Miniconda3-latest-Linux-x86_64.sh ;;
47+
MYMCBUNDLE=Miniconda3-latest-Linux-x86_64.sh;
48+
MYCXXCOMPILER=gxx_linux-64
49+
;;
4850
osx)
49-
MYMCBUNDLE=Miniconda3-latest-MacOSX-x86_64.sh ;;
51+
MYMCBUNDLE=Miniconda3-latest-MacOSX-x86_64.sh;
52+
MYCXXCOMPILER=clangxx_osx-64
53+
;;
5054
*)
5155
echo "Unsupported operating system." >&2;
5256
exit 2 ;;
@@ -61,7 +65,7 @@ before_install:
6165
- $NOMC || source ~/mc/bin/activate root
6266
- $NOMC || conda update --yes conda
6367
- $NOMC || conda install --yes conda-build jinja2
64-
- $NOMC || conda create --name=testenv --yes python=${MYPYTHON_VERSION}
68+
- $NOMC || conda create --name=testenv --yes $MYCXXCOMPILER
6569
- $NOMC || conda config --add channels diffpy
6670

6771
- $NOAPT || test "${TRAVIS_OS_NAME}" = "linux" || exit $?
@@ -107,17 +111,16 @@ install:
107111
exit 1;
108112
fi
109113

110-
- $NOMC || export LIBRARY_PATH="${MYLIB}"
111-
- $NOMC || export CPATH="${MYINCLUDE}"
112-
- $NOMC || MYLINKFLAGS="-Wl,-rpath,${MYLIB}"
114+
- $NOMC || MYCOMPILEFLAGS="-I${MYINCLUDE} ${CXXFLAGS} ${CPPFLAGS}"
115+
- $NOMC || MYLINKFLAGS="-L${MYLIB} ${LDFLAGS} -Wl,-rpath,${MYLIB}"
113116

114117

115118
before_script:
116119
- cd "${TRAVIS_BUILD_DIR}/examples"
117120

118121

119122
script:
120-
- $CXX -o testlib testlib.cpp -lObjCryst $MYLINKFLAGS
123+
- $CXX -o testlib $MYCOMPILEFLAGS testlib.cpp -lObjCryst $MYLINKFLAGS
121124
- ./testlib
122125

123126

conda-recipe/build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/bash
22

3-
export CPATH="$PREFIX/include:$CPATH"
43
MYNCPU=$(( (CPU_COUNT > 8) ? 8 : CPU_COUNT ))
54

5+
# Apply sconscript.local customizations.
6+
cp ${RECIPE_DIR}/sconscript.local ./
7+
68
scons -j $MYNCPU
79
scons install prefix=$PREFIX

conda-recipe/meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ build:
1313

1414
requirements:
1515
build:
16+
- {{ compiler('cxx') }}
1617
- python
1718
- scons
1819
host:

conda-recipe/sconscript.local

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Customize scons build environment.
2+
3+
Import('env')
4+
5+
import os
6+
7+
# Silence copious warnings from the boost headers.
8+
P = os.environ['PREFIX']
9+
env.Prepend(CCFLAGS=['-isystem{}/include'.format(P)])
10+
env.Replace(CXX=os.environ['CXX'])
11+
12+
# vim: ft=python

src/SConscript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Import('env')
55
# Build environment configuration --------------------------------------------
66

77
# Apply CFLAGS, CXXFLAGS, LDFLAGS from the system environment.
8-
flagnames = 'CFLAGS CXXFLAGS LDFLAGS'.split()
8+
flagnames = 'CFLAGS CXXFLAGS CPPFLAGS LDFLAGS'.split()
99
env.MergeFlags([os.environ.get(n, '') for n in flagnames])
1010

1111
# Insert LIBRARY_PATH explicitly because some compilers

0 commit comments

Comments
 (0)