-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.bash
executable file
·66 lines (48 loc) · 1.51 KB
/
build.bash
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
#!/usr/bin/env bash
# thanks to https://www.digitalocean.com/community/tutorials/building-go-applications-for-different-operating-systems-and-architectures
function has_param() {
local terms="$1"
shift
for term in $terms;
do
for arg;
do
if [[ $arg == "$term" ]];
then
echo "yes"
fi
done
done
}
package=github.com/memob0x/slf-extractor
package_split=(${package//\// })
package_name=${package_split[-1]}
with_gui=$(has_param "-h --with-gui" "$@")
# go tool dist list
platforms=("linux/amd64" "darwin/amd64" "windows/amd64")
for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
output_name=$package_name
if [ $GOOS = "windows" ];
then
output_name+='.exe'
fi
# NOTE: darwin gui build is not supported atm since xcode requirements are too strict
# see https://github.com/fyne-io/fyne-cross/blob/3b7d42345c647393361e9eea2335921b33eaabcf/README.md#build-the-docker-image-for-osxdarwinapple-cross-compiling
if [[ "$with_gui" == "yes" ]] && [[ $GOOS != "darwin" ]];
then
fyne-cross $GOOS --pull -arch $GOARCH -tags gui -output $output_name
mkdir -p dist/gui/$GOOS-$GOARCH
cp -r fyne-cross/bin/$GOOS-$GOARCH dist/gui/$GOOS-$GOARCH
rm -rf fyne-cross
fi
env GOOS=$GOOS GOARCH=$GOARCH go build -tags cli -o dist/cli/$GOOS-$GOARCH/$output_name_cli $package
if [ $? -ne 0 ];
then
echo 'An error has occurred! Aborting the script execution...'
exit 1
fi
done