generatePlugin.sh 2.87 KB
Newer Older
1
2
#!/bin/sh

3
4
# Reminder in shell 0 = true, 1 = false

5
#TODO: make sensor and group name configurable
Micha Mueller's avatar
Micha Mueller committed
6

7
8
9
10
# Init variables
DATE=`date '+%d.%m.%Y'`
AUTHOR="Your name goes here!"
PLUGIN_NAME=""
11
enableEntities=false
12
13

# parse input
14
while getopts "hp:e:a:" opt; do
15
16
17
18
19
20
	case "$opt" in
	h)
		echo "Usage:"
		echo "./generatePlugin.sh -p pluginName"
		echo "Options:"
		echo "-h\tPrint this help section"
21
		echo "-e xx\tGenerate files for entity"
22
23
24
25
26
27
28
		echo "-a xx\tSpecify name of the author which is  to be mentioned in the"
		echo "\tsource files"
		exit 0
		;;
	p)	PLUGIN_NAME=$OPTARG
		echo "Plugin named ${PLUGIN_NAME}"
		;;
29
30
31
32
	e)	enableEntities=true
	  ENTITY_NAME=$OPTARG
    echo "Generating entity ${ENTITY_NAME}"
		;;
33
34
35
36
37
	a)	AUTHOR=$OPTARG
		echo "Author: ${AUTHOR}"
		;;
	esac
done
38
39

# first check input parameters
40
if [ -z ${PLUGIN_NAME} ]
41
  then
42
    echo "Invalid plugin name!"
43
44
45
    exit 1
fi

46
# Set further variables
47
48
PLUGIN_NAME_UPC=`echo $PLUGIN_NAME | tr 'a-z' 'A-Z'`
PLUGIN_NAME_LWC=`echo $PLUGIN_NAME | tr 'A-Z' 'a-z'`
49
50
51
52
53
if [ "$enableEntities" = true ]
then
	ENTITY_NAME_UPC=`echo $ENTITY_NAME | tr 'a-z' 'A-Z'`
	ENTITY_NAME_LWC=`echo $ENTITY_NAME | tr 'A-Z' 'a-z'`
fi
54
55
56

if [ -e ${PLUGIN_NAME_LWC} ]
then
57
	echo "${PLUGIN_NAME_LWC}/ directory already present. Overwriting"
58
59
60
61
62
63
64
65
66
67
else
	echo "Creating ${PLUGIN_NAME_LWC}/ directory"
	mkdir ${PLUGIN_NAME_LWC}
fi
cd ${PLUGIN_NAME_LWC}

# Generate ...SensorBase.h
echo "Generating ${PLUGIN_NAME}SensorBase.h ..."
. ../SensorBase_h.sh

Micha Mueller's avatar
Micha Mueller committed
68
69
70
# Generate ...SensorGroup.h
echo "Generating ${PLUGIN_NAME}SensorGroup.h ..."
. ../SensorGroup_h.sh
71

Micha Mueller's avatar
Micha Mueller committed
72
73
74
# Generate ...SensorGroup.cpp
echo "Generating ${PLUGIN_NAME}SensorGroup.cpp ..."
. ../SensorGroup_cpp.sh
75

76
77
78
79
80
81
82
83
84
85
86
if [ "$enableEntities" = true ]
then
	# Generate ...$Entity.h
	echo "Generating ${PLUGIN_NAME}${ENTITY_NAME}.h ..."
	. ../Entity_h.sh

	# Generate ...$Entity.cpp
	echo "Generating ${PLUGIN_NAME}${ENTITY_NAME}.cpp ..."
	. ../Entity_cpp.sh
fi

87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Generate ...Configurator.h
echo "Generating ${PLUGIN_NAME}Configurator.h ..."
. ../Configurator_h.sh

# Generate ...Configurator.cpp
echo "Generating ${PLUGIN_NAME}Configurator.cpp ..."
. ../Configurator_cpp.sh

# Generate Makefile code
echo "Generating code for Makefile ..."
. ../makefile.sh

# Generate ....conf
echo "Generating ${PLUGIN_NAME}.conf ..."
. ../config.sh

echo ""
echo "Plugin generator completed succefully"
echo ""
echo "Further steps to take from here:"
echo "* The generated files should go to their appropriate location:"
echo "  - the .conf goes to the other config files in config/"
echo "  - the source files should go in their own plugin directory at src/sensors/"
echo "  - copy required lines into Makefile as instructed in appendToMakefile.txt"
echo "* Complete the code in the generated source files. The TODOs are a good starting point, but you"
echo "  may need to make even more changes (and create more source files) for your plugin to work"
echo "* Extend the .conf and Makefile as required."