From bfeccad8a09823823eeb5fa1b22f1f8c35841f91 Mon Sep 17 00:00:00 2001 From: Joe Schiffler <41972063+JoeSchiff@users.noreply.github.com> Date: Mon, 20 Jan 2025 11:42:05 -0500 Subject: [PATCH] use github arm64 runner --- .github/workflows/build-ffmpeg.yml | 76 ++---------------------------- scripts/build-ffmpeg.py | 51 ++++---------------- 2 files changed, 11 insertions(+), 116 deletions(-) diff --git a/.github/workflows/build-ffmpeg.yml b/.github/workflows/build-ffmpeg.yml index 8cd30520..1d2af9db 100644 --- a/.github/workflows/build-ffmpeg.yml +++ b/.github/workflows/build-ffmpeg.yml @@ -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 }} @@ -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/ diff --git a/scripts/build-ffmpeg.py b/scripts/build-ffmpeg.py index 1198b1fa..93fa46d2 100644 --- a/scripts/build-ffmpeg.py +++ b/scripts/build-ffmpeg.py @@ -204,7 +204,7 @@ ) -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()` @@ -212,16 +212,7 @@ def download_tars(use_gnutls, stage): 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], @@ -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 @@ -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): @@ -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 @@ -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: @@ -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", @@ -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__":