Skip to content

Commit cd2df57

Browse files
committed
address PR feedback
1 parent b3b5bc7 commit cd2df57

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

build-ffmpeg

+26-21
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# LICENSE: https://github.com/markus-perl/ffmpeg-build-script/blob/master/LICENSE
55

66
PROGNAME=$(basename "$0")
7-
VERSION=1.21.rc4
7+
VERSION=1.21.rc5
88
CWD=$(pwd)
99
PACKAGES="$CWD/packages"
1010
WORKSPACE="$CWD/workspace"
@@ -14,6 +14,14 @@ LDEXEFLAGS=""
1414
EXTRALIBS="-ldl -lpthread -lm -lz"
1515
CONFIGURE_OPTIONS=()
1616

17+
is_mac () {
18+
if [[ "$OSTYPE" == "darwin"* ]]; then
19+
return 0
20+
fi
21+
22+
return 1
23+
}
24+
1725
# read by gcc and cmake
1826
# https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_DEPLOYMENT_TARGET.html
1927
export MACOSX_DEPLOYMENT_TARGET=10.11
@@ -24,7 +32,7 @@ if [[ -n "$NUMJOBS" ]]; then
2432
MJOBS="$NUMJOBS"
2533
elif [[ -f /proc/cpuinfo ]]; then
2634
MJOBS=$(grep -c processor /proc/cpuinfo)
27-
elif [[ "$OSTYPE" == "darwin"* ]]; then
35+
elif is_mac; then
2836
MJOBS=$(sysctl -n machdep.cpu.thread_count)
2937
CONFIGURE_OPTIONS=("--enable-videotoolbox")
3038
else
@@ -148,6 +156,13 @@ library_exists () {
148156
return 0
149157
}
150158

159+
set_mac_install_name () {
160+
local name="${2:-$1}"
161+
if is_mac; then
162+
execute install_name_tool -id "${WORKSPACE}/lib/$name" $1
163+
fi
164+
}
165+
151166
build_done () {
152167
touch "$PACKAGES/$1.done"
153168
}
@@ -190,7 +205,7 @@ while (( $# > 0 )); do
190205
cleanup
191206
fi
192207
if [[ "$1" == "--full-static" || "$1" =~ 'f' ]]; then
193-
if [[ "$OSTYPE" == "darwin"* ]]; then
208+
if is_mac; then
194209
echo "Error: A full static binary can only be build on Linux."
195210
exit 1
196211
fi
@@ -324,9 +339,7 @@ if build "x265"; then
324339
execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=on -DBUILD_SHARED_LIBS=on ../../source
325340
execute make -j $MJOBS
326341

327-
if [[ "$OSTYPE" == "darwin"* ]]; then
328-
execute install_name_tool -id "${WORKSPACE}/lib/libx265.198.dylib" libx265.198.dylib
329-
fi
342+
set_mac_install_name "libx265.198.dylib"
330343

331344
execute make install
332345

@@ -343,7 +356,7 @@ if build "libvpx"; then
343356

344357
EXTRA_FLAG=""
345358

346-
if [[ "$OSTYPE" == "darwin"* ]]; then
359+
if is_mac; then
347360
echo "Applying Darwin patch"
348361
sed "s/,--version-script//g" build/make/Makefile > build/make/Makefile.patched
349362
sed "s/-Wl,--no-undefined -Wl,-soname/-Wl,-undefined,error -Wl,-install_name/g" build/make/Makefile.patched > build/make/Makefile
@@ -354,9 +367,7 @@ if build "libvpx"; then
354367
execute ./configure --prefix="${WORKSPACE}" --disable-unit-tests --enable-shared --disable-static --as=yasm "${EXTRA_FLAG}"
355368
execute make -j $MJOBS
356369

357-
if [[ "$OSTYPE" == "darwin"* ]]; then
358-
execute install_name_tool -id "${WORKSPACE}/lib/libvpx.6.dylib" libvpx.6.dylib
359-
fi
370+
set_mac_install_name "libvpx.6.dylib"
360371

361372
execute make install
362373

@@ -389,9 +400,7 @@ if build "vid_stab"; then
389400
execute make
390401
execute make install
391402

392-
if [[ "$OSTYPE" == "darwin"* ]]; then
393-
execute install_name_tool -id "${WORKSPACE}/lib/libvidstab.1.1.dylib" "${WORKSPACE}/lib/libvidstab.1.1.dylib"
394-
fi
403+
set_mac_install_name "${WORKSPACE}/lib/libvidstab.1.1.dylib" "libvidstab.1.1.dylib"
395404

396405
build_done "vid_stab"
397406
fi
@@ -415,9 +424,7 @@ if build "av1"; then
415424
execute cmake -DBUILD_SHARED_LIBS=1 -DENABLE_TESTS=0 -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib "$PACKAGES"/av1
416425
execute make -j $MJOBS
417426

418-
if [[ "$OSTYPE" == "darwin"* ]]; then
419-
execute install_name_tool -id "${WORKSPACE}/lib/libaom.2.dylib" libaom.2.0.0.dylib
420-
fi
427+
set_mac_install_name "libaom.2.0.0.dylib" "libaom.2.dylib"
421428

422429
execute make install
423430

@@ -597,9 +604,7 @@ if build "snappy"; then
597604
execute cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DBUILD_SHARED_LIBS:bool=on
598605
execute make -j $MJOBS
599606

600-
if [[ "$OSTYPE" == "darwin"* ]]; then
601-
execute install_name_tool -id "${WORKSPACE}/lib/libsnappy.1.dylib" libsnappy.1.1.8.dylib
602-
fi
607+
set_mac_install_name "libsnappy.1.1.8.dylib" "libsnappy.1.dylib"
603608

604609
execute make install
605610

@@ -680,7 +685,7 @@ execute make -j $MJOBS
680685
execute make install
681686

682687
INSTALL_FOLDER="/usr/bin"
683-
if [[ "$OSTYPE" == "darwin"* ]]; then
688+
if is_mac; then
684689
INSTALL_FOLDER="/usr/local/bin"
685690
fi
686691

@@ -723,7 +728,7 @@ elif [[ ! "$SKIPINSTALL" == "yes" ]]; then
723728
fi
724729

725730
cd $CWD
726-
if [[ "$OSTYPE" == "darwin"* ]]; then
731+
if is_mac; then
727732
node copy_mac_libs.js
728733
cd "$WORKSPACE/mac"
729734
execute zip --symlinks -r "ffmpeg-ffprobe-shared-darwin-x86_64.${VERSION}.zip" *

copy_mac_libs.js

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ function copyDylibs(binaryName, base = baseBinDir) {
4949
if (path !== newFilename) {
5050
// copy sym-linked libraries as well
5151
let nameWithoutVersion = filename.split('.')[0];
52+
// libSDL2 weirdly has hypthen after then name (i.e., libSDL2-2.0.0.dylib)
5253
if (filename.includes('libSDL2')) {
5354
nameWithoutVersion = 'libSDL2';
5455
}

0 commit comments

Comments
 (0)