2020-09-10 03:05:08 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Copyright (c) Microsoft Corporation.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the 'License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set +x
|
|
|
|
|
|
|
|
trap "cd $(pwd -P)" EXIT
|
|
|
|
cd "$(dirname $0)"
|
|
|
|
|
|
|
|
if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then
|
2021-12-23 01:59:10 +03:00
|
|
|
echo "usage: $(basename $0) [--mac|--linux|--cross-compile-win64] [--full]"
|
2020-09-10 03:05:08 +03:00
|
|
|
echo
|
|
|
|
echo "Build ffmpeg for the given platform"
|
|
|
|
echo
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$1" ]]; then
|
|
|
|
echo "ERROR: expected build target. Run with --help for more info"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-02-04 06:36:10 +03:00
|
|
|
LICENSE_FILE="COPYING.LGPLv2.1"
|
|
|
|
|
2020-09-10 03:05:08 +03:00
|
|
|
rm -rf ./output
|
|
|
|
mkdir -p output
|
2021-02-04 06:36:10 +03:00
|
|
|
cp ffmpeg-license/"${LICENSE_FILE}" output
|
2020-09-10 03:05:08 +03:00
|
|
|
|
2020-09-15 01:12:35 +03:00
|
|
|
dockerflags="";
|
|
|
|
# Use |-it| to run docker to support Ctrl-C if we run the script inside interactive terminal.
|
|
|
|
# Otherwise (e.g. cronjob) - do nothing.
|
|
|
|
if [[ -t 0 ]]; then
|
|
|
|
dockerflags="-it"
|
|
|
|
fi
|
|
|
|
|
2021-11-02 22:02:16 +03:00
|
|
|
function ensure_docker_or_die() {
|
|
|
|
if ! command -v docker >/dev/null; then
|
|
|
|
echo "ERROR: docker is required for the script"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
2021-02-04 06:36:10 +03:00
|
|
|
|
2020-09-10 03:05:08 +03:00
|
|
|
if [[ "$1" == "--mac" ]]; then
|
2021-12-23 01:59:10 +03:00
|
|
|
bash ./build-mac.sh $2
|
2021-02-04 06:36:10 +03:00
|
|
|
cd output && zip ffmpeg.zip ffmpeg-mac "${LICENSE_FILE}"
|
2020-09-15 01:12:35 +03:00
|
|
|
elif [[ "$1" == "--linux" ]]; then
|
2021-11-02 22:02:16 +03:00
|
|
|
ensure_docker_or_die
|
|
|
|
|
2020-09-15 01:12:35 +03:00
|
|
|
time docker run --init --rm -v"${PWD}":/host ${dockerflags} ubuntu:18.04 bash /host/build-linux.sh /host/output/ffmpeg-linux
|
2021-02-04 06:36:10 +03:00
|
|
|
cd output && zip ffmpeg.zip ffmpeg-linux "${LICENSE_FILE}"
|
2021-11-02 22:02:16 +03:00
|
|
|
elif [[ "$1" == --cross-compile-win64 ]]; then
|
|
|
|
ensure_docker_or_die
|
2020-09-10 03:27:14 +03:00
|
|
|
|
2021-11-02 22:02:16 +03:00
|
|
|
time docker run --init --rm -v"${PWD}":/host ${dockerflags} ubuntu:18.04 bash /host/crosscompile-from-linux.sh --win64 /host/output/ffmpeg-win64.exe
|
|
|
|
cd output && zip ffmpeg.zip ffmpeg-win64.exe "${LICENSE_FILE}"
|
|
|
|
elif [[ "$1" == "--cross-compile-linux-arm64" ]]; then
|
|
|
|
ensure_docker_or_die
|
|
|
|
|
2021-12-23 01:43:13 +03:00
|
|
|
time docker run --init --rm -v"${PWD}":/host ${dockerflags} ubuntu:18.04 bash /host/crosscompile-from-linux.sh --linux-arm64 /host/output/ffmpeg-linux
|
|
|
|
cd output && zip ffmpeg.zip ffmpeg-linux "${LICENSE_FILE}"
|
2020-09-10 03:05:08 +03:00
|
|
|
else
|
|
|
|
echo "ERROR: unsupported platform - $1"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|