summaryrefslogtreecommitdiff
path: root/intro2-tldr
blob: ee1f48729685b346ef2884b1b2e7e1e75bb2918a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#! /usr/bin/env bash

# Test examples from the intro2, the TL;DR section.
#
# Usage: intro [options]
#
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

function show () # <cmd> ...
{
  if [ $show = "y" ]; then
    echo
    echo "+ $*"
    "${@}"
  else
    "${@}"
  fi
}

cd "$tmp"

rm -rf hello.git hello hello-gcc

# Prepare hello.git repository.
#
bdep new -t exe -l c++ --no-init -o hello.git hello
cd hello.git
sed -i -re 's/version: .+/version: 0.1.0/' manifest
git add .
git commit -m "first commit"
cd ..

show git clone file://$tmp/hello.git
show tree hello

show cd hello
show bdep init --config-create ../hello-gcc cc config.cxx=g++
show b
show hello/hello World

cat <<EOF >>repositories.manifest
:
role: prerequisite
location: https://git.build2.org/hello/libhello.git#v1.0.0
EOF
cat <<EOF >>manifest
depends: libhello ^1.0.0
EOF
sed -i -re 's/#import/import/' hello/buildfile
cat <<EOF >>hello/hello.cxx
#include <libhello/hello.hxx>
EOF

show b

sed -i -re 's/#v1.0.0//' repositories.manifest
show bdep fetch
bdep sync
show bdep status -i

show bdep sync libhello
show bdep sync libhello/1.0.0

cd ..