File: genproto.sh

package info (click to toggle)
golang-github-farsightsec-go-nmsg 0.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 500 kB
  • sloc: sh: 21; makefile: 3
file content (29 lines) | stat: -rwxr-xr-x 641 bytes parent folder | download | duplicates (2)
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
#!/bin/sh

go_package() {
	local file pkg line script
	file=$1; shift
	pkg=$1; shift

	line="option go_package = \"$pkg\";"
	grep "^$line\$" $file > /dev/null && return

	script="/^package nmsg/|a|$line|.|w|q|"
	if grep "^option go_package" $file > /dev/null; then
		script="/^option go_package/d|1|${script}"
	fi
	echo "$script" | tr '|' '\n' | ed $file || exit
}

dir=$(dirname $0)
[ -n "$dir" ] && cd $dir

go_package nmsg.proto "github.com/farsightsec/go-nmsg;nmsg"
protoc --go_out=../../.. nmsg.proto

cd nmsg_base
for f in *.proto; do
	go_package $f "github.com/farsightsec/go-nmsg/nmsg_base"
done

protoc --go_out=../../../.. *.proto