aboutsummaryrefslogtreecommitdiff
path: root/build/meta/vcsln
diff options
context:
space:
mode:
Diffstat (limited to 'build/meta/vcsln')
-rwxr-xr-xbuild/meta/vcsln135
1 files changed, 135 insertions, 0 deletions
diff --git a/build/meta/vcsln b/build/meta/vcsln
new file mode 100755
index 0000000..c714afd
--- /dev/null
+++ b/build/meta/vcsln
@@ -0,0 +1,135 @@
+#! /usr/bin/env bash
+
+# file : build/meta/vcsln
+# 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++ solution templates.
+#
+# Options:
+#
+# -b <base-dir>
+# -o <output-file>
+# -e <project-ext>
+#
+# Arguments:
+#
+# <template-file>
+#
+trap 'exit 1' ERR
+
+function error ()
+{
+ echo "$*" 1>&2
+}
+
+base=
+output=
+projext=
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ -b)
+ base=$2
+ shift 2
+ ;;
+ -o)
+ output=$2
+ shift 2
+ ;;
+ -e)
+ projext=$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 [ "$output" = "" ]; then
+ error "no output file"
+ exit 1
+fi
+
+if [ "$projext" = "" ]; then
+ error "no VC++ project file extension"
+ exit 1
+fi
+
+m4=m4
+u2d=unix2dos
+
+# Assume this script is never found via PATH.
+#
+meta=`dirname $0`
+
+build="$meta/.."
+install=$build/install/install
+
+# Find all the solution files.
+#
+proj_files=`find $base -name '*'$projext`
+proj_names=`echo "$proj_files" | sed -e "s%^$base/\(.*\)/.*$%\1%"`
+
+# Determine available configurations and project uuids.
+#
+for f in $proj_files; do
+
+ if [ "$conf" = "" ]; then
+ if [ "$projext" = ".vcproj" ]; then
+ conf=`cat $f | dos2unix | sed -n -e \
+ '/^[ ]*<Configuration$/{n;s/[ ]*Name="\([^"]*\)"$/"\1",/p};d' -`
+ conf=`echo $conf | sed -e 's/,$//'`
+ else
+ conf=`cat $f | dos2unix | sed -n -e \
+ 's/^[ ]*<ProjectConfiguration Include="\([^"]*\)">$/"\1",/p;d' -`
+ conf=`echo $conf | sed -e 's/,$//'`
+ fi
+ fi
+
+ if [ "$projext" = ".vcproj" ]; then
+ uuid=`cat $f | dos2unix | sed -n -e \
+ 's/^[ ]*ProjectGUID="{\([^}]*\)}"$/\1/p;d'`
+ else
+ uuid=`cat $f | dos2unix | sed -n -e \
+ 's/^[ ]*<ProjectGuid>{\([^}]*\)}<\/ProjectGuid>$/\1/p;d'`
+ fi
+
+ if [ "$proj_uuids" = "" ]; then
+ proj_uuids=$uuid
+ else
+ proj_uuids="$proj_uuids $uuid"
+ fi
+done
+
+proj_files=`echo "$proj_files" | sed -e "s%^$base/%%"`
+
+#echo $proj_names
+#echo $proj_uuids
+
+export configurations=$conf
+export project_files=$proj_files
+export project_names=$proj_names
+export project_uuids=$proj_uuids
+
+# Make sure the output directory exist.
+#
+$install -d -m 755 `dirname $output`
+
+$m4 -P -D__meta_base__=$meta $meta/vcsln.m4 $input >$output
+$u2d $output
+chmod 644 $output