@@ -15,60 +15,60 @@ package=''
1515declare -i verbose=0
1616
1717until [ $# -eq 0 ]; do
18- case " $1 " in
19- --help|-h)
20- printf " usage: bash ${0##*/ } [--verbose|-v] [--package|-p <package-name>] [--name|-n <app-name>] [--output|-o <output-path>]\n"
21- exit 0
22- ;;
23- --verbose|-v)
24- verbose=1
25- ;;
26- --package|-n)
27- shift
28- if [ -z " $1 " ] || [[ " $1 " =~ ^\- ]]; then
29- printf " ERROR: package argument error: $1 \n"
30- exit 1
31- fi
32- package=$1
33- ;;
34- --name|-n)
35- shift
36- if [ -z " $1 " ] || [[ " $1 " =~ ^\- ]]; then
37- printf " ERROR: name argument error: $1 \n"
38- exit 1
39- fi
40- appname=$1
41- ;;
42- --output|-o)
43- shift
44- if [ -z " $1 " ] || [[ " $1 " =~ ^\- ]]; then
45- printf " ERROR: output argument error: $1 \n"
46- exit 1
47- fi
48- outputpath=$1
49- ;;
50- * )
51- printf " ERROR: arguments error. please run \" bash ${0##*/ } --help\" to get usage\n"
52- exit 1
53- ;;
54- esac
55- shift
18+ case " $1 " in
19+ --help|-h)
20+ printf " usage: bash ${0##*/ } [--verbose|-v] [--package|-p <package-name>] [--name|-n <app-name>] [--output|-o <output-path>]\n"
21+ exit 0
22+ ;;
23+ --verbose|-v)
24+ verbose=1
25+ ;;
26+ --package|-n)
27+ shift
28+ if [ -z " $1 " ] || [[ " $1 " =~ ^\- ]]; then
29+ printf " ERROR: package argument error: $1 \n"
30+ exit 1
31+ fi
32+ package=$1
33+ ;;
34+ --name|-n)
35+ shift
36+ if [ -z " $1 " ] || [[ " $1 " =~ ^\- ]]; then
37+ printf " ERROR: name argument error: $1 \n"
38+ exit 1
39+ fi
40+ appname=$1
41+ ;;
42+ --output|-o)
43+ shift
44+ if [ -z " $1 " ] || [[ " $1 " =~ ^\- ]]; then
45+ printf " ERROR: output argument error: $1 \n"
46+ exit 1
47+ fi
48+ outputpath=$1
49+ ;;
50+ * )
51+ printf " ERROR: arguments error. please run \" bash ${0##*/ } --help\" to get usage\n"
52+ exit 1
53+ ;;
54+ esac
55+ shift
5656done
5757
5858if [ -z " $appname " ]; then
59- printf " ERROR: please input an app-name by --name\n"
60- exit 2
59+ printf " ERROR: please input an app-name by --name\n"
60+ exit 2
6161fi
6262
6363if [ -z " $outputpath " ]; then
64- printf " ERROR: please input an output-path by --output\n"
65- exit 2
64+ printf " ERROR: please input an output-path by --output\n"
65+ exit 2
6666fi
6767
6868mkdir -p " $outputpath "
6969if [ $? -ne 0 ]; then
70- printf " ERROR: create $outputpath failed: $? \n"
71- exit 2
70+ printf " ERROR: create $outputpath failed: $? \n"
71+ exit 2
7272fi
7373
7474cat << EOF
@@ -78,41 +78,41 @@ Output: $outputpath
7878EOF
7979
8080if [ ! -f go.mod ]; then
81- printf " \nCreating go.mod ...\n"
82- go mod init $appname
83- if [ $? -ne 0 ]; then
84- printf " Error: $? \n"
85- exit 2
86- fi
81+ printf " \nCreating go.mod ...\n"
82+ go mod init $appname
83+ if [ $? -ne 0 ]; then
84+ printf " Error: $? \n"
85+ exit 2
86+ fi
8787fi
8888
8989declare -i count=${# GOOS_GOARCH_array[*]}
9090declare -i num=0
9191for target in " ${GOOS_GOARCH_array[@]} " ; do
92- let num+=1
93- output=$outputpath /${appname} _${target}
94- mygoos=${target%% _* }
95- mygoarch=${target##* _}
96- myverbose=' '
97- mycgo=' '
98- if [ $verbose -eq 1 ]; then
99- myverbose=' -v'
100- fi
101- case " $mygoos " in
102- windows)
103- output=" $output .exe"
104- ;;
105- android)
106- mycgo=' CGO_ENABLED=1'
107- ;;
108- esac
109- printf " \n($num /$count ) Building $output ...\n"
110- env GOOS=$mygoos GOARCH=$mygoarch ` printf " $mycgo " ` go build $myverbose -ldflags " -s -w" -o $output $package
111- file $output
92+ let num+=1
93+ output=$outputpath /${appname} _${target}
94+ mygoos=${target%% _* }
95+ mygoarch=${target##* _}
96+ myverbose=' '
97+ mycgo=' '
98+ if [ $verbose -eq 1 ]; then
99+ myverbose=' -v'
100+ fi
101+ case " $mygoos " in
102+ windows)
103+ output=" $output .exe"
104+ ;;
105+ android)
106+ mycgo=' CGO_ENABLED=1'
107+ ;;
108+ esac
109+ printf " \n($num /$count ) Building $output ...\n"
110+ env GOOS=$mygoos GOARCH=$mygoarch ` printf " $mycgo " ` go build $myverbose -ldflags " -s -w" -o $output $package
111+ file $output
112112done
113113
114114if [ -t 1 ]; then
115- printf " \nDone. Press any key to exit..."
116- read -n1
117- printf " \n"
115+ printf " \nDone. Press any key to exit..."
116+ read -n1
117+ printf " \n"
118118fi
0 commit comments