diff --git a/.github/workflows/build-project.yaml b/.github/workflows/build-project.yaml index 697afccd2ab031..19a2da7883d7ab 100644 --- a/.github/workflows/build-project.yaml +++ b/.github/workflows/build-project.yaml @@ -14,6 +14,7 @@ jobs: notarize: ${{ steps.setup.outputs.notarize }} config: ${{ steps.setup.outputs.config }} commitHash: ${{ steps.setup.outputs.commitHash }} + flatpakArch: ${{ steps.setup.outputs.flatpakArch }} steps: - uses: actions/checkout@v3 with: @@ -28,25 +29,30 @@ jobs: case "${GITHUB_EVENT_NAME}" in pull_request) - config_data=('codesign:false' 'notarize:false' 'package:false' 'config:RelWithDebInfo') - if gh pr view ${{ github.event.number }} --json labels \ + config_data=('codesign:false' 'notarize:false' 'package:false' 'config:RelWithDebInfo' 'flatpakArch:["x86_64"]') + label_data=$(gh pr view ${{ github.event.number }} --json labels) + if echo "${label_data}" \ | jq -e -r '.labels[] | select(.name == "Seeking Testers")' > /dev/null; then config_data[0]='codesign:true' config_data[2]='package:true' fi + if echo "${label_data}" \ + | jq -e -r '.labels[] | select(.name == "Flatpak QEMU")' > /dev/null; then + config_data[5]='flatpakArch:["x86_64", "aarch64"]' + fi ;; push) - config_data=('codesign:true' 'notarize:false' 'package:true' 'config:RelWithDebInfo') + config_data=('codesign:true' 'notarize:false' 'package:true' 'config:RelWithDebInfo' 'flatpakArch:["x86_64", "aarch64"]') if [[ ${GITHUB_REF_NAME} =~ [0-9]+.[0-9]+.[0-9]+(-(rc|beta).+)? ]]; then config_data[1]='notarize:true' config_data[3]='config:Release' fi ;; workflow_dispatch) - config_data=('codesign:true' 'notarize:false' 'package:false' 'config:RelWithDebInfo') + config_data=('codesign:true' 'notarize:false' 'package:false' 'config:RelWithDebInfo' 'flatpakArch:["x86_64", "aarch64"]') ;; schedule) - config_data=('codesign:true' 'notarize:false' 'package:true' 'config:RelWithDebInfo') + config_data=('codesign:true' 'notarize:false' 'package:true' 'config:RelWithDebInfo' 'flatpakArch:["x86_64", "aarch64"]') ;; *) ;; esac @@ -243,79 +249,19 @@ jobs: flatpak-build: name: Flatpak ๐Ÿ“ฆ - runs-on: ubuntu-22.04 needs: check-event - defaults: - run: - shell: bash - container: - image: bilelmoussaoui/flatpak-github-actions:kde-6.5 - options: --privileged - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - fetch-depth: 0 - set-safe-directory: ${{ env.GITHUB_WORKSPACE }} - - - name: Set Up Environment ๐Ÿ”ง - id: setup - env: - GH_TOKEN: ${{ github.token }} - run: | - : Set Up Environment ๐Ÿ”ง - if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi - - git config --global --add safe.directory "${GITHUB_WORKSPACE}" - - echo '::group::Install GitHub CLI tool' - dnf install -y -q gh - gh extension install actions/gh-actions-cache - echo '::endgroup::' - - cache_key='flatpak-builder-${{ hashFiles('build-aux/**/*.json') }}' - cache_ref='master' - read -r key size unit _ ref _ <<< \ - "$(gh actions-cache list -B ${cache_ref} --key "${cache_key}-x86_64" | head -1)" - - if [[ "${key}" ]]; then - echo "cacheHit=true" >> $GITHUB_OUTPUT - else - echo "cacheHit=false" >> $GITHUB_OUTPUT - fi - - echo "cacheKey=${cache_key}" >> $GITHUB_OUTPUT - - - name: Validate Flatpak manifest - uses: ./.github/actions/flatpak-builder-lint - with: - artifact: manifest - path: build-aux/com.obsproject.Studio.json - validateToPublish: false - - - name: Build Flatpak Manifest ๐Ÿงพ - uses: flatpak/flatpak-github-actions/flatpak-builder@0ab9dd6a6afa6fe7e292db0325171660bf5b6fdf - with: - build-bundle: ${{ fromJSON(needs.check-event.outputs.package) }} - bundle: obs-studio-flatpak-${{ needs.check-event.outputs.commitHash }}.flatpak - manifest-path: ${{ github.workspace }}/build-aux/com.obsproject.Studio.json - cache: ${{ fromJSON(steps.setup.outputs.cacheHit) || (github.event_name == 'push' && github.ref_name == 'master')}} - restore-cache: ${{ fromJSON(steps.setup.outputs.cacheHit) }} - cache-key: ${{ steps.setup.outputs.cacheKey }} - - - name: Validate build directory - uses: ./.github/actions/flatpak-builder-lint - with: - artifact: builddir - path: flatpak_app - validateToPublish: false - - - name: Validate repository - uses: ./.github/actions/flatpak-builder-lint - with: - artifact: repo - path: repo - validateToPublish: false + uses: ./.github/workflows/flatpak-build.yaml + strategy: + fail-fast: false + matrix: + arch: ${{ fromJson(needs.check-event.outputs.flatpakArch) }} + with: + build-bundle: ${{ fromJSON(needs.check-event.outputs.package) }} + bundle: obs-studio-flatpak-${{ needs.check-event.outputs.commitHash }}-${{ matrix.arch }}.flatpak + arch: ${{ matrix.arch }} + secrets: inherit + permissions: + contents: read windows-build: name: Windows ๐ŸชŸ diff --git a/.github/workflows/flatpak-build.yaml b/.github/workflows/flatpak-build.yaml new file mode 100644 index 00000000000000..9ef0198d722620 --- /dev/null +++ b/.github/workflows/flatpak-build.yaml @@ -0,0 +1,199 @@ +name: Flatpak Build +on: + workflow_call: + inputs: + arch: + description: Architecture of the build + default: x86_64 + type: string + build-bundle: + description: Build a bundle and upload it as an artifact + default: true + type: boolean + bundle: + description: Name of the bundle + default: obs-studio-flatpak.flatpak + type: string +jobs: + build-until-90: + name: Build Modules Until 90-* ๐Ÿงพ + runs-on: ubuntu-22.04 + defaults: + run: + shell: bash + outputs: + cacheKey: ${{ steps.setup.outputs.cacheKey }} + cacheHit: ${{ steps.setup.outputs.cacheHit }} + qemuArch: ${{ steps.setup.outputs.qemuArch }} + container: + image: bilelmoussaoui/flatpak-github-actions:kde-6.5 + options: --privileged + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + fetch-depth: 0 + set-safe-directory: ${{ env.GITHUB_WORKSPACE }} + + - name: Set Up Environment ๐Ÿ”ง + id: setup + env: + GH_TOKEN: ${{ github.token }} + run: | + : Set Up Environment ๐Ÿ”ง + if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi + + git config --global --add safe.directory "${GITHUB_WORKSPACE}" + + echo '::group::Install GitHub CLI and jq tool' + dnf install -y -q gh jq + gh extension install actions/gh-actions-cache + echo '::endgroup::' + + if [[ "${{ inputs.arch }}" != "x86_64" ]]; then + echo '::group::Install Docker' + dnf install -y -q docker + echo '::endgroup::' + + if [[ "${{ inputs.arch }}" == "aarch64" ]]; then + echo "qemuArch=arm64" >> $GITHUB_OUTPUT + else + echo "qemuArch=${{ inputs.arch }}" >> $GITHUB_OUTPUT + fi + fi + + stop_at_module=$(jq -r '.modules[:-1] | map(select(test("90-*")))[0]' build-aux/com.obsproject.Studio.json) + echo "stopAtModule=$(jq -r '.name' build-aux/$stop_at_module)" >> $GITHUB_OUTPUT + + cache_key='flatpak-builder-${{ hashFiles('build-aux/**/*.json') }}' + cache_ref='master' + read -r key size unit _ ref _ <<< \ + "$(gh actions-cache list -B ${cache_ref} --key "${cache_key}-${{ inputs.arch }}" | head -1)" + + if [[ "${key}" ]]; then + echo "cacheHit=true" >> $GITHUB_OUTPUT + else + echo "cacheHit=false" >> $GITHUB_OUTPUT + fi + + echo "cacheKey=${cache_key}" >> $GITHUB_OUTPUT + + - name: Setup QEMU ๐Ÿฆค + if: ${{ (inputs.arch != 'x86_64') && !fromJSON(steps.setup.outputs.cacheHit) }} + uses: docker/setup-qemu-action@v2 + with: + platforms: ${{ steps.setup.outputs.qemuArch }} + + - name: Validate Flatpak manifest + uses: ./.github/actions/flatpak-builder-lint + with: + artifact: manifest + path: build-aux/com.obsproject.Studio.json + validateToPublish: false + + - name: Build Modules ๐Ÿงฑ + if: ${{ !fromJSON(steps.setup.outputs.cacheHit) }} + uses: flatpak/flatpak-github-actions/flatpak-builder@0ab9dd6a6afa6fe7e292db0325171660bf5b6fdf + with: + arch: ${{ inputs.arch }} + manifest-path: ${{ github.workspace }}/build-aux/com.obsproject.Studio.json + stop-at-module: ${{ steps.setup.outputs.stopAtModule }} + cache: false + + - name: Prepare Modules Artifact ๐Ÿ—œ๏ธ + if: ${{ !fromJSON(steps.setup.outputs.cacheHit) }} + run: tar -cvf flatpak-build-until-90-${{ inputs.arch }}.tar .flatpak-builder + + - name: Upload Modules Artifact ๐Ÿ“ก + if: ${{ !fromJSON(steps.setup.outputs.cacheHit) }} + uses: actions/upload-artifact@v3 + with: + name: flatpak-build-until-90-${{ inputs.arch }} + path: flatpak-build-until-90-${{ inputs.arch }}.tar + retention-days: 1 + + build-obs: + name: Build OBS Studio ๐Ÿงพ + runs-on: ubuntu-22.04 + needs: build-until-90 + defaults: + run: + shell: bash + container: + image: bilelmoussaoui/flatpak-github-actions:kde-6.5 + options: --privileged + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + fetch-depth: 0 + set-safe-directory: ${{ env.GITHUB_WORKSPACE }} + + - name: Set Up Environment ๐Ÿ”ง + id: setup + env: + GH_TOKEN: ${{ github.token }} + run: | + : Set Up Environment ๐Ÿ”ง + if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi + + git config --global --add safe.directory "${GITHUB_WORKSPACE}" + + if [[ "${{ inputs.arch }}" != "x86_64" ]]; then + echo '::group::Install Docker' + dnf install -y -q docker + echo '::endgroup::' + fi + + - name: Setup QEMU ๐Ÿฆค + if: ${{ (inputs.arch != 'x86_64') && !fromJSON(needs.build-until-90.outputs.cacheHit) }} + uses: docker/setup-qemu-action@v2 + with: + platforms: ${{ needs.build-until-90.outputs.qemuArch }} + + - name: Download Modules Artifact ๐Ÿ›ฐ๏ธ + if: ${{ !fromJSON(needs.build-until-90.outputs.cacheHit) }} + uses: actions/download-artifact@v3 + with: + name: flatpak-build-until-90-${{ inputs.arch }} + + - name: Extract Modules Artifact ๐Ÿ—œ๏ธ + if: ${{ !fromJSON(needs.build-until-90.outputs.cacheHit) }} + run: tar -xvf flatpak-build-until-90-${{ inputs.arch }}.tar + + - name: Build Modules ๐Ÿงฑ + uses: flatpak/flatpak-github-actions/flatpak-builder@0ab9dd6a6afa6fe7e292db0325171660bf5b6fdf + with: + arch: ${{ inputs.arch }} + build-bundle: ${{ fromJSON(inputs.build-bundle) }} + bundle: ${{ inputs.bundle }} + manifest-path: ${{ github.workspace }}/build-aux/com.obsproject.Studio.json + cache: ${{ fromJSON(needs.build-until-90.outputs.cacheHit) || (github.event_name == 'push' && github.ref_name == 'master')}} + restore-cache: ${{ fromJSON(needs.build-until-90.outputs.cacheHit) }} + cache-key: ${{ needs.build-until-90.outputs.cacheKey }} + + - name: Validate build directory + uses: ./.github/actions/flatpak-builder-lint + with: + artifact: builddir + path: flatpak_app + validateToPublish: false + + - name: Validate repository + uses: ./.github/actions/flatpak-builder-lint + with: + artifact: repo + path: repo + validateToPublish: false + + cleanup-artifact: + name: Cleanup Artifact ๐Ÿงน + runs-on: ubuntu-22.04 + needs: [build-until-90, build-obs] + if: ${{ !fromJSON(needs.build-until-90.outputs.cacheHit) }} + steps: + - name: Delete Modules Artifact ๐Ÿ—‘๏ธ + uses: geekyeggo/delete-artifact@v2 + with: + useGlob: false + name: flatpak-build-until-90-${{ inputs.arch }} diff --git a/build-aux/com.obsproject.Studio.json b/build-aux/com.obsproject.Studio.json index 37d898d851fbd4..4e45a3d90b958d 100644 --- a/build-aux/com.obsproject.Studio.json +++ b/build-aux/com.obsproject.Studio.json @@ -85,8 +85,7 @@ "-DENABLE_RTMPS=ON", "-DENABLE_VLC=OFF", "-DENABLE_AJA=ON", - "-DENABLE_LIBFDK=ON", - "-DENABLE_QSV11=ON" + "-DENABLE_LIBFDK=ON" ], "secret-opts": [ "-DRESTREAM_CLIENTID=$RESTREAM_CLIENTID", diff --git a/build-aux/modules/50-intel-media-sdk.json b/build-aux/modules/50-intel-media-sdk.json index 8f52b5c2139863..1e2d5c935e86da 100644 --- a/build-aux/modules/50-intel-media-sdk.json +++ b/build-aux/modules/50-intel-media-sdk.json @@ -1,5 +1,8 @@ { "name": "intel-media-sdk", + "only-arches": [ + "x86_64" + ], "buildsystem": "cmake-ninja", "builddir": true, "config-opts": [ diff --git a/build-aux/modules/50-onevpl-intel-gpu.json b/build-aux/modules/50-onevpl-intel-gpu.json index 3613012b99d500..4750596129f365 100644 --- a/build-aux/modules/50-onevpl-intel-gpu.json +++ b/build-aux/modules/50-onevpl-intel-gpu.json @@ -1,5 +1,8 @@ { "name": "onevpl-intel-gpu", + "only-arches": [ + "x86_64" + ], "buildsystem": "cmake-ninja", "builddir": true, "config-opts": [ diff --git a/build-aux/modules/50-onevpl.json b/build-aux/modules/50-onevpl.json index fc6e88227dcb4b..191d4a4ea039b0 100644 --- a/build-aux/modules/50-onevpl.json +++ b/build-aux/modules/50-onevpl.json @@ -1,5 +1,8 @@ { "name": "onevpl", + "only-arches": [ + "x86_64" + ], "buildsystem": "cmake-ninja", "builddir": true, "config-opts": [ diff --git a/build-aux/modules/99-cef.json b/build-aux/modules/99-cef.json index 23bf14cd64eed0..f5c0a50ead765f 100644 --- a/build-aux/modules/99-cef.json +++ b/build-aux/modules/99-cef.json @@ -21,8 +21,28 @@ "sources": [ { "type": "archive", + "only-arches": [ + "x86_64" + ], "url": "https://cdn-fastly.obsproject.com/downloads/cef_binary_5060_linux_x86_64_v3.tar.xz", "sha256": "1253a6a36c3b8ac5b5ece9bfdb6eae6ab75e49516375fc475e2e871795ad9bea" + }, + { + "type": "archive", + "only-arches": [ + "aarch64" + ], + "url": "https://cdn-fastly.obsproject.com/downloads/cef_binary_5060_linux_aarch64_v3.tar.xz", + "sha256": "66ebcfce94a4527c8dd085a685691d0c43291adab9f2be4f8a0762f4a614083a" + }, + { + "type": "shell", + "only-arches": [ + "aarch64" + ], + "commands": [ + "sed -i 's/set(PROJECT_ARCH \"x86_64\")/set(PROJECT_ARCH \"aarch64\")/g' cmake/cef_variables.cmake # Fix PROJECT_ARCH on aarch64" + ] } ] } diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 90bea35be27345..3c5aba161ac7cf 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -33,6 +33,12 @@ if(OBS_CMAKE_VERSION VERSION_GREATER_EQUAL 3.0.0) endif() endmacro() + macro(check_obs_qsv11) + if(OS_WINDOWS OR (OS_LINUX AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|x86|x64|x86_64|amd64|AMD64)$")) + add_subdirectory(obs-qsv11) + endif() + endmacro() + # Add plugins in alphabetical order to retain order in IDE projects add_subdirectory(aja) if(OS_WINDOWS OR OS_MACOS) @@ -63,8 +69,8 @@ if(OBS_CMAKE_VERSION VERSION_GREATER_EQUAL 3.0.0) add_subdirectory(obs-ffmpeg) add_subdirectory(obs-filters) add_subdirectory(obs-outputs) + check_obs_qsv11() if(OS_WINDOWS) - add_subdirectory(obs-qsv11) add_subdirectory(obs-text) endif() add_subdirectory(obs-transitions) diff --git a/plugins/obs-qsv11/CMakeLists.txt b/plugins/obs-qsv11/CMakeLists.txt index 7a6f5d831aaed7..b6d90cb7982c67 100644 --- a/plugins/obs-qsv11/CMakeLists.txt +++ b/plugins/obs-qsv11/CMakeLists.txt @@ -2,6 +2,12 @@ cmake_minimum_required(VERSION 3.22...3.25) legacy_check() +if(NOT OS_LINUX OR CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|x86|x64|x86_64|amd64|AMD64)$") + set(_enable_qsv11 TRUE) +else() + set(_enable_qsv11 FALSE) +endif() + option(ENABLE_QSV11 "Build Intel QSV11 Hardware Encoder." TRUE) if(NOT ENABLE_QSV11) target_disable_feature(obs-qsv11 "Intel QSV11 Hardware Encoder") diff --git a/plugins/obs-qsv11/cmake/legacy.cmake b/plugins/obs-qsv11/cmake/legacy.cmake index 34a445bde2433c..8ab46125fb688e 100644 --- a/plugins/obs-qsv11/cmake/legacy.cmake +++ b/plugins/obs-qsv11/cmake/legacy.cmake @@ -1,9 +1,21 @@ -option(ENABLE_QSV11 "Build Intel QSV11 Hardware Encoder." TRUE) +if(NOT OS_LINUX OR CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|x86|x64|x86_64|amd64|AMD64)$") + set(_enable_qsv11 TRUE) +else() + set(_enable_qsv11 FALSE) +endif() + +option(ENABLE_QSV11 "Build Intel QSV11 Hardware Encoder." _enable_qsv11) if(NOT ENABLE_QSV11) obs_status(DISABLED "obs-qsv11") return() +elseif(NOT _enable_qsv11) + message( + FATAL_ERROR + "QSV plugin is not compatible with ${CMAKE_SYSTEM_PROCESSOR} architecture.\n Disable this error by setting ENABLE_QSV11 to OFF." + ) endif() +unset(_enable_qsv11) project(obs-qsv11)