Skip to content

Commit d01753b

Browse files
committed
update scripts
1 parent ea28aa7 commit d01753b

3 files changed

Lines changed: 118 additions & 36 deletions

File tree

scripts/common/helpers.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,24 @@ git_clone() {
5858
else
5959
local to_dir="${package}-$(echo ${branch} | sed s/^v//)"
6060
fi
61-
echoerr -n "downloading (via git clone) ${to_dir} from $repo_url ..."
62-
rm -rf "${to_dir}"
63-
git clone -c advice.detachedHead=false "${repo_url}" -b "${branch}" --depth 1 "${to_dir}"
64-
echoerr "done."
65-
cd ${to_dir}
61+
62+
if [ -d "${to_dir}/.git" ]; then
63+
# Repository already exists - clean and reset it
64+
echoerr -n "cleaning existing repository ${to_dir} ..."
65+
cd ${to_dir}
66+
git fetch origin "${branch}" --depth 1 2>/dev/null || true
67+
git checkout -f "${branch}" 2>/dev/null || git checkout -f -B "${branch}" "origin/${branch}"
68+
git reset --hard "origin/${branch}" 2>/dev/null || git reset --hard "${branch}"
69+
git clean -fdx
70+
echoerr "done."
71+
else
72+
# Clone fresh repository
73+
echoerr -n "downloading (via git clone) ${to_dir} from $repo_url ..."
74+
rm -rf "${to_dir}"
75+
git clone -c advice.detachedHead=false "${repo_url}" -b "${branch}" --depth 1 "${to_dir}"
76+
echoerr "done."
77+
cd ${to_dir}
78+
fi
6679
}
6780

6881
get_latest_tag() {

scripts/macos/base.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ export ACLOCAL_PATH="${PREFIX}/share/aclocal"
3636
export LIBRARY_PATH="${PREFIX}/lib"
3737
export C_INCLUDE_PATH="${PREFIX}/include"
3838
export CPLUS_INCLUDE_PATH="${PREFIX}/include"
39-
# export CFLAGS="-static-libgcc -static-libstdc++ -I${PREFIX}/include -O2 -pipe -D_FORTIFY_SOURCE=2 -fstack-protector-strong -Wno-error=implicit-function-declaration ${CFLAGS:-""}"
40-
# export CXXFLAGS="${CFLAGS}"
41-
# export LDFLAGS="-static-libgcc -static-libstdc++ -L${PREFIX}/lib -O2 -pipe -fstack-protector-strong ${LDFLAGS:-""}"
42-
# export STAGE_CFLAGS="-fno-semantic-interposition"
43-
# export STAGE_CXXFLAGS="${STAGE_CFLAGS}"
4439
export PATH="${PREFIX}/bin:$PATH"
4540

4641
# Detect architecture
@@ -50,7 +45,14 @@ else
5045
HOST_ARCH="x86_64"
5146
fi
5247

53-
mkdir -p ${WORKDIR} ${PREFIX}/{bin,share,lib/pkgconfig,include}
48+
rm -rf ${ARTIFACT_DIR}
49+
rm -rf ${PREFIX}/{bin,include,lib,share}
50+
rm -rf ${PREFIX}/{configure_options,ffmpeg_configure_options,ffmpeg_extra_libs}
51+
52+
mkdir -p ${ARTIFACT_DIR}
53+
mkdir -p ${WORKDIR}
54+
mkdir -p ${RUNTIME_LIB_DIR}
55+
mkdir -p ${PREFIX}/{bin,share,lib/pkgconfig,include}
5456

5557
FFMPEG_CONFIGURE_OPTIONS=()
5658
FFMPEG_EXTRA_LIBS=()
@@ -67,6 +69,7 @@ CPU_NUM=$(expr $(getconf _NPROCESSORS_ONLN) / 2)
6769

6870
# Cmake build toolchain
6971
cat << EOS > ${WORKDIR}/toolchains.cmake
72+
SET(CMAKE_POLICY_VERSION_MINIMUM 3.5)
7073
SET(CMAKE_SYSTEM_NAME ${TARGET_OS})
7174
SET(CMAKE_PREFIX_PATH ${PREFIX})
7275
SET(CMAKE_INSTALL_PREFIX ${PREFIX})

scripts/macos/build.sh

Lines changed: 91 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,110 @@
33
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
44
source ${SCRIPT_DIR}/base.sh
55

6-
rm -rf ${ARTIFACT_DIR}
7-
mkdir -p ${RUNTIME_LIB_DIR}
8-
mkdir -p ${ARTIFACT_DIR}
9-
106

117
#==============================================================================
128
# Build Libraries
139
#==============================================================================
1410

15-
echo "macOS library build script"
16-
echo "Currently no additional libraries are built."
17-
echo "This structure allows for future library additions."
11+
#
12+
# Video
13+
#
14+
15+
# Build libvpx
16+
LIBVPX_REPO="https://chromium.googlesource.com/webm/libvpx.git"
17+
LIBVPX_TAG_PREFIX="v"
18+
LIBVPX_VERSION="1.15.2" # get_latest_tag ${LIBVPX_REPO} ${LIBVPX_TAG_PREFIX}
19+
git_clone ${LIBVPX_REPO} ${LIBVPX_TAG_PREFIX}${LIBVPX_VERSION}
20+
./configure --prefix="${PREFIX}" --disable-shared --enable-static --enable-pic --disable-examples \
21+
--disable-tools --disable-docs --disable-unit-tests --enable-vp9-highbitdepth --as=yasm
22+
do_make_and_make_install
23+
FFMPEG_CONFIGURE_OPTIONS+=("--enable-libvpx")
24+
25+
# Build x264
26+
download_and_unpack_file "https://code.videolan.org/videolan/x264/-/archive/master/x264-master.tar.bz2"
27+
do_configure "--cross-prefix=${CROSS_PREFIX} --enable-static --enable-pic --disable-cli --disable-lavf --disable-swscale"
28+
do_make_and_make_install
29+
FFMPEG_CONFIGURE_OPTIONS+=("--enable-libx264")
30+
31+
# Build x265
32+
X265_VERSION="master"
33+
git_clone "https://bitbucket.org/multicoreware/x265_git" "${X265_VERSION}"
34+
mkcd build
35+
mkdir -p 8bit 10bit 12bit
36+
37+
cd 12bit
38+
do_cmake "-DHIGH_BIT_DEPTH=1 -DEXPORT_C_API=0 -DENABLE_SHARED=0 -DBUILD_SHARED_LIBS=0 -DENABLE_CLI=0 -DENABLE_TESTS=0 -DMAIN12=1" ../../source
39+
make -j ${CPU_NUM}
40+
cp libx265.a ../8bit/libx265_main12.a
41+
42+
cd ../10bit
43+
do_cmake "-DHIGH_BIT_DEPTH=1 -DEXPORT_C_API=0 -DENABLE_SHARED=0 -DBUILD_SHARED_LIBS=0 -DENABLE_CLI=0 -DENABLE_TESTS=0" ../../source
44+
make -j ${CPU_NUM}
45+
cp libx265.a ../8bit/libx265_main10.a
46+
47+
cd ../8bit
48+
do_cmake '-DEXTRA_LIB="x265_main10.a;x265_main12.a" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=1 -DLINKED_12BIT=1
49+
-DENABLE_SHARED=0 -DBUILD_SHARED_LIBS=0 -DENABLE_CLI=0 -DENABLE_TESTS=0' ../../source
50+
make -j ${CPU_NUM}
51+
52+
mv libx265.a libx265_main.a
53+
54+
libtool -static -o libx265.a libx265_main.a libx265_main10.a libx265_main12.a
55+
56+
make install
57+
cat <<EOS > ${PKG_CONFIG_PATH}/x265.pc
58+
prefix=${PREFIX}
59+
exec_prefix=\${prefix}
60+
libdir=\${exec_prefix}/lib
61+
includedir=\${prefix}/include
62+
63+
Name: x265
64+
Description: H.265 (HEVC) encoder library
65+
Version: 5.0
66+
67+
Libs: -L\${libdir} -lx265 -lpthread -lstdc++
68+
Cflags: -I\${includedir}
69+
EOS
70+
FFMPEG_CONFIGURE_OPTIONS+=("--enable-libx265")
71+
72+
# Build libaom
73+
LIBAOM_REPO="https://aomedia.googlesource.com/aom.git"
74+
LIBAOM_TAG_PREFIX="v"
75+
LIBAOM_VERSION="3.13.1" # get_latest_tag ${LIBAOM_REPO} ${LIBAOM_TAG_PREFIX}
76+
git_clone ${LIBAOM_REPO} ${LIBAOM_TAG_PREFIX}${LIBAOM_VERSION}
77+
mkcd _build
78+
do_cmake "-DBUILD_SHARED_LIBS=0 -DENABLE_DOCS=0 -DENABLE_TESTS=0 -DENABLE_EXAMPLES=0" ..
79+
do_make_and_make_install
80+
FFMPEG_CONFIGURE_OPTIONS+=("--enable-libaom")
81+
1882

19-
# 将来的にここにライブラリビルドを追加可能
20-
# 例:
21-
# - x264
22-
# - x265
23-
# - libvpx
24-
# など
83+
#
84+
# Audio
85+
#
86+
87+
# Build opus
88+
OPUS_REPO="https://github.com/xiph/opus.git"
89+
OPUS_TAG_PREFIX="v"
90+
OPUS_VERSION="1.6" # get_latest_tag ${OPUS_REPO} ${OPUS_TAG_PREFIX}
91+
git_clone ${OPUS_REPO} ${OPUS_TAG_PREFIX}${OPUS_VERSION}
92+
mkcd build
93+
do_cmake "-DBUILD_SHARED_LIBS=0 -DBUILD_TESTING=0" ..
94+
do_make_and_make_install
95+
FFMPEG_CONFIGURE_OPTIONS+=("--enable-libopus")
96+
97+
# Build mp3lame
98+
svn_checkout "https://svn.code.sf.net/p/lame/svn/trunk/lame"
99+
do_configure "--disable-shared --enable-static --enable-nasm --disable-decoder --disable-gtktest --disable-cpml --disable-frontend"
100+
do_make_and_make_install
101+
FFMPEG_CONFIGURE_OPTIONS+=("--enable-libmp3lame")
25102

26103

27104
#------------------------------------------------------------------------------
28105
# Prepare FFmpeg Build Options
29106
#------------------------------------------------------------------------------
30107

31108
# Write library options to files for FFmpeg configure
32-
# echo -n "${FFMPEG_EXTRA_LIBS[@]}" > ${PREFIX}/ffmpeg_extra_libs
33-
# echo -n "${FFMPEG_CONFIGURE_OPTIONS[@]}" > ${PREFIX}/ffmpeg_configure_options
34-
touch ${PREFIX}/ffmpeg_extra_libs
35-
touch ${PREFIX}/ffmpeg_configure_options
36-
109+
echo -n "${FFMPEG_CONFIGURE_OPTIONS[@]}" > ${PREFIX}/ffmpeg_configure_options
37110

38111
#==============================================================================
39112
# Build FFmpeg
@@ -53,7 +126,6 @@ git_clone "https://github.com/FFmpeg/FFmpeg.git" n${FFMPEG_VERSION}
53126
--enable-version3 \
54127
--enable-videotoolbox \
55128
--enable-neon \
56-
--extra-libs="`cat ${PREFIX}/ffmpeg_extra_libs`" \
57129
--pkg-config-flags="--static" \
58130
--prefix=${PREFIX} | tee ${PREFIX}/configure_options 1>&2
59131

@@ -66,13 +138,7 @@ do_strip ${PREFIX}/bin "ff*"
66138
# Finalize - Copy build artifacts to output directory
67139
#==============================================================================
68140

69-
# Copy library files
70-
# cp_archive ${PREFIX}/lib/*{.a,.la} ${ARTIFACT_DIR}
71-
# cp_archive ${PREFIX}/lib/pkgconfig ${ARTIFACT_DIR}
72-
# cp_archive ${PREFIX}/include ${ARTIFACT_DIR}
73-
74141
# Copy FFmpeg build options (for reference)
75-
cp_archive ${PREFIX}/ffmpeg_extra_libs ${ARTIFACT_DIR}
76142
cp_archive ${PREFIX}/ffmpeg_configure_options ${ARTIFACT_DIR}
77143

78144
# Copy FFmpeg binaries and configuration

0 commit comments

Comments
 (0)