forked from Konstantin8105/c4go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneatpost.sh
executable file
·65 lines (54 loc) · 2.05 KB
/
neatpost.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
#!/bin/bash
set -e
go build
mkdir -p ./testdata/
# prepare variables
export C4GO_DIR=$GOPATH/src/github.com/Konstantin8105/c4go
export C4GO=$C4GO_DIR/c4go
export GIT_SOURCE="https://github.com/aligrudi/neatpost.git"
export NAME="neatpost"
export TEMP_FOLDER="./testdata/$NAME"
export GO_FILE="$TEMP_FOLDER/$NAME.go"
export GO_APP="$TEMP_FOLDER/$NAME.app"
# prepare C code
if [ ! -d $TEMP_FOLDER ]; then
mkdir -p $TEMP_FOLDER
git clone $GIT_SOURCE $TEMP_FOLDER
sed -i.bak '92,98d' $TEMP_FOLDER/font.c
sed -i.bak '163,173d;158,161d;152,156d;145,150d;139,143d;133,137d;128,131d;123,127d;109,121d;90,107d;80,88d;58,78d;47,56d;42,45d;33,40d;8d' $TEMP_FOLDER/ps.c
sed -i.bak '219,232d;212,217d;204,210d;196,202d;179,194d;175,177d;131,173d' $TEMP_FOLDER/ps.c
sed -i.bak '238,262d;123,129d;116,121d;109,114d;102,107d;95,100d;82,93d;73,80d;65,71d;57,63d' $TEMP_FOLDER/ps.c
sed -i.bak '47d;46d;11d;10d;9d' $TEMP_FOLDER/ps.c
fi
# remove go files from last transpilation
echo "***** remove go files"
rm -f $TEMP_FOLDER/*.go
rm -f $TEMP_FOLDER/*.app
# transpilation of all projects
echo "Transpile to $GO_FILE"
$C4GO transpile \
-clang-flag="-DTROFFFDIR=\"MMM\"" \
-clang-flag="-DTROFFMDIR=\"WWW\"" \
-o="$GO_FILE" \
$TEMP_FOLDER/*.c
# show warnings comments in Go source
echo "Calculate warnings in file: $GO_FILE"
WARNINGS=`cat $GO_FILE | grep "^// Warning" | sort | uniq | wc -l`
echo " After transpiling : $WARNINGS warnings."
# show other warnings
# show amount error from `go build`:
echo "Build to $GO_APP file"
WARNINGS_GO=`go build -o $GO_APP -gcflags="-e" $GO_FILE 2>&1 | wc -l`
echo " Go build : $WARNINGS_GO warnings"
# amount unsafe
UNSAFE=`cat $GO_FILE | grep "unsafe\." | wc -l`
echo " Unsafe : $UNSAFE"
# Arguments menu
echo " -s for show detail of Go build errors"
if [ "$1" == "-s" ]; then
# show go build warnings
# c4go warnings
cat $GO_FILE | grep "^// Warning" | sort | uniq
# show amount error from `go build`:
go build -o $GO_APP -gcflags="-e" $GO_FILE 2>&1
fi