-
Notifications
You must be signed in to change notification settings - Fork 0
/
autobuild.sh
executable file
·175 lines (149 loc) · 5.02 KB
/
autobuild.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/bash
#set -e
##################################################################
##################################################################
#Function List
print_help()
{
echo ""
echo "------------------------ help menu --------------------------"
echo " help menu option: "
echo "./autobuild.sh all ------build all"
echo "./autobuild.sh senddoc ----- send doc to server"
echo "./autobuild.sh syncdoc -----syncdoc"
echo "./autobuild.sh clean ----clean all"
echo "./autobuild.sh run ---- open html"
echo "./autobuild.sh help (-h, --help) show help menu"
echo "-------------------------------------------------------------"
}
echo_autobuild_start()
{
echo ""
echo -e "\e[32m*********** ./autobuild.sh $1 **************\e[0m"
}
build_all()
{
echo "make clean && make html"
make clean
rm -rf _html
rm -rf _build
rm -rf docs
make html
cp -R _build/html _html
cp .nojekyll _html/
cp _html/ docs/ -af
echo "create _html finished"
}
clean()
{
echo "clean all"
make clean
rm -rf _html
rm -rf _build
rm -rf docs
}
sync_doc_old()
{
echo "copy ../robot_sdk/ ../robot_ref/ ../robot_actuator file to robot_doc/source/syncdoc/"
echo "search README.md"
readme_files=$(find ../robot_sdk/ ../robot_ref/ ../robot_actuator/ -name 'README.md')
for file in $readme_files; do
dir=$(dirname "$file")
new_dir=$(echo "$dir" | cut -d'/' -f2-)
#echo "copy $file to source/syncdoc/$new_dir/README.md"
echo "source/syncdoc/$new_dir/README.md"
mkdir -p "source/syncdoc/$new_dir"
cp -r "$file" "source/syncdoc/$new_dir/"
if [ -d "$dir/image" ]; then
cp -r "$dir/image" "source/syncdoc/$new_dir/"
fi
done
}
sync_doc()
{
echo "search *.rst and *.md from source code"
# readme_files=$(find ../robot_sdk/ ../robot_ref/ ../robot_actuator/ -name 'README.rst')
# readme_files=$(find ../robot_sdk/ ../robot_ref/ ../robot_actuator/ -name '*.rst' -o -name '*.md')
readme_files=$(find ../robot_sdk/ ../robot_ref/ ../robot_actuator/ -name 'README.rst' -o -name 'README.md')
for file in $readme_files; do
dir=$(dirname "$file")
new_dir=$(echo "$dir" | cut -d'/' -f2-)
#echo "copy $file to source/syncdoc/$new_dir/README.md"
mkdir -p "source/syncdoc/$new_dir"
cp -r "$file" "source/syncdoc/$new_dir/"
echo "copy $file --> source/syncdoc/$new_dir/README.rst"
echo "search image in $dir"
find "$dir" -type f \( -name "*.png" -o -name "*.gif" -o -name "*.jpg" \) | while read -r serach_file; do
target_path="source/syncdoc/$new_dir/$(echo "$serach_file" | sed "s|^$dir/||")"
mkdir -p "$(dirname "$target_path")"
cp "$serach_file" "$target_path"
echo "copy $serach_file --> $target_path"
done
done
}
#####################################################################
# 初始化
#####################################################################
datetime=$(date +%Y%m%d_%H%M)
echo_autobuild_start;
##################################################################
if [ "$#" -eq "0" ]; then
echo "unknown option: $1 [$#]. pls enter correct cmd:"
print_help;
exit 0
fi
while [ $# -gt 0 ]; do
echo "option=$1 total=$#:"
case $1 in
-h | --help | help | h | --h)
print_help
;;
clear | clean | cl)
clean
;;
build | all)
build_all
;;
syncdoc | sync | sd)
sync_doc
;;
run | r)
echo "open html"
# Google Chrome的完整路径
CHROME_PATH="/usr/bin/google-chrome"
# get full path name of html.html
HTML_FILE="$(pwd)/_build/html/index.html"
# 使用绝对路径确保脚本在任何目录下都能正确执行
CHROME_EXECUTABLE="$(which "$CHROME_PATH")"
# 使用绝对路径确保脚本在任何目录下都能正确执行
CHROME_EXECUTABLE="$(which "$CHROME_PATH")"
# x-www-browser _build/html/index
# open -a /Applications/Firefox.app _build/html/index
"$CHROME_EXECUTABLE" "$HTML_FILE"
;;
senddoc | send)
echo "send doc update to 20.13"
# echo "send doc update to 10.8.170.85"
# sshpass -p pwd@123 scp -r _html/* [email protected]:/var/www/html/robot_doc/
OUT_IMAGE_SERVER_FOLDER=orbbec_sdk_ros2_doc
sshpass -p 123 ssh [email protected] "[ -d /home/orbbec/.SDKBuild/20_13_build_sdk/${OUT_IMAGE_SERVER_FOLDER} ] && echo 20.13 server ready || mkdir -p /home/orbbec/.SDKBuild/20_13_build_sdk/${OUT_IMAGE_SERVER_FOLDER}"
sshpass -p 123 scp -r _html [email protected]:/home/orbbec/.SDKBuild/20_13_build_sdk/orbbec_sdk_ros2_doc/
;;
test1 )
echo "test1"
;;
test2 )
echo "test2"
;;
test3 )
echo "test3"
;;
*)
echo "unknown option: $1"
print_help
;;
esac
shift
done
echo "autobuild.sh end"
##################################################################