Skip to content

Commit dac02f5

Browse files
committed
install multiple pre compile lib, pc file prefix maybe not right
1 parent a396e11 commit dac02f5

File tree

5 files changed

+87
-36
lines changed

5 files changed

+87
-36
lines changed

apple/do-compile/any.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ do_lipo_all() {
8585
local uni_dir="$XC_UNI_PROD_DIR"
8686
fi
8787

88-
local inc_dst_dir="$uni_dir/$LIB_NAME/include"
88+
local inc_dst_dir="$uni_dir/$LIB_NAME"
8989

9090
if [[ -d "$inc_src_dir" ]]; then
9191
echo "copy include dir to $inc_dst_dir"
92-
cp -R "$inc_src_dir" "$inc_dst_dir"
92+
cp -Rf "$inc_src_dir" "$inc_dst_dir"
9393

9494
local pc_src_dir="$XC_PRODUCT_ROOT/$LIB_NAME-$arch/lib/pkgconfig"
9595
if ls ${pc_src_dir}/*.pc >/dev/null 2>&1;then

apple/do-compile/ffmpeg.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ pkg-config --libs dvdread --silence-errors >/dev/null && enable_dvdread=1
191191

192192
if [[ $enable_dvdread ]];then
193193
echo "[*] --enable-libdvdread"
194-
CFG_FLAGS="$CFG_FLAGS --enable-libdvdread"
194+
CFG_FLAGS="$CFG_FLAGS --enable-libdvdread --enable-protocol=dvd"
195195
else
196196
echo "[*] --disable-libdvdread"
197197
fi

apple/init-env.sh

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ function init_plat_env() {
6363
if [[ "$XC_PLAT" == 'ios' ]]; then
6464
export XC_OTHER_CFLAGS="-fembed-bitcode"
6565
ALL_ARCHS="arm64 arm64_simulator x86_64_simulator"
66-
elif [[ "$XC_PLAT" == 'macos' ]]; then
66+
elif [[ "$XC_PLAT" == 'macos' ]]; then
6767
export XC_OTHER_CFLAGS=""
6868
ALL_ARCHS="x86_64 arm64"
69-
elif [[ "$XC_PLAT" == 'tvos' ]]; then
69+
elif [[ "$XC_PLAT" == 'tvos' ]]; then
7070
export XC_OTHER_CFLAGS=''
7171
ALL_ARCHS="arm64 arm64_simulator x86_64_simulator"
7272
fi
73-
73+
7474
if [[ -z "$XC_ALL_ARCHS" ]];then
7575
export XC_ALL_ARCHS=$ALL_ARCHS
7676
else
@@ -94,12 +94,12 @@ function init_plat_env() {
9494
export XC_PRODUCT_ROOT="${THIS_DIR}/../build/product/${XC_PLAT}"
9595
export XC_UNI_PROD_DIR="${XC_PRODUCT_ROOT}/universal"
9696
export XC_UNI_SIM_PROD_DIR="${XC_PRODUCT_ROOT}/universal-simulator"
97-
97+
9898
export XC_IOS_PRODUCT_ROOT="${THIS_DIR}/../build/product/ios"
9999
export XC_MACOS_PRODUCT_ROOT="${THIS_DIR}/../build/product/macos"
100100
export XC_TVOS_PRODUCT_ROOT="${THIS_DIR}/../build/product/tvos"
101101
export XC_XCFRMK_DIR="${THIS_DIR}/../build/product/xcframework"
102-
102+
103103
#common xcode configuration
104104
export XC_TAGET_OS="darwin"
105105
export DEBUG_INFORMATION_FORMAT=dwarf-with-dsym
@@ -115,14 +115,27 @@ function init_libs_pkg_config_path() {
115115
fi
116116

117117
pkg_cfg_dir=
118-
for lib in $(ls "$universal_dir"); do
118+
119+
for dir in `find "${XC_PRODUCT_ROOT}" -type f -name "*.pc" | xargs dirname | uniq` ;
120+
do
121+
if [[ "$dir" =~ "$_XC_ARCH" ]];then
122+
if [[ $pkg_cfg_dir ]];then
123+
pkg_cfg_dir="${pkg_cfg_dir}:${dir}"
124+
else
125+
pkg_cfg_dir="${dir}"
126+
fi
127+
fi
128+
done
129+
130+
for dir in `find "${universal_dir}" -type f -name "*.pc" | xargs dirname | uniq` ;
131+
do
119132
if [[ $pkg_cfg_dir ]];then
120-
pkg_cfg_dir="${pkg_cfg_dir}:${universal_dir}/${lib}/lib/pkgconfig"
133+
pkg_cfg_dir="${pkg_cfg_dir}:${dir}"
121134
else
122-
pkg_cfg_dir="${universal_dir}/${lib}/lib/pkgconfig"
135+
pkg_cfg_dir="${dir}"
123136
fi
124137
done
125-
138+
126139
# disabling pkg-config-path
127140
# https://gstreamer-devel.narkive.com/TeNagSKN/gst-devel-disabling-pkg-config-path
128141
# export PKG_CONFIG_LIBDIR=${sysroot}/lib/pkgconfig
@@ -138,7 +151,7 @@ function init_arch_env () {
138151
fi
139152

140153
export _XC_ARCH="$1"
141-
154+
142155
if [[ "$XC_PLAT" == 'ios' ]]; then
143156
case $_XC_ARCH in
144157
*_simulator)
@@ -155,11 +168,11 @@ function init_arch_env () {
155168
exit 1
156169
;;
157170
esac
158-
elif [[ "$XC_PLAT" == 'macos' ]]; then
171+
elif [[ "$XC_PLAT" == 'macos' ]]; then
159172
export XCRUN_PLATFORM='MacOSX'
160173
export MACOSX_DEPLOYMENT_TARGET=10.11
161174
export XC_DEPLOYMENT_TARGET="-mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
162-
elif [[ "$XC_PLAT" == 'tvos' ]]; then
175+
elif [[ "$XC_PLAT" == 'tvos' ]]; then
163176
case $_XC_ARCH in
164177
*_simulator)
165178
export XCRUN_PLATFORM='AppleTVSimulator'
@@ -188,7 +201,7 @@ function init_arch_env () {
188201
# xcrun -sdk macosx --show-sdk-path
189202
# /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk
190203
export XCRUN_SDK_PATH=`xcrun -sdk $XCRUN_SDK --show-sdk-path`
191-
204+
192205
# x86_64
193206
export XC_ARCH="${_XC_ARCH/_simulator/}"
194207
# ffmpeg-x86_64

install-pre-any.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,61 @@ LIBS=$2
4444
THIS_DIR=$(DIRNAME=$(dirname "$0"); cd "$DIRNAME"; pwd)
4545
cd "$THIS_DIR"
4646

47+
function fix_prefix(){
48+
local plat=$1
49+
local dir=${PWD}
50+
51+
echo "fix $plat platform pc files prefix"
52+
53+
if [[ "$plat" == 'all' ]];then
54+
cd "build/product"
55+
else
56+
cd "build/product/$plat"
57+
fi
58+
59+
for pc in `find . -type f -name "*.pc"` ;
60+
do
61+
echo "$pc"
62+
local pc_dir=$(dirname "$pc")
63+
local lib_dir=$(dirname "$pc_dir")
64+
local base_dir=$(dirname "$lib_dir")
65+
66+
base_dir=$(cd "$base_dir";pwd)
67+
local escaped_base_dir=$(echo $base_dir | sed 's/\//\\\//g')
68+
local escaped_lib_dir=$(echo "${base_dir}/lib" | sed 's/\//\\\//g')
69+
local escaped_include_dir=$(echo "${base_dir}/include" | sed 's/\//\\\//g')
70+
71+
sed -i "" "s/^prefix=.*/prefix=$escaped_base_dir/" "$pc"
72+
sed -i "" "s/^libdir=.*/libdir=$escaped_lib_dir/" "$pc"
73+
sed -i "" "s/^includedir=.*/includedir=$escaped_include_dir/" "$pc"
74+
75+
# filte Libs using -L/ absolute path
76+
local str=
77+
for t in `cat "$pc" | grep "Libs: " | grep "\-L/"` ;
78+
do
79+
if [[ "$t" != -L/* ]];then
80+
if [[ $str ]];then
81+
str="${str} $t"
82+
else
83+
str="$t"
84+
fi
85+
fi
86+
done
87+
[[ ! -z $str ]] && sed -i "" "s/^Libs:.*/$str/" "$pc"
88+
done
89+
90+
if command -v tree >/dev/null 2>&1; then
91+
92+
if [[ "$plat" == 'all' ]];then
93+
tree -L 3 ./
94+
else
95+
tree -L 2 ./
96+
fi
97+
98+
fi
99+
cd "$dir"
100+
}
101+
47102
function install_lib ()
48103
{
49104
local plat=$1
@@ -128,6 +183,8 @@ if [[ "$PLAT" == 'ios' || "$PLAT" == 'macos' || "$PLAT" == 'tvos'|| "$PLAT" == '
128183
fi
129184
echo "===================================="
130185
done
186+
187+
fix_prefix $plat
131188
else
132189
usage
133190
fi

tools/install-pre-lib.sh

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ cd ../
2727
function usage() {
2828
echo "=== useage ===================="
2929
echo "Download precompiled libs from github,The usage is as follows:"
30-
echo "$0 [ios|macos|all] [<release tag>]"
30+
echo "$0 [ios|macos|tvos|all] [<release tag>]"
3131
}
3232

3333
function download_arch() {
@@ -67,41 +67,22 @@ function extract(){
6767
mkdir -p "$PRODUCT_DIR"
6868
unzip -oq "$ONAME" -d "$PRODUCT_DIR"
6969
echo "extract zip file"
70-
if command -v tree >/dev/null 2>&1; then
71-
tree -L 2 "$PRODUCT_DIR"
72-
fi
7370
else
7471
echo "you need download ${ONAME} firstly."
7572
exit 1
7673
fi
7774
}
7875

79-
function fix_prefix(){
80-
local plat=$1
81-
local pc_dir="$PRODUCT_DIR/$LIB_NAME/lib/pkgconfig"
82-
if [[ -d "$pc_dir" ]];then
83-
if ls ${pc_dir}/*.pc >/dev/null 2>&1;then
84-
echo "fix $plat $LIB_NAME pc file prefix"
85-
p=$(cd "$PRODUCT_DIR/$LIB_NAME";pwd)
86-
escaped_p=$(echo $p | sed 's/\//\\\//g')
87-
sed -i "" "s/^prefix=.*/prefix=$escaped_p/" "$pc_dir/"*.pc
88-
fi
89-
fi
90-
}
91-
9276
function install() {
9377
local plat=$1
9478
if [[ "$plat" == 'ios' || "$plat" == 'tvos' ]];then
9579
download_arch "$plat"
9680
extract "$plat"
97-
fix_prefix "$plat"
9881
download_arch "$plat" "simulator"
9982
extract "$plat"
100-
fix_prefix "$plat"
10183
else
10284
download_arch "$plat"
10385
extract "$plat"
104-
fix_prefix "$plat"
10586
fi
10687
}
10788

0 commit comments

Comments
 (0)