File: generate.sh

package info (click to toggle)
continuity 0.0~git20180216.d8fb858-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 620 kB
  • sloc: makefile: 46; sh: 28; asm: 3
file content (37 lines) | stat: -rwxr-xr-x 1,097 bytes parent folder | download
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
#!/bin/bash

set -e

mksyscall="$(go env GOROOT)/src/syscall/mksyscall.pl"

fix() {
	sed 's,^package syscall$,package sysx,' \
		| sed 's,^import "unsafe"$,import (\n\t"syscall"\n\t"unsafe"\n),' \
		| gofmt -r='BytePtrFromString -> syscall.BytePtrFromString' \
		| gofmt -r='Syscall6 -> syscall.Syscall6' \
		| gofmt -r='Syscall -> syscall.Syscall' \
		| gofmt -r='SYS_GETXATTR -> syscall.SYS_GETXATTR' \
		| gofmt -r='SYS_LISTXATTR -> syscall.SYS_LISTXATTR' \
		| gofmt -r='SYS_SETXATTR -> syscall.SYS_SETXATTR' \
		| gofmt -r='SYS_REMOVEXATTR -> syscall.SYS_REMOVEXATTR' \
		| gofmt -r='SYS_LGETXATTR -> syscall.SYS_LGETXATTR' \
		| gofmt -r='SYS_LLISTXATTR -> syscall.SYS_LLISTXATTR' \
		| gofmt -r='SYS_LSETXATTR -> syscall.SYS_LSETXATTR' \
		| gofmt -r='SYS_LREMOVEXATTR -> syscall.SYS_LREMOVEXATTR'
}

if [ "$GOARCH" == "" ] || [ "$GOOS" == "" ]; then
	echo "Must specify \$GOARCH and \$GOOS"
	exit 1
fi

mkargs=""

if [ "$GOARCH" == "386" ] || [ "$GOARCH" == "arm" ]; then
	mkargs="-l32"
fi

for f in "$@"; do
	$mksyscall $mkargs "${f}_${GOOS}.go" | fix > "${f}_${GOOS}_${GOARCH}.go"
done