From b049fc8ab3b8f914fe1128c6cb21538737fd147d Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Sat, 20 May 2023 13:05:50 +0300 Subject: [PATCH] Enable building artifacts for Apple TV and simulator (#38) --- .github/workflows/build.yml | 63 +++++++++++++++++++++++++++---------- script/build.py | 25 ++++++++++----- script/prepare_linux.sh | 2 ++ 3 files changed, 66 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dfa6537..f380d4e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,16 +13,19 @@ on: default: 'false' env: - version: m110-ad42464-1 + version: m110-d88a7b5 jobs: macos: - runs-on: macos-11 + runs-on: ${{ fromJson('{"macos":"macos-11","ios":"macos-11","iosSim":"macos-11","tvos":"macos-13","tvosSim":"macos-13"}')[matrix.target] }} strategy: matrix: - target: ["macos", "ios", "iosSim"] + target: ["macos", "ios", "iosSim", "tvos", "tvosSim"] machine: ["x64", "arm64"] build_type: [Release, Debug] + exclude: + - target: tvos + machine: x64 fail-fast: false steps: - uses: actions/checkout@v2 @@ -43,28 +46,29 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - linux-ubuntu18: - runs-on: ubuntu-18.04 + linux: + runs-on: ubuntu-latest + container: ubuntu:20.04 strategy: matrix: build_type: [Debug, Release] fail-fast: false steps: - uses: actions/checkout@v2 - - run: sudo ./script/prepare_linux.sh - - run: python3 script/check_release.py --version ${{ env.version }} --build-type ${{ matrix.build_type }} --classifier ubuntu18 + - run: ./script/prepare_linux.sh + - run: python3 script/check_release.py --version ${{ env.version }} --build-type ${{ matrix.build_type }} if: ${{ github.event.inputs.skip_release != 'true' && github.ref == 'refs/heads/main' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: PATH=/usr/lib/binutils-2.26/bin:$PATH python3 script/checkout.py --version ${{ env.version }} - run: PATH=/usr/lib/binutils-2.26/bin:$PATH python3 script/build.py --build-type ${{ matrix.build_type }} - - run: PATH=/usr/lib/binutils-2.26/bin:$PATH python3 script/archive.py --version ${{ env.version }} --build-type ${{ matrix.build_type }} --classifier ubuntu18 + - run: PATH=/usr/lib/binutils-2.26/bin:$PATH python3 script/archive.py --version ${{ env.version }} --build-type ${{ matrix.build_type }} - uses: actions/upload-artifact@v2 if: ${{ github.event.inputs.skip_release != 'true' && github.ref == 'refs/heads/main' }} with: - name: Skia-${{ env.version }}-linux-${{ matrix.build_type }}-x64-ubuntu18.zip + name: Skia-${{ env.version }}-linux-${{ matrix.build_type }}-x64.zip path: '*.zip' - - run: python3 script/release.py --version ${{ env.version }} --build-type ${{ matrix.build_type }} --classifier ubuntu18 + - run: python3 script/release.py --version ${{ env.version }} --build-type ${{ matrix.build_type }} if: ${{ github.event.inputs.skip_release != 'true' && github.ref == 'refs/heads/main' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -97,15 +101,16 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} linux-android: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest + container: ubuntu:20.04 strategy: matrix: build_type: [ Debug, Release ] machine: ["x64", "arm64"] fail-fast: false steps: - - run: sudo apt-get install unzip -y - uses: actions/checkout@v2 + - run: ./script/prepare_linux.sh - run: python3 script/check_release.py --version ${{ env.version }} --target android --build-type ${{ matrix.build_type }} --machine ${{ matrix.machine }} if: ${{ github.event.inputs.skip_release != 'true' && github.ref == 'refs/heads/main' }} env: @@ -127,8 +132,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - linux-arm64-2004: - runs-on: ubuntu-18.04 + linux-arm64: + runs-on: ubuntu-latest strategy: matrix: build_type: [ Debug, Release ] @@ -136,8 +141,8 @@ jobs: steps: - uses: actions/checkout@v2 - uses: uraimo/run-on-arch-action@v2.0.5 - name: Run commands - id: runcmd + name: Assemble + id: assemble if: ${{ github.event.inputs.skip_release != 'true' && github.ref == 'refs/heads/main' }} with: arch: aarch64 @@ -164,6 +169,32 @@ jobs: python3 script/build.py --build-type ${build_type} --build-type ${build_type} python3 script/archive.py --version ${build_version} --build-type ${build_type} echo "Produced artifact at ${PWD}/${artifact_name}" + - uses: uraimo/run-on-arch-action@v2.0.5 + name: Test Build + id: test-build + if: ${{ github.event.inputs.skip_release == 'true' || github.ref != 'refs/heads/main' }} + with: + arch: aarch64 + distro: ubuntu20.04 + githubToken: ${{ secrets.GITHUB_TOKEN }} + # Mount checkout directory as /checkout in the container + dockerRunArgs: | + --volume "${GITHUB_WORKSPACE}:/checkout" + env: | + build_type: ${{ matrix.build_type }} + build_version: ${{ env.version }} + artifact_name: Skia-${{ env.version }}-linux-${{ matrix.build_type }}-arm64.zip + # The shell to run commands with in the container + shell: /bin/bash + install: | + apt-get update -q -y + apt-get install -q -y bash + run: | + cd /checkout + /bin/bash script/prepare_linux_arm.sh + python3 script/checkout.py --version ${build_version} + python3 script/build.py --build-type ${build_type} --build-type ${build_type} + echo "Verified build" - uses: actions/upload-artifact@v2 if: ${{ github.event.inputs.skip_release != 'true' && github.ref == 'refs/heads/main' }} with: diff --git a/script/build.py b/script/build.py index f995b6b..f5f21cb 100755 --- a/script/build.py +++ b/script/build.py @@ -15,7 +15,9 @@ def main(): tools_dir = "depot_tools" ninja = 'ninja.bat' if 'windows' == host else 'ninja' isIos = 'ios' == target or 'iosSim' == target + isTvos = 'tvos' == target or 'tvosSim' == target isIosSim = 'iosSim' == target + isTvosSim = 'tvosSim' == target if build_type == 'Debug': args = ['is_debug=true'] @@ -37,11 +39,9 @@ def main(): 'skia_enable_skottie=true' ] - if 'macos' == target or isIos: - args += [ - 'skia_use_metal=true', - 'extra_cflags_cc=["-frtti"]' - ] + if 'macos' == target or isIos or isTvos: + args += ['extra_cflags_cc=["-frtti"]'] + args += ['skia_use_metal=true'] if isIos: args += ['target_os="ios"'] if isIosSim: @@ -49,10 +49,19 @@ def main(): else: args += ['ios_min_target="11.0"'] else: - if 'arm64' == machine: - args += ['extra_cflags=["-stdlib=libc++"]'] + if isTvos: + args += ['target_os="tvos"'] + # Metal needs tvOS version 14 and SK_BUILD_FOR_TVOS to skip legacy iOS checks + if isTvosSim: + args += ['ios_use_simulator=true'] + args += ['extra_cflags=["-mtvos-simulator-version-min=14", "-DSK_BUILD_FOR_TVOS"]'] + else: + args += ['extra_cflags=["-mtvos-version-min=14", "-DSK_BUILD_FOR_TVOS"]'] else: - args += ['extra_cflags=["-stdlib=libc++", "-mmacosx-version-min=10.13"]'] + if 'arm64' == machine: + args += ['extra_cflags=["-stdlib=libc++"]'] + else: + args += ['extra_cflags=["-stdlib=libc++", "-mmacosx-version-min=10.13"]'] elif 'linux' == target: if 'arm64' == machine: # TODO: use clang on all targets! diff --git a/script/prepare_linux.sh b/script/prepare_linux.sh index 111ca0e..3180a16 100755 --- a/script/prepare_linux.sh +++ b/script/prepare_linux.sh @@ -1,6 +1,8 @@ #!/bin/bash set -o errexit -o nounset -o pipefail +export DEBIAN_FRONTEND=noninteractive + apt-get update -y apt-get install build-essential software-properties-common -y add-apt-repository ppa:ubuntu-toolchain-r/test -y