xref: /btstack/tool/migration_to_v1.0/migration.sh (revision 401038441ef6e979c0e146a8f6666852739d1fe9)
1#!/bin/bash
2set -e
3set -u
4
5USAGE="Usage: migration.sh src-path dest-path"
6
7echo "BTstack conversion to v1.0 helper"
8echo "BlueKitchen GmbH, 2016"
9echo
10
11# command line checks, bash
12if [ $# -ne 2 ]; then
13        echo ${USAGE}
14        exit 0
15fi
16SRC=$1
17DEST=$2
18DIR=`dirname $0`
19
20echo "Creating copy of $SRC at $DEST"
21cp -r $SRC/ $DEST
22
23echo "Updating function calls"
24
25# simple function rename
26find $DEST -type f -print0 | xargs -0 sed -i -f $DIR/migration.sed
27
28# complext function rename using coccinelle
29command -v spatch >/dev/null 2>&1 || { echo >&2 "spatch from cocinelle required but not installed. Aborting."; exit 1; }
30spatch --sp-file $DIR/migration.cocci --in-place  --dir $DEST > /dev/null # 2>&1
31echo "Done. Good luck!"
32
33
34