diff --git a/.ci/travis-build.sh b/.ci/travis-build.sh new file mode 100755 index 0000000..6c76689 --- /dev/null +++ b/.ci/travis-build.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -e -x + +# set RTEMS to eg. "4.9" or "4.10" +# requires qemu, bison, flex, texinfo, install-info +if [ -n "$RTEMS" ] +then + # find local qemu-system-i386 + export PATH="$HOME/.cache/qemu/usr/bin:$PATH" + echo -n "Using QEMU: " + type qemu-system-i386 || echo "Missing qemu" + EXTRA=RTEMS_QEMU_FIXUPS=YES +fi + +make -j2 $EXTRA + +if [ "$TEST" != "NO" ] +then + make tapfiles + find . -name '*.tap' -print0 | xargs -0 -n1 prove -e cat -f +fi diff --git a/.ci/travis-prepare.sh b/.ci/travis-prepare.sh new file mode 100755 index 0000000..6d40fb1 --- /dev/null +++ b/.ci/travis-prepare.sh @@ -0,0 +1,180 @@ +#!/bin/sh +set -e -x + +CURDIR="$PWD" + +QDIR="$HOME/.cache/qemu" + +if [ -n "$RTEMS" -a "$TEST" = "YES" ] +then + git clone --quiet --branch vme --depth 10 https://github.com/mdavidsaver/qemu.git "$HOME/.build/qemu" + cd "$HOME/.build/qemu" + + HEAD=`git log -n1 --pretty=format:%H` + echo "HEAD revision $HEAD" + + [ -e "$HOME/.cache/qemu/built" ] && BUILT=`cat "$HOME/.cache/qemu/built"` + echo "Cached revision $BUILT" + + if [ "$HEAD" != "$BUILT" ] + then + echo "Building QEMU" + git submodule --quiet update --init + + install -d "$HOME/.build/qemu/build" + cd "$HOME/.build/qemu/build" + + "$HOME/.build/qemu/configure" --prefix="$HOME/.cache/qemu/usr" --target-list=i386-softmmu --disable-werror + make -j2 + make install + + echo "$HEAD" > "$HOME/.cache/qemu/built" + fi +fi + +cat << EOF > $CURDIR/configure/RELEASE.local +EPICS_BASE=$HOME/.source/epics-base +EOF + +install -d "$HOME/.source" +cd "$HOME/.source" + +add_base_module() { + MODULE=$1 + BRANCH=$2 + ( cd epics-base/modules && \ + git clone --quiet --depth 5 --branch $MODULE/$BRANCH https://github.com/${REPOBASE:-epics-base}/epics-base.git $MODULE && \ + cd $MODULE && git log -n1 ) +} + +add_gh_module() { + MODULE=$1 + REPOOWNER=$2 + REPONAME=$3 + BRANCH=$4 + ( cd epics-base/modules && \ + git clone --quiet --depth 5 --branch $BRANCH https://github.com/$REPOOWNER/$REPONAME.git $MODULE && \ + cd $MODULE && git log -n1 ) +} + +add_gh_flat() { + MODULE=$1 + REPOOWNER=$2 + REPONAME=$3 + BRANCH=$4 + MODULE_UC=$(echo $MODULE | tr 'a-z' 'A-Z') + ( git clone --quiet --depth 5 --branch $BRANCH https://github.com/$REPOOWNER/$REPONAME.git $MODULE && \ + cd $MODULE && git log -n1 ) + cat < $CURDIR/configure/RELEASE.local > $MODULE/configure/RELEASE.local + cat << EOF >> $CURDIR/configure/RELEASE.local +${MODULE_UC}=$HOME/.source/$MODULE +EOF +} + +if [ "$BRBASE" ] +then + git clone --quiet --depth 5 --branch "$BRBASE" https://github.com/${REPOBASE:-epics-base}/epics-base.git epics-base + (cd epics-base && git log -n1 ) + add_gh_flat pvData ${REPOPVD:-epics-base} pvDataCPP ${BRPVD:-master} + add_gh_flat pvAccess ${REPOPVA:-epics-base} pvAccessCPP ${BRPVA:-master} + add_gh_flat normativeTypes ${REPONT:-epics-base} normativeTypesCPP ${BRNT:-master} +else + git clone --quiet --depth 5 --branch core/"${BRCORE:-master}" https://github.com/${REPOBASE:-epics-base}/epics-base.git epics-base + ( cd epics-base && git log -n1 ) + add_base_module libcom "${BRLIBCOM:-master}" + add_base_module ca "${BRCA:-master}" + add_base_module database "${BRDATABASE:-master}" + add_gh_module pvData ${REPOPVD:-epics-base} pvDataCPP ${BRPVD:-master} + add_gh_module pvAccess ${REPOPVA:-epics-base} pvAccessCPP ${BRPVA:-master} + add_gh_module normativeTypes ${REPONT:-epics-base} normativeTypesCPP ${BRNT:-master} +fi + +if [ -e $CURDIR/configure/RELEASE.local ] +then + cat $CURDIR/configure/RELEASE.local +fi + +EPICS_HOST_ARCH=`sh epics-base/startup/EpicsHostArch` + +# requires wine and g++-mingw-w64-i686 +if [ "$WINE" = "32" ] +then + echo "Cross mingw32" + sed -i -e '/CMPLR_PREFIX/d' epics-base/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw + cat << EOF >> epics-base/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw +CMPLR_PREFIX=i686-w64-mingw32- +EOF + cat << EOF >> epics-base/configure/CONFIG_SITE +CROSS_COMPILER_TARGET_ARCHS+=win32-x86-mingw +EOF +fi + +if [ "$STATIC" = "YES" ] +then + echo "Build static libraries/executables" + cat << EOF >> epics-base/configure/CONFIG_SITE +SHARED_LIBRARIES=NO +STATIC_BUILD=YES +EOF +fi + +case "$CMPLR" in +clang) + echo "Host compiler is clang" + cat << EOF >> epics-base/configure/os/CONFIG_SITE.Common.$EPICS_HOST_ARCH +GNU = NO +CMPLR_CLASS = clang +CC = clang +CCC = clang++ +EOF + + # hack + sed -i -e 's/CMPLR_CLASS = gcc/CMPLR_CLASS = clang/' epics-base/configure/CONFIG.gnuCommon + + clang --version + ;; +*) + echo "Host compiler is default" + gcc --version + ;; +esac + +cat <> epics-base/configure/CONFIG_SITE +USR_CPPFLAGS += $USR_CPPFLAGS +USR_CFLAGS += $USR_CFLAGS +USR_CXXFLAGS += $USR_CXXFLAGS +EOF + +# set RTEMS to eg. "4.9" or "4.10" +# requires qemu, bison, flex, texinfo, install-info +if [ -n "$RTEMS" ] +then + echo "Cross RTEMS${RTEMS} for pc386" + install -d /home/travis/.cache + curl -L "https://github.com/mdavidsaver/rsb/releases/download/travis-20160306-2/rtems${RTEMS}-i386-trusty-20190306-2.tar.gz" \ + | tar -C /home/travis/.cache -xj + + sed -i -e '/^RTEMS_VERSION/d' -e '/^RTEMS_BASE/d' epics-base/configure/os/CONFIG_SITE.Common.RTEMS + cat << EOF >> epics-base/configure/os/CONFIG_SITE.Common.RTEMS +RTEMS_VERSION=$RTEMS +RTEMS_BASE=/home/travis/.cache/rtems${RTEMS}-i386 +EOF + cat << EOF >> epics-base/configure/CONFIG_SITE +CROSS_COMPILER_TARGET_ARCHS+=RTEMS-pc386 +EOF + + # find local qemu-system-i386 + export PATH="$HOME/.cache/qemu/usr/bin:$PATH" + echo -n "Using QEMU: " + type qemu-system-i386 || echo "Missing qemu" + EXTRA=RTEMS_QEMU_FIXUPS=YES +fi + +make -j2 -C epics-base $EXTRA + +if [ "$BRBASE" ] +then +make -j2 -C pvData $EXTRA +make -j2 -C pvAccess $EXTRA +make -j2 -C normativeTypes $EXTRA +fi diff --git a/.travis.yml b/.travis.yml index e4b2b82..575951f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,12 +11,19 @@ addons: - perl - clang - g++-mingw-w64-i686 -env: - - BRBASE=3.16 WINE=32 - - BRBASE=3.16 USR_CXXFLAGS=-std=c++11 CMPLR=clang - - BRBASE=3.15 - - BRBASE=3.14 install: - - ./build-deps.sh + - ./.ci/travis-prepare.sh script: - - make -j2 + - ./.ci/travis-build.sh +env: + - BRCORE=master BRLIBCOM=master BRPVD=master BRPVA=master BRNT=master TEST=NO + - CMPLR=clang TEST=NO + - USR_CXXFLAGS=-std=c++11 TEST=NO + - CMPLR=clang USR_CXXFLAGS=-std=c++11 TEST=NO + - WINE=32 TEST=NO STATIC=YES + - WINE=32 TEST=NO STATIC=NO + - RTEMS=4.10 TEST=NO + - RTEMS=4.9 TEST=NO + - BRBASE=3.16 TEST=NO + - BRBASE=3.15 TEST=NO + - BRBASE=3.14 TEST=NO diff --git a/build-deps.sh b/build-deps.sh deleted file mode 100755 index 4e0254b..0000000 --- a/build-deps.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -set -e -x - -CURDIR="$PWD" - -cat << EOF > configure/RELEASE.local -EPICS_BASE=$HOME/.source/epics-base -PVDATA=$HOME/.source/pvDataCPP -PVACCESS=$HOME/.source/pvAccessCPP -NORMATIVETYPES=$HOME/.source/normativeTypesCPP -EOF -cat configure/RELEASE.local - -install -d "$HOME/.source" -cd "$HOME/.source" - -git clone --quiet --depth 5 --branch "${BRBASE:-master}" https://github.com/epics-base/epics-base.git epics-base -git clone --quiet --depth 5 --branch "${BRPVD:-master}" https://github.com/epics-base/pvDataCPP.git pvDataCPP -git clone --quiet --depth 5 --branch "${BRPVA:-master}" https://github.com/epics-base/pvAccessCPP.git pvAccessCPP -git clone --quiet --depth 5 --branch "${BRNT:-master}" https://github.com/epics-base/normativeTypesCPP.git normativeTypesCPP - -(cd epics-base && git log -n1 ) -(cd pvDataCPP && git log -n1 ) -(cd pvAccessCPP && git log -n1 ) -(cd normativeTypesCPP && git log -n1 ) - -EPICS_HOST_ARCH=`sh epics-base/startup/EpicsHostArch` - -# requires wine and g++-mingw-w64-i686 -if [ "$WINE" = "32" ] -then - echo "Cross mingw32" - sed -i -e '/CMPLR_PREFIX/d' epics-base/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw - cat << EOF >> epics-base/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw -CMPLR_PREFIX=i686-w64-mingw32- -EOF - cat << EOF >> epics-base/configure/CONFIG_SITE -CROSS_COMPILER_TARGET_ARCHS+=win32-x86-mingw -EOF -fi - -case "$CMPLR" in -clang) - echo "Host compiler is clang" - cat << EOF >> epics-base/configure/os/CONFIG_SITE.Common.$EPICS_HOST_ARCH -GNU = NO -CMPLR_CLASS = clang -CC = clang -CCC = clang++ -EOF - - # hack - sed -i -e 's/CMPLR_CLASS = gcc/CMPLR_CLASS = clang/' epics-base/configure/CONFIG.gnuCommon - - clang --version - ;; -*) - echo "Host compiler is default" - gcc --version - ;; -esac - -cat << EOF > pvDataCPP/configure/RELEASE.local -EPICS_BASE=$HOME/.source/epics-base -EOF - -cat << EOF > pvAccessCPP/configure/RELEASE.local -PVDATA=$HOME/.source/pvDataCPP -EPICS_BASE=$HOME/.source/epics-base -EOF - -cat << EOF > normativeTypesCPP/configure/RELEASE.local -PVDATA=$HOME/.source/pvDataCPP -EPICS_BASE=$HOME/.source/epics-base -EOF - -make -j2 -C epics-base -make -j2 -C pvDataCPP -make -j2 -C pvAccessCPP -make -j2 -C normativeTypesCPP diff --git a/src/pv/pvaClient.h b/src/pv/pvaClient.h index 3031e38..b31092f 100644 --- a/src/pv/pvaClient.h +++ b/src/pv/pvaClient.h @@ -95,6 +95,7 @@ typedef std::tr1::weak_ptr PvaClientRPCRequesterWPtr; class PvaClientChannelCache; typedef std::tr1::shared_ptr PvaClientChannelCachePtr; + /** * @brief pvaClient is a synchronous wrapper for the pvAccess API, which is a callback based API. * @@ -172,14 +173,13 @@ public: * * @param value true or false */ - static void setDebug(bool value) {debug = value;} + static void setDebug(bool value); /** @brief Is debug set? * * @return true or false */ - static bool getDebug() {return debug;} + static bool getDebug(); private: - static bool debug; PvaClient(std::string const & providerNames); PvaClientChannelCachePtr pvaClientChannelCache; epics::pvData::Requester::weak_pointer requester; diff --git a/src/pvaClient.cpp b/src/pvaClient.cpp index cb3790d..4fea159 100644 --- a/src/pvaClient.cpp +++ b/src/pvaClient.cpp @@ -87,7 +87,18 @@ size_t PvaClientChannelCache::cacheSize() } -bool PvaClient::debug = false; +// MSVC doesn't like making this a class static data member: +static bool debug = 0; + +void PvaClient::setDebug(bool value) +{ + debug = value; +} + +bool PvaClient::getDebug() +{ + return debug; +} PvaClientPtr PvaClient::get(std::string const & providerNames) { @@ -109,19 +120,19 @@ PvaClient::PvaClient(std::string const & providerNames) { stringstream ss(providerNames); string providerName; - if(PvaClient::debug) { + if(getDebug()) { cout<< "PvaClient::PvaClient()\n"; } while (getline(ss, providerName, ' ')) { if(providerName=="pva") { - if(PvaClient::debug) { + if(getDebug()) { cout<< "calling ClientFactory::start()\n"; } ClientFactory::start(); pvaStarted = true; } else if(providerName=="ca") { - if(PvaClient::debug) { + if(getDebug()) { cout<< "calling CAClientFactory::start()\n"; } CAClientFactory::start(); @@ -135,20 +146,20 @@ PvaClient::PvaClient(std::string const & providerNames) } PvaClient::~PvaClient() { - if(PvaClient::debug) { + if(getDebug()) { cout<< "PvaClient::~PvaClient()\n" << "pvaChannel cache:\n"; showCache(); } if(pvaStarted){ - if(PvaClient::debug) cout<< "calling ClientFactory::stop()\n"; + if(getDebug()) cout<< "calling ClientFactory::stop()\n"; ClientFactory::stop(); - if(PvaClient::debug) cout<< "after calling ClientFactory::stop()\n"; + if(getDebug()) cout<< "after calling ClientFactory::stop()\n"; } if(caStarted) { - if(PvaClient::debug) cout<< "calling CAClientFactory::stop()\n"; + if(getDebug()) cout<< "calling CAClientFactory::stop()\n"; CAClientFactory::stop(); - if(PvaClient::debug) cout<< "after calling CAClientFactory::stop()\n"; + if(getDebug()) cout<< "after calling CAClientFactory::stop()\n"; } channelRegistry.reset(); }