-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.sh
138 lines (126 loc) · 3.66 KB
/
build.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
#!/bin/bash
# libVideoCodec的构建脚本
cur_file_path=$(cd $(dirname "${0}");pwd)
error()
{
echo -e "\033[1;31m${*}\033[0m"
}
info()
{
echo -e "\033[1;36m${*}\033[0m"
}
link_dirs=(
media
)
source_dirs="
media
"
so_list=(
vendor/lib/libVideoCodec.so
vendor/lib64/libVideoCodec.so
)
android9_link()
{
root_dir=$(pwd)
for link_dir in ${link_dirs[*]}
do
rm -rf ${AN_AOSPDIR}/${link_dir}
[ ${?} != 0 ] && error "failed to clean link ${link_dir}" && retrun -1
ln -vs ${root_dir}/${link_dir} ${AN_AOSPDIR}
[ ${?} != 0 ] && error "failed to link ${link_dir} to ${AN_AOSPDIR}" && retrun -1
done
}
setup_env()
{
export TOP=${AN_AOSPDIR}
export OUT_DIR=${AN_AOSPDIR}/out
export ANDROID_BUILD_TOP=${AN_AOSPDIR}
cd ${cur_file_path}/..
if [ -z "${ANDROID_VERSION}" ];then
android9_link
else
for link_dir in ${link_dirs[*]}
do
rsync -azr --delete --exclude=".git" ${link_dir} ${AN_AOSPDIR}
done
fi
cd -
}
package()
{
output_dir=${MODULE_OUTPUT_DIR}
output_symbols_dir=${MODULE_SYMBOL_DIR}
[ -z "${output_dir}" ] && output_dir=${cur_file_path}/output/aosp && rm -rf ${output_dir} && mkdir -p ${output_dir}
[ -z "${output_symbols_dir}" ] && output_symbols_dir=${cur_file_path}/output/aosp/symbols && rm -rf ${output_symbols_dir} && mkdir -p ${output_symbols_dir}
for so_name in ${so_list[@]}
do
source_path=${AN_AOSPDIR}/out/target/product/generic_arm64/${so_name}
source_symbols_path=${AN_AOSPDIR}/out/target/product/generic_arm64/symbols/${so_name}
target_path=${output_dir}/${so_name%/*}
[ ! -d "${target_path}" ] && mkdir -p ${target_path}
symbols_target_path=${output_symbols_dir}/${so_name%/*}
[ ! -d "${symbols_target_path}" ] && mkdir -p ${symbols_target_path}
cp -d ${source_path} ${target_path}
[ ${?} != 0 ] && error "failed to copy ${source_path} to ${target_path}"
[ -L ${source_path} ] && continue
cp -d ${source_symbols_path} ${symbols_target_path}
[ ${?} != 0 ] && error "failed to copy ${source_symbols_path} to ${symbols_target_path}"
done
if [ -z "${MODULE_OUTPUT_DIR}" ];then
cd ${output_dir}
tar zcvf ../libVideoCodec_aosp.tar.gz vendor
cd -
fi
if [ -z "${MODULE_SYMBOL_DIR}" ];then
cd ${output_symbols_dir}
tar zcvf ../../libVideoCodecSymbols_aosp.tar.gz *
cd -
fi
}
clean()
{
if [ -z "${MODULE_OUTPUT_DIR}" ];then
output_dir=${cur_file_path}/output
if [ -f "${output_dir}/libVideoCodec_aosp.tar.gz" ];then
rm -rf ${output_dir}/libVideoCodec_aosp.tar.gz
fi
if [ -f "${output_dir}/libVideoCodecSymbols_aosp.tar.gz" ];then
rm -rf ${output_dir}/libVideoCodecSymbols_aosp.tar.gz
fi
if [ -d "${output_dir}/aosp" ];then
rm -rf ${output_dir}/aosp
fi
if [ -f "${output_dir}" ];then
rm -rf ${output_dir}
fi
fi
}
inc()
{
info "begin incremental compile"
setup_env
cd ${AN_AOSPDIR}
source build/envsetup.sh
lunch aosp_arm64-eng
mmm ${source_dirs} -j
[ ${?} != 0 ] && error "failed to incremental compile ${source_dirs}" && return -1
cd -
package
info "incremental compile success"
}
build()
{
info "begin build"
clean
[ ${?} != 0 ] && error "failed to clean" && return -1
inc $@
[ ${?} != 0 ] && error "failed to build" && return -1
info "build success"
}
ACTION=$1; shift
case "$ACTION" in
build) build "$@";;
inc) inc "$@";;
clean) clean "$@";;
*) error "input command[$ACTION] not support.";;
esac