1####
2#  Travis-CI configuration file for FreeCAD.
3#
4#  This build configuration will build and test FreeCAD on both Linux
5#  and Mac OS X.  For Mac OS X, this configuration will also package
6#  and deploy the build to GitHub provided the following prerequisites
7#  are satisfied:
8#
9#  GH_TOKEN is defined as a secure environment variable and contains a
10#           a valid GitHub OAUTH token with repo_deployment scope.
11#           NOTE: Define this env using the Travis-CI Repo Settings UI
12#
13#  FREECAD_RELEASE: A GitHub Release with this identifier exists in the
14#           repo.  The Travis job will deploy the OS X build to this
15#           GitHub release name as a release asset.
16#
17#  DEPLOY: Repo setting to deploy (defaults to no deploy to reduce
18#          Travis build times. Set DEPLOY=1 to enable in repo settings.
19##
20env:
21  global:
22    - GENERATOR="Unix Makefiles"
23    - CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release}
24#    - FREECAD_RELEASE="0.18"
25#    - DEPLOY_RELEASE=${DEPLOY_RELEASE:-$FREECAD_RELEASE}
26#    - OSX_PORTS_CACHE=${OSX_PORTS_CACHE:-FreeCAD/FreeCAD-ports-cache}
27#    - DEPLOY=${DEPLOY:-0}
28
29# jobs:
30    # chunk.io key (if needed, obtain it with Yorik, PrzemoF, Kunda1)
31    # secure: MJu0ZU/9Yqut6bUkHoSrXTV/c/WhCLR0KnHKCsnEU081PYoukzH6ngzgKk7/trAH2In080d/ra4B2OmTNl/LAgV6DXKFY9dO1aG8QwcrHgaMPf0pHYUy/OfwQSFYFByQDV2OEMAHcIWc/dtNkzK2QUi44Kn7d0GtSEiN4s816lriWtjg0vmEGAU8MjvcAGss4gKyn05Xm1NUCYPKgpgIHsywLbpE76lv0eOYoosEuKv5Q9Pb4FMQts02+JUlqE8eY4ZZ3nV8iQbgIDdseOSA7Ixn05zWjU/ZRZ74TrYxMnzfUAwQcJe9OcqoESq+pPWQt5HYG66VmeVxQim1gmsiDASH51U/nswKt0Q4bISj3tVk0YZMFV8Ax+SzPvLEmFZJQGfgO1mg7HdNcz9N9G5JHPawrV19DwYIEFbAw8MCSAoIXFOcPQZUWXCbtjm7NO9vCjMrqyVJMDD9L8omvQajHoajuHbOT8KB250gFokeLj3z8yu++Tz+IrZX5inUMrXsARVt/ALXpi8rJPXmoFMpMUjyWmDPqPWlnqUhLtTtEtKpuOWP8ZnWVwkg4QYOUhCy95C1okJSGkG+ylHWncWfY4mS+UBT525laoh+GOhH+sRW+p2xkI21xGFRqg1oHjjgY1yIYF6nnSHPzxMBRYmZwagyXsjkFG5FPMWR2oYk0Yg
32
33git:
34  depth: 5000
35
36notifications:
37  email: false
38  webhooks:
39    urls:
40      - https://webhooks.gitter.im/e/479456663cdf5c84e4d8
41    on_success: always
42    on_failure: always
43    on_start:   change
44
45# Inject osx build into matrix - needed to specify image/dist
46jobs:
47#    allow_failures:
48#      - python: 3.7
49    fast_finish: true  # https://blog.travis-ci.com/2013-11-27-fast-finishing-builds
50    include:
51      - os: linux
52        dist: bionic
53        language: cpp
54        compiler: clang
55        cache: ccache
56        addons:
57          apt:
58            sources:
59              - sourceline: 'ppa:ubuntu-toolchain-r/test'
60              - sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
61                key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
62            packages:
63              - clang-9
64        env:
65          - CC=clang-9
66          - CXX=clang++-9
67          - CMAKE_ARGS="-DPYTHON_EXECUTABLE=/usr/bin/python3 -DBUILD_FEM_NETGEN=ON -DBUILD_QT5=ON"
68          - CACHE_NAME=JOB1
69
70      - os: linux
71        dist: bionic
72        language: cpp
73        compiler: gcc-9
74        cache: ccache
75        addons:
76          apt:
77            sources:
78              - sourceline: 'ppa:ubuntu-toolchain-r/test'
79            packages:
80              - gcc-9
81              - g++-9
82        env:
83          - CC=gcc-9
84          - CXX=g++-9
85          - CC_FOR_BUILD=gcc-9
86          - CXX_FOR_BUILD=g++-9
87          - CMAKE_ARGS="-DCMAKE_CXX_COMPILER=/usr/bin/c++ -DCMAKE_C_COMPILER=/usr/bin/cc -DPYTHON_EXECUTABLE=/usr/bin/python3 -DBUILD_FEM_NETGEN=ON -DBUILD_QT5=ON"
88          - CACHE_NAME=JOB2
89
90      - os: linux
91        dist: bionic
92        language: cpp
93        compiler: gcc-7
94        cache: ccache
95        env:
96          - CC=gcc-7
97          - CXX=g++-7
98          - CC_FOR_BUILD=gcc-7
99          - CXX_FOR_BUILD=g++-7
100          - CMAKE_ARGS="-DCMAKE_CXX_COMPILER=/usr/bin/c++ -DCMAKE_C_COMPILER=/usr/bin/cc"
101          - CACHE_NAME=JOB3
102
103      - os: windows
104        language: cpp
105        env:
106          - CMAKE_OPTS="-DBUILD_FEM_NETGEN=ON -DFREECAD_RELEASE_PDB=OFF -DFREECAD_RELEASE_SEH=OFF"
107          - GENERATOR="Visual Studio 15 2017 Win64"
108          - PYTHON_MAJOR_VERSION=3
109          - MSBUILD_PATH="c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
110          - TEST_PATH="C:\Users\travis\build\FreeCAD\FreeCAD\build\bin"
111          - CLCACHE_PATH="C:\Users\travis\build\FreeCAD\FreeCAD"
112          - VS15=true
113          - CCACHE_TEMPDIR=/tmp/.ccache-temp
114          - CCACHE_COMPRESS=1
115          - CCACHE_DIR=$HOME/.ccache
116          - CACHE_NAME=JOB5
117          # enable this if clcache extended log is needed
118          #- CLCACHE_LOG=1
119        cache:
120          directories:
121            - $HOME/clcache
122
123#      - language: python
124#        python: 3.7
125#        dist: xenial  # required for Python >= 3.7 (travis-ci/travis-ci#9069)
126#        before_install: true
127#        install: python3 -m pip install flake8
128#        # fail the build if there are Python syntax errors or undefined names
129#        script: flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
130
131
132before_install:
133# - eval "$(curl -fsSL "https://raw.githubusercontent.com/${OSX_PORTS_CACHE}/v${FREECAD_RELEASE}/travis-helpers.sh")"
134- |
135  case "${TRAVIS_OS_NAME}" in
136
137   "linux")
138       # Daily PPA for OCCT, Pivy, Netgen, PySide ... packages
139       sudo apt-add-repository -y ppa:freecad-maintainers/freecad-daily 
140       sudo apt-get update -qq
141       # Build deps
142       sudo apt-get install -y --no-install-recommends          \
143                               python-dev                       \
144                               python-pyside                    \
145                               python-matplotlib                \
146                               python3-dev                      \
147                               python3-pyside                   \
148                               python3-matplotlib               \
149                               libboost1.65-dev                 \
150                               libboost-filesystem1.65-dev      \
151                               libboost-program-options1.65-dev \
152                               libboost-python1.65-dev          \
153                               libboost-regex1.65-dev           \
154                               libboost-signals1.65-dev         \
155                               libboost-system1.65-dev          \
156                               libboost-thread1.65-dev          \
157                               libxerces-c-dev                  \
158                               libocct-data-exchange-dev        \
159                               libocct-ocaf-dev                 \
160                               libocct-visualization-dev        \
161                               libvtk7-dev                      \
162                               libmedc-dev                      \
163                               pybind11-dev                     \
164                               swig                             \
165                               qt4-qmake                        \
166                               libqt4-opengl-dev                \
167                               libqtwebkit-dev                  \
168                               qtbase5-dev                      \
169                               libqt5xmlpatterns5-dev           \
170                               libqt5svg5-dev                   \
171                               libqt5opengl5-dev                \
172                               qttools5-dev                     \
173                               qtwebengine5-dev                 \
174                               libcoin80-dev                    \
175                               libpyside-dev                    \
176                               libpyside2-dev                   \
177                               libshiboken-dev                  \
178                               libshiboken2-dev                 \
179                               pyside-tools                     \
180                               pyside2-tools                    \
181                               doxygen                          \
182                               graphviz                         \
183                               libnglib-dev                     \
184                               netgen                           \
185                               netgen-headers                   \
186                               libmetis-dev                     \
187                               libspnav-dev
188       # Runtime deps
189       sudo apt-get install -y --no-install-recommends freecad-daily-python3 python-ply python3-ply
190
191       export DISPLAY=:99.0
192       sh -e /etc/init.d/xvfb start
193
194       export INSTALLED_APP_PATH="/usr/local/bin/FreeCAD"
195       export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/netgen/:$LD_LIRBARY_PATH
196       ;;
197
198   "osx")
199       #xcodebuild -version -sdk
200       #brew --config
201       #if [ "${OSX_PORTS_CACHE}X" != "X" ]; then
202       #     brew install jq
203       #     cacheContext=$(create_helper_context repo=${OSX_PORTS_CACHE} auth_token=${GH_TOKEN} release=${FREECAD_RELEASE})
204       #     travis_wait prime_local_ports_cache $cacheContext
205       #fi
206       #brew update >/dev/null
207       #brew --config
208
209       #brew tap FreeCAD/freecad
210
211       #brew install --verbose --only-dependencies freecad --with-packaging-utils
212       #pip install six
213       ## Qt5:  Set Qt5 build flag and CMAKE_PREFIX
214       #QT5_CMAKE_PREFIX=$(ls -d $(brew --cellar)/qt/*/lib/cmake)
215       #QT5_WEBKIT_CMAKE_PREFIX=$(ls -d $(brew --cellar)/qtwebkit/*/lib/cmake)
216       #CMAKE_OPTS="${CMAKE_OPTS} -DBUILD_QT5=ON -DCMAKE_PREFIX_PATH=${QT5_CMAKE_PREFIX};${QT5_WEBKIT_CMAKE_PREFIX}"
217
218       ##Install the 3DConnexion frameworks
219       #if [ "${DEPLOY}" == "1" ]; then
220       #   if [ ! -d /Library/Frameworks/3DconnexionClient.framework ]; then
221       #      curl -o /tmp/3dFW.dmg -L 'http://www.3dconnexion.com/index.php?eID=sdl&ext=tx_iccsoftware&oid=a273bdbc-c289-e10d-816b-567043331c9e&filename=3DxWareMac_v10-4-1_r2428.dmg'
222       #      hdiutil attach -readonly /tmp/3dFW.dmg
223       #      sudo installer -package /Volumes/3Dconnexion\ Software/Install\ 3Dconnexion\ software.pkg -target /
224       #      diskutil eject /Volumes/3Dconnexion\ Software
225       #   fi
226       #   export CMAKE_OPTS="${CMAKE_OPTS} -DFREECAD_CREATE_MAC_APP=ON"
227       #   export INSTALLED_APP_PATH="/usr/local/FreeCAD.app/Contents/MacOS/FreeCAD"
228       #else
229       #   export INSTALLED_APP_PATH="/usr/local/MacOS/FreeCAD"
230       #fi
231
232       #export CMAKE_ARGS="${CMAKE_OPTS} -DFREECAD_USE_EXTERNAL_KDL=ON"
233       ;;
234
235   "windows")
236       #choco install -y python
237       #py -m pip install --quiet --upgrade pip
238       #py -m pip install git+https://github.com/frerich/clcache.git@v4.2.0
239       curl -L https://github.com/frerich/clcache/releases/download/v4.2.0/clcache-4.2.0.zip --output clcache-4.2.0.zip
240       7z x clcache-4.2.0.zip > /dev/null
241       export PATH=$CLCACHE_PATH:$PATH
242       export PATH=$TEST_PATH:$PATH
243       #reset clcache hit stats
244       cmd.exe //C 'C:\Users\travis\build\FreeCAD\FreeCAD\clcache.exe -z'
245       # clcache stats before compilation
246       cmd.exe //C 'C:\Users\travis\build\FreeCAD\FreeCAD\clcache.exe -s'
247
248       curl -L https://github.com/FreeCAD/FreeCAD/releases/download/0.19_pre/FreeCADLibs_12.1.4_x64_VC15.7z --output FreeCADLibs.7z
249       7z x FreeCADLibs.7z -oFreeCADLibs > /dev/null
250       rm -f FreeCADLibs.7z
251       export FREECAD_LIBPACK_DIR="$TRAVIS_BUILD_DIR\FreeCADLibs\FreeCADLibs_12.1.4_x64_VC15"
252
253       export CMAKE_ARGS="${CMAKE_OPTS} -DFREECAD_LIBPACK_DIR=$TRAVIS_BUILD_DIR\FreeCADLibs\FreeCADLibs_12.1.4_x64_VC15 -DPYTHON_EXECUTABLE=$TRAVIS_BUILD_DIR\FreeCADLibs\FreeCADLibs_12.1.4_x64_VC15\bin\python.exe \
254       -DBUILD_QT5=TRUE"
255       export PATH=$MSBUILD_PATH:$PATH
256       ;;
257
258   *)
259       echo "Invalid or unsupported operating system ${TRAVIS_OS_NAME}"
260       exit 1
261       ;;
262  esac
263
264install:
265####
266#  Build FreeCAD with cmake options set above for each platform
267##
268  - mkdir build && cd build && cmake -G"${GENERATOR}" ${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ../
269
270script:
271####
272#  Install FreeCAD and run unit tests.  Test failures will fail the build
273##
274#        MSBuild.exe /m FreeCAD.sln
275  - |
276    if [ "${TRAVIS_OS_NAME}" == "windows" ]; then
277        # https://travis-ci.community/t/vcvarsall-bat-freezes-on-new-1809-based-windows-images/7098/6
278        # call msbuild using clcache 
279        #cmd.exe //C '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" amd64 && MSBuild.exe FreeCAD.sln /p:CLToolExe=clcache.exe /p:TrackFileAccess=false /p:CLToolPath=C:\Users\travis\build\FreeCAD\FreeCAD /m:2 /nologo /verbosity:minimal /p:Configuration=Release /p:Platform=x64'
280        cmd.exe //C 'C:\Users\travis\build\FreeCAD\FreeCAD\.travis\build.bat'
281        # ls -lahR
282        mkdir bin/
283        mv ../FreeCADLibs/FreeCADLibs_12.1.4_x64_VC15/bin/* bin/
284        du -hs bin/
285        # show clcache hit stats
286        cmd.exe //C 'C:\Users\travis\build\FreeCAD\FreeCAD\clcache.exe -s'
287        # run the tests
288        #cmd.exe //C 'cd C:\Users\travis\build\FreeCAD\FreeCAD\build\bin && FreeCADCmd.exe --run-test 0'
289        # Make build fail if ANY of the following fails
290        #set -ev 
291        winpty.exe -Xallow-non-tty -Xplain /C/Users/travis/build/FreeCAD/FreeCAD/build/bin/FreeCADCmd.exe --run-test 0 | tee runlog.txt
292        grep -q FAILED runlog.txt ; [ $? == 1 ] && echo "Build succeeded and tests passed!" || ( echo "Tests failed!" && false )
293    else
294        # Stop compiling (GCC) after 2 hrs 50 min (3 hrs limit).
295        # Preserves created ccache for the next build job.
296        # if [ "${TRAVIS_OS_NAME}" == "linux" ]; then sudo timeout -k 175m 170m make -j2 install || true; fi
297        # if [ "${TRAVIS_OS_NAME}" == "osx" ]; then sudo make -j2 install; fi
298        cat $HOME/.ccache/ccache.conf
299        ccache -z -s
300        sudo make -j2 install
301        ccache -s
302        ${INSTALLED_APP_PATH} --console --run-test 0 || travis_terminate 1
303        ${INSTALLED_APP_PATH} --log-file /tmp/FreeCAD_installed.log &
304        sleep 10 && pkill FreeCAD
305        cat /tmp/FreeCAD_installed.log
306        grep --file=../.log_errors /tmp/FreeCAD_installed.log ; [ $? == 1 ] && echo "No errors from .log_errors file found in the log after start from /usr/local/bin" || ( echo "Error from .log_errors found!" && false )
307    fi
308
309#after_success:
310#  Package and deploy the build to GitHub.  This will only run for builds on
311#  master (i.e. pull requests are only built and tested but not deployed).
312#
313#  GH_TOKEN must be set in order to deploy releases to GitHub
314#
315#- |
316#  if [ "${TRAVIS_OS_NAME}" == "osx" -a "${TRAVIS_PULL_REQUEST}" == "false" -a "${DEPLOY}" == "1" ]; then
317#     brew ls --versions jq || brew install jq
318#     npm install -g appdmg
319#     export VSN=$(python ${TRAVIS_BUILD_DIR}/src/Tools/ArchiveNameFromVersionHeader.py ${TRAVIS_BUILD_DIR}/build/src/Build/Version.h)
320#     export DEPLOYMENT_ARCHIVE=${VSN}-${QT}.dmg
321#     appdmg ${TRAVIS_BUILD_DIR}/src/MacAppBundle/DiskImage/layout.json "${DEPLOYMENT_ARCHIVE}"
322#     deployContext=$(create_helper_context repo=${TRAVIS_REPO_SLUG} auth_token=${GH_TOKEN} release=${DEPLOY_RELEASE})
323#     gitHub_deploy_asset_to_release_named $deployContext ${DEPLOYMENT_ARCHIVE}
324#     gitHub_prune_assets_for_release_named $deployContext "-${QT}" 1
325#  fi
326
327