Skip to content

Commit c467b17

Browse files
authored
Add Travis CI integration (#1)
Add CI scripts, and fix a build error in g++-7 (see https://en.cppreference.com/w/cpp/string/byte/isspace).
1 parent ed30569 commit c467b17

11 files changed

+222
-8
lines changed

Diff for: .travis.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
language: cpp
2+
dist: bionic
3+
compiler: gcc
4+
sudo: false
5+
6+
# Only build master or PRs merging into master
7+
branches:
8+
only:
9+
- master
10+
11+
# List of configurations to check
12+
matrix:
13+
include:
14+
- os: linux
15+
env: FLIBCPP_DEV=ON GENERATOR=ninja
16+
FLIBCPP_FORTRAN_STD=f2003
17+
addons:
18+
apt:
19+
packages:
20+
- gfortran
21+
- python3-sphinx
22+
- os: linux
23+
env: FLIBCPP_DEV=OFF GENERATOR=make
24+
FLIBCPP_FORTRAN_STD=f2008
25+
addons:
26+
apt:
27+
packages:
28+
- gfortran
29+
- os: linux
30+
env: FLIBCPP_DEV=OFF GENERATOR=make
31+
FLIBCPP_FORTRAN_STD=f2008
32+
addons:
33+
apt:
34+
packages:
35+
- gfortran
36+
37+
# Build phases
38+
before_install:
39+
- source ./scripts/travis/before_install.sh
40+
install:
41+
- ./scripts/travis/install.sh
42+
script:
43+
- run_script configure
44+
- run_script compile
45+
- run_script test
46+
- run_script deploy

Diff for: CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ project(Flibcpp VERSION 0.2.1 LANGUAGES CXX Fortran)
1212
# OPTIONS
1313
#---------------------------------------------------------------------------#
1414

15+
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
1516
option(FLIBCPP_DEV "Default to using development-centered options" OFF)
1617
option(FLIBCPP_BUILD_DOCS "Build documentation with Sphinx" ${FLIBCPP_DEV})
17-
option(FLIBCPP_USE_SWIG "Regenerate source files using SWIG" ${FLIBCPP_DEV})
18-
option(FLIBCPP_BUILD_TESTS "Build unit tests" ${FLIBCPP_DEV})
1918
option(FLIBCPP_BUILD_EXAMPLES "Build examples" ON)
20-
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
19+
option(FLIBCPP_BUILD_TESTS "Build unit tests" ${FLIBCPP_DEV})
20+
option(FLIBCPP_USE_SWIG "Regenerate source files using SWIG" ${FLIBCPP_DEV})
2121

2222
#---------------------------------------------------------------------------#
2323
# FLAGS

Diff for: example/run-examples.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
FAIL=0
44

5-
function overall_result()
5+
function overall_result
66
{
77
exit ${FAIL}
88
}
99
trap overall_result EXIT
1010

11-
function run_test()
11+
function run_test
1212
{
1313
local TESTNAME=$1
1414
local EXE=./${TESTNAME}.exe

Diff for: include/flc_string.i

+2-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ class string {
125125

126126
%fragment("flc_has_junk", "header", fragment="<cctype>", fragment="<algorithm>") %{
127127
SWIGINTERN bool flc_has_junk(const std::string& s, size_t pos) {
128-
return !std::all_of(s.begin() + pos, s.end(), std::isspace);
128+
return !std::all_of(s.begin() + pos, s.end(),
129+
[](unsigned char c) -> bool { return std::isspace(c); });
129130
}
130131
%}
131132

Diff for: scripts/travis/before_install.sh

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash -e
2+
###############################################################################
3+
# File : example/before_install.sh
4+
###############################################################################
5+
6+
export SOURCE_ROOT=${PWD}
7+
export BUILD_ROOT=${SOURCE_ROOT}/build
8+
export INSTALL_ROOT=${HOME}/install
9+
export CMAKE_PREFIX_PATH=${INSTALL_ROOT}:${CMAKE_PREFIX_PATH}
10+
export PATH=${INSTALL_ROOT}/bin:${PATH}
11+
export FC=${FC:-gfortran}
12+
13+
mkdir -p ${BUILD_ROOT}
14+
15+
# Define a command (using built-in travis functions) to launch one of our
16+
# scripts
17+
function run_script {
18+
set +x
19+
set -e
20+
fold_start $1 "$2"
21+
local scriptloc="${SOURCE_ROOT}/scripts/travis/$1.sh"
22+
echo "Running ${scriptloc}"
23+
${scriptloc}
24+
local result=$?
25+
fold_end $1
26+
return $?
27+
}
28+
29+
###############################################################################
30+
# UTILITIES FROM TRAVIS
31+
#
32+
# from https://github.com/travis-ci/travis-rubies/blob/build/build.sh
33+
###############################################################################
34+
35+
function fold_start() {
36+
echo -e "travis_fold:start:$1\033[33;1m$2\033[0m"
37+
}
38+
39+
function fold_end() {
40+
echo -e "\ntravis_fold:end:$1\r"
41+
}
42+
43+
###############################################################################
44+
# end of example/before_install.sh
45+
###############################################################################

Diff for: scripts/travis/compile.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh -e
2+
###############################################################################
3+
# File : scripts/travis/compile.sh
4+
###############################################################################
5+
6+
cd ${BUILD_ROOT} && ${GENERATOR}
7+
8+
###############################################################################
9+
# end of scripts/travis/compile.sh
10+
###############################################################################

Diff for: scripts/travis/configure.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh -e
2+
###############################################################################
3+
# File : scripts/travis/configure.sh
4+
###############################################################################
5+
6+
if [ "${GENERATOR}" = "ninja" ]; then
7+
CMAKE_GENERATOR="Ninja"
8+
elif [ "${GENERATOR}" = "make" ]; then
9+
CMAKE_GENERATOR="Unix Makefiles"
10+
else
11+
echo "Invalid generator '${GENERATOR}'"
12+
exit 1
13+
fi
14+
15+
CXX_FLAGS="-Wall -Wextra -Werror"
16+
Fortran_FLAGS="-Wall -Wextra -Wimplicit-procedure -Wimplicit-interface -Wno-compare-reals -Wno-maybe-uninitialized"
17+
18+
set -x
19+
cd ${BUILD_ROOT} && cmake -G "${CMAKE_GENERATOR}" \
20+
-D FLIBCPP_DEV=${FLIBCPP_DEV} \
21+
-D FLIBCPP_BUILD_EXAMPLES=ON \
22+
-D FLIBCPP_BUILD_TESTS=ON \
23+
-D FLIBCPP_FORTRAN_STD="${FLIBCPP_FORTRAN_STD}" \
24+
-D CMAKE_CXX_FLAGS="${CXX_FLAGS}" \
25+
-D CMAKE_Fortran_FLAGS="${Fortran_FLAGS}" \
26+
-D CMAKE_INSTALL_PREFIX="${INSTALL_ROOT}" \
27+
${SOURCE_ROOT}
28+
29+
###############################################################################
30+
# end of scripts/travis/configure.sh
31+
###############################################################################

Diff for: scripts/travis/deploy.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh -e
2+
###############################################################################
3+
# File : scripts/travis/deploy.sh
4+
###############################################################################
5+
6+
if [ $(uname -s) = "Darwin" ]; then
7+
SO_EXT=.dylib
8+
else
9+
SO_EXT=.so
10+
fi
11+
12+
set -x
13+
cd ${BUILD_ROOT} && ${GENERATOR} install
14+
15+
# Test existence of install files
16+
17+
if [ "${FLIBCPP_DEV}" = "ON" ]; then
18+
test -f ${INSTALL_ROOT}/share/doc/Flibcpp/index.html
19+
test -f ${INSTALL_ROOT}/include/flc.i
20+
fi
21+
22+
test -f ${INSTALL_ROOT}/include/flc.mod
23+
test -f ${INSTALL_ROOT}/lib/libflc${SO_EXT}
24+
test -f ${INSTALL_ROOT}/lib/cmake/Flibcpp/FlibcppConfig.cmake
25+
26+
###############################################################################
27+
# end of scripts/travis/deploy.sh
28+
###############################################################################

Diff for: scripts/travis/install.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh -e
2+
###############################################################################
3+
# File : scripts/travis/install.sh
4+
#
5+
# Install dependencies.
6+
###############################################################################
7+
8+
set -x
9+
10+
mkdir -p ${INSTALL_ROOT}/bin
11+
12+
if [ "${GENERATOR}" = "ninja" ]; then
13+
# Install Ninja
14+
cd $(mktemp -d)
15+
NINJA_VERSION=1.9.0.g99df1.kitware.dyndep-1.jobserver-1
16+
curl -L https://github.com/Kitware/ninja/releases/download/v${NINJA_VERSION}/ninja-${NINJA_VERSION}_x86_64-linux-gnu.tar.gz \
17+
| tar -xz --strip 1
18+
mv ninja ${INSTALL_ROOT}/bin
19+
echo "Installed Ninja version: $(ninja --version | head -1)"
20+
fi
21+
22+
echo "Fortran compiler: ${FC}"
23+
if hash "${FC}" 2>/dev/null; then
24+
echo "Compiler version: $(${FC} --version | head -1)"
25+
fi
26+
27+
if [ "${FLIBCPP_DEV}" = "ON" ]; then
28+
# Install SWIG-fortran
29+
cd $(mktemp -d)
30+
git clone --depth=1 https://github.com/swig-fortran/swig
31+
cd swig
32+
echo "SWIG git revision: $(git rev-parse HEAD)"
33+
./autogen.sh
34+
./configure --prefix="${INSTALL_ROOT}" --without-alllang --with-fortran=$FC
35+
make
36+
make install
37+
echo "Installed SWIG version: $(swig -version | grep SWIG)"
38+
fi
39+
40+
###############################################################################
41+
# end of scripts/travis/install.sh
42+
###############################################################################

Diff for: scripts/travis/test.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh -e
2+
###############################################################################
3+
# File : scripts/travis/test.sh
4+
###############################################################################
5+
6+
cd ${BUILD_ROOT} && ctest --output-on-failure
7+
8+
###############################################################################
9+
# end of scripts/travis/test.sh
10+
###############################################################################

Diff for: src/flc_stringFORTRAN_wrap.cxx

+2-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,8 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) {
427427

428428

429429
SWIGINTERN bool flc_has_junk(const std::string& s, size_t pos) {
430-
return !std::all_of(s.begin() + pos, s.end(), std::isspace);
430+
return !std::all_of(s.begin() + pos, s.end(),
431+
[](unsigned char c) -> bool { return std::isspace(c); });
431432
}
432433

433434
extern "C" {

0 commit comments

Comments
 (0)