summaryrefslogtreecommitdiff
path: root/intro2-tour
diff options
context:
space:
mode:
Diffstat (limited to 'intro2-tour')
-rwxr-xr-xintro2-tour201
1 files changed, 201 insertions, 0 deletions
diff --git a/intro2-tour b/intro2-tour
new file mode 100755
index 0000000..d9ef011
--- /dev/null
+++ b/intro2-tour
@@ -0,0 +1,201 @@
+#! /usr/bin/env bash
+
+# Test examples from the intro2, the Tour section. The optional <repo>
+# and <trust> arguments specify the pkg repository and its fingerpring
+# that contain libhello-1.0.0.
+#
+# Usage: intro [options] [<repo> <trust>]
+#
+usage="usage: $0 [options]"
+
+owd=`pwd`
+trap "{ cd $owd; exit 1; }" ERR
+set -o errtrace # Trap in functions.
+
+function error () { echo "$*" 1>&2; exit 1; }
+
+tmp=/tmp
+show=y
+
+gcc=g++
+clang=clang++-5.0
+msvc=cl-15
+repo=https://stage.build2.org/1/
+trust="37:CE:2C:A5:1D:CF:93:81:D7:07:46:AD:66:B3:C3:90:83:B8:96:9E:34:F0:E7:B3:A2:B0:6C:EF:66:A4:BE:65"
+
+function show () # <cmd> ...
+{
+ if [ $show = "y" ]; then
+ echo
+ echo "+ $*"
+ "${@}"
+ else
+ "${@}"
+ fi
+}
+
+cd "$tmp"
+
+function clean ()
+{
+ rm -rf hello hello-gcc hello-clang hello-vc-* hello-mingw
+}
+
+##if false; then
+
+clean
+
+show bdep new -t exe -l c++ hello
+show tree hello
+show cd hello
+show cat hello/hello.cxx
+show cat hello/buildfile
+show cat hello/testscript
+show cat manifest
+
+show bdep init -C ../hello-gcc @gcc cc config.cxx=$gcc
+show bdep init -C ../hello-clang @clang cc config.cxx=$clang
+show ls -d -1 ../hello*
+
+show bdep init -C ../hello-vc-debug @debug cc config.cxx=$msvc \
+ "config.cc.coptions=/MDd /Z7" config.cc.loptions=/DEBUG
+show bdep init -C ../hello-vc-release @release cc config.cxx=$msvc \
+ config.cc.coptions=/O2
+
+show bdep status
+show b
+show b test
+show hello/hello World
+
+show bdep status @clang
+show b ../hello-clang/hello/
+show b test: ../hello-clang/hello/
+show ../hello-clang/hello/hello/hello World
+
+show bdep init -C ../hello-mingw @mingw cc config.cxx=x86_64-w64-mingw32-g++
+show b ../hello-mingw/hello/
+show b test: ../hello-mingw/hello/
+show ../hello-mingw/hello/hello/hello.exe Windows
+
+cd ..
+##fi
+
+##if false; then
+
+clean
+show bdep new -C hello-gcc @gcc -t exe -l c++ hello cc config.cxx=$gcc
+cd hello
+show bdep init -C ../hello-clang @clang cc config.cxx=$clang
+
+# Package Repositories
+#
+show bpkg rep-info https://git.build2.org/hello/libhello.git
+show bpkg rep-info https://git.build2.org/hello/libhello.git#HEAD
+
+# Adding and Removing Dependencies
+#
+cat <<EOF >>repositories.manifest
+:
+role: prerequisite
+location: $repo
+EOF
+cat <<EOF >>manifest
+depends: libhello ^1.0.0
+EOF
+sed -i -re 's/^#import/import/' hello/buildfile
+cat <<EOF >hello/hello.cxx
+#include <iostream>
+
+#include <libhello/hello.hxx>
+
+using namespace std;
+
+int main (int argc, char* argv[])
+{
+ if (argc < 2)
+ {
+ cerr << "error: missing name" << endl;
+ return 1;
+ }
+
+ hello::say_hello (cout, "World");
+}
+EOF
+
+show bdep status
+
+cat <<EOF >>repositories.manifest
+trust: $trust
+EOF
+
+show bdep sync
+
+echo '' >>manifest
+show b
+
+show bdep status -ai
+show bdep sync -a
+
+sed -i -re 's/^import/#import/' hello/buildfile
+sed -i -re 's/^depends: libhello/#depends: libhello/' manifest
+
+show bdep status
+show bdep sync
+
+# Upgrading and Downgrading Dependencies
+#
+sed -i -re 's/^#import/import/' hello/buildfile
+sed -i -re 's/^#depends: libhello/depends: libhello/' manifest
+bdep sync
+
+cat <<EOF >>repositories.manifest
+:
+role: prerequisite
+location: https://git.build2.org/hello/libhello.git
+EOF
+
+show bdep fetch
+show bdep status libhello
+show bdep sync libhello
+
+show bdep status -r
+
+show bdep status -o libhello
+show bdep sync libhello/1.0.0
+
+# Versioning and Release Management.
+#
+git add .
+git commit -m "Start hello project"
+
+show bdep status
+show b info
+show bdep sync
+show bdep status
+
+echo '' >>buildfile
+git commit -a -m "Another commit"
+
+show bdep status
+
+cd ..
+##fi
+
+# Package Consumption.
+#
+rm -rf tools
+
+show bpkg create -d tools cc \
+ config.cxx=$gcc \
+ config.cc.coptions=-O3 \
+ config.install.root=/opt/tools \
+ config.install.sudo=sudo \
+ config.bin.rpath=/opt/tools/lib
+
+show cd tools
+
+show bpkg build hello@https://git.build2.org/hello/hello.git
+show bpkg install hello
+show /opt/tools/bin/hello World
+show bpkg uninstall hello
+show bpkg drop hello