diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2014-05-17 21:07:38 -0700 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2014-05-17 21:07:38 -0700 |
commit | c995248fc8bd605c2dee03e799e72d89872aa917 (patch) | |
tree | cfce8d8b2bca0cf708cbeff9f7e892e7f159fb5d /bin/vc10change.sh | |
parent | 5948f1df883cabc99b5fde0bfc6177df27e86178 (diff) |
Add helper scripts for changing VC projects
Diffstat (limited to 'bin/vc10change.sh')
-rwxr-xr-x | bin/vc10change.sh | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/bin/vc10change.sh b/bin/vc10change.sh new file mode 100755 index 0000000..e4f820d --- /dev/null +++ b/bin/vc10change.sh @@ -0,0 +1,93 @@ +#! /usr/bin/env bash + +# Change VC10 project file for another example. +# +# -n <new name> +# -f <old-file>=<new-file> matched with trailing . (must have ext); multiple +# -x <new xsd command and options> +# + +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 <new name> expected' + exit 1 +fi + +if [ "$xsd" = "" ]; then + error '-x <new xsd command and options> expected' + exit 1 +fi + +if [ "$1" = "" ]; then + error 'input file expected' + exit 1 +fi + +old=`echo "$1" | sed -e 's/\(.*\)-10.0.vcxproj/\1/'` +ext=`echo "$1" | sed -e 's/.*-\(10.0.vcxproj\)/\1/'` + +echo "old name : $old" +echo "new name : $new" +echo "new xsd cmd: $xsd" + +sed \ +-e "s#<ProjectName>$old#<ProjectName>$new#" \ +-e "s#<ProjectGuid>{.*}#<ProjectGuid>{`uuid`}#" \ +-e "s#<RootNamespace>$old#<RootNamespace>$new#" \ +-e "s#xsd.exe .* \([^ ][^ ]*\)</Command>#xsd.exe $xsd \1</Command>#" \ +$fop \ +$1 >$new-$ext + +todos $new-$ext + +sed \ +-e "s#<UniqueIdentifier>.*#uuidgen | sed -e 's%\\\\(.*\\\\)% <UniqueIdentifier>{\\\\U\\\\1\\\\E}</UniqueIdentifier>%'#e" \ +$fop \ +$1.filters >$new-$ext.filters + +todos $new-$ext.filters |