Skip to content

Commit b272be4

Browse files
committed
finish ios protobuf script and test success.
1 parent 88fe964 commit b272be4

File tree

3 files changed

+60
-11
lines changed

3 files changed

+60
-11
lines changed

script/__util.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ function util_get_cpu_count() {
7171
fi
7272
}
7373

74+
function util_get_mac_version() {
75+
local var=$(sw_vers | grep ProductVersion)
76+
echo "${var#*:}"
77+
}
78+
7479
function util_print_current_datetime() {
7580
echo $(date +%Y-%m-%d\ %H:%M:%S)
7681
}

script/ios-protobuf.sh

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ function ios_protobuf_printf_variable() {
6060

6161
function ios_protobuf_pre_tool_check() {
6262

63+
# protobuf-3.11.4 need mac version > 10.3
64+
local mac_version=$(util_get_mac_version)
65+
local mac_version_list=($(echo ${mac_version} | sed "s/\./ /g"))
66+
if test ${#mac_version_list[@]} -lt 3; then
67+
common_die "get mac version error!"
68+
fi
69+
export MACOSX_DEPLOYMENT_TARGET="${mac_version_list[0]}.${mac_version_list[1]}"
70+
6371
local protobuf_version=$(protoc --version)
6472
util_is_in "$COMMON_LIBRARY_VERSION" "$protobuf_version" || common_die "Protobuf is not installed on the system, see the protobuf installation instructions. (ref: https://github.com/protocolbuffers/protobuf/blob/master/src/README.md)"
6573

@@ -114,10 +122,6 @@ function ios_protobuf_build_config_make() {
114122

115123
elif [[ "${library_arch}" == "arm64" ]]; then
116124

117-
# for test
118-
export CFLAGS='-arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -Wno-unused-function -fstrict-aliasing -Wno-ignored-optimization-argument -DIOS -fembed-bitcode -miphoneos-version-min=8.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk/usr/include'
119-
export CPPFLAGS=${CFLAGS}
120-
121125
./configure --host=$(ios_get_build_host "${library_arch}") --prefix="${library_arch_path}" --disable-shared --with-protoc=protobuf_command >"${library_arch_path}/log/output.log" 2>&1 || common_die "configure error!"
122126

123127
elif [[ "${library_arch}" == "arm64e" ]]; then
@@ -128,12 +132,17 @@ function ios_protobuf_build_config_make() {
128132
common_die "not support $library_arch"
129133
fi
130134

131-
make clean >>"${library_arch_path}/log/output.log"
132-
if make -j$(util_get_cpu_count) >>"${library_arch_path}/log/output.log" 2>&1; then
133-
if make check >>"${library_arch_path}/log/output.log" 2>&1; then
134-
make install >>"${library_arch_path}/log/output.log" 2>&1
135-
fi
136-
fi
135+
echo "[${COMMON_LIBRARY_NAME}_make_clean]" >>"${library_arch_path}/log/output.log"
136+
make clean >>"${library_arch_path}/log/output.log" 2>&1 || common_die "make clean error!"
137+
138+
echo "[${COMMON_LIBRARY_NAME}_make]" >>"${library_arch_path}/log/output.log"
139+
make -j$(util_get_cpu_count) >>"${library_arch_path}/log/output.log" 2>&1 || common_die "make error!"
140+
141+
# echo "[${COMMON_LIBRARY_NAME}_make_check]" >>"${library_arch_path}/log/output.log"
142+
# make check >>"${library_arch_path}/log/output.log" 2>&1 || common_die "make check error!"
143+
144+
echo "[${COMMON_LIBRARY_NAME}_make_install]" >>"${library_arch_path}/log/output.log"
145+
make install >>"${library_arch_path}/log/output.log" 2>&1 || common_die "make install error!"
137146

138147
popd
139148
}

script/test.sh

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,39 @@ echo "##########################################################################
150150
# local str=$*
151151
# echo "$str" | sed "s/$sub//g"
152152
# }
153-
# util_remove_substr2 "cpp-" "protobuf-cpp-3.11.4"
153+
# util_remove_substr2 "cpp-" "protobuf-cpp-3.11.4"
154+
155+
# 测试protobuf
156+
# VAR=7
157+
# case $VAR in
158+
# [456]) echo 1
159+
# ;;
160+
# 2|3) echo 2 or 3
161+
# ;;
162+
# *) echo default
163+
# ;;
164+
# esac
165+
# var=$(sw_vers | grep ProductVersion)
166+
# echo "var=$var"
167+
# MACOSX_DEPLOYMENT_TARGET="${var#*:}"
168+
# MACOSX_DEPLOYMENT_TARGET=$(util_get_mac_version)
169+
# MACOSX_DEPLOYMENT_TARGET="10.15"
170+
# echo ${MACOSX_DEPLOYMENT_TARGET-10.0}
171+
# case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
172+
# 10.[0123])
173+
# echo 1
174+
# # func_append compile_command " $wl-bind_at_load"
175+
# # func_append finalize_command " $wl-bind_at_load"
176+
# ;;
177+
# esac
178+
179+
# 测试分割字符串
180+
# MACOSX_DEPLOYMENT_TARGET="10.15.2"
181+
# ALL_VERSION=($(echo ${MACOSX_DEPLOYMENT_TARGET} | sed "s/\./ /g"))
182+
# echo "ALL_VERSION=${ALL_VERSION[@]}"
183+
# mac_version=$(util_get_mac_version)
184+
# mac_version_list=($(echo ${mac_version} | sed "s/\./ /g"))
185+
# if test ${#mac_version_list[@]} -lt 3; then
186+
# common_die "get mac version error!"
187+
# fi
188+
# echo "mac_version_list=${mac_version_list[@]}"

0 commit comments

Comments
 (0)