-
Notifications
You must be signed in to change notification settings - Fork 0
/
createproject.sh
executable file
·72 lines (57 loc) · 1.51 KB
/
createproject.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
me=$0
shortopts="lhm::n:"
longopts="help,platforms,name:,mcu:"
opts=$(getopt -o "$shortopts" -l "$longopts" -n "$(basename $0)" -- "$@")
eval set -- "$opts"
MCU=''
NAME=''
function print_help
{
echo "Usage $me [param(s)]";
echo -e "\tParams:";
echo -e "\t-h|--help\tPrints this help screen";
echo -e "\t-l|--platforms\tList supported platforms(mcu)";
echo -e "\t-n|--name\tNew project name (manditory)";
echo -e "\t-m|--mcu\tTarget MCU (manditory). See --platforms";
exit;
}
function print_platforms
{
echo "Supported achitectures and MCUs";
echo ""
cat scripts/platforms.dat
echo ""
echo "To define target MCU use parameter -m . Example: $0 --mcu=stm8s"
exit;
}
function dump_gcc_vars
{
avr-gcc -dM -E - < /dev/null
}
while true; do
case "$1" in
-h | --help) print_help ;;
-l | --platforms) print_platforms ;;
-m | --mcu ) MCU=$2; shift 2;;
-n | --name ) NAME=$2; shift 2;;
-- ) shift; break ;;
* ) break ;;
esac
done
if [ -z $MCU ] || [ -z $NAME ];then
print_help
fi
ARCH=$(cat scripts/platforms.dat | grep $MCU | awk -F ':' '{print $1}' )
PROJECTNAME=`echo firmware-$NAME-$ARCH | tr '[:upper:]' '[:lower:]'`
WORKDIR="devices/$PROJECTNAME"
mkdir -p $WORKDIR
. scripts/create-makefile-$ARCH.sh
create_makefile
echo -e "Project created !";
echo -e "\nNext steps:\n"
echo -e "1. cd $WORKDIR"
echo -e "2. Edit config.h and define WIREBUS_UUID_MAJOR and WIREBUS_UUID_MINOR of your new device"
echo -e "3. Edit file $PROJECTNAME.c to insert your custom code"
echo -e "4. make"
echo ""