diff options
Diffstat (limited to 'build/meta/vctest')
-rwxr-xr-x | build/meta/vctest | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/build/meta/vctest b/build/meta/vctest new file mode 100755 index 0000000..5aa70eb --- /dev/null +++ b/build/meta/vctest @@ -0,0 +1,137 @@ +#! /usr/bin/env bash + +# file : build/meta/vctest +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# Process VC++ test templates. +# +# Options: +# +# -b <base-dir> +# -r <root-dir> +# -o <output-file> +# -s <vc-solution> +# +# Arguments: +# +# <template-file> +# +trap 'exit 1' ERR + +function error () +{ + echo "$*" 1>&2 +} + +base= +root= +output= +sln= + +while [ $# -gt 0 ]; do + case $1 in + -b) + base=$2 + shift 2 + ;; + -r) + root=$2 + shift 2 + ;; + -o) + output=$2 + shift 2 + ;; + -s) + sln=$2 + shift 2 + ;; + *) + break + ;; + esac +done + +input=$1 + +if [ "$input" = "" ]; then + error "no input file" + exit 1 +fi + +if [ "$base" = "" ]; then + error "no base directory" + exit 1 +fi + +if [ "$root" = "" ]; then + error "no root directory" + exit 1 +fi + +if [ "$output" = "" ]; then + error "no output file" + exit 1 +fi + +if [ "$sln" = "" ]; then + error "no solution file" + exit 1 +fi + +m4=m4 +u2d=unix2dos + +# Assume this script is never found via PATH. +# +meta=`dirname $0` + +build="$meta/.." +install=$build/install/install + +# Figure out topdir +# +if [ "$base" = "$root" ]; then + topdir=. +else + topdir=`echo $base | sed -e "s%^$root/%%" - | \ +sed -e 's%[^/][^/]*/%../%g;s%[^./][^./]*$%..%' -` +fi + +# + +# Determine possible configurations. +# +sln_conf=`cat $sln | dos2unix | sed -n -e \ +'/^[ ]*GlobalSection(SolutionConfigurationPlatforms).*$/{\ +: loop;\ +n;\ +/^[ ]*EndGlobalSection$/q;\ +s/^[ ]*\([^=]*\) = \([^=]*\)$/\1/p;\ +b loop};\ +d' -` + +conf= +for c in $sln_conf; do + build=`echo $c | sed -e 's/^\(.*\)|.*$/\1/'` + arch=`echo $c | sed -e 's/^.*|\(.*\)$/\1/'` + + if [ "$arch" = "Win32" ]; then + conf="$conf $build" + else + conf="$conf $arch/$build" + fi +done + +export topdir +export configurations=$conf + +# Make sure the output directory exist. +# +$install -d -m 755 `dirname $output` + +$m4 -P -D__meta_base__=$meta $meta/vctest.m4 $input >$output +$u2d $output +chmod 644 $output |