From f5a226a77e8dd24fa5546ded2f60330a4f3af62b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= Date: Mon, 20 Dec 2021 09:18:07 +0100 Subject: [PATCH] Target based builds (#10) * Target based macOS builds * Fix build * Fix output dir * Simplify artifact uploading for macos * Print tarballs * Fix tarball name * Use different tarball names for linux/windows * Fix --- .github/workflows/build.yml | 56 ++++++++++++------------------------- README.md | 4 +-- build-linux.sh | 6 ++-- build-macos.sh | 30 ++++++++++---------- build-windows.sh | 6 ++-- 5 files changed, 40 insertions(+), 62 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91532f5..97eed6b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,12 +18,9 @@ jobs: - name: Install dependencies run: | sudo apt-get update -y && \ - sudo apt-get install -y cmake yasm + sudo apt-get install -y yasm - name: Build - run: | - mkdir artifacts - ./build-linux.sh - mv ffmpeg-*-audio-linux-* artifacts + run: ./build-linux.sh - name: Archive production artifacts uses: actions/upload-artifact@v1 with: @@ -43,12 +40,9 @@ jobs: - name: Install dependencies run: | sudo apt-get update -y && \ - sudo apt-get install -y cmake yasm mingw-w64 + sudo apt-get install -y yasm mingw-w64 - name: Build - run: | - mkdir artifacts - ./build-windows.sh - mv ffmpeg-*-audio-windows-* artifacts + run: ./build-windows.sh - name: Archive production artifacts uses: actions/upload-artifact@v1 with: @@ -59,61 +53,47 @@ jobs: runs-on: macos-latest strategy: matrix: - arch: - - x86_64 - - arm64 + # https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary#Update-the-Architecture-List-of-Custom-Makefiles + target: + - x86_64-apple-macos10.8 + - arm64-apple-macos11 env: - ARCH: ${{ matrix.arch }} + TARGET: ${{ matrix.target }} steps: - uses: actions/checkout@v1 - name: Install dependencies - run: brew install nasm + run: brew install yasm - name: Build - run: | - mkdir artifacts - ./build-macos.sh - mv ffmpeg-*-audio-macos-** artifacts - - name: Archive production artifacts + run: ./build-macos.sh + - name: Archive artifacts uses: actions/upload-artifact@v1 with: - name: ffmpeg-macos-${{ env.ARCH }} + name: ffmpeg-${{ matrix.target }} path: artifacts/ release: runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/v') needs: - package-linux - package-windows - package-macos steps: - - uses: actions/download-artifact@v1 + - uses: actions/download-artifact@v2 with: - name: ffmpeg-linux-x86_64 path: artifacts/ - - - uses: actions/download-artifact@v1 - with: - name: ffmpeg-windows-x86_64 - path: artifacts/ - - - uses: actions/download-artifact@v1 - with: - name: ffmpeg-macos-x86_64 - path: artifacts/ - - name: Make tarballs run: | mkdir artifacts/release/ cd artifacts/ - dirs=$(find . -name 'ffmpeg-*' -type d) - for dir in $dirs + for dir in ffmpeg-*/ffmpeg-* do name=$(basename $dir) - tar cvzf release/$name.tar.gz $dir + tar czf release/$name.tar.gz $dir done + ls -l release/ - name: Release uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/v') with: files: artifacts/release/* env: diff --git a/README.md b/README.md index 14f0605..f417f95 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ Building is done using GitHub Actions. You can find the built binaries on the re Supported platforms: - Linux - * x86\_64 + * `x86\_64-linux-gnu` - Windows - * x86\_64 + * `x86\_64-w64-mingw32` - macOS * `x86_64-apple-macos10.8` (macOS Mountain Lion and newer on Intel CPU) * `arm64-apple-macos11` (macOS Big Sur and newer on Apple M1 CPU) diff --git a/build-linux.sh b/build-linux.sh index 7b64575..3731bd8 100755 --- a/build-linux.sh +++ b/build-linux.sh @@ -14,7 +14,7 @@ fi : ${ARCH?} -TARGET=ffmpeg-$FFMPEG_VERSION-audio-linux-$ARCH +OUTPUT_DIR=artifacts/ffmpeg-$FFMPEG_VERSION-audio-$ARCH-linux-gnu case $ARCH in x86_64) @@ -66,11 +66,11 @@ trap 'rm -rf $BUILD_DIR' EXIT cd $BUILD_DIR tar --strip-components=1 -xf $BASE_DIR/$FFMPEG_TARBALL -FFMPEG_CONFIGURE_FLAGS+=(--prefix=$BASE_DIR/$TARGET) +FFMPEG_CONFIGURE_FLAGS+=(--prefix=$BASE_DIR/$OUTPUT_DIR) ./configure "${FFMPEG_CONFIGURE_FLAGS[@]}" || (cat ffbuild/config.log && exit 1) make make install -chown $(stat -c '%u:%g' $BASE_DIR) -R $BASE_DIR/$TARGET +chown $(stat -c '%u:%g' $BASE_DIR) -R $BASE_DIR/$OUTPUT_DIR diff --git a/build-macos.sh b/build-macos.sh index 5cec185..11734ae 100755 --- a/build-macos.sh +++ b/build-macos.sh @@ -12,30 +12,28 @@ then curl -O $FFMPEG_TARBALL_URL fi -: ${ARCH?} +: ${TARGET?} -OUTPUT_DIR=ffmpeg-$FFMPEG_VERSION-audio-macos-$ARCH - -BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX) -trap 'rm -rf $BUILD_DIR' EXIT - -cd $BUILD_DIR -tar --strip-components=1 -xf $BASE_DIR/$FFMPEG_TARBALL - -# https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary#Update-the-Architecture-List-of-Custom-Makefiles -case $ARCH in - x86_64) - TARGET="x86_64-apple-macos10.8" +case $TARGET in + x86_64-*) + ARCH="x86_64" ;; - arm64) - TARGET="arm64-apple-macos11" + arm64-*) + ARCH="arm64" ;; *) - echo "Unknown architecture: $ARCH" + echo "Unknown target: $TARGET" exit 1 ;; esac +OUTPUT_DIR=artifacts/ffmpeg-$FFMPEG_VERSION-audio-$TARGET + +BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX) +trap 'rm -rf $BUILD_DIR' EXIT + +cd $BUILD_DIR +tar --strip-components=1 -xf $BASE_DIR/$FFMPEG_TARBALL FFMPEG_CONFIGURE_FLAGS+=( --cc=/usr/bin/clang diff --git a/build-windows.sh b/build-windows.sh index 8385bf5..3f7f2af 100755 --- a/build-windows.sh +++ b/build-windows.sh @@ -14,7 +14,7 @@ fi : ${ARCH?} -TARGET=ffmpeg-$FFMPEG_VERSION-audio-windows-$ARCH +OUTPUT_DIR=artifacts/ffmpeg-$FFMPEG_VERSION-audio-$ARCH-w64-mingw32 BUILD_DIR=$(mktemp -d -p $(pwd) build.XXXXXXXX) trap 'rm -rf $BUILD_DIR' EXIT @@ -23,7 +23,7 @@ cd $BUILD_DIR tar --strip-components=1 -xf $BASE_DIR/$FFMPEG_TARBALL FFMPEG_CONFIGURE_FLAGS+=( - --prefix=$BASE_DIR/$TARGET + --prefix=$BASE_DIR/$OUTPUT_DIR --extra-cflags='-static -static-libgcc -static-libstdc++' --target-os=mingw32 --arch=$ARCH @@ -34,4 +34,4 @@ FFMPEG_CONFIGURE_FLAGS+=( make make install -chown $(stat -c '%u:%g' $BASE_DIR) -R $BASE_DIR/$TARGET +chown $(stat -c '%u:%g' $BASE_DIR) -R $BASE_DIR/$OUTPUT_DIR