Refactor Travis CI and add CI for Windows (build + release)
Windows is built using Cross-compilation, facilitated by a prebuilt, static version of MXE which contains a Qt5 environment.
MODIFY
.travis.yml
.travis.yml
-language: cpp
-compiler: gcc
-sudo: require
+
+
+matrix:
+ include:
+
+ #- env: RIPES_PLATFORM='mac'
+ # os: osx
+ # osx_image: xcode8
+ # language: c++ ruby
+
+ - env: RIPES_PLATFORM='windows'
+ os: linux
dist: trusty
+ sudo: required
+ language: c++
-before_install:
- - sudo add-apt-repository --yes ppa:beineri/opt-qt593-trusty
- - sudo apt-get update
- - sudo apt-get install qt59-meta-minimal qt59svg libc6-dev
- # C++14
- - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- - sudo apt-get update -qq
+ - env: RIPES_PLATFORM='linux'
+ os: linux
+ dist: trusty
+ sudo: required
+ language: c++
+ compiler: gcc
+ addons:
+ apt:
+ sources:
+ - sourceline: 'ppa:beineri/opt-qt593-trusty'
+ key_url: 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x10C56D0DE9977759'
+ - ubuntu-toolchain-r-test
+ packages:
+ - qt59-meta-minimal
+ - qt59svg
+ - libc6-dev
+ - g++-6
-install:
- - source /opt/qt*/bin/qt*-env.sh
+before_install:
+ - source ${TRAVIS_BUILD_DIR}/scripts/${RIPES_PLATFORM}/before_install.sh
script:
- # C++14
- - sudo apt-get install -qq g++-6
- - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 90
- # Set new Qt environment
- - source /opt/qt59/bin/qt59-env.sh
- - qmake --version
- # build
- - qmake CONFIG+=release PREFIX=/usr
- - make -j$(nproc)
- - make INSTALL_ROOT=appdir -j$(nproc) install ; find appdir/
- - wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
- - chmod a+x linuxdeployqt-continuous-x86_64.AppImage
- - unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH
- - export VERSION=continuous # linuxdeployqt uses this for naming the file
- - ./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/share/applications/*.desktop -appimage -extra-plugins=iconengines
+ - source ${TRAVIS_BUILD_DIR}/scripts/${RIPES_PLATFORM}/travisbuild.sh
after_success:
- - find appdir -executable -type f -exec ldd {} \; | grep " => /usr" | cut -d " " -f 2-3 | sort | uniq
- - wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
- - bash upload.sh Ripes*.AppImage*
+ - source ${TRAVIS_BUILD_DIR}/scripts/${RIPES_PLATFORM}/after_success.sh
branches:
except:

MODIFY
appdir/usr/share/applications/Ripes.desktop
appdir/usr/share/applications/Ripes.desktop
@@ -4,3 +4,4 @@ Name=Ripes
Comment=Ripes simulator
Exec=Ripes
Icon=Ripes
+Categories=Education;Utility;
\ No newline at end of file

ADD
scripts/linux/after_success.sh
+#!/bin/bash
+
+find appdir -executable -type f -exec ldd {} \; | grep " => /usr" | cut -d " " -f 2-3 | sort | uniq
+wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
+bash upload.sh Ripes*.AppImage*

ADD
scripts/linux/before_install.sh
+export CC=gcc-6
+export CXX=g++-6
+
+git fetch --unshallow
+git pull --tags
+git describe
+
+sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 90
+
+source /opt/qt*/bin/qt*-env.sh

ADD
scripts/linux/travisbuild.sh
+#!/bin/bash
+qmake --version
+ # build
+qmake CONFIG+=release PREFIX=/usr
+make -j$(nproc)
+make INSTALL_ROOT=appdir -j$(nproc) install ; find appdir/
+wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
+chmod a+x linuxdeployqt-continuous-x86_64.AppImage
+unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH
+export VERSION=continuous-linux # linuxdeployqt uses this for naming the file
+./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/share/applications/*.desktop -appimage -extra-plugins=iconengines
+

ADD
scripts/mac/after_success.sh
+#!/bin/bash
+
+wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
+bash upload.sh Ripes*.zip

ADD
scripts/mac/before_install.sh
+#!/bin/bash
+
+# Adapted from https://github.com/Subsurface-divelog/subsurface/blob/master/scripts/mac/before_install.sh
+
+set -x
+
+# try to get rid of the insane debug crap
+unalias -a
+unset -f rvm_debug
+unset -f cd
+unset -f pushd
+unset -f popd
+
+# Travis only pulls shallow repos. But that messes with git describe.
+# Sorry Travis, fetching the whole thing and the tags as well...
+git fetch --unshallow
+git pull --tags
+git describe
+
+# prep things so we can build for Mac
+# we have a custom built Qt some gives us just what we need
+# we should just build and install this into /usr/local/ as well and have
+# it all be part of the cache...
+
+pushd ${TRAVIS_BUILD_DIR}
+
+mkdir -p Qt/5.11.1
+
+echo "Get custom Qt build and unpack it"
+curl --output Qt-5.11.1-mac.tar.xz \
+ https://storage.googleapis.com/travis-cache/Qt-5.11.1-mac.tar.xz
+md5 Qt-5.11.1-mac.tar.xz
+
+tar -xJ -C Qt/5.11.1 -f Qt-5.11.1-mac.tar.xz

ADD
scripts/mac/travisbuild.sh
+#!/bin/bash
+
+set -x
+set -e
+
+# this gets executed by Travis when building an App for Mac
+# it gets started from inside the subsurface directory
+
+export QT_ROOT=${TRAVIS_BUILD_DIR}/Qt/5.11.1/clang_64
+export PATH=$QT_ROOT/bin:$PATH # Make sure correct qmake is found on the $PATH
+export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
+
+
+qmake CONFIG+=release CONFIG+=c++14
+make -j$(nproc)
+
+# Start bundling the app
+macdeployqt Ripes.app
+
+APPNAME=Ripes-continuous-mac-x86_64.app
+sudo mv Ripes.app $APPNAME
+
+sudo zip -r ${APPNAME}.zip ${APPNAME}/
+
+ln -s . 5.0
+popd

ADD
scripts/windows/after_success.sh
+#!/bin/bash
+echo "Uploading to git"
+wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
+bash upload.sh Ripes*.exe

ADD
scripts/windows/before_install.sh
+#!/bin/bash
+
+sudo apt-get update
+
+echo "deb http://pkg.mxe.cc/repos/apt/debian wheezy main" \
+ | sudo tee /etc/apt/sources.list.d/mxeapt.list
+sudo apt-key adv --keyserver x-hkp://keys.gnupg.net \
+ --recv-keys D43A795B73B16ABE9643FE1AFD8FFF16DB45C6AB
+
+sudo apt-get update
+
+# sudo apt-get --yes install upx-ucl
+
+export MXE_TARGET=i686-w64-mingw32.static #x86-64-w64-mingw32.static
+
+MXE2_TARGET=$(echo "$MXE_TARGET" | sed 's/_/-/g')
+sudo apt-get --yes install \
+ mxe-${MXE2_TARGET} || true

ADD
scripts/windows/travisbuild.sh
+#!/bin/bash
+echo $MXE_TARGET
+MXE_DIR=/usr/lib/mxe
+
+export PATH=$MXE_DIR/usr/bin:$PATH
+
+echo $PATH
+
+echo "Running QMake"
+${MXE_DIR}/usr/${MXE_TARGET}/qt5/bin/qmake CONFIG+=release CONFIG+=c++14 QMAKE_LFLAGS+=-static-libgcc
+
+
+echo "Running make"
+make -j 2
+echo "Done."
+
+# Start bundling the .zip
+APPNAME=Ripes-continuous-win-x86_64
+
+cd release
+sudo mv Ripes.exe $APPNAME.exe
\ No newline at end of file

MODIFY
src/pipelineobjects.h
src/pipelineobjects.h
#include "defines.h"
#include "mainmemory.h"
-#include <math.h>
+#include <cmath>
#include <cstdint>
#include <functional>
#include <stdexcept>
@@ -341,20 +341,17 @@ void ALU<n>::update() {
case ALUOps::MUL:
m_output = (int)*m_op1 * (int)*m_op2;
break;
- case ALUOps::MULH:
- {
+ case ALUOps::MULH: {
int64_t res = (int)*m_op1 * (int)*m_op2;
m_output = static_cast<uint32_t>(res >> 32);
break;
}
- case ALUOps::MULHU:
- {
+ case ALUOps::MULHU: {
int64_t res = (uint32_t)*m_op1 * (uint32_t)*m_op2;
m_output = static_cast<uint32_t>(res >> 32);
break;
}
- case ALUOps::MULHSU:
- {
+ case ALUOps::MULHSU: {
int64_t res = (int)*m_op1 * (uint32_t)*m_op2;
m_output = static_cast<uint32_t>(res >> 32);
break;
@@ -382,8 +379,7 @@ void ALU<n>::update() {
} else if ((int)*m_op1 == (-(std::pow(2, 32 - 1))) && (int)*m_op2 == -1) {
// Overflow
m_output = 0;
- }
- else {
+ } else {
m_output = (int)*m_op1 % (int)*m_op2;
}
break;

Refactor Travis CI and add CI for Windows (build + release)

Windows is built using Cross-compilation, facilitated by a prebuilt, static version of MXE which contains a Qt5 environment.