-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathplugin_template.sh
84 lines (67 loc) · 1.78 KB
/
plugin_template.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
set -e
[ "$1" ] || {
echo "usage: $0 <plugin name> (parent type)"
exit 1
}
PARENT_CLASS=Object
[ "$2" ] && PARENT_CLASS="$2"
mkdir "$1"
cat << EOF >> "$1/Makefile"
include ../config.mk
#CFLAGS+=-I<more include>
#LDFLAGS+=-l<more LIBS>
include ../config_post.mk
EOF
cat << EOF > "$1/README.md"
# $1
a [Gwion](https://github.com/Gwion/Gwion) plugin.
## Description
use [$1](https://github.com/.../$1)
## Configuration
check your [Gwion-plug](https://github.com/Gwion/gwion-plug) configuration. (e.g. edit config.mk)
edit Makefile
## Building
ensure [$1](https://github.com/.../$1) is installed
\`\`\`
make
# optionnal
make install
\`\`\`
# Usage
check .gw files in the directory.
EOF
cat << EOF > "$1/${1,,}.c"
#include "gwion_util.h"
#include "gwion_ast.h"
#include "gwion_env.h"
#include "vm.h"
#include "instr.h"
#include "gwion.h"
#include "object.h"
#include "plug.h"
#include "operator.h"
#include "import.h"
#include "ugen.h"
#include "array.h"
static CTOR(${1,,}_ctor) { /*code here */ }
static DTOR(${1,,}_dtor) { /*code here */ }
static MFUN(mfun) { /*code here */ }
static SFUN(sfun) { /*code here */ }
GWION_IMPORT($1) {
DECL_OB(const Type, t_${1,,}, = gwi_class_ini(gwi, "${1,,}", "$PARENT_CLASS"));
gwi_class_xtor(gwi, ${1,,}_ctor, ${1,,}_dtor);
GWI_BB(gwi_item_ini(gwi, "int", "member"));
GWI_BB(gwi_item_end(gwi, ae_flag_none, num, 0)));
GWI_BB(gwi_item_ini(gwi, "int", "static"));
GWI_BB(gwi_item_end(gwi, ae_flag_static, num, 1234)));
GWI_BB(gwi_func_ini(gwi, "int", "mfun"));
GWI_BB(gwi_func_arg(gwi, "int", "arg"));
GWI_BB(gwi_func_end(gwi, mfun, ae_flag_none));
GWI_BB(gwi_func_ini(gwi, "int", "sfun"));
GWI_BB(gwi_func_arg(gwi, "int", "arg"));
GWI_BB(gwi_func_end(gwi, sfun, ae_flag_static));
GWI_BB(gwi_class_end(gwi));
return GW_OK;
}
EOF