From c995248fc8bd605c2dee03e799e72d89872aa917 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 17 May 2014 21:07:38 -0700 Subject: Add helper scripts for changing VC projects --- bin/vc89change.sh | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 bin/vc89change.sh (limited to 'bin/vc89change.sh') diff --git a/bin/vc89change.sh b/bin/vc89change.sh new file mode 100755 index 0000000..f49764d --- /dev/null +++ b/bin/vc89change.sh @@ -0,0 +1,87 @@ +#! /usr/bin/env bash + +# Change VC8 or VC9 project file for another example. +# +# -n +# -f = matched with trailing . (must have ext); multiple +# -x +# + +trap 'exit 1' ERR + +function error () +{ + echo "$*" 1>&2 +} + +function uuid () +{ + uuidgen | sed -e 's#\(.*\)#\U\1#' +} + +new= +xsd= +fop= + +while [ $# -gt 0 ]; do + case $1 in + -n) + shift + new=$1 + shift + ;; + -f) + shift + o=`echo $1 | sed -e 's#\(.*\)=\(.*\)#\1#'` + n=`echo $1 | sed -e 's#\(.*\)=\(.*\)#\2#'` + echo "file change: $o.* -> $n.*" + fop="$fop -e s/$o\./$n./g" + shift + ;; + -x) + shift + xsd=$1 + shift + ;; + -*) + error "unknown option: $1" + exit 1 + ;; + *) + break + ;; + esac +done + +if [ "$new" = "" ]; then + error '-n expected' + exit 1 +fi + +if [ "$xsd" = "" ]; then + error '-x expected' + exit 1 +fi + +if [ "$1" = "" ]; then + error 'input file expected' + exit 1 +fi + +old=`echo "$1" | sed -e 's/\(.*\)-[89].*vcproj/\1/'` +ext=`echo "$1" | sed -e 's/.*-\([89].*vcproj\)/\1/'` + +echo "old name : $old" +echo "new name : $new" +echo "new xsd cmd: $xsd" + +sed \ +-e "s#Name=\"$old\"#Name=\"$new\"#" \ +-e "s#ProjectGUID=\"{.*}\"#ProjectGUID=\"{`uuid`}\"#" \ +-e "s#RootNamespace=\"$old\"#RootNamespace=\"$new\"#" \ +-e "s#UniqueIdentifier=.*#uuidgen | sed -e 's%\\\\(.*\\\\)%\t\t\tUniqueIdentifier=\"{\\\\U\\\\1}\"%'#e" \ +-e "s#CommandLine=\"xsd.exe .* \([^ ][^ ]*\)\"#CommandLine=\"xsd.exe $xsd \1\"#" \ +$fop \ +$1 >$new-$ext + +todos $new-$ext -- cgit v1.1