-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile_webidebridge.sh
executable file
·97 lines (84 loc) · 2.41 KB
/
compile_webidebridge.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
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
# git submodule init
# git submodule update
#dependencies
#go install github.com/sanbornm/go-selfupdate
VERSION=xxx
APP_NAME=Molmc_Create_Bridge
# OUTPUT-COLORING
red='\e[0;31m'
green='\e[0;32m'
NC='\e[0m' # No Color
extractVersionFromMain()
{
VERSION=`grep version main.go | cut -d "\"" -f2 | cut -d "\"" -f1 | head -1`
}
createZipEmbeddableFileArduino()
{
echo 'In createZipEmbeddableFileArduino'
GOOS=$1
GOARCH=$2
# start clean
rm arduino/arduino.zip
rm -r arduino/arduino
mkdir arduino/arduino
cp -r arduino/hardware arduino/tools\_$GOOS\_$GOARCH arduino/boards.json arduino/arduino
cp config.ini arduino
cp fakecerts/*.pem fakecerts/*.cer arduino/
mv arduino/arduino/tools* arduino/arduino/tools
cd arduino
zip -r arduino.zip config.ini *.pem *.cer > /dev/null
cd ..
#cat arduino/arduino.zip >> $3
#zip --adjust-sfx $3
mkdir -p snapshot/$GOOS\_$GOARCH
cp $3 snapshot/$GOOS\_$GOARCH/$3
cp arduino/arduino.zip snapshot/$GOOS\_$GOARCH
ls -la snapshot/$GOOS\_$GOARCH/$3
}
bootstrapPlatforms()
{
echo 'In bootstrapPlatforms'
#export PATH=$PATH:/opt/osxcross/target/bin
cd $GOROOT/src
env CC_FOR_TARGET=o64-clang CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 ./make.bash --no-clean
env CC_FOR_TARGET=gcc CGO_ENABLED=1 GOOS=linux GOARCH=amd64 ./make.bash --no-clean
env CC_FOR_TARGET=gcc CGO_ENABLED=1 GOOS=linux GOARCH=386 ./make.bash --no-clean
#env CGO_ENABLED=0 GOOS=linux GOARCH=arm ./make.bash --no-clean
env CC_FOR_TARGET=i686-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows GOARCH=386 ./make.bash --no-clean
}
compilePlatform()
{
echo 'In compilePlatform'
GOOS=$1
GOARCH=$2
CC=$3
CGO_ENABLED=$4
NAME=$APP_NAME
if [ $GOOS == "windows" ]
then
NAME=$NAME".exe"
EXTRAFLAGS="-ldflags -H=windowsgui"
fi
env GOOS=$GOOS GOARCH=$GOARCH CC=$CC CXX=$CC CGO_ENABLED=$CGO_ENABLED go build -o=$NAME $EXTRAFLAGS
if [ $? != 0 ]
then
echo -e "${red}Target $GOOS, $GOARCH failed${NC}"
exit 1
fi
echo createZipEmbeddableFileArduino $GOOS $GOARCH $NAME
createZipEmbeddableFileArduino $GOOS $GOARCH $NAME
GOOS=$GOOS GOARCH=$GOARCH go-selfupdate $NAME $VERSION
rm -rf $NAME*
}
rm -rf snapshot/linux_amd64
rm -rf snapshot/linux_arm
rm -rf snapshot/darwin_amd64
rm -rf snapshot/windows_386
extractVersionFromMain
#compilePlatform darwin amd64 o64-clang 1
#compilePlatformLinux linux 386 gcc
compilePlatform linux amd64 gcc 1
#compilePlatform linux arm 0
compilePlatform windows 386 i686-w64-mingw32-gcc 1
exit 0