summaryrefslogtreecommitdiff
path: root/gst-plugin/tools/make_element
blob: fd79c2f2a0971ea3f9c672b85a695b516e9c8224 (plain)
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
85
86
87
#!/bin/sh

Template=$1;
srcfile=$2.c;
srcfile_h=$2.h;
meson_build=../meson.build;

if test x"$1" = x ; then
	echo "$0 Objectname [srcfile]\n";
	echo "  creates gstobjectname.{c,h} implementing GstObjectname\n";
	exit 1;
fi

if test x"$2" = x ; then
	srcfile="gstplugin.c"
	srcfile_h="gstplugin.h"
fi

id=$(echo '$Id$' | sed \
	-e 's/\$I[d]: \([^$]*\)\$/\1/g' \
	)

TEMPLATE=$(echo $Template | tr a-z A-Z)
template=$(echo $Template | tr A-Z a-z)
filename=$(echo $template | tr -d _)
Template=$(echo $Template | tr -d _)
template_=$(echo $Template | sed "s/\([a-z]\)\([A-Z]\)/\1_\2/g" | tr A-Z a-z)

YEAR=`date "+%Y"`
if [ -z "$REAL_NAME" ]; then
  user=`id -u`
  if [ `which 2>/dev/null getent` ]; then
    entry=`getent passwd $user`
  else
    entry=`grep $user /etc/passwd`
  fi
  REAL_NAME=`echo $entry | awk -F":" '{ print $5 }' | awk -F"," '{ print $1 }'`
fi
if [ -z "$EMAIL_ADDRESS" ]; then
  EMAIL_ADDRESS="<user@hostname.org>"
fi

# remember to break up the Id: in the line below
sed \
	-e 's/gstplugin\.c/SOURCEFILE/g' \
	-e "s/gstplugin\.h/gst$filename.h/g" \
        -e "s/gsttransform\.h/gst$filename.h/g" \
	-e "s/GstPluginTemplate/Gst$Template/g" \
	-e "s/plugin_template/$template_/g" \
	-e "s/GST_PLUGIN_TEMPLATE/GST_$TEMPLATE/g" \
	-e "s/GST_TYPE_PLUGIN_TEMPLATE/GST_TYPE_$TEMPLATE/g" \
	-e 's/\$I[d]: \([^$]*\)\$/\1/g' \
	-e 's/SOURCEFILE/gstobject\.c/g' \
	-e "s%MAKEFILTERVERSION%$id%g" \
	-e "s/plugin/$template/g" \
	-e "s/\([^G][^s][^t]\)Plugin/\1$Template/g" \
	-e "s/YEAR/$YEAR/g" \
	-e "s/AUTHOR_NAME/$REAL_NAME/g" \
	-e "s/AUTHOR_EMAIL/<$EMAIL_ADDRESS>/g" \
	$srcfile >gst$filename.c.tmp && mv gst$filename.c.tmp gst$filename.c

if [ -e $srcfile_h ]; then
  sed \
	-e 's/gstplugin\.c/SOURCEFILE/g' \
	-e "s/GstPluginTemplate/Gst$Template/g" \
	-e "s/plugin_template/$template_/g" \
	-e "s/gst_type_plugin_template/gst_$template_/g" \
	-e "s/PLUGIN_TEMPLATE/$TEMPLATE/g" \
	-e "s/GST_TYPE_PLUGIN_TEMPLATE/GST_TYPE_$TEMPLATE/g" \
	-e "s/GST_IS_PLUGIN_TEMPLATE/GST_IS_$TEMPLATE/g" \
	-e 's/\$I[d]: \([^$]*\)\$/\1/g' \
	-e 's/SOURCEFILE/gstobject\.c/g' \
	-e "s%MAKEFILTERVERSION%$id%g" \
	-e "s/plugin/$template/g" \
	-e "s/\([^G][^s][^t]\)Plugin/\1$Template/g" \
	-e "s/YEAR/$YEAR/g" \
	-e "s/AUTHOR_NAME/$REAL_NAME/g" \
	-e "s/AUTHOR_EMAIL/<$EMAIL_ADDRESS>/g" \
	$srcfile_h >gst$filename.h.tmp && mv gst$filename.h.tmp gst$filename.h
fi

if [ -e $meson_build ]; then
  sed \
	-e "s/TEMPLATE/$template/g" \
	-e "s/###//g" \
	$meson_build > $meson_build.tmp && mv $meson_build.tmp $meson_build
fi