Skip to content

Commit a70e294

Browse files
committed
mv correct_pc to install module
1 parent 92d86b5 commit a70e294

File tree

3 files changed

+85
-50
lines changed

3 files changed

+85
-50
lines changed

do-install/correct-pc.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#! /usr/bin/env bash
2+
#
3+
# Copyright (C) 2022 Matt Reach<qianlongxu@gmail.com>
4+
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
set -e
19+
20+
THIS_DIR=$(DIRNAME=$(dirname "$0"); cd "$DIRNAME"; pwd)
21+
cd "$THIS_DIR"
22+
23+
function correct_pc_file(){
24+
local fix_path="$1"
25+
local dir=${PWD}
26+
27+
echo "fix pc files in folder: $fix_path"
28+
cd "$fix_path"
29+
30+
for pc in `find . -type f -name "*.pc"` ;
31+
do
32+
local pkgconfig=$(cd $(dirname "$pc"); pwd)
33+
local lib_dir=$(cd $(dirname "$pkgconfig"); pwd)
34+
local base_dir=$(cd $(dirname "$lib_dir"); pwd)
35+
local include_dir="${base_dir}/include"
36+
local bin_dir="${base_dir}/bin"
37+
38+
my_sed_i "s|^prefix=.*|prefix=$base_dir|" "$pc"
39+
my_sed_i "s|^exec_prefix=[^$].*|exec_prefix=$bin_dir|" $pc
40+
my_sed_i "s|^libdir=[^$].*|libdir=$lib_dir|" "$pc"
41+
my_sed_i "s|^includedir=[^$].*include|includedir=$include_dir|" "$pc"
42+
my_sed_i "s|-L/[^ ]*lib|-L$lib_dir|" "$pc"
43+
my_sed_i "s|-I/[^ ]*include|-I$include_dir|" "$pc"
44+
done
45+
46+
cd "$dir"
47+
}
48+
49+
correct_pc_file "$1"

do-install/main.sh

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ THIS_DIR=$(DIRNAME=$(dirname "$0"); cd "$DIRNAME"; pwd)
2323
cd "$THIS_DIR"
2424

2525
function parse_lib_config() {
26-
26+
2727
local t=$(echo "PRE_COMPILE_TAG_$MR_PLAT" | tr '[:lower:]' '[:upper:]')
2828
local vt=$(eval echo "\$$t")
29-
29+
3030
if test -z $vt ;then
3131
echo "$t can't be nil"
3232
exit
@@ -42,28 +42,36 @@ function parse_lib_config() {
4242
local temp=${TAG#$prefix}
4343
# 去掉后缀
4444
VER=${temp%$suffix}
45-
45+
4646
export VER
4747
export LIB_NAME
4848
}
4949

50-
# 循环编译所有的库
51-
for lib in $MR_VENDOR_LIBS
52-
do
53-
[[ ! -f "$MR_SHELL_CONFIGS_DIR/libs/${lib}.sh" ]] && (echo "$lib config not exist,install will stop.";exit 1;)
50+
function install_libs()
51+
{
52+
# 循环安装所有的库
53+
for lib in $MR_VENDOR_LIBS
54+
do
55+
[[ ! -f "$MR_SHELL_CONFIGS_DIR/libs/${lib}.sh" ]] && (echo "$lib config not exist,install will stop.";exit 1;)
56+
57+
echo "===[install $lib]===================="
58+
source "$MR_SHELL_CONFIGS_DIR/libs/${lib}.sh"
59+
parse_lib_config
60+
if [[ $FORCE_XCFRAMEWORK ]];then
61+
./install-pre-xcf.sh
62+
else
63+
./install-pre-lib.sh
64+
fi
65+
echo "===================================="
66+
done
5467

55-
echo "===[install $lib]===================="
56-
source "$MR_SHELL_CONFIGS_DIR/libs/${lib}.sh"
57-
parse_lib_config
58-
if [[ $FORCE_XCFRAMEWORK ]];then
59-
./install-pre-xcf.sh
60-
else
61-
./install-pre-lib.sh
68+
if [[ ! "$FORCE_XCFRAMEWORK" ]];then
69+
./correct-pc.sh "$MR_WORKSPACE/product/$MR_PLAT"
6270
fi
63-
echo "===================================="
64-
done
71+
}
6572

66-
if [[ ! "$FORCE_XCFRAMEWORK" ]];then
67-
correct_pc_file "$MR_WORKSPACE/product/$MR_PLAT"
73+
if [[ -n $MR_PC_FILE_DIR ]];then
74+
./correct-pc.sh "$MR_PC_FILE_DIR"
75+
else
76+
install_libs
6877
fi
69-

tools/parse-arguments.sh

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -86,32 +86,6 @@ OPTIONS:
8686
EOF
8787
}
8888

89-
function correct_pc_file(){
90-
local fix_path="$1"
91-
local dir=${PWD}
92-
93-
echo "fix pc files in folder: $fix_path"
94-
cd "$fix_path"
95-
96-
for pc in `find . -type f -name "*.pc"` ;
97-
do
98-
local pkgconfig=$(cd $(dirname "$pc"); pwd)
99-
local lib_dir=$(cd $(dirname "$pkgconfig"); pwd)
100-
local base_dir=$(cd $(dirname "$lib_dir"); pwd)
101-
local include_dir="${base_dir}/include"
102-
local bin_dir="${base_dir}/bin"
103-
104-
my_sed_i "s|^prefix=.*|prefix=$base_dir|" "$pc"
105-
my_sed_i "s|^exec_prefix=[^$].*|exec_prefix=$bin_dir|" $pc
106-
my_sed_i "s|^libdir=[^$].*|libdir=$lib_dir|" "$pc"
107-
my_sed_i "s|^includedir=[^$].*include|includedir=$include_dir|" "$pc"
108-
my_sed_i "s|-L/[^ ]*lib|-L$lib_dir|" "$pc"
109-
my_sed_i "s|-I/[^ ]*include|-I$include_dir|" "$pc"
110-
done
111-
112-
cd "$dir"
113-
}
114-
11589
function parse_path()
11690
{
11791
local p="$1"
@@ -149,6 +123,7 @@ arch=
149123
libs=
150124
workspace=
151125
debug=
126+
pc_file_dir=
152127

153128
case $1 in
154129
init | install)
@@ -166,7 +141,6 @@ case $1 in
166141
;;
167142
esac
168143

169-
export -f correct_pc_file
170144
export MR_ACTION=$action
171145

172146
while [[ $# -gt 0 ]]; do
@@ -213,8 +187,7 @@ while [[ $# -gt 0 ]]; do
213187
;;
214188
-correct-pc)
215189
shift
216-
correct_pc_file "$1"
217-
exit 0
190+
pc_file_dir="$1"
218191
;;
219192
**)
220193
echo "unkonwn option:$1"
@@ -224,6 +197,7 @@ while [[ $# -gt 0 ]]; do
224197
done
225198

226199
if [[ -z "$platform" ]];then
200+
echo "platform can't empty"
227201
help
228202
exit 1
229203
fi
@@ -233,7 +207,9 @@ if [[ "$platform" != 'ios' && "$platform" != 'macos' && "$platform" != 'tvos' &&
233207
exit 1
234208
fi
235209

236-
if [[ -z "$libs" ]];then
210+
export MR_PC_FILE_DIR="$pc_file_dir"
211+
212+
if [[ -z "$MR_PC_FILE_DIR" && -z "$libs" ]];then
237213
echo "libs can't be nil, use -l specify libs"
238214
exit 1
239215
fi
@@ -293,6 +269,7 @@ else
293269
done
294270
fi
295271

272+
296273
echo "MR_ACTION : [$MR_ACTION]"
297274
echo "MR_PLAT : [$MR_PLAT]"
298275
echo "MR_CMD : [$MR_CMD]"
@@ -304,5 +281,6 @@ echo "MR_INIT_CFLAGS : [$MR_INIT_CFLAGS]"
304281
echo "SKIP_PULL_BASE : [$SKIP_PULL_BASE]"
305282
echo "SKIP_FFMPEG_PATHCHES : [$SKIP_FFMPEG_PATHCHES]"
306283
echo "MR_SKIP_MAKE_XCFRAMEWORK" : [$MR_SKIP_MAKE_XCFRAMEWORK]
284+
[[ -n $MR_PC_FILE_DIR ]] && echo "MR_PC_FILE_DIR : [$MR_PC_FILE_DIR]"
307285

308-
unset platform cmd arch libs workspace debug action cflags
286+
unset platform cmd arch libs workspace debug action cflags pc_file_dir

0 commit comments

Comments
 (0)