diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-05-05 14:26:14 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-05-05 14:26:14 +0200 |
commit | b22f2f86d4a7166b7098fc82944a198e6ad63748 (patch) | |
tree | 5e52471866323e253d3d53a07a24710ccc8273d6 /version | |
parent | 56c433b914d65ccf9b9c53a78562452475353e8d (diff) |
Updates for 0.5.0 release0.5.0
Diffstat (limited to 'version')
-rwxr-xr-x | version | 329 |
1 files changed, 73 insertions, 256 deletions
@@ -2,294 +2,111 @@ # Manage build2 toolchain version. # -# Usage: version [<module>...] -# -usage="usage: $0 [<module>...]" - -# Notes: -# -# * min/max are [min max) -# if min == max, then '== min' is assumed -# if max is unspecified, then '>= min' is assumed -# currently, max can only be 1.2.3- (#if-conditions will need adjustment) +# Usage: etc/version # +usage="usage: etc/version" # No max, always >=. # -build2_min=0.4.0 -bpkg_min=0.4.0 - -libbutl=0.5.0-a1 -libbutl_min=$libbutl -libbutl_max=$libbutl -#libbutl_max=0.6.0- # Comment if pre-release. -libbutl_build2=$build2_min -libbutl_bpkg=$bpkg_min -libbutl_hxx=butl/version -libbutl_libver=y - -build2=0.5.0-a1 -build2_libbutl_min=$libbutl_min -build2_libbutl_max=$libbutl_max -build2_build2=$build2_min -build2_bpkg=$bpkg_min -build2_hxx=build2/version - -libbpkg=0.5.0-a1 -libbpkg_min=$libbpkg -libbpkg_max=$libbpkg -#libbpkg_max=0.6.0- # Comment if pre-release. -libbpkg_libbutl_min=$libbutl_min -libbpkg_libbutl_max=$libbutl_max -libbpkg_build2=$build2_min -libbpkg_bpkg=$bpkg_min -libbpkg_hxx=bpkg/version -libbpkg_libver=y - -bpkg=0.5.0-a1 -bpkg_libbutl_min=$libbutl_min -bpkg_libbutl_max=$libbutl_max -bpkg_libbpkg_min=$libbpkg_min -bpkg_libbpkg_max=$libbpkg_max -bpkg_build2=$build2_min -bpkg_bpkg=$bpkg_min -bpkg_hxx=bpkg/bpkg-version - -build2_toolchain=0.5.0-a1 -build2_toolchain_build2=$build2_min - -brep=0.5.0-a1 -brep_libbutl_min=$libbutl_min -brep_libbutl_max=$libbutl_max -brep_libbpkg_min=$libbpkg_min -brep_libbpkg_max=$libbpkg_max -brep_build2=$build2_min -brep_bpkg=$bpkg_min -brep_hxx=brep/version -brep_libver=y - -# -# -owd=`pwd` -trap "{ cd $owd; exit 1; }" ERR -set -o errtrace # Trap in functions. +build2_min=0.5.0- +bpkg_min=0.5.0- -function info () { echo "$*" 1>&2; } -function error () { info "$*"; exit 1; } +ver=0.6.0-a.0.z +mods=(libbutl libbpkg libbbot) -modules= +odb_ver=2.5.0-b.2.z +odb_mods=(libodb libodb-sqlite libodb-pgsql) -while [ $# -gt 0 ]; do - case $1 in - *) - modules="$modules ${1%/}" - shift - ;; - esac -done +xml_ver=1.1.0-b.1.z +xml_mods=(libstudxml) -if [ -z "$modules" ]; then - modules="libbutl build2 libbpkg bpkg build2-toolchain brep" -fi +all=(libbutl build2 libbpkg bpkg libbbot brep bbot msvc-linux build2-toolchain) -function str_major () { echo "$1" | sed -e 's/\([0-9]*\).*/\1/' -; } -function str_minor () { echo "$1" | sed -e 's/[^.]*\.\([0-9]*\).*/\1/' -; } -function str_patch () { echo "$1" | sed -e 's/[^.]*\.[^.]*\.\([0-9]*\).*/\1/' -; } -function str_prere () { echo "$1" | sed -n -e 's/[^.]*\.[^.]*\.[^-]*\(-[ab]*[0-9]*\)/\1/p' -; } - -# Convert string version representation (1.2.3-a1) to its numeric equivalent -# in the form AABBCCDD where: -# -# AA - major version number -# BB - minor version number -# CC - bugfix version number -# DD - alpha / beta (DD + 50) version number -# -# When DD is not 00, 1 is subtracted from AABBCC. For example: -# -# Version AABBCCDD -# 2.0.0 02000000 -# 2.1.0 02010000 -# 2.1.1 02010100 -# 2.2.0-a1 02019901 -# 3.0.0-b2 02999952 +# In manifests for alpha/beta we use an exact match. For snapshots -- snapshot +# range. Otherwise an X.Y.* range. # -# For a version in the 1.2.3- form, it returns (AABBCC-1)00, which is the -# highest possible version that is less than 1.2.3-. -# -function str_num () # <ver-str> +function constraint () # <ver> { - # Here we assume the version is valid. - # - local a="$(str_major "$1")" - local b="$(str_minor "$1")" - local c="$(str_patch "$1")" - local d="$(str_prere "$1")" + local mj mn pt ab pr r - local v=$(($a * 1000000 + $b * 10000 + $c * 100)) + 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 [ "$d" ]; then - ((v -= 100)) - if [ $d != "-" ]; then - if [ ${d:1:1} = 'b' ]; then - ((v += 50)) - fi - d=`echo $d | sed -e 's/-[ab]\([0-9]*\)/\1/' -` - ((v += $d)) + 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 - #info $1 -> $a $b $c $d -> $v - echo $v + echo "$r" } -function str_num_test () { if [ `str_num $1` != $2 ]; then error $1 != $2; fi } - -str_num_test 2.0.0 2000000 -str_num_test 2.1.0 2010000 -str_num_test 2.1.1 2010100 -str_num_test 2.2.0-a1 2019901 -str_num_test 3.0.0-b2 2999952 +dep="$(constraint "$ver")" +odb_dep="$(constraint "$odb_ver")" +xml_dep="$(constraint "$xml_ver")" -str_num_test 2.0.0- 1999900 -str_num_test 2.2.0- 2019900 - - -# In-place sed. -# -function ised () # <regex> <file> +function process () # { - local r=$1 - local f=$2 - local o=$f.orig - - mv $f $o - cp -p $o $f # Keep owner, permissions. - - if ! sed -e "$r" $o >$f; then - mv $o $f - return 1 - fi - - if cmp -s $o $f; then - mv $o $f - else - rm $o - fi -} - -# Modules which we may depend on. These are translated to 'depends:' in the -# manifest and preprocessor checks in the version header. Note that we can -# add external modules like libodb, etc., when the time comes. -# -depends="libbutl libbpkg" - -for m in $modules; do - v=`echo $m | sed -e 's/-/_/g'` - V=`echo $v | sed -e 's/\(.*\)/\U\1/'` - - s=${!v} - n=`str_num $s` - - - b=${v}_build2; b=${!b} - p=${v}_bpkg; p=${!p} - l=${v}_libver; l=${!l} - - # version - # - ised "s/^[0-9].*/$s/" $m/version - - # manifest - # - if [ -f $m/manifest ]; then - ised "s/^\(version:\) .*/\1 $s/" $m/manifest - ised "s/^\(depends: \* build2\) .*/\1 >= $b/" $m/manifest - ised "s/^\(depends: \* bpkg\) .*/\1 >= $p/" $m/manifest - fi - - # bootstrap.build - # - ised "s/^\(version =\) .*/\1 $s/" $m/build/bootstrap.build - ised "s/^\(using build@\).*/\1$b/" $m/build/bootstrap.build - - # Library abi_* versions. + # Manifest. # - if [ "$l" = "y" ]; then - a="$(str_major "$s")" - b="$(str_minor "$s")" - c="$(str_patch "$s")" - d="$(str_prere "$s")" + 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 - #info "$m $s -> $a $b $c $d" - - if [ -z "$d" ]; then - d="false" - else - d="true" - fi - - ised "s/^\(abi_major =\) .*/\1 $a/" $m/build/bootstrap.build - ised "s/^\(abi_minor =\) .*/\1 $b/" $m/build/bootstrap.build - ised "s/^\(abi_patch =\) .*/\1 $c/" $m/build/bootstrap.build - ised "s/^\(abi_prerelease =\) .*/\1 $d/" $m/build/bootstrap.build - fi + local m + for m in "${mods[@]}"; do + sed -i -re "s/^(depends: $m) .*/\1 $dep/" manifest + done - # Fix configuration version in build scripts. - # - if [ "$m" = "build2-toolchain" ]; then - a="$(str_major "$s")" - b="$(str_minor "$s")" - d="$(str_prere "$s")" + for m in "${odb_mods[@]}"; do + sed -i -re "s/^(depends: $m) .*/\1 $odb_dep/" manifest + done - ised 's/^\(cver=\).*/\1"'"$a.$b$d"'"/' $m/build.sh - ised 's/^\(set "cver=\).*/\1'"$a.$b$d"'"/' $m/build-msvc.bat - ised 's/^\(set "cver=\).*/\1'"$a.$b$d"'"/' $m/build-mingw.bat - fi + for m in "${xml_mods[@]}"; do + sed -i -re "s/^(depends: $m) .*/\1 $xml_dep/" manifest + done - # version header + # cli.sh # - h=${v}_hxx; h=${!h} - if [ "$h" ]; then - ised "s/^\(#define ${V}_VERSION\) .*/\1 $n/" $m/$h - ised "s/^\(#define ${V}_VERSION_STR\) .*/\1 \"$s\"/" $m/$h + if [ -f doc/cli.sh ]; then + sed -i -re "s/^version=.*/version=$ver/" doc/cli.sh fi +} - # Dependencies (manifest and version header). - # - for d in $depends; do - if [ $d = $m ]; then continue; fi - - dv=`echo $d | sed -e 's/-/_/g'` - DV=`echo $dv | sed -e 's/\(.*\)/\U\1/'` +for m in "${all[@]}"; do + cd "$m" + process + cd .. +done - dmin=${v}_${dv}_min; dmin=${!dmin} - dmax=${v}_${dv}_max; dmax=${!dmax} +# 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')" - if [ -z "$dmin" ]; then continue; fi # No dependency. +cver="$mj.$mn" - dminn=`str_num $dmin` +if [ -n "$ab" ]; then + cver="$cver-$ab.$pr" +fi - # Figure out dependency contraints for the manifest and the header. - # - if [ -z "$dmax" ]; then - dcm=">= $dmin" - dch="${DV}_VERSION < $dminn" - elif [ "$dmin" = "$dmax" ]; then - dcm="== $dmin" - dch="${DV}_VERSION != $dminn" - else - dmaxn=`str_num $dmax` - dcm="[$dmin $dmax)" - dch="${DV}_VERSION < $dminn || ${DV}_VERSION > $dmaxn" - fi +cd build2-toolchain - if [ -f $m/manifest ]; then - ised "s/^\(depends: $d\) .*/\1 $dcm/" $m/manifest - fi +for m in build*.sh; do + sed -i -re "s/cver=\".+\"/cver=\"$cver\"/" $m +done - if [ "$h" ]; then - ised "s/^#if ${DV}_VERSION .*/#if $dch/" $m/$h - fi - done +for m in build*.bat; do + sed -i -re "s/\"cver=.+\"/\"cver=$cver\"/" $m done + +cd .. |