summaryrefslogtreecommitdiff
path: root/version
blob: cce45ad32dca41e4bb3772e4e32c54af12643b24 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#! /usr/bin/env bash

# Manage build2 toolchain version.
#
# Usage: etc/version
#
usage="usage: etc/version"

# No max, always >=.
#
build2_min=0.5.0-
bpkg_min=0.5.0-

ver=0.6.0-a.0.z
mods=(libbutl libbpkg libbbot)

odb_ver=2.5.0-b.4.z
odb_mods=(libodb libodb-sqlite libodb-pgsql)

xml_ver=1.1.0-b.1.z
xml_mods=(libstudxml)

all=(libbutl build2 libbpkg bpkg libbbot brep bbot msvc-linux build2-toolchain)

# In manifests for alpha/beta we use an exact match. For snapshots -- snapshot
# range. Otherwise an X.Y.* range.
#
function constraint () # <ver>
{
  local mj mn pt ab pr r

  mj="$(echo "$1" | sed -re 's/([^.]+)\..*/\1/')"
  mn="$(echo "$1" | sed -re 's/[^.]+\.([^.]+)\..*/\1/')"
  pt="$(echo "$1" | sed -re 's/[^.]+\.[^.]+\.([^.-]+).*/\1/')"
  ab="$(echo "$1" | sed -n -re 's/[^.]+\.[^.]+\.[^.-]+-([ab]).*/\1/p')"
  pr="$(echo "$1" | sed -n -re 's/[^.]+\.[^.]+\.[^.-]+-[ab]\.([^.+]+).*/\1/p')"

  if [ -n "$ab" ]; then
    if [[ $1 == *.z ]]; then
      r="[$mj.$mn.$pt-$ab.$pr.1 $mj.$mn.$pt-$ab.$(($pr+1)))"
    else
      r="== $1"
    fi
  else
    r="[$mj.$mn.0 $mj.$(($mn+1)).0-); $mj.$mn.X"
  fi

  echo "$r"
}

dep="$(constraint "$ver")"
odb_dep="$(constraint "$odb_ver")"
xml_dep="$(constraint "$xml_ver")"

function process () #
{
  # Manifest.
  #
  sed -i -re "s/^(version:).*/\1 $ver/"                      manifest
  sed -i -re "s/^(depends: \* build2) .*/\1 >= $build2_min/" manifest
  sed -i -re "s/^(depends: \* bpkg) .*/\1 >= $bpkg_min/"     manifest

  local m
  for m in "${mods[@]}"; do
    sed -i -re "s/^(depends: $m) .*/\1 $dep/" manifest
  done

  for m in "${odb_mods[@]}"; do
    sed -i -re "s/^(depends: $m) .*/\1 $odb_dep/" manifest
  done

  for m in "${xml_mods[@]}"; do
    sed -i -re "s/^(depends: $m) .*/\1 $xml_dep/" manifest
  done

  # cli.sh
  #
  if [ -f doc/cli.sh ]; then
    sed -i -re "s/^version=.*/version=$ver/" doc/cli.sh
  fi
}

for m in "${all[@]}"; do
  cd "$m"
  process
  cd ..
done

# Configuration version.
#
mj="$(echo "$ver" | sed -re 's/([^.]+)\..*/\1/')"
mn="$(echo "$ver" | sed -re 's/[^.]+\.([^.]+)\..*/\1/')"
ab="$(echo "$ver" | sed -n -re 's/[^.]+\.[^.]+\.[^.-]+-([ab]).*/\1/p')"
pr="$(echo "$ver" | sed -n -re 's/[^.]+\.[^.]+\.[^.-]+-[ab]\.([^.+]+).*/\1/p')"

cver="$mj.$mn"

if [ -n "$ab" ]; then
  cver="$cver-$ab.$pr"
fi

cd build2-toolchain

for m in build*.sh; do
  sed -i -re "s/cver=\".+\"/cver=\"$cver\"/" $m
done

for m in build*.bat; do
  sed -i -re "s/\"cver=.+\"/\"cver=$cver\"/" $m
done

cd ..