diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-02-04 07:14:34 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-02-04 07:14:34 +0200 |
commit | ec050b2f1a1a1e51692251d3a7687e48c226fff5 (patch) | |
tree | 4601d8d4c8060486a5170a0b49c6762d69feb2c1 /intro | |
parent | 0d7d9b481d8dff60c96b20967bc6e30aa388b3c5 (diff) |
Updates during the 0.2.0 release0.2.0
Diffstat (limited to 'intro')
-rwxr-xr-x | intro | 242 |
1 files changed, 242 insertions, 0 deletions
@@ -0,0 +1,242 @@ +#! /usr/bin/env bash + +# Test examples from the into. +# +# Usage: install [options] <hello-repo> +# +# -t <toolchain> +# Specify the build2 toolchain install/stage directory. The script will +# use <toolchain>/bin/b and <toolchain>/bin/bpkd instead of just b and +# bpkg. +# +# -c1 +# -c2 +# -c3 +# C++ compilers 1 (g++-5), 2 (clang++-3.6), and 3 prefix +# (x86_64-w64-mingw32). If the value for 2 or 2 is empty, then this test +# is skipped. +# +# -h +# The hello2 source directory, by default hello/hello2 +# +# For example: +# +# intro https://pkg.cppget.org/1/hello +# intro /var/bpkg/1/hello +# +usage="usage: $0 [options] <hello-repo>" + +owd=`pwd` +trap "{ cd $owd; exit 1; }" ERR +set -o errtrace # Trap in functions. + +function error () { echo "$*" 1>&2; exit 1; } + +tmp=/tmp +rep= +toolchain= +hello2=hello/hello2 + +c1=g++-5 +c2=clang++-3.6 +c3=x86_64-w64-mingw32 + +while [ $# -gt 0 ]; do + case $1 in + -t) + shift + toolchain=${1%/} + shift + ;; + -c1) + shift + c1=$1 + shift + ;; + -c2) + shift + c2=$1 + shift + ;; + -c3) + shift + c3=$1 + shift + ;; + -h) + shift + hello2=${1%/} + shift + ;; + *) + rep=${1%/} + break + ;; + esac +done + +if [ -z "$rep" ]; then + error "$usage" +fi + +if [[ $hello2 != /* ]]; then + hello2=$owd/$hello2 +fi + +if [ ! -d "$hello2" ]; then + error "hello2 directory $hello2 does not exist" +fi + +if [ -n "$toolchain" ]; then + export PATH="$toolchain/bin:$PATH" + + if [ "`which b`" != "$toolchain/bin/b" ]; then + error "b does not appear to be in $toolchain/bin/" + fi + + if [ "`which bpkg`" != "$toolchain/bin/bpkg" ]; then + error "bpkg does not appear to be in $toolchain/bin/" + fi +fi + +if [ -z "`which tree`" ]; then + tree="ls -1" +else + tree=tree +fi + +function create () # <dir> <bpkg-args> +{ + local d=$1; shift + + rm -rf $tmp/$d + mkdir $tmp/$d + cd $tmp/$d + bpkg create $* +} + +function info () # stable|testing +{ + local d=$1; shift + bpkg rep-info $rep/$d +} + +function add () # stable|testing +{ + local d=$1; shift + bpkg add $rep/$d +} + +function fetch () +{ + bpkg fetch +} + +function build () # <bpkg-args> +{ + bpkg build -y $* +} + +function drop () # <bpkg-args> +{ + bpkg drop -y $* +} + +function status () # <pkg> <expected> +{ + local s=`bpkg status $1` + echo "$s" + + if [ "$s" != "$2" ]; then + error "status $1: '"$s"', expected: '"$2"'" + fi +} + +function update () # <bpk> +{ + bpkg update $* +} + +function test () # <bpk> +{ + bpkg test $* +} + +create hello-gcc5-release cxx config.cxx=$c1 config.cxx.coptions=-O3 +info stable +add stable +fetch +build hello +drop hello +build -v hello +status libhello "configured 1.0.0+1" +status hello "configured 1.0.0 hold_package" +drop hello +status hello "available 1.0.0" +status libfoobar "unknown" + +build hello +add testing +fetch +build hello +build libhello +update hello +build libhello/1.0.0 hello + +test libhello hello +ls -1F +ls -1F hello-1.0.0/ +hello-1.0.0/hello || true +hello-1.0.0/hello World + +bpkg install config.install.root=/opt/hello config.install.root.sudo=sudo hello +$tree -F /opt/hello/ +/opt/hello/bin/hello World +sudo rm -rf /opt/hello + +cd $hello2 +b config.cxx=$c1 config.import.libhello=$tmp/hello-gcc5-release +$tree -F +./hello +b config.cxx=$c1 config.import.libhello=$tmp/hello-gcc5-release clean # Extra. + +cd $tmp +rm -rf hello2-gcc5-release +mkdir hello2-gcc5-release +b config.cxx=$c1 config.cxx.coptions=-O3 \ +config.import.libhello=$tmp/hello-gcc5-release \ +"configure($hello2/@hello2-gcc5-release/)" +b hello2-gcc5-release/ +cd hello2-gcc5-release/ +b +b clean +b -v + +cd $tmp +b "configure($hello2/@$tmp/hello-gcc5-release/hello2/)" +b $tmp/hello-gcc5-release/hello2/ +b "{clean disfigure}($tmp/hello-gcc5-release/hello2/)" + +build -d $tmp/hello-gcc5-release $hello2/ +build -d $tmp/hello-gcc5-release libhello +update -d $tmp/hello-gcc5-release hello2 +$tmp/hello-gcc5-release/hello2-1.0.0/hello + +if [ -n "$c2" ]; then + create hello-clang36-release cxx config.cxx=$c2 config.cxx.coptions=-O3 + add testing + fetch + build libhello/1.0.0 $hello2/ +fi + +if [ -n "$c3" ]; then + create hello-mingw32 cxx \ + config.cxx=$c3-g++ \ + config.bin.ar=$c3-ar \ + config.bin.lib=static config.cxx.loptions=-static + add stable + fetch + build hello + export WINEDEBUG=fixme-all + wine hello-1.0.0/hello.exe Windows +fi |