Skip to content

Commit 22bbdb3

Browse files
committed
update script
1 parent 3d38c8d commit 22bbdb3

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ main() {
147147
fun_do_config
148148

149149
# [-h] [-e] [-i install path] [-c compiler path]
150-
ARGS=$(getopt -o hdrei::c::s:: --long help,clean,debug,release,example,install::,compiler::,shared::,toolchanin: -- "$@")
150+
ARGS=$(getopt -o hdrei::c:s:: --long help,clean,debug,release,example,install::,compiler:,shared::,toolchanin: -- "$@")
151151
if [ $? != 0 ]; then
152152
echo "Terminating..." >&2
153153
exit 1

make_deb.sh

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ fun_do_generate_ld_conf() {
4545
mkdir -p ${work_dir}/${deb_name}${ld_so_config_path}
4646
fi
4747

48-
sudo echo "$mqttclient_ld_conf_file" > ${work_dir}/${deb_name}${ld_so_config_path}/${deb_name}.conf
48+
sudo echo "$mqttclient_ld_conf_file" >${work_dir}/${deb_name}${ld_so_config_path}/${deb_name}.conf
4949
}
5050

5151
fun_do_help() {
52-
echo "usage: $0 [-i install path] [-c compiler / compiler path] [-d] [-r] [-s <on> <off>] [-n <name>]"
52+
echo "usage: $0 [-i install path] [-c compiler / compiler path] [-s <on> <off>] [-n <name>]"
53+
echo "[-r / --release] [-d / --debug] [--toolchanin <toolchanin file>]"
5354
echo " [-i] install path: install $deb_name path"
5455
echo " [-c] compiler: specify the compiler you are using, default: gcc"
5556
echo " [-c] compiler path: specify the compiler path you are using"
@@ -59,12 +60,12 @@ fun_do_help() {
5960
echo " $0"
6061
echo " $0 -i"
6162
echo " $0 -i /usr/lib/"
62-
echo " $0 -carm-linux-gnueabihf-gcc"
63-
echo " $0 -c/usr/bin/arm-linux-gnueabihf-gcc"
63+
echo " $0 -c arm-linux-gnueabihf-gcc"
64+
echo " $0 -c /usr/bin/arm-linux-gnueabihf-gcc"
6465
echo " $0 -r"
6566
echo " $0 -d"
66-
echo " $0 -soff"
67-
echo " $0 -son"
67+
echo " $0 -n <name>"
68+
echo " $0 --toolchanin [toolchanin file]"
6869
}
6970

7071
fun_do_install() {
@@ -78,6 +79,11 @@ fun_do_install() {
7879
fun_do_compiler() {
7980
if [ " $1" != " " ]; then
8081
compiler=$1
82+
compiler_path=$(which $compiler)
83+
if [ " $compiler_path" == " " ]; then
84+
echo -e "\033[31mNo $compiler compiler found in the system\033[0m"
85+
exit
86+
fi
8187
fi
8288
}
8389

@@ -95,6 +101,12 @@ fun_do_config_shared() {
95101
fi
96102
}
97103

104+
fun_do_toolchanin() {
105+
if [ " $1" != " " ]; then
106+
toolchanin=$1
107+
fi
108+
}
109+
98110
fun_do_config_name() {
99111
if [ " $1" != " " ]; then
100112
deb_name=$1
@@ -109,13 +121,13 @@ fun_do_make_deb() {
109121
# 去掉临时安装目录的前缀
110122
sudo sed -i "s#${work_dir}/$deb_name##g" $(find ${work_dir}/$deb_name -name "*.cmake")
111123
# 分号换行,避免太长
112-
sudo sed -i "s#;#;\n#g" $(find ${work_dir}/$deb_name -name "*.cmake")
124+
sudo sed -i "s#;#;#g" $(find ${work_dir}/$deb_name -name "*.cmake")
113125
$work_dir/build_deb.sh "${work_dir}/$deb_name/" "$deb_name.deb"
114126
}
115127

116128
fun_do_arg_init() {
117129
if [ " $compiler_path" != " " ]; then
118-
build_arg="-c${compiler_path} ${build_arg}"
130+
build_arg="-c ${compiler_path} ${build_arg}"
119131
fi
120132

121133
if [ " $install_path" != " " ]; then
@@ -134,7 +146,7 @@ fun_do_arg_init() {
134146
}
135147

136148
main() {
137-
ARGS=$(getopt -o hrdi::c::s::n: --long help,release,debug,install::,compiler::,shared::,name: -- "$@")
149+
ARGS=$(getopt -o hrdi::c:s::n: --long help,release,debug,install::,compiler::,shared:,name:,toolchanin: -- "$@")
138150
if [ $? != 0 ]; then
139151
echo "Terminating..." >&2
140152
exit 1
@@ -167,6 +179,11 @@ main() {
167179
fun_do_build_debug
168180
shift
169181
;;
182+
--toolchanin)
183+
fun_do_toolchanin $2
184+
shift
185+
exit 0
186+
;;
170187
-h | --help)
171188
fun_do_help
172189
shift

0 commit comments

Comments
 (0)