Skip to content

Commit

Permalink
use github arm64 runner
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeSchiff authored and WyattBlue committed Jan 20, 2025
1 parent b70f43d commit bfeccad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 116 deletions.
76 changes: 3 additions & 73 deletions .github/workflows/build-ffmpeg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
- os: windows-latest
arch: AMD64
shell: 'msys2 {0}'
- os: ubuntu-24.04-arm
arch: aarch64
shell: bash
defaults:
run:
shell: ${{ matrix.shell }}
Expand Down Expand Up @@ -76,76 +79,3 @@ jobs:
with:
name: output-${{ matrix.os }}-${{ matrix.arch }}
path: output/

build-qemu-stage-1:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
arch: [aarch64]
os: [ubuntu-latest]
env:
stage: 1
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Build FFmpeg dependencies
run: |
docker run -v $PWD:/project:rw --workdir=/project quay.io/pypa/manylinux2014_${{ matrix.arch }} bash -exc '
export PATH=/opt/python/cp39-cp39/bin:$PATH;
export CIBUILDWHEEL=1;
python scripts/build-ffmpeg.py /tmp/vendor --enable-gpl --stage ${{ env.stage }};
cp -ar /tmp/vendor /project;
'
shell: bash
- uses: actions/upload-artifact@v4
with:
name: stage-1-${{ matrix.os }}-${{ matrix.arch }}
path: vendor

build-qemu-stage-2:
needs: build-qemu-stage-1
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
arch: [aarch64]
os: [ubuntu-latest]
env:
stage: 2
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- uses: actions/download-artifact@v4
with:
name: stage-1-${{ matrix.os }}-${{ matrix.arch }}
path: vendor
- name: Build FFmpeg
env:
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_BEFORE_ALL_LINUX: |
yum install -y openssl-devel
cp -ar vendor /tmp
CIBW_BEFORE_BUILD: python scripts/build-ffmpeg.py /tmp/vendor --enable-gpl --stage ${{ env.stage }}
CIBW_BUILD: cp39-*
CIBW_REPAIR_WHEEL_COMMAND_LINUX: LD_LIBRARY_PATH=/tmp/vendor/lib:$LD_LIBRARY_PATH auditwheel repair -w {dest_dir} {wheel}
CIBW_SKIP: "*musllinux*"
CIBW_TEST_COMMAND: python -c "import dummy"
run: |
pip install cibuildwheel
cibuildwheel --output-dir output
rm -f output/*.whl
shell: bash
- name: Upload FFmpeg
uses: actions/upload-artifact@v4
with:
name: output-${{ matrix.os }}-${{ matrix.arch }}
path: output/
51 changes: 8 additions & 43 deletions scripts/build-ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,24 +204,15 @@
)


def download_tars(use_gnutls, stage):
def download_tars(use_gnutls):
# Try to download all tars at the start.
# If there is an curl error, do nothing, then try again in `main()`

local_libs = library_group
if use_gnutls:
local_libs += gnutls_group

if stage is None:
the_packages = local_libs + codec_group
elif stage == 0:
the_packages = local_libs
elif stage == 1:
the_packages = codec_group
else:
the_packages = []

for package in the_packages:
for package in local_libs + codec_group:
tarball = os.path.join(
os.path.abspath("source"),
package.source_filename or package.source_url.split("/")[-1],
Expand All @@ -238,18 +229,12 @@ def main():

parser = argparse.ArgumentParser("build-ffmpeg")
parser.add_argument("destination")
parser.add_argument(
"--stage",
default=None,
help="AArch64 build requires stage and possible values can be 1, 2",
)
parser.add_argument("--enable-gpl", action="store_true")
parser.add_argument("--disable-gpl", action="store_true")

args = parser.parse_args()

dest_dir = args.destination
build_stage = None if args.stage is None else int(args.stage) - 1
disable_gpl = args.disable_gpl
del args

Expand All @@ -258,8 +243,6 @@ def main():
# FFmpeg has native TLS backends for macOS and Windows
use_gnutls = plat == "Linux"

if plat == "Linux" and os.environ.get("CIBUILDWHEEL") == "1":
output_dir = "/output"
output_tarball = os.path.join(output_dir, f"ffmpeg-{get_platform()}.tar.gz")

if os.path.exists(output_tarball):
Expand All @@ -268,25 +251,11 @@ def main():
builder = Builder(dest_dir=dest_dir)
builder.create_directories()

download_tars(use_gnutls, build_stage)
download_tars(use_gnutls)

# install packages
available_tools = set()
if plat == "Linux" and os.environ.get("CIBUILDWHEEL") == "1":
with log_group("install packages"):
run(
[
"yum",
"-y",
"install",
"gperf",
"libuuid-devel",
"libxcb-devel",
"zlib-devel",
]
)
available_tools.update(["gperf"])
elif plat == "Windows":
if plat == "Windows":
available_tools.update(["gperf", "nasm"])

# print tool locations
Expand Down Expand Up @@ -372,10 +341,7 @@ def main():
library_group += gnutls_group

package_groups = [library_group + codec_group, [ffmpeg_package]]
if build_stage is not None:
packages = package_groups[build_stage]
else:
packages = [p for p_list in package_groups for p in p_list]
packages = [p for p_list in package_groups for p in p_list]

for package in packages:
if disable_gpl and package.gpl:
Expand All @@ -386,7 +352,7 @@ def main():
else:
builder.build(package)

if plat == "Windows" and (build_stage is None or build_stage == 1):
if plat == "Windows":
# fix .lib files being installed in the wrong directory
for name in (
"avcodec",
Expand Down Expand Up @@ -436,9 +402,8 @@ def main():
run(["strip", "-s"] + libraries)

# build output tarball
if build_stage is None or build_stage == 1:
os.makedirs(output_dir, exist_ok=True)
run(["tar", "czvf", output_tarball, "-C", dest_dir, "bin", "include", "lib"])
os.makedirs(output_dir, exist_ok=True)
run(["tar", "czvf", output_tarball, "-C", dest_dir, "bin", "include", "lib"])


if __name__ == "__main__":
Expand Down

0 comments on commit bfeccad

Please sign in to comment.