aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-10-20 10:50:22 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-10-20 10:50:22 +0200
commitb135374d5e40df21871b3e0c9efc69ba2d8361cb (patch)
tree0f53bf8253ff16b7ce176f47b56e4ac879a768c6 /build
parent54ed525e5b8680e8737b7750fd73458d9ef1d30c (diff)
Add tests to the distribution
The distribution makefiles for tests are automatically generated by the build/dist script. nmakefiles are not yet generated.
Diffstat (limited to 'build')
-rwxr-xr-xbuild/dist294
1 files changed, 294 insertions, 0 deletions
diff --git a/build/dist b/build/dist
new file mode 100755
index 0000000..7476952
--- /dev/null
+++ b/build/dist
@@ -0,0 +1,294 @@
+#! /usr/bin/env bash
+
+# file : build/dist
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+# Create test distribution and generate makefiles.
+#
+# -src $(src_base)
+# -out <dist root>
+# -xsd <schema files>
+# -cxx <c++ source files>
+# -hxx <c++ header files>
+# -ixx <c++ inline files>
+# -gen <generated files>
+# -cmd <xsde command>
+# -opt <xsde options>
+# -lib <extra libraries>
+#
+# -win generate MS nmakefile
+#
+# bld_root
+#
+trap 'exit 1' ERR
+
+function error ()
+{
+ echo "$*" 1>&2
+}
+
+function gen ()
+{
+ echo -e "$*" >>$out/makefile
+}
+
+type=gnu
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ -src)
+ src=$2
+ shift 2
+ ;;
+ -out)
+ out=$2
+ shift 2
+ ;;
+ -xsd)
+ xsd=$2
+ shift 2
+ ;;
+ -cxx)
+ cxx=$2
+ shift 2
+ ;;
+ -hxx)
+ hxx=$2
+ shift 2
+ ;;
+ -ixx)
+ ixx=$2
+ shift 2
+ ;;
+ -gen)
+ gen=$2
+ shift 2
+ ;;
+ -cmd)
+ cmd=$2
+ shift 2
+ ;;
+ -opt)
+ opt=$2
+ shift 2
+ ;;
+ -win)
+ type=win
+ shift
+ ;;
+ -lib)
+ lib=$2
+ shift 2
+ ;;
+ *)
+ error "unknown option: $1"
+ exit 1
+ ;;
+ esac
+done
+
+if [ "$src" = "" ]; then
+ error "-src option is not specified"
+ exit 1
+fi
+
+if [ "$out" = "" ]; then
+ error "-out option is not specified"
+ exit 1
+fi
+
+# Calculate the root path.
+#
+root=`echo $src | sed -e 's%.*/tests/\(.*\)%tests/\1%' -`
+out=$out/$root
+root=`echo $root | sed -e 's%[^/]*%..%g' -`
+
+# Sanitize any absolute paths in opt.
+#
+opt=`echo $opt | sed -e "s%$src/\([^ ]*\)%\1%g" -`
+
+# Gather object files.
+#
+if [ "$gen" != "" ]; then
+ gen_cxx=`echo $gen | sed -e 's%[^ ]*\.[h|i]xx *%%g' -`
+ gen_hxx=`echo $gen | sed -e 's%[^ ]*\.[c|i]xx *%%g' -`
+ gen_ixx=`echo $gen_cxx | sed -e 's%.cxx%.ixx%g' -`
+fi
+
+obj=`echo $cxx $gen_cxx | sed -e 's%\.cxx%.o%g' -`
+
+if [ "$obj" = "" ]; then
+ error "no source files specified"
+ exit 1
+fi
+
+# Find the test driver name.
+#
+if [ "$cxx" != "" ]; then
+ driver=`echo $cxx | sed -e "s/ /\n/g" | sed -e "s/driver\.cxx/driver/" -e t -e d -`
+ driver=`echo $driver` # Get rid of newlines.
+fi
+
+if [ "$driver" = "" -a "$gen_cxx" != "" ]; then
+ # See if the driver is auto-generated.
+ #
+ driver=`echo $gen_cxx | sed -e "s/ /\n/g" | sed -e "s/\([^ ]*\)driver\.cxx/\1driver/" -e t -e d -`
+ driver=`echo $driver` # Get rid of newlines.
+fi
+
+if [ "$driver" = "" ]; then
+ error "no driver file found"
+ exit 1
+fi
+
+# Figure out the stem and pattern for the schema and gen files. If
+# we have more than one schema file, base the stem and the pattern
+# on the first file.
+#
+for i in $xsd; do
+ stem=`echo $i | sed -e 's%\.xsd%%' -`
+ pat=`echo $gen | sed -e "s/ /\n/g" | sed -e "s/$stem/%/" -e t -e d -`
+ pat=`echo $pat` # Get rid of newlines.
+done
+
+
+# Sense what kind of tests we need to run.
+#
+xml=`find $src -name 'test-*.xml' | sed -e 's%.*/\([^/]*\)%\1%' -`
+std=`find $src -name 'test-*.std' | sed -e 's%.*/\([^/]*\)%\1%' -`
+
+# Install files.
+#
+install=$bld_root/install/install
+
+$install -d -m 755 $out
+
+for i in $cxx $hxx $ixx; do
+ $install -p -m 644 $src/$i $out/$i
+done
+
+for i in $xsd; do
+ $install -p -m 644 $src/$i $out/$i
+
+ # See if we have a map file for this schema.
+ #
+ m=`echo $i | sed -e 's%\.xsd%.map%' -`
+ if [ -f "$src/$m" ]; then
+ $install -p -m 644 $src/$m $out/$m
+ fi
+done
+
+for i in $xml; do
+ $install -p -m 644 $src/$i $out/$i
+done
+
+for i in $std; do
+ $install -p -m 644 $src/$i $out/$i
+done
+
+# Generate the makefile.
+#
+rm -f $out/makefile
+
+gen "root := $root"
+gen
+gen 'include $(root)/build/cxx/rules.make'
+gen
+gen 'EXTRA_CPPFLAGS := -I$(root)/libxsde'
+gen
+
+if [ "$lib" != "" ]; then
+ s=`echo $lib | sed -e 's/\([^ ]*\)/-l\1/g' -`
+ gen "override LIBS += $s"
+ gen
+fi
+
+gen 'ifeq ($(XSDE_STL),n)'
+gen 'EXTRA_XSDFLAGS += --no-stl'
+gen 'endif'
+gen
+gen 'ifeq ($(XSDE_IOSTREAM),n)'
+gen 'EXTRA_XSDFLAGS += --no-iostream'
+gen 'endif'
+gen
+gen 'ifeq ($(XSDE_EXCEPTIONS),n)'
+gen 'EXTRA_XSDFLAGS += --no-exceptions'
+gen 'endif'
+gen
+gen 'ifeq ($(XSDE_LONGLONG),n)'
+gen 'EXTRA_XSDFLAGS += --no-long-long'
+gen 'endif'
+gen
+gen 'ifeq ($(XSDE_PARSER_VALIDATION),n)'
+gen 'EXTRA_XSDFLAGS += --suppress-parser-val'
+gen 'endif'
+gen
+gen 'ifeq ($(XSDE_SERIALIZER_VALIDATION),n)'
+gen 'EXTRA_XSDFLAGS += --suppress-serializer-val'
+gen 'endif'
+gen
+gen 'ifeq ($(XSDE_REUSE_STYLE),mixin)'
+gen 'EXTRA_XSDFLAGS += --reuse-style-mixin'
+gen 'endif'
+gen
+gen 'ifeq ($(XSDE_POLYMORPHIC),y)'
+gen 'EXTRA_XSDFLAGS += --runtime-polymorphic'
+gen 'endif'
+gen
+gen "$driver: $obj" '$(root)/libxsde/xsde/libxsde.a'
+gen
+
+for i in $cxx; do
+ o=`echo $i | sed -e 's%\.cxx%.o%' -`
+ gen "$o: $i $gen_hxx"
+done
+
+for i in $gen_cxx; do
+ o=`echo $i | sed -e 's%\.cxx%.o%' -`
+ gen "$o: $i"
+done
+
+gen
+
+if [ "$xsd" != "" ]; then
+gen ".PRECIOUS: $pat"
+gen "$pat: %.xsd"
+gen '\t$(root)/bin/xsde' $cmd '$(XSDFLAGS) $(EXTRA_XSDFLAGS)' $opt '$<'
+gen
+fi
+
+gen '.PHONY: test'
+gen "test: $driver"
+if [ "$xml" = "" ]; then
+ if [ "$std" = "" ]; then
+ # Simple return value test.
+ #
+ gen "\t./$driver"
+ else
+ # Test with result comparison.
+ #
+ gen "\t./$driver | diff -u $std -"
+ fi
+else
+ for i in $xml; do
+ if [ "$std" = "" ]; then
+ # Return value test with argument.
+ #
+ gen "\t./$driver $i"
+ else
+ # Test with argument and result comparison.
+ #
+ s=`echo $i | sed -e 's%\.xml%.std%' -`
+ gen "\t./$driver $i | diff -u $s -"
+ fi
+ done
+fi
+
+gen
+
+gen '.PHONY: clean'
+gen 'clean:'
+gen "\trm -f $driver $obj $gen_cxx $gen_ixx $gen_hxx"
+gen