diff --git a/.github/workflows/bridge.yml b/.github/workflows/bridge.yml index c94322102307..5b9367221cb9 100644 --- a/.github/workflows/bridge.yml +++ b/.github/workflows/bridge.yml @@ -8,7 +8,7 @@ on: env: FLUTTER_VERSION: "3.13.9" FLUTTER_RUST_BRIDGE_VERSION: "1.80.1" - + jobs: generate_bridge: runs-on: ${{ matrix.job.os }} @@ -27,9 +27,25 @@ jobs: - name: Install prerequisites run: | - sudo apt install ca-certificates -y - sudo apt update -y - sudo apt install -y g++ gcc git curl wget nasm yasm libgtk-3-dev clang cmake libclang-dev ninja-build llvm-dev libclang-10-dev llvm-10-dev pkg-config + sudo apt-get install ca-certificates -y + sudo apt-get update -y + sudo apt-get install -y \ + clang \ + cmake \ + curl \ + gcc \ + git \ + g++ \ + libclang-10-dev \ + libclang-dev \ + libgtk-3-dev \ + llvm-10-dev \ + llvm-dev \ + nasm \ + ninja-build \ + pkg-config \ + wget \ + yasm - name: Install Rust toolchain uses: actions-rs/toolchain@v1 @@ -74,5 +90,5 @@ jobs: path: | ./src/bridge_generated.rs ./src/bridge_generated.io.rs - ./flutter/lib/generated_bridge.dart + ./flutter/lib/generated_bridge.dart ./flutter/lib/generated_bridge.freezed.dart diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 028df3860ea0..080a0b7434fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,12 @@ name: CI -# env: +env: # MIN_SUPPORTED_RUST_VERSION: "1.46.0" # CICD_INTERMEDIATES_DIR: "_cicd-intermediates" + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + # vcpkg version: 2023.10.19 + # for multiarch gcc compatibility + VCPKG_COMMIT_ID: "8eb57355a4ffb410a2e94c07b4dca2dffbee8e50" on: workflow_dispatch: @@ -76,6 +80,13 @@ jobs: - { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 } # - { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } steps: + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + - name: Checkout source code uses: actions/checkout@v3 @@ -83,21 +94,43 @@ jobs: shell: bash run: | case ${{ matrix.job.target }} in - x86_64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt install -y g++ gcc git curl wget nasm yasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev;; + x86_64-unknown-linux-gnu) + sudo apt-get -y update + sudo apt-get install -y \ + clang \ + cmake \ + curl \ + gcc \ + git \ + g++ \ + libasound2-dev \ + libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev \ + libgtk-3-dev \ + libpulse-dev \ + libxcb-randr0-dev \ + libxcb-shape0-dev \ + libxcb-xfixes0-dev \ + libxdo-dev \ + libxfixes-dev \ + nasm \ + wget \ + yasm + ;; # arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;; # aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;; esac - - name: Restore from cache and install vcpkg - uses: lukka/run-vcpkg@v7 + - name: Setup vcpkg with Github Actions binary cache + uses: lukka/run-vcpkg@v11 with: - setupOnly: true - vcpkgGitCommitId: '501db0f17ef6df184fcdbfbe0f87cde2313b6ab1' #2023.04.15 - + vcpkgDirectory: /opt/artifacts/vcpkg + vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }} + - name: Install vcpkg dependencies run: | - $VCPKG_ROOT/vcpkg install libvpx libyuv opus aom - shell: bash + $VCPKG_ROOT/vcpkg install --x-install-root="$VCPKG_ROOT/installed" + shell: bash - name: Install Rust toolchain uses: actions-rs/toolchain@v1 @@ -118,7 +151,7 @@ jobs: rustc -V - uses: Swatinem/rust-cache@v1 - + - name: Build uses: actions-rs/cargo@v1 with: @@ -183,7 +216,7 @@ jobs: ;; esac; - echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS} + echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS} - name: Run tests uses: actions-rs/cargo@v1 diff --git a/.github/workflows/flutter-build.yml b/.github/workflows/flutter-build.yml index 8b28f763adc3..fda65e972c05 100644 --- a/.github/workflows/flutter-build.yml +++ b/.github/workflows/flutter-build.yml @@ -1,4 +1,4 @@ -name: Build the flutter version of the RustDesk +name: Build the flutter version of the RustDesk on: workflow_call: @@ -15,15 +15,13 @@ env: LLVM_VERSION: "15.0.6" FLUTTER_VERSION: "3.13.9" FLUTTER_RUST_BRIDGE_VERSION: "1.80.1" - # for arm64 linux - FLUTTER_ELINUX_VERSION: "3.10.6" - FLUTTER_ELINUX_COMMIT_ID: "410b3ca42f2cd0c485edf517a1666652bab442d4" TAG_NAME: "${{ inputs.upload-tag }}" - # vcpkg version: 2023.04.15 + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + # vcpkg version: 2023.10.19 # for multiarch gcc compatibility - VCPKG_COMMIT_ID: "501db0f17ef6df184fcdbfbe0f87cde2313b6ab1" + VCPKG_COMMIT_ID: "8eb57355a4ffb410a2e94c07b4dca2dffbee8e50" VERSION: "1.2.4" - NDK_VERSION: "r25c" + NDK_VERSION: "r26b" #signing keys env variable checks ANDROID_SIGNING_KEY: '${{ secrets.ANDROID_SIGNING_KEY }}' MACOS_P12_BASE64: '${{ secrets.MACOS_P12_BASE64 }}' @@ -45,6 +43,13 @@ jobs: - { target: x86_64-pc-windows-msvc, os: windows-2019, arch: x86_64 } # - { target: aarch64-pc-windows-msvc, os: windows-2019, arch: aarch64 } steps: + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + - name: Checkout source code uses: actions/checkout@v3 @@ -87,14 +92,18 @@ jobs: Push-Location flutter ; flutter pub get ; Pop-Location ~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart + - name: Setup vcpkg with Github Actions binary cache + uses: lukka/run-vcpkg@v11 + with: + vcpkgDirectory: C:\vcpkg + vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }} + - name: Install vcpkg dependencies run: | - cd C:\ - git clone https://github.com/Kingtous/rustdesk_thirdpary_lib --depth=1 - + $VCPKG_ROOT/vcpkg install --triplet x64-windows-static --x-install-root="$VCPKG_ROOT/installed" + shell: bash + - name: Build rustdesk - env: - VCPKG_ROOT: C:\rustdesk_thirdpary_lib\vcpkg run: python3 .\build.py --portable --hwcodec --flutter --feature IddDriver - name: find Runner.res @@ -169,6 +178,13 @@ jobs: - { target: i686-pc-windows-msvc, os: windows-2019, arch: x86 } # - { target: aarch64-pc-windows-msvc, os: windows-2019 } steps: + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + - name: Checkout source code uses: actions/checkout@v3 @@ -189,22 +205,20 @@ jobs: with: prefix-key: ${{ matrix.job.os }}-sciter - - name: Restore from cache and install vcpkg - uses: lukka/run-vcpkg@v7 + - name: Setup vcpkg with Github Actions binary cache + uses: lukka/run-vcpkg@v11 with: - setupOnly: true + vcpkgDirectory: C:\vcpkg vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }} - name: Install vcpkg dependencies run: | - cd C:\ - git clone https://github.com/Kingtous/rustdesk_thirdpary_lib --depth=1 + $VCPKG_ROOT/vcpkg install --triplet x86-windows-static --x-install-root="$VCPKG_ROOT/installed" + shell: bash - name: Build rustdesk id: build shell: bash - env: - VCPKG_ROOT: C:\rustdesk_thirdpary_lib\vcpkg run: | python3 res/inline-sciter.py # Patch sciter x86 @@ -251,7 +265,7 @@ jobs: popd mkdir -p ./SignOutput mv ./target/release/rustdesk-portable-packer.exe ./SignOutput/rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}-sciter.exe - + - name: Sign rustdesk self-extracted file uses: GermanBluefox/code-sign-action@v7 with: @@ -285,17 +299,24 @@ jobs: arch: x86_64 } steps: + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + - name: Checkout source code uses: actions/checkout@v3 - name: Import the codesign cert if: env.MACOS_P12_BASE64 != null uses: apple-actions/import-codesign-certs@v1 - with: + with: p12-file-base64: ${{ secrets.MACOS_P12_BASE64 }} p12-password: ${{ secrets.MACOS_P12_PASSWORD }} keychain: rustdesk - + - name: Check sign and import sign key if: env.MACOS_P12_BASE64 != null run: | @@ -310,11 +331,11 @@ jobs: fileName: rustdesk.json fileDir: ${{ github.workspace }} encodedString: ${{ secrets.MACOS_NOTARIZE_JSON }} - + - name: Install rcodesign tool if: env.MACOS_P12_BASE64 != null shell: bash - run: | + run: | pushd /tmp wget https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F0.22.0/apple-codesign-0.22.0-macos-universal.tar.gz tar -zxvf apple-codesign-0.22.0-macos-universal.tar.gz @@ -350,15 +371,14 @@ jobs: pushd flutter && flutter pub get && popd ~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart --c-output ./flutter/macos/Runner/bridge_generated.h - - name: Restore from cache and install vcpkg - uses: lukka/run-vcpkg@v7 + - name: Setup vcpkg with Github Actions binary cache + uses: lukka/run-vcpkg@v11 with: - setupOnly: true vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }} - name: Install vcpkg dependencies run: | - $VCPKG_ROOT/vcpkg install libvpx libyuv opus aom + $VCPKG_ROOT/vcpkg install --x-install-root="$VCPKG_ROOT/installed" - name: Show version information (Rust, cargo, Clang) shell: bash @@ -403,9 +423,6 @@ jobs: files: | rustdesk*-${{ matrix.job.arch }}.dmg - build-vcpkg-deps-linux: - uses: ./.github/workflows/vcpkg-deps-linux.yml - generate-bridge-linux: uses: ./.github/workflows/bridge.yml @@ -425,6 +442,13 @@ jobs: extra-build-features: "", } steps: + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + - name: Install dependencies run: | brew install nasm yasm @@ -436,11 +460,15 @@ jobs: channel: "stable" flutter-version: ${{ env.FLUTTER_VERSION }} - - name: Clone deps - shell: bash + - name: Setup vcpkg with Github Actions binary cache + uses: lukka/run-vcpkg@v11 + with: + vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }} + + - name: Install vcpkg dependencies run: | - pushd /opt - sudo git clone https://github.com/rustdesk-org/rustdesk_thirdparty_lib.git --depth=1 + $VCPKG_ROOT/vcpkg install --triplet arm64-ios --x-install-root="$VCPKG_ROOT/installed" + shell: bash - name: Restore bridge files uses: actions/download-artifact@master @@ -458,21 +486,20 @@ jobs: - uses: Swatinem/rust-cache@v2 with: - prefix-key: rustdesk-lib-cache + prefix-key: rustdesk-lib-cache-ios key: ${{ matrix.job.target }}-${{ matrix.job.extra-build-features }} - - name: Install flutter rust bridge deps - shell: bash - run: | - cargo install flutter_rust_bridge_codegen --version ${{ env.FLUTTER_RUST_BRIDGE_VERSION }} --features "uuid" - pushd flutter && flutter pub get && popd - ~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart --c-output ./flutter/ios/Runner/bridge_generated.h +# TODO: Re-evaluate caching bridge with flutter-rust-bridge >= 1.81.0 +# - name: Install flutter rust bridge deps +# shell: bash +# run: | +# cargo install flutter_rust_bridge_codegen --version ${{ env.FLUTTER_RUST_BRIDGE_VERSION }} --features "uuid" +# pushd flutter && flutter pub get && popd +# ~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart --c-output ./flutter/ios/Runner/bridge_generated.h - name: Build rustdesk lib - env: - VCPKG_ROOT: /opt/rustdesk_thirdparty_lib/vcpkg run: | - rustup target add ${{ matrix.job.target }} + rustup target add ${{ matrix.job.target }} cargo build --features flutter --release --target aarch64-apple-ios --lib - name: Build rustdesk @@ -482,7 +509,7 @@ jobs: # flutter build ipa --release --obfuscate --split-debug-info=./split-debug-info --no-codesign # for easy debugging flutter build ipa --release --no-codesign - + # - name: Upload Artifacts # # if: env.ANDROID_SIGNING_KEY != null && env.UPLOAD_ARTIFACT == 'true' # uses: actions/upload-artifact@master @@ -498,7 +525,6 @@ jobs: # tag_name: ${{ env.TAG_NAME }} # files: | # flutter/build/ios/ipa/*.ipa - build-rustdesk-android: needs: [generate-bridge-linux] @@ -523,10 +549,51 @@ jobs: openssl-arch: android-arm } steps: + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + - name: Install dependencies run: | - sudo apt update - sudo apt-get -qq install -y git curl wget nasm yasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake libclang-dev ninja-build libappindicator3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libvdpau-dev libva-dev libpam0g-dev libclang-dev llvm-dev libclang-10-dev llvm-10-dev pkg-config tree g++ libc6-dev gcc-multilib g++-multilib openjdk-11-jdk-headless + sudo apt-get update + sudo apt-get install -y \ + clang \ + cmake \ + curl \ + gcc-multilib \ + git \ + g++ \ + g++-multilib \ + libappindicator3-dev \ + libasound2-dev \ + libc6-dev \ + libclang-10-dev \ + libclang-dev \ + libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev \ + libgtk-3-dev \ + libpam0g-dev \ + libpulse-dev \ + libva-dev \ + libvdpau-dev \ + libxcb-randr0-dev \ + libxcb-shape0-dev \ + libxcb-xfixes0-dev \ + libxdo-dev \ + libxfixes-dev \ + llvm-10-dev \ + llvm-dev \ + nasm \ + ninja-build \ + openjdk-11-jdk-headless \ + pkg-config \ + tree \ + wget \ + yasm + - name: Checkout source code uses: actions/checkout@v3 - name: Install flutter @@ -540,11 +607,23 @@ jobs: ndk-version: ${{ env.NDK_VERSION }} add-to-path: true - - name: Clone deps - shell: bash + - name: Setup vcpkg with Github Actions binary cache + uses: lukka/run-vcpkg@v11 + with: + vcpkgDirectory: /opt/artifacts/vcpkg + vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }} + + - name: Install vcpkg dependencies run: | - pushd /opt - git clone https://github.com/rustdesk-org/rustdesk_thirdparty_lib.git --depth=1 + case ${{ matrix.job.target }} in + aarch64-linux-android) + ./flutter/build_android_deps.sh arm64-v8a + ;; + armv7-linux-androideabi) + ./flutter/build_android_deps.sh armeabi-v7a + ;; + esac + shell: bash - name: Restore bridge files uses: actions/download-artifact@master @@ -561,16 +640,15 @@ jobs: - uses: Swatinem/rust-cache@v2 with: - prefix-key: rustdesk-lib-cache + prefix-key: rustdesk-lib-cache-android # TODO: drop '-android' part after caches are invalidated key: ${{ matrix.job.target }}-${{ matrix.job.extra-build-features }} - name: Build rustdesk lib env: ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }} - VCPKG_ROOT: /opt/rustdesk_thirdparty_lib/vcpkg run: | - rustup target add ${{ matrix.job.target }} + rustup target add ${{ matrix.job.target }} cargo install cargo-ndk --version ${{ env.CARGO_NDK_VERSION }} case ${{ matrix.job.target }} in aarch64-linux-android) @@ -596,7 +674,7 @@ jobs: case ${{ matrix.job.target }} in aarch64-linux-android) mkdir -p ./flutter/android/app/src/main/jniLibs/arm64-v8a - cp /opt/rustdesk_thirdparty_lib/android/app/src/main/jniLibs/arm64-v8a/*.so ./flutter/android/app/src/main/jniLibs/arm64-v8a/ + cp ${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so ./flutter/android/app/src/main/jniLibs/arm64-v8a/ cp ./target/${{ matrix.job.target }}/release/liblibrustdesk.so ./flutter/android/app/src/main/jniLibs/arm64-v8a/librustdesk.so # build flutter pushd flutter @@ -605,7 +683,7 @@ jobs: ;; armv7-linux-androideabi) mkdir -p ./flutter/android/app/src/main/jniLibs/armeabi-v7a - cp /opt/rustdesk_thirdparty_lib/android/app/src/main/jniLibs/armeabi-v7a/*.so ./flutter/android/app/src/main/jniLibs/armeabi-v7a/ + cp ${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/libc++_shared.so ./flutter/android/app/src/main/jniLibs/armeabi-v7a/ cp ./target/${{ matrix.job.target }}/release/liblibrustdesk.so ./flutter/android/app/src/main/jniLibs/armeabi-v7a/librustdesk.so # build flutter pushd flutter @@ -616,7 +694,7 @@ jobs: popd mkdir -p signed-apk; pushd signed-apk mv ../rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.apk . - + - uses: r0adkll/sign-android-release@v1 name: Sign app APK if: env.ANDROID_SIGNING_KEY != null @@ -657,7 +735,7 @@ jobs: signed-apk/rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.apk build-rustdesk-lib-linux-amd64: - needs: [generate-bridge-linux, build-vcpkg-deps-linux] + needs: [generate-bridge-linux] name: build-rust-lib ${{ matrix.job.target }} (${{ matrix.job.os }}) [${{ matrix.job.extra-build-features }}] runs-on: ${{ matrix.job.os }} strategy: @@ -690,13 +768,20 @@ jobs: } # - { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } steps: + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + - name: Maximize build space run: | sudo rm -rf /opt/ghc sudo rm -rf /usr/local/lib/android sudo rm -rf /usr/share/dotnet - sudo apt update -y - sudo apt install qemu-user-static -y + sudo apt-get update -y + sudo apt-get install -y nasm qemu-user-static yasm - name: Checkout source code uses: actions/checkout@v3 @@ -718,7 +803,7 @@ jobs: target: ${{ matrix.job.target }} override: true profile: minimal # minimal component installation (ie, no documentation) - + - name: Save Rust toolchain version run: | RUST_TOOLCHAIN_VERSION=$(cargo --version | awk '{print $2}') @@ -735,11 +820,16 @@ jobs: name: bridge-artifact path: ./ - - name: Restore vcpkg files - uses: actions/download-artifact@master + - name: Setup vcpkg with Github Actions binary cache + uses: lukka/run-vcpkg@v11 with: - name: vcpkg-artifact-${{ matrix.job.arch }} - path: /opt/artifacts/vcpkg/installed + vcpkgDirectory: /opt/artifacts/vcpkg + vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }} + + - name: Install vcpkg dependencies + run: | + $VCPKG_ROOT/vcpkg install --x-install-root="$VCPKG_ROOT/installed" + shell: bash - uses: rustdesk-org/run-on-arch-action@amd64-support name: Build rustdesk library for ${{ matrix.job.arch }} @@ -758,11 +848,41 @@ jobs: --volume "/opt/artifacts:/opt/artifacts" shell: /bin/bash install: | - apt update -y + apt-get update -y echo -e "installing deps" - apt-get -qq install -y git curl wget nasm yasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake libclang-dev ninja-build libappindicator3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libvdpau-dev libva-dev libpam0g-dev libclang-dev llvm-dev libclang-10-dev llvm-10-dev pkg-config tree g++ gcc libvpx-dev tree > /dev/null + apt-get install -y \ + clang \ + cmake \ + curl \ + gcc \ + git \ + g++ \ + libappindicator3-dev \ + libasound2-dev \ + libclang-10-dev \ + libclang-dev \ + libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev \ + libgtk-3-dev \ + libpam0g-dev \ + libpulse-dev \ + libva-dev \ + libvdpau-dev \ + libxcb-randr0-dev \ + libxcb-shape0-dev \ + libxcb-xfixes0-dev \ + libxdo-dev \ + libxfixes-dev \ + llvm-10-dev \ + llvm-dev \ + nasm \ + ninja-build \ + pkg-config \ + tree \ + wget \ + yasm # we have libopus compiled by us. - apt remove -y libopus-dev || true + apt-get remove -y libopus-dev || true # output devs ls -l ./ tree -L 3 /opt/artifacts/vcpkg/installed @@ -806,7 +926,7 @@ jobs: build-rustdesk-lib-linux-arm: if: ${{ inputs.upload-artifact }} - needs: [generate-bridge-linux, build-vcpkg-deps-linux] + needs: [generate-bridge-linux] name: build-rust-lib ${{ matrix.job.target }} (${{ matrix.job.os }}) [${{ matrix.job.extra-build-features }}] runs-on: [self-hosted, Linux, ARM64] strategy: @@ -841,13 +961,29 @@ jobs: # - { arch: armv7, target: armv7-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true, extra-build-features: "appimage" } # - { target: arm-unknown-linux-musleabihf, os: ubuntu-20.04, use-cross: true } steps: + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + crossbuild-essential-arm64 \ + nasm \ + pkg-config \ + yasm + #- name: Maximize build space # run: | # sudo rm -rf /opt/ghc # sudo rm -rf /usr/local/lib/android # sudo rm -rf /usr/share/dotnet - # sudo apt update -y - # sudo apt install qemu-user-static -y + # sudo apt-get update -y + # sudo apt-get install qemu-user-static -y - name: Checkout source code uses: actions/checkout@v3 @@ -869,7 +1005,7 @@ jobs: target: ${{ matrix.job.target }} override: true profile: minimal # minimal component installation (ie, no documentation) - + - name: Save Rust toolchain version run: | RUST_TOOLCHAIN_VERSION=$(cargo --version | awk '{print $2}') @@ -886,11 +1022,23 @@ jobs: name: bridge-artifact path: ./ - - name: Restore vcpkg files - uses: actions/download-artifact@master + - name: Setup vcpkg with Github Actions binary cache + uses: lukka/run-vcpkg@v11 with: - name: vcpkg-artifact-${{ matrix.job.arch }} - path: /opt/artifacts/vcpkg/installed + vcpkgDirectory: /opt/artifacts/vcpkg + vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }} + + - name: Install vcpkg dependencies + run: | + case ${{ matrix.job.target }} in + aarch64-unknown-linux-gnu) + $VCPKG_ROOT/vcpkg install --triplet arm64-linux --x-install-root="$VCPKG_ROOT/installed" + ;; + armv7-unknown-linux-gnueabihf) + $VCPKG_ROOT/vcpkg install --triplet arm-linux --x-install-root="$VCPKG_ROOT/installed" + ;; + esac + shell: bash - uses: rustdesk-org/run-on-arch-action@amd64-support name: Build rustdesk library for ${{ matrix.job.arch }} @@ -907,11 +1055,41 @@ jobs: --volume "/opt/artifacts:/opt/artifacts" shell: /bin/bash install: | - apt update -y + apt-get update -y echo -e "installing deps" - apt-get -qq install -y git curl wget nasm yasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake libclang-dev ninja-build libappindicator3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libvdpau-dev libva-dev libpam0g-dev libclang-dev llvm-dev libclang-10-dev llvm-10-dev pkg-config tree g++ gcc libvpx-dev tree > /dev/null + apt-get install -y \ + clang \ + cmake \ + curl \ + gcc \ + git \ + g++ \ + libappindicator3-dev \ + libasound2-dev \ + libclang-10-dev \ + libclang-dev \ + libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev \ + libgtk-3-dev \ + libpam0g-dev \ + libpulse-dev \ + libva-dev \ + libvdpau-dev \ + libxcb-randr0-dev \ + libxcb-shape0-dev \ + libxcb-xfixes0-dev \ + libxdo-dev \ + libxfixes-dev \ + llvm-10-dev \ + llvm-dev \ + nasm \ + ninja-build \ + pkg-config \ + tree \ + wget \ + yasm # we have libopus compiled by us. - apt remove -y libopus-dev || true + apt-get remove -y libopus-dev || true # output devs ls -l ./ tree -L 3 /opt/artifacts/vcpkg/installed @@ -950,7 +1128,6 @@ jobs: build-rustdesk-sciter-arm: if: ${{ inputs.upload-artifact }} - needs: [build-vcpkg-deps-linux] name: build-rustdesk(sciter) ${{ matrix.job.target }} (${{ matrix.job.os }}) [${{ matrix.job.extra-build-features }}] runs-on: [self-hosted, Linux, ARM64] strategy: @@ -970,14 +1147,29 @@ jobs: # - { arch: armv7, target: armv7-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true, extra-build-features: "appimage" } # - { target: arm-unknown-linux-musleabihf, os: ubuntu-20.04, use-cross: true } steps: + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + crossbuild-essential-armhf \ + nasm \ + pkg-config \ + yasm #- name: Maximize build space # run: | # sudo rm -rf /opt/ghc # sudo rm -rf /usr/local/lib/android # sudo rm -rf /usr/share/dotnet - # sudo apt update -y - # sudo apt install qemu-user-static -y + # sudo apt-get update -y + # sudo apt-get install qemu-user-static -y - name: Checkout source code uses: actions/checkout@v3 @@ -999,17 +1191,22 @@ jobs: target: ${{ matrix.job.target }} override: true profile: minimal # minimal component installation (ie, no documentation) - + - name: Save Rust toolchain version run: | RUST_TOOLCHAIN_VERSION=$(cargo --version | awk '{print $2}') echo "RUST_TOOLCHAIN_VERSION=$RUST_TOOLCHAIN_VERSION" >> $GITHUB_ENV - - name: Restore vcpkg files - uses: actions/download-artifact@master + - name: Setup vcpkg with Github Actions binary cache + uses: lukka/run-vcpkg@v11 with: - name: vcpkg-artifact-${{ matrix.job.arch }} - path: /opt/artifacts/vcpkg/installed + vcpkgDirectory: /opt/artifacts/vcpkg + vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }} + + - name: Install vcpkg dependencies + run: | + $VCPKG_ROOT/vcpkg install --triplet arm-linux --x-install-root="$VCPKG_ROOT/installed" + shell: bash - uses: rustdesk-org/run-on-arch-action@amd64-support name: Build rustdesk sciter binary for ${{ matrix.job.arch }} @@ -1025,10 +1222,42 @@ jobs: --volume "/opt/artifacts:/opt/artifacts" shell: /bin/bash install: | - apt update -y - apt-get -qq install -y git cmake g++ gcc build-essential nasm yasm curl unzip xz-utils python3 wget pkg-config ninja-build pkg-config libgtk-3-dev liblzma-dev clang libappindicator3-dev rpm libclang-dev - apt-get -qq install -y libdbus-1-dev pkg-config nasm yasm libglib2.0-dev libxcb-randr0-dev libxdo-dev libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev - apt-get -qq install -y libpulse-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libvpx-dev libvdpau-dev libva-dev libpam0g-dev + apt-get update -y + apt-get install -y \ + build-essential \ + clang \ + cmake \ + curl \ + gcc \ + git \ + g++ \ + libappindicator3-dev \ + libasound2-dev \ + libclang-dev \ + libdbus-1-dev \ + libglib2.0-dev \ + libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev \ + libgtk-3-dev \ + liblzma-dev \ + libpam0g-dev \ + libpulse-dev \ + libva-dev \ + libvdpau-dev \ + libxcb-randr0-dev \ + libxcb-shape0-dev \ + libxcb-xfixes0-dev \ + libxdo-dev \ + libxfixes-dev \ + nasm \ + ninja-build \ + pkg-config \ + python3 \ + rpm \ + unzip \ + wget \ + xz-utils \ + yasm run: | # disable git safe.directory git config --global --add safe.directory "*" @@ -1046,7 +1275,7 @@ jobs: registry = 'https://github.com/rust-lang/crates.io-index' """ > ~/.cargo/config cat ~/.cargo/config - + # build pushd /workspace python3 ./res/inline-sciter.py @@ -1133,8 +1362,15 @@ jobs: - name: Prepare env run: | - sudo apt update -y - sudo apt-get -qq install -y git curl wget nasm yasm libgtk-3-dev libarchive-tools + sudo apt-get update -y + sudo apt-get install -y \ + curl \ + git \ + libarchive-tools \ + libgtk-3-dev \ + nasm \ + wget \ + yasm mkdir -p ./target/release/ - name: Restore the rustdesk lib file @@ -1143,19 +1379,6 @@ jobs: name: librustdesk-${{ matrix.job.arch }}-${{ matrix.job.extra-build-features }}.so path: ./target/release/ - - name: Download Flutter - shell: bash - run: | - # disable git safe.directory - git config --global --add safe.directory "*" - pushd /opt - # clone repo and reset to flutter ${{ env.FLUTTER_VERSION }} - git clone https://github.com/sony/flutter-elinux.git || true - pushd flutter-elinux - git fetch - git reset --hard ${{ env.FLUTTER_ELINUX_COMMIT_ID }} - popd - - uses: rustdesk-org/run-on-arch-action@amd64-support name: Build rustdesk binary for ${{ matrix.job.arch }} id: vcpkg @@ -1168,26 +1391,40 @@ jobs: dockerRunArgs: | --volume "${PWD}:/workspace" --volume "/opt/artifacts:/opt/artifacts" - --volume "/opt/flutter-elinux:/opt/flutter-elinux" shell: /bin/bash install: | - apt update -y - apt-get -qq install -y git cmake g++ gcc build-essential nasm yasm curl unzip xz-utils python3 wget pkg-config ninja-build pkg-config libgtk-3-dev liblzma-dev clang libappindicator3-dev rpm + apt-get update -y + apt-get install -y \ + build-essential \ + clang \ + cmake \ + curl \ + gcc \ + git \ + g++ \ + libappindicator3-dev \ + libgtk-3-dev \ + liblzma-dev \ + nasm \ + ninja-build \ + pkg-config \ + python3 \ + rpm \ + unzip \ + wget \ + xz-utils \ + yasm run: | # disable git safe.directory git config --global --add safe.directory "*" - pushd /workspace - # we use flutter-elinux to build our rustdesk - export PATH=/opt/flutter-elinux/bin:$PATH - sed -i "s/flutter build linux --release/flutter-elinux build linux/g" ./build.py - # Setup flutter-elinux. Run doctor to check if issues here. - flutter-elinux doctor -v - # Patch arm64 engine for flutter 3.6.0+ - flutter-elinux precache --linux - pushd /tmp - curl -O https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${{ env.FLUTTER_ELINUX_VERSION }}-stable.tar.xz - tar -xvf flutter_linux_${{ env.FLUTTER_ELINUX_VERSION }}-stable.tar.xz flutter/bin/cache/artifacts/engine/linux-x64/shader_lib - cp -R flutter/bin/cache/artifacts/engine/linux-x64/shader_lib /opt/flutter-elinux/flutter/bin/cache/artifacts/engine/linux-arm64 + # Setup Flutter + pushd /opt + wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${{ env.FLUTTER_VERSION }}-stable.tar.xz + tar xf flutter_linux_${{ env.FLUTTER_VERSION }}-stable.tar.xz + ls -l . + export PATH=/opt/flutter/bin:$PATH + flutter doctor -v + flutter precache --linux popd # edit to corresponding arch case ${{ matrix.job.arch }} in @@ -1218,7 +1455,7 @@ jobs: pushd ~/rpmbuild/RPMS/${{ matrix.job.arch }} mkdir -p /opt/artifacts/rpm for name in rustdesk*??.rpm; do - mv "$name" "/opt/artifacts/rpm/${name%%.rpm}.rpm" + mv "$name" "/opt/artifacts/rpm/${name%%.rpm}.rpm" done # rpm suse package echo -e "start packaging suse package" @@ -1236,7 +1473,7 @@ jobs: pushd ~/rpmbuild/RPMS/${{ matrix.job.arch }} mkdir -p /opt/artifacts/rpm for name in rustdesk*??.rpm; do - mv "$name" "/opt/artifacts/rpm/${name%%.rpm}-suse.rpm" + mv "$name" "/opt/artifacts/rpm/${name%%.rpm}-suse.rpm" done - name: Rename rustdesk @@ -1254,7 +1491,7 @@ jobs: tag_name: ${{ env.TAG_NAME }} files: | rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.deb - + - name: Build appimage package if: ${{ matrix.job.extra-build-features == 'appimage' }} shell: bash @@ -1365,7 +1602,7 @@ jobs: - { arch: x86_64, target: x86_64-unknown-linux-gnu, - os: ubuntu-18.04, + os: ubuntu-18.04, extra-build-features: "", } - { @@ -1393,8 +1630,15 @@ jobs: - name: Prepare env run: | - sudo apt update -y - sudo apt-get -qq install -y git curl wget nasm yasm libgtk-3-dev libarchive-tools + sudo apt-get update -y + sudo apt-get install -y \ + curl \ + git \ + libarchive-tools \ + libgtk-3-dev \ + nasm \ + wget \ + yasm mkdir -p ./target/release/ - name: Restore the rustdesk lib file @@ -1417,8 +1661,27 @@ jobs: --volume "/opt/artifacts:/opt/artifacts" shell: /bin/bash install: | - apt update -y - apt-get -qq install -y git cmake g++ gcc build-essential nasm yasm curl unzip xz-utils python3 wget pkg-config ninja-build pkg-config libgtk-3-dev liblzma-dev clang libappindicator3-dev rpm + apt-get update -y + apt-get install -y \ + build-essential \ + clang \ + cmake \ + curl \ + gcc \ + git \ + g++ \ + libappindicator3-dev \ + libgtk-3-dev \ + liblzma-dev \ + nasm \ + ninja-build \ + pkg-config \ + python3 \ + rpm \ + unzip \ + wget \ + xz-utils \ + yasm run: | # disable git safe.directory git config --global --add safe.directory "*" @@ -1442,7 +1705,7 @@ jobs: pushd ~/rpmbuild/RPMS/${{ matrix.job.arch }} mkdir -p /opt/artifacts/rpm for name in rustdesk*??.rpm; do - mv "$name" "/opt/artifacts/rpm/${name%%.rpm}.rpm" + mv "$name" "/opt/artifacts/rpm/${name%%.rpm}.rpm" done # rpm suse package pushd /workspace @@ -1455,7 +1718,7 @@ jobs: pushd ~/rpmbuild/RPMS/${{ matrix.job.arch }} mkdir -p /opt/artifacts/rpm for name in rustdesk*??.rpm; do - mv "$name" "/opt/artifacts/rpm/${name%%.rpm}-suse.rpm" + mv "$name" "/opt/artifacts/rpm/${name%%.rpm}-suse.rpm" done - name: Rename rustdesk @@ -1605,13 +1868,24 @@ jobs: # --volume "${PWD}:/workspace" # shell: /bin/bash # install: | - # apt update -y - # apt install -y rpm + # apt-get update -y + # apt-get install -y rpm # run: | # pushd /workspace # # install - # apt update -y - # apt install -y flatpak flatpak-builder cmake g++ gcc git curl wget nasm yasm libgtk-3-dev git + # apt-get update -y + # apt-get install -y \ + # cmake \ + # curl \ + # flatpak \ + # flatpak-builder \ + # gcc \ + # git \ + # g++ \ + # libgtk-3-dev \ + # nasm \ + # wget \ + # yasm # # flatpak deps # flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo # flatpak --user install -y flathub org.freedesktop.Platform/${{ matrix.job.arch }}/23.08 @@ -1666,15 +1940,30 @@ jobs: --volume "${PWD}:/workspace" shell: /bin/bash install: | - apt update -y - apt install -y rpm git wget curl + apt-get update -y + apt-get install -y \ + curl \ + git \ + rpm \ + wget run: | # disable git safe.directory git config --global --add safe.directory "*" pushd /workspace # install - apt update -y - apt install -y flatpak flatpak-builder cmake g++ gcc git curl wget nasm yasm libgtk-3-dev git + apt-get update -y + apt-get install -y \ + cmake \ + curl \ + flatpak \ + flatpak-builder \ + gcc \ + git \ + g++ \ + libgtk-3-dev \ + nasm \ + wget \ + yasm # flatpak deps flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo flatpak --user install -y flathub org.freedesktop.Platform/${{ matrix.job.arch }}/23.08 diff --git a/.github/workflows/flutter-ci.yml b/.github/workflows/flutter-ci.yml index 6dab5f7d4b2a..5a1608c6987a 100644 --- a/.github/workflows/flutter-ci.yml +++ b/.github/workflows/flutter-ci.yml @@ -19,4 +19,3 @@ jobs: uses: ./.github/workflows/flutter-build.yml with: upload-artifact: false - diff --git a/.github/workflows/flutter-nightly.yml b/.github/workflows/flutter-nightly.yml index 67dc14ae95db..b16db4c4a6a1 100644 --- a/.github/workflows/flutter-nightly.yml +++ b/.github/workflows/flutter-nightly.yml @@ -12,4 +12,4 @@ jobs: secrets: inherit with: upload-artifact: true - upload-tag: "nightly" + upload-tag: "nightly" diff --git a/.github/workflows/flutter-tag.yml b/.github/workflows/flutter-tag.yml index 20083a3f9d11..df1b524955db 100644 --- a/.github/workflows/flutter-tag.yml +++ b/.github/workflows/flutter-tag.yml @@ -15,4 +15,4 @@ jobs: secrets: inherit with: upload-artifact: true - upload-tag: "1.2.4" + upload-tag: "1.2.4" diff --git a/.github/workflows/history.yml b/.github/workflows/history.yml index c40641fcd383..d1991977d881 100644 --- a/.github/workflows/history.yml +++ b/.github/workflows/history.yml @@ -7,9 +7,7 @@ env: FLUTTER_VERSION: "3.13.9" TAG_NAME: "tmp" FLUTTER_RUST_BRIDGE_VERSION: "1.80.1" - # vcpkg version: 2022.05.10 - # for multiarch gcc compatibility - VCPKG_COMMIT_ID: "501db0f17ef6df184fcdbfbe0f87cde2313b6ab1" + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" VERSION: "1.2.4" jobs: @@ -54,14 +52,18 @@ jobs: Push-Location flutter ; flutter pub get ; Pop-Location ~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart + - name: Setup vcpkg with Github Actions binary cache + uses: lukka/run-vcpkg@v11 + with: + vcpkgDirectory: C:\vcpkg + vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }} + - name: Install vcpkg dependencies run: | - cd C:\ - git clone https://github.com/Kingtous/rustdesk_thirdpary_lib --depth=1 - + $VCPKG_ROOT/vcpkg install --x-install-root="$VCPKG_ROOT/installed" + shell: bash + - name: Build rustdesk - env: - VCPKG_ROOT: C:\rustdesk_thirdpary_lib\vcpkg run: python3 .\build.py --portable --hwcodec --flutter --feature IddDriver - name: Build self-extracted executable @@ -72,7 +74,7 @@ jobs: popd mkdir -p ./SignOutput mv ./target/release/rustdesk-portable-packer.exe ./SignOutput/rustdesk-${{ matrix.job.date }}-${{ matrix.job.target }}.exe - + - name: Publish Release uses: softprops/action-gh-release@v1 with: diff --git a/.github/workflows/vcpkg-deps-linux.yml b/.github/workflows/vcpkg-deps-linux.yml deleted file mode 100644 index 9801764e403b..000000000000 --- a/.github/workflows/vcpkg-deps-linux.yml +++ /dev/null @@ -1,92 +0,0 @@ -name: Build vcpkg dependencies for linux clients - -on: - workflow_call: - -jobs: - build-vcpkg-deps-linux: - runs-on: ${{ matrix.job.os }} - strategy: - fail-fast: true - matrix: - job: - - { arch: armv7, os: ubuntu-20.04 } - - { arch: x86_64, os: ubuntu-20.04 } - - { arch: aarch64, os: ubuntu-20.04 } - steps: - - name: Create vcpkg artifacts folder - run: mkdir -p /opt/artifacts - - - name: Cache Vcpkg - id: cache-vcpkg - uses: actions/cache@v3 - with: - path: /opt/artifacts - key: vcpkg-${{ matrix.job.arch }} - - - uses: rustdesk-org/run-on-arch-action@amd64-support - name: Run vcpkg install on ${{ matrix.job.arch }} - id: vcpkg - with: - arch: ${{ matrix.job.arch }} - distro: ubuntu18.04 - githubToken: ${{ github.token }} - setup: | - ls -l "/opt/artifacts" - dockerRunArgs: | - --volume "/opt/artifacts:/artifacts" - shell: /bin/bash - install: | - apt update -y - case "${{ matrix.job.arch }}" in - x86_64) - apt update -y - apt install -y curl zip unzip tar git g++ gcc build-essential pkg-config wget nasm yasm ninja-build libjpeg8-dev libssl-dev - wget https://github.com/Kitware/CMake/releases/download/v3.27.5/cmake-3.27.5.tar.gz - apt remove -y --purge cmake - tar -zxvf cmake-3.27.5.tar.gz - cd cmake-3.27.5 - ./bootstrap - make - make install - cd - - cmake --version - gcc -v - ;; - aarch64|armv7) - apt install -y curl zip unzip git - esac - run: | - # disable git safe.directory - git config --global --add safe.directory "*" - case "${{ matrix.job.arch }}" in - x86_64) - export VCPKG_FORCE_SYSTEM_BINARIES=1 - pushd /artifacts - git clone https://github.com/microsoft/vcpkg.git || true - pushd vcpkg - git reset --hard ${{ env.VCPKG_COMMIT_ID }} - ./bootstrap-vcpkg.sh - ./vcpkg install libvpx libyuv opus aom - ;; - aarch64) - pushd /artifacts - rm -rf rustdesk_thirdparty_lib - git clone https://github.com/Kingtous/rustdesk_thirdparty_lib.git --depth=1 - mkdir -p /artifacts/vcpkg/installed - mv ./rustdesk_thirdparty_lib/vcpkg/installed/arm64-linux /artifacts/vcpkg/installed/arm64-linux - ;; - armv7) - pushd /artifacts - rm -rf rustdesk_thirdparty_lib - git clone https://github.com/Kingtous/rustdesk_thirdparty_lib.git --depth=1 - mkdir -p /artifacts/vcpkg/installed - mv ./rustdesk_thirdparty_lib/vcpkg/installed/arm-linux /artifacts/vcpkg/installed/arm-linux - ;; - esac - - name: Upload artifacts - uses: actions/upload-artifact@master - with: - name: vcpkg-artifact-${{ matrix.job.arch }} - path: | - /opt/artifacts/vcpkg/installed diff --git a/build.py b/build.py index 8cff351e2d79..786ef199b412 100755 --- a/build.py +++ b/build.py @@ -180,8 +180,8 @@ def generate_build_script_for_docker(): export VCPKG_ROOT=`pwd`/vcpkg git clone https://github.com/microsoft/vcpkg vcpkg/bootstrap-vcpkg.sh - vcpkg/vcpkg install libvpx libyuv opus popd + $VCPKG_ROOT/vcpkg install --x-install-root="$VCPKG_ROOT/installed" # build rustdesk ./build.py --flutter --hwcodec ''') diff --git a/build.rs b/build.rs index ad745667de0a..bb115e66dc7e 100644 --- a/build.rs +++ b/build.rs @@ -41,7 +41,7 @@ fn build_manifest() { } } -fn install_oboe() { +fn install_android_deps() { let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); if target_os != "android" { return; @@ -49,6 +49,8 @@ fn install_oboe() { let mut target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap(); if target_arch == "x86_64" { target_arch = "x64".to_owned(); + } else if target_arch == "x86" { + target_arch = "x86".to_owned(); } else if target_arch == "aarch64" { target_arch = "arm64".to_owned(); } else { @@ -66,22 +68,15 @@ fn install_oboe() { path.join("lib").to_str().unwrap() ) ); + println!("cargo:rustc-link-lib=ndk_compat"); println!("cargo:rustc-link-lib=oboe"); println!("cargo:rustc-link-lib=c++"); println!("cargo:rustc-link-lib=OpenSLES"); - // I always got some strange link error with oboe, so as workaround, put oboe.cc into oboe src: src/common/AudioStreamBuilder.cpp - // also to avoid libc++_shared not found issue, cp ndk's libc++_shared.so to jniLibs, e.g. - // ./flutter_hbb/android/app/src/main/jniLibs/arm64-v8a/libc++_shared.so - // let include = path.join("include"); - //cc::Build::new().file("oboe.cc").include(include).compile("oboe_wrapper"); } fn main() { hbb_common::gen_version(); - install_oboe(); - // there is problem with cfg(target_os) in build.rs, so use our workaround - // let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); - // if target_os == "android" || target_os == "ios" { + install_android_deps(); #[cfg(all(windows, feature = "inline"))] build_manifest(); #[cfg(windows)] diff --git a/flutter/build_android_deps.sh b/flutter/build_android_deps.sh index 2f876ca6eefe..64d92f194a39 100755 --- a/flutter/build_android_deps.sh +++ b/flutter/build_android_deps.sh @@ -1,13 +1,15 @@ #!/bin/bash -# Build libyuv / opus / libvpx / oboe for Android +ANDROID_ABI=$1 + +# Build RustDesk dependencies for Android using vcpkg.json # Required: # 1. set VCPKG_ROOT / ANDROID_NDK path environment variables # 2. vcpkg initialized -# 3. ndk, version: 22 (if ndk < 22 you need to change LD as `export LD=$TOOLCHAIN/bin/$NDK_LLVM_TARGET-ld`) +# 3. ndk, version: r25c or newer -if [ -z "$ANDROID_NDK" ]; then - echo "Failed! Please set ANDROID_NDK" +if [ -z "$ANDROID_NDK_HOME" ]; then + echo "Failed! Please set ANDROID_NDK_HOME" exit 1 fi @@ -18,107 +20,66 @@ fi API_LEVEL="21" +# Get directory of this script + +SCRIPTDIR="$(readlink -f "$0")" +SCRIPTDIR="$(dirname "$SCRIPTDIR")" + +# Check if vcpkg.json is one level up - in root directory of RD + +if [ ! -f "$SCRIPTDIR/../vcpkg.json" ]; then + echo "Failed! Please check where vcpkg.json is!" + exit 1 +fi + # NDK llvm toolchain + HOST_TAG="linux-x86_64" # current platform, set as `ls $ANDROID_NDK/toolchains/llvm/prebuilt/` TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/$HOST_TAG function build { ANDROID_ABI=$1 - VCPKG_TARGET=$2 - NDK_LLVM_TARGET=$3 - LIBVPX_TARGET=$4 - - PREFIX=$VCPKG_ROOT/installed/$VCPKG_TARGET/ - - # 1 - echo "*** [$ANDROID_ABI][Start] Build opus / libyuv from vcpkg" - export ANDROID_NDK_HOME=$ANDROID_NDK - pushd $VCPKG_ROOT - $VCPKG_ROOT/vcpkg install opus --triplet $VCPKG_TARGET - $VCPKG_ROOT/vcpkg install libyuv --triplet $VCPKG_TARGET - popd - echo "*** [$ANDROID_ABI][Finished] Build opus / libyuv from vcpkg" - - # 2 - echo "*** [$ANDROID_ABI][Start] Build libvpx" - pushd build/libvpx - export AR=$TOOLCHAIN/bin/${NDK_LLVM_TARGET}-ar - export AS=$TOOLCHAIN/bin/${NDK_LLVM_TARGET}-as - export LD=$TOOLCHAIN/bin/${NDK_LLVM_TARGET}-ld.gold # if ndk < 22, use aarch64-linux-android-ld - export RANLIB=$TOOLCHAIN/bin/${NDK_LLVM_TARGET}-ranlib - export STRIP=$TOOLCHAIN/bin/${NDK_LLVM_TARGET}-strip - - if [ $NDK_LLVM_TARGET == "arm-linux-androideabi" ] - then - export CC=$TOOLCHAIN/bin/armv7a-linux-androideabi${API_LEVEL}-clang - export CXX=$TOOLCHAIN/bin/armv7a-linux-androideabi${API_LEVEL}-clang++ - else - export CC=$TOOLCHAIN/bin/${NDK_LLVM_TARGET}${API_LEVEL}-clang - export CXX=$TOOLCHAIN/bin/${NDK_LLVM_TARGET}${API_LEVEL}-clang++ - fi - make clean - ./configure --target=$LIBVPX_TARGET \ - --enable-pic - --disable-webm-io \ - --disable-unit-tests \ - --disable-examples \ - --disable-libyuv \ - --disable-postproc \ - --disable-tools \ - --disable-docs \ - --prefix=$PREFIX - make -j5 - make install + case "$ANDROID_ABI" in + arm64-v8a) + ABI=aarch64-linux-android$API_LEVEL + VCPKG_TARGET=arm64-android + ;; + armeabi-v7a) + ABI=armv7a-linux-androideabi$API_LEVEL + VCPKG_TARGET=arm-neon-android + ;; + x86_64) + ABI=x86_64-linux-android$API_LEVEL + VCPKG_TARGET=x64-android + ;; + x86) + ABI=i686-linux-android$API_LEVEL + VCPKG_TARGET=x86-android + ;; + *) + echo "ERROR: ANDROID_ABI must be one of: arm64-v8a, armeabi-v7a, x86_64, x86" >&2 + return 1 + esac + + echo "*** [$ANDROID_ABI][Start] Build and install vcpkg dependencies" + pushd "$SCRIPTDIR/.." + $VCPKG_ROOT/vcpkg install --triplet $VCPKG_TARGET --x-install-root="$VCPKG_ROOT/installed" popd - echo "*** [$ANDROID_ABI][Finished] Build libvpx" - - # 3 - echo "*** [$ANDROID_ABI][Start] Build oboe" - pushd build/oboe - make clean - cmake -DBUILD_SHARED_LIBS=true \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DANDROID_TOOLCHAIN=clang \ - -DANDROID_STL=c++_shared \ - -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \ - -DCMAKE_INSTALL_PREFIX=$PREFIX \ - -DANDROID_ABI=$ANDROID_ABI \ - -DANDROID_PLATFORM=android-$API_LEVEL - make -j5 - make install - mv $PREFIX/lib/$ANDROID_ABI/liboboe.a $PREFIX/lib/ - popd - echo "*** [$ANDROID_ABI][Finished] Build oboe" + echo "*** [$ANDROID_ABI][Finished] Build and install vcpkg dependencies" + +if [ -d "$VCPKG_ROOT/installed/arm-neon-android" ]; then + echo "*** [Start] Move arm-neon-android to arm-android" + + mv "$VCPKG_ROOT/installed/arm-neon-android" "$VCPKG_ROOT/installed/arm-android" - echo "*** [$ANDROID_ABI][All Finished]" + echo "*** [Finished] Move arm-neon-android to arm-android" +fi } -git clone -b v1.11.0 --depth=1 https://github.com/webmproject/libvpx.git build/libvpx -git clone -b 1.6.1 --depth=1 https://github.com/google/oboe build/oboe -patch -N -d build/oboe -p1 < ../src/oboe.patch - -# VCPKG_TARGET ANDROID_ABI -# arm64-android arm64-v8a -# arm-android armeabi-v7a -# x64-android x86_64 -# x86-android x86 - -# NDK_LLVM_TARGET -# aarch64-linux-android -# arm-linux-androideabi -# x86_64-linux-android -# i686-linux-android - -# LIBVPX_TARGET : -# arm64-android-gcc -# armv7-android-gcc -# x86_64-android-gcc -# x86-android-gcc - -# args: ANDROID_ABI VCPKG_TARGET NDK_LLVM_TARGET LIBVPX_TARGET -build arm64-v8a arm64-android aarch64-linux-android arm64-android-gcc -build armeabi-v7a arm-android arm-linux-androideabi armv7-android-gcc - -# rm -rf build/libvpx -# rm -rf build/oboe +if [ ! -z "$ANDROID_ABI" ]; then + build "$ANDROID_ABI" +else + echo "Usage: build-android-deps.sh " >&2 + exit 1 +fi diff --git a/libs/scrap/build.rs b/libs/scrap/build.rs index 7d162adfab20..90518eb9bd18 100644 --- a/libs/scrap/build.rs +++ b/libs/scrap/build.rs @@ -23,14 +23,18 @@ fn link_pkg_config(_name: &str) -> Vec { unimplemented!() } -/// Link vcppkg package. +/// Link vcpkg package. fn link_vcpkg(mut path: PathBuf, name: &str) -> PathBuf { let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); let mut target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap(); if target_arch == "x86_64" { target_arch = "x64".to_owned(); + } else if target_arch == "x86" { + target_arch = "x86".to_owned(); } else if target_arch == "aarch64" { target_arch = "arm64".to_owned(); + } else { + target_arch = "arm".to_owned(); } let mut target = if target_os == "macos" { if target_arch == "x64" { diff --git a/res/vcpkg/aom/aom-install.diff b/res/vcpkg/aom/aom-install.diff new file mode 100644 index 000000000000..e24b8c536ee6 --- /dev/null +++ b/res/vcpkg/aom/aom-install.diff @@ -0,0 +1,75 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 18190f647..f4b1b359d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -23,6 +23,9 @@ endif() + + project(AOM C CXX) + ++include(GNUInstallDirs) ++include(CMakePackageConfigHelpers) ++ + # GENERATED source property global visibility. + if(POLICY CMP0118) + cmake_policy(SET CMP0118 NEW) +@@ -302,6 +305,52 @@ if(BUILD_SHARED_LIBS) + set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_static) + endif() + ++set(PUBLIC_HEADERS ++ aom/aom.h ++ aom/aom_codec.h ++ aom/aom_decoder.h ++ aom/aom_encoder.h ++ aom/aom_frame_buffer.h ++ aom/aom_image.h ++ aom/aom_integer.h ++ aom/aomcx.h ++ aom/aomdx.h ++) ++ ++set_target_properties(aom PROPERTIES ++ PUBLIC_HEADER "${PUBLIC_HEADERS}") ++ ++ ++target_include_directories(aom ++ PUBLIC $ ++ $) ++ ++install(TARGETS aom ++ EXPORT unofficial-aom-targets ++ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" ++ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ++ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aom") ++ ++install(EXPORT unofficial-aom-targets ++ FILE unofficial-aom-targets.cmake ++ NAMESPACE unofficial:: ++ DESTINATION lib/cmake/aom) ++ ++configure_package_config_file(cmake/aom-config.cmake.in ++ ${CMAKE_CURRENT_BINARY_DIR}/aom-config.cmake ++ INSTALL_DESTINATION lib/cmake/aom ++ NO_SET_AND_CHECK_MACRO ++ NO_CHECK_REQUIRED_COMPONENTS_MACRO) ++ ++write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/aom-config-version.cmake ++ VERSION ${SO_FILE_VERSION} ++ COMPATIBILITY SameMajorVersion) ++ ++install(FILES ${CMAKE_CURRENT_BINARY_DIR}/aom-config.cmake ++ ${CMAKE_CURRENT_BINARY_DIR}/aom-config-version.cmake ++ DESTINATION lib/cmake/aom) ++ + # Setup dependencies. + if(CONFIG_THREE_PASS) + setup_ivf_dec_targets() +diff --git a/cmake/aom-config.cmake.in b/cmake/aom-config.cmake.in +new file mode 100644 +index 000000000..91cac3b5b +--- /dev/null ++++ b/cmake/aom-config.cmake.in +@@ -0,0 +1,2 @@ ++@PACKAGE_INIT@ ++include(${CMAKE_CURRENT_LIST_DIR}/unofficial-aom-targets.cmake) diff --git a/res/vcpkg/aom/aom-rename-static.diff b/res/vcpkg/aom/aom-rename-static.diff new file mode 100644 index 000000000000..dfb911f21c05 --- /dev/null +++ b/res/vcpkg/aom/aom-rename-static.diff @@ -0,0 +1,19 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8f459f39c4..d8c1bb2b02 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -286,12 +286,12 @@ add_library(aom ${target_objs_aom} $) + + if(BUILD_SHARED_LIBS) + add_library(aom_static STATIC ${target_objs_aom} $) +- set_target_properties(aom_static PROPERTIES OUTPUT_NAME aom) ++ set_target_properties(aom_static PROPERTIES OUTPUT_NAME aom_static) + if(MSVC OR (WIN32 AND NOT MINGW)) + # Fix race condition on the export library file between the two versions. + # Affects MSVC in all three flavors (stock, Clang/CL, LLVM-- the latter sets + # MSVC and MINGW both to FALSE). +- set_target_properties(aom PROPERTIES ARCHIVE_OUTPUT_NAME "aom_dll") ++ set_target_properties(aom PROPERTIES ARCHIVE_OUTPUT_NAME "aom") + endif() + + if(NOT MSVC) diff --git a/res/vcpkg/aom/aom-uninitialized-pointer.diff b/res/vcpkg/aom/aom-uninitialized-pointer.diff new file mode 100644 index 000000000000..37a7166cc046 --- /dev/null +++ b/res/vcpkg/aom/aom-uninitialized-pointer.diff @@ -0,0 +1,13 @@ +diff --git a/build/cmake/aom_configure.cmake b/build/cmake/aom_configure.cmake +index aaef2c310..5500ad4a3 100644 +--- a/build/cmake/aom_configure.cmake ++++ b/build/cmake/aom_configure.cmake +@@ -309,6 +309,8 @@ if(MSVC) + + # Disable MSVC warnings that suggest making code non-portable. + add_compiler_flag_if_supported("/wd4996") ++ # Disable MSVC warnings for potentially uninitialized local pointer variable. ++ add_compiler_flag_if_supported("/wd4703") + if(ENABLE_WERROR) + add_compiler_flag_if_supported("/WX") + endif() diff --git a/res/vcpkg/aom/portfile.cmake b/res/vcpkg/aom/portfile.cmake new file mode 100644 index 000000000000..2d05ffac8a4a --- /dev/null +++ b/res/vcpkg/aom/portfile.cmake @@ -0,0 +1,60 @@ +# NASM is required to build AOM +vcpkg_find_acquire_program(NASM) +get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY) +vcpkg_add_to_path(${NASM_EXE_PATH}) + +# Perl is required to build AOM +vcpkg_find_acquire_program(PERL) +get_filename_component(PERL_PATH ${PERL} DIRECTORY) +vcpkg_add_to_path(${PERL_PATH}) + +vcpkg_from_git( + OUT_SOURCE_PATH SOURCE_PATH + URL "https://aomedia.googlesource.com/aom" + REF 6054fae218eda6e53e1e3b4f7ef0fff4877c7bf1 # v3.7.0 + PATCHES + aom-rename-static.diff + aom-uninitialized-pointer.diff + # Can be dropped when https://bugs.chromium.org/p/aomedia/issues/detail?id=3029 is merged into the upstream + aom-install.diff +) + +set(aom_target_cpu "") +if(VCPKG_TARGET_IS_UWP OR (VCPKG_TARGET_IS_WINDOWS AND VCPKG_TARGET_ARCHITECTURE MATCHES "^arm")) + # UWP + aom's assembler files result in weirdness and build failures + # Also, disable assembly on ARM and ARM64 Windows to fix compilation issues. + set(aom_target_cpu "-DAOM_TARGET_CPU=generic") +endif() + +if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" AND VCPKG_TARGET_IS_LINUX) + set(aom_target_cpu "-DENABLE_NEON=OFF") +endif() + +vcpkg_cmake_configure( + SOURCE_PATH ${SOURCE_PATH} + OPTIONS + ${aom_target_cpu} + -DENABLE_DOCS=OFF + -DENABLE_EXAMPLES=OFF + -DENABLE_TESTDATA=OFF + -DENABLE_TESTS=OFF + -DENABLE_TOOLS=OFF +) + +vcpkg_cmake_install() + +vcpkg_copy_pdbs() + +vcpkg_fixup_pkgconfig() + +# Move cmake configs +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/${PORT}) + +# Remove duplicate files +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include + ${CURRENT_PACKAGES_DIR}/debug/share) + +# Handle copyright +file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) + +vcpkg_fixup_pkgconfig() diff --git a/res/vcpkg/aom/vcpkg.json b/res/vcpkg/aom/vcpkg.json new file mode 100644 index 000000000000..7fc53a398f6c --- /dev/null +++ b/res/vcpkg/aom/vcpkg.json @@ -0,0 +1,17 @@ +{ + "name": "aom", + "version-semver": "3.7.0", + "description": "AV1 codec library", + "homepage": "https://aomedia.googlesource.com/aom", + "license": "BSD-2-Clause", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/res/vcpkg/libvpx/0002-Fix-nasm-debug-format-flag.patch b/res/vcpkg/libvpx/0002-Fix-nasm-debug-format-flag.patch new file mode 100644 index 000000000000..5f4749ae0056 --- /dev/null +++ b/res/vcpkg/libvpx/0002-Fix-nasm-debug-format-flag.patch @@ -0,0 +1,21 @@ +diff --git a/build/make/configure.sh b/build/make/configure.sh +index 81d30a1..325017e 100644 +--- a/build/make/configure.sh ++++ b/build/make/configure.sh +@@ -1370,12 +1370,14 @@ EOF + case ${tgt_os} in + win32) + add_asflags -f win32 +- enabled debug && add_asflags -g cv8 ++ enabled debug && [ "${AS}" = yasm ] && add_asflags -g cv8 ++ enabled debug && [ "${AS}" = nasm ] && add_asflags -gcv8 + EXE_SFX=.exe + ;; + win64) + add_asflags -f win64 +- enabled debug && add_asflags -g cv8 ++ enabled debug && [ "${AS}" = yasm ] && add_asflags -g cv8 ++ enabled debug && [ "${AS}" = nasm ] && add_asflags -gcv8 + EXE_SFX=.exe + ;; + linux*|solaris*|android*) diff --git a/res/vcpkg/libvpx/0003-add-uwp-v142-and-v143-support.patch b/res/vcpkg/libvpx/0003-add-uwp-v142-and-v143-support.patch new file mode 100644 index 000000000000..43cebde3116b --- /dev/null +++ b/res/vcpkg/libvpx/0003-add-uwp-v142-and-v143-support.patch @@ -0,0 +1,153 @@ +diff --git a/build/make/configure.sh b/build/make/configure.sh +index 110f16e..c161d0e 100644 +--- a/build/make/configure.sh ++++ b/build/make/configure.sh +@@ -1038,7 +1038,7 @@ EOF + # A number of ARM-based Windows platforms are constrained by their + # respective SDKs' limitations. Fortunately, these are all 32-bit ABIs + # and so can be selected as 'win32'. +- if [ ${tgt_os} = "win32" ]; then ++ if [ ${tgt_os} = "win32" ] || [ ${tgt_isa} = "armv7" ]; then + asm_conversion_cmd="${source_path_mk}/build/make/ads2armasm_ms.pl" + AS_SFX=.S + msvs_arch_dir=arm-msvs +@@ -1272,6 +1272,9 @@ EOF + android) + soft_enable realtime_only + ;; ++ uwp) ++ enabled gcc && add_cflags -fno-common ++ ;; + win*) + enabled gcc && add_cflags -fno-common + ;; +@@ -1390,6 +1393,16 @@ EOF + fi + AS_SFX=.asm + case ${tgt_os} in ++ uwp) ++ if [ {$tgt_isa} = "x86" ] || [ {$tgt_isa} = "armv7" ]; then ++ add_asflags -f win32 ++ else ++ add_asflags -f win64 ++ fi ++ enabled debug && [ "${AS}" = yasm ] && add_asflags -g cv8 ++ enabled debug && [ "${AS}" = nasm ] && add_asflags -gcv8 ++ EXE_SFX=.exe ++ ;; + win32) + add_asflags -f win32 + enabled debug && [ "${AS}" = yasm ] && add_asflags -g cv8 +@@ -1519,6 +1532,8 @@ EOF + # Almost every platform uses pthreads. + if enabled multithread; then + case ${toolchain} in ++ *-uwp-vs*) ++ ;; + *-win*-vs*) + ;; + *-android-gcc) +diff --git a/build/make/gen_msvs_vcxproj.sh b/build/make/gen_msvs_vcxproj.sh +index 58bb66b..b4cad6c 100644 +--- a/build/make/gen_msvs_vcxproj.sh ++++ b/build/make/gen_msvs_vcxproj.sh +@@ -296,7 +296,22 @@ generate_vcxproj() { + tag_content ProjectGuid "{${guid}}" + tag_content RootNamespace ${name} + tag_content Keyword ManagedCProj +- if [ $vs_ver -ge 12 ] && [ "${platforms[0]}" = "ARM" ]; then ++ if [ $vs_ver -ge 16 ]; then ++ if [[ $target =~ [^-]*-uwp-.* ]]; then ++ # Universal Windows Applications ++ tag_content AppContainerApplication true ++ tag_content ApplicationType "Windows Store" ++ tag_content ApplicationTypeRevision 10.0 ++ fi ++ if [[ $target =~ [^-]*-uwp-.* ]] || [ "${platforms[0]}" = "ARM" ] || [ "${platforms[0]}" = "ARM64" ]; then ++ # Default to the latest Windows 10 SDK ++ tag_content WindowsTargetPlatformVersion 10.0 ++ else ++ # Minimum supported version of Windows for the desktop ++ tag_content WindowsTargetPlatformVersion 8.1 ++ fi ++ tag_content MinimumVisualStudioVersion 16.0 ++ elif [ $vs_ver -ge 12 ] && [ "${platforms[0]}" = "ARM" ]; then + tag_content AppContainerApplication true + # The application type can be one of "Windows Store", + # "Windows Phone" or "Windows Phone Silverlight". The +@@ -394,7 +409,7 @@ generate_vcxproj() { + Condition="'\$(Configuration)|\$(Platform)'=='$config|$plat'" + if [ "$name" == "vpx" ]; then + hostplat=$plat +- if [ "$hostplat" == "ARM" ]; then ++ if [ "$hostplat" == "ARM" ] && [ $vs_ver -le 15 ]; then + hostplat=Win32 + fi + fi +diff --git a/configure b/configure +index ae289f7..78f5fc1 100644 +--- a/configure ++++ b/configure +@@ -103,6 +103,8 @@ all_platforms="${all_platforms} arm64-darwin20-gcc" + all_platforms="${all_platforms} arm64-darwin21-gcc" + all_platforms="${all_platforms} arm64-darwin22-gcc" + all_platforms="${all_platforms} arm64-linux-gcc" ++all_platforms="${all_platforms} arm64-uwp-vs16" ++all_platforms="${all_platforms} arm64-uwp-vs17" + all_platforms="${all_platforms} arm64-win64-gcc" + all_platforms="${all_platforms} arm64-win64-vs15" + all_platforms="${all_platforms} arm64-win64-vs16" +@@ -112,6 +114,8 @@ all_platforms="${all_platforms} armv7-darwin-gcc" #neon Cortex-A8 + all_platforms="${all_platforms} armv7-linux-rvct" #neon Cortex-A8 + all_platforms="${all_platforms} armv7-linux-gcc" #neon Cortex-A8 + all_platforms="${all_platforms} armv7-none-rvct" #neon Cortex-A8 ++all_platforms="${all_platforms} armv7-uwp-vs16" ++all_platforms="${all_platforms} armv7-uwp-vs17" + all_platforms="${all_platforms} armv7-win32-gcc" + all_platforms="${all_platforms} armv7-win32-vs14" + all_platforms="${all_platforms} armv7-win32-vs15" +@@ -143,6 +147,8 @@ all_platforms="${all_platforms} x86-linux-gcc" + all_platforms="${all_platforms} x86-linux-icc" + all_platforms="${all_platforms} x86-os2-gcc" + all_platforms="${all_platforms} x86-solaris-gcc" ++all_platforms="${all_platforms} x86-uwp-vs16" ++all_platforms="${all_platforms} x86-uwp-vs17" + all_platforms="${all_platforms} x86-win32-gcc" + all_platforms="${all_platforms} x86-win32-vs14" + all_platforms="${all_platforms} x86-win32-vs15" +@@ -167,6 +173,8 @@ all_platforms="${all_platforms} x86_64-iphonesimulator-gcc" + all_platforms="${all_platforms} x86_64-linux-gcc" + all_platforms="${all_platforms} x86_64-linux-icc" + all_platforms="${all_platforms} x86_64-solaris-gcc" ++all_platforms="${all_platforms} x86_64-uwp-vs16" ++all_platforms="${all_platforms} x86_64-uwp-vs17" + all_platforms="${all_platforms} x86_64-win64-gcc" + all_platforms="${all_platforms} x86_64-win64-vs14" + all_platforms="${all_platforms} x86_64-win64-vs15" +@@ -491,11 +499,10 @@ process_targets() { + ! enabled multithread && DIST_DIR="${DIST_DIR}-nomt" + ! enabled install_docs && DIST_DIR="${DIST_DIR}-nodocs" + DIST_DIR="${DIST_DIR}-${tgt_isa}-${tgt_os}" +- case "${tgt_os}" in +- win*) enabled static_msvcrt && DIST_DIR="${DIST_DIR}mt" || DIST_DIR="${DIST_DIR}md" +- DIST_DIR="${DIST_DIR}-${tgt_cc}" +- ;; +- esac ++ if [[ ${tgt_os} =~ win.* ]] || [ "${tgt_os}" = "uwp" ]; then ++ enabled static_msvcrt && DIST_DIR="${DIST_DIR}mt" || DIST_DIR="${DIST_DIR}md" ++ DIST_DIR="${DIST_DIR}-${tgt_cc}" ++ fi + if [ -f "${source_path}/build/make/version.sh" ]; then + ver=`"$source_path/build/make/version.sh" --bare "$source_path"` + DIST_DIR="${DIST_DIR}-${ver}" +@@ -584,6 +591,10 @@ process_detect() { + + # Specialize windows and POSIX environments. + case $toolchain in ++ *-uwp-*) ++ # Don't check for any headers in UWP builds. ++ false ++ ;; + *-win*-*) + # Don't check for any headers in Windows builds. + false diff --git a/res/vcpkg/libvpx/0004-remove-library-suffixes.patch b/res/vcpkg/libvpx/0004-remove-library-suffixes.patch new file mode 100644 index 000000000000..e7f827d7b156 --- /dev/null +++ b/res/vcpkg/libvpx/0004-remove-library-suffixes.patch @@ -0,0 +1,13 @@ +diff --git a/build/make/gen_msvs_vcxproj.sh b/build/make/gen_msvs_vcxproj.sh +index 916851662..e60405bc9 100755 +--- a/build/make/gen_msvs_vcxproj.sh ++++ b/build/make/gen_msvs_vcxproj.sh +@@ -394,7 +394,7 @@ generate_vcxproj() { + else + config_suffix="" + fi +- tag_content TargetName "${name}${lib_sfx}${config_suffix}" ++ tag_content TargetName "${name}" + fi + close_tag PropertyGroup + done diff --git a/res/vcpkg/libvpx/0005-fix-arm64-build.patch b/res/vcpkg/libvpx/0005-fix-arm64-build.patch new file mode 100644 index 000000000000..76c0c8171f7b --- /dev/null +++ b/res/vcpkg/libvpx/0005-fix-arm64-build.patch @@ -0,0 +1,13 @@ +diff --git a/vp9/encoder/arm/neon/vp9_diamond_search_sad_neon.c b/vp9/encoder/arm/neon/vp9_diamond_search_sad_neon.c +index 33753f7..997775a 100644 +--- a/vp9/encoder/arm/neon/vp9_diamond_search_sad_neon.c ++++ b/vp9/encoder/arm/neon/vp9_diamond_search_sad_neon.c +@@ -220,7 +220,7 @@ int vp9_diamond_search_sad_neon(const MACROBLOCK *x, + // Look up the component cost of the residual motion vector + { + uint32_t cost[4]; +- int16_t __attribute__((aligned(16))) rowcol[8]; ++ DECLARE_ALIGNED(16, int16_t, rowcol[8]); + vst1q_s16(rowcol, v_diff_mv_w); + + // Note: This is a use case for gather instruction diff --git a/res/vcpkg/libvpx/portfile.cmake b/res/vcpkg/libvpx/portfile.cmake new file mode 100644 index 000000000000..02052f563342 --- /dev/null +++ b/res/vcpkg/libvpx/portfile.cmake @@ -0,0 +1,314 @@ +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO webmproject/libvpx + REF "v${VERSION}" + SHA512 49706838563c92fab7334376848d0f374efcbc1729ef511e967c908fd2ecd40e8d197f1d85da6553b3a7026bdbc17e5a76595319858af26ce58cb9a4c3854897 + HEAD_REF master + PATCHES + 0002-Fix-nasm-debug-format-flag.patch + 0003-add-uwp-v142-and-v143-support.patch + 0004-remove-library-suffixes.patch + 0005-fix-arm64-build.patch # Upstream commit: https://github.com/webmproject/libvpx/commit/858a8c611f4c965078485860a6820e2135e6611b +) + +vcpkg_find_acquire_program(PERL) + +get_filename_component(PERL_EXE_PATH ${PERL} DIRECTORY) + +if(CMAKE_HOST_WIN32) + vcpkg_acquire_msys(MSYS_ROOT PACKAGES make) + set(BASH ${MSYS_ROOT}/usr/bin/bash.exe) + set(ENV{PATH} "${MSYS_ROOT}/usr/bin;$ENV{PATH};${PERL_EXE_PATH}") +else() + set(BASH /bin/bash) + set(ENV{PATH} "${MSYS_ROOT}/usr/bin:$ENV{PATH}:${PERL_EXE_PATH}") +endif() + +if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) + vcpkg_find_acquire_program(NASM) + get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY) + vcpkg_add_to_path(${NASM_EXE_PATH}) + + file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-tmp") + + if(VCPKG_CRT_LINKAGE STREQUAL static) + set(LIBVPX_CRT_LINKAGE --enable-static-msvcrt) + set(LIBVPX_CRT_SUFFIX mt) + else() + set(LIBVPX_CRT_SUFFIX md) + endif() + + if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL WindowsStore AND (VCPKG_PLATFORM_TOOLSET STREQUAL v142 OR VCPKG_PLATFORM_TOOLSET STREQUAL v143)) + set(LIBVPX_TARGET_OS "uwp") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL x86 OR VCPKG_TARGET_ARCHITECTURE STREQUAL arm) + set(LIBVPX_TARGET_OS "win32") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL x64 OR VCPKG_TARGET_ARCHITECTURE STREQUAL arm64) + set(LIBVPX_TARGET_OS "win64") + endif() + + if(VCPKG_TARGET_ARCHITECTURE STREQUAL x86) + set(LIBVPX_TARGET_ARCH "x86-${LIBVPX_TARGET_OS}") + set(LIBVPX_ARCH_DIR "Win32") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL x64) + set(LIBVPX_TARGET_ARCH "x86_64-${LIBVPX_TARGET_OS}") + set(LIBVPX_ARCH_DIR "x64") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL arm64) + set(LIBVPX_TARGET_ARCH "arm64-${LIBVPX_TARGET_OS}") + set(LIBVPX_ARCH_DIR "ARM64") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL arm) + set(LIBVPX_TARGET_ARCH "armv7-${LIBVPX_TARGET_OS}") + set(LIBVPX_ARCH_DIR "ARM") + endif() + + if(VCPKG_PLATFORM_TOOLSET STREQUAL v143) + set(LIBVPX_TARGET_VS "vs17") + elseif(VCPKG_PLATFORM_TOOLSET STREQUAL v142) + set(LIBVPX_TARGET_VS "vs16") + else() + set(LIBVPX_TARGET_VS "vs15") + endif() + + set(OPTIONS "--disable-examples --disable-tools --disable-docs --enable-pic") + + if("realtime" IN_LIST FEATURES) + set(OPTIONS "${OPTIONS} --enable-realtime-only") + endif() + + if("highbitdepth" IN_LIST FEATURES) + set(OPTIONS "${OPTIONS} --enable-vp9-highbitdepth") + endif() + + message(STATUS "Generating makefile") + file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-tmp") + vcpkg_execute_required_process( + COMMAND + ${BASH} --noprofile --norc + "${SOURCE_PATH}/configure" + --target=${LIBVPX_TARGET_ARCH}-${LIBVPX_TARGET_VS} + ${LIBVPX_CRT_LINKAGE} + ${OPTIONS} + --as=nasm + WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-tmp" + LOGNAME configure-${TARGET_TRIPLET}) + + message(STATUS "Generating MSBuild projects") + vcpkg_execute_required_process( + COMMAND + ${BASH} --noprofile --norc -c "make dist" + WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-tmp" + LOGNAME generate-${TARGET_TRIPLET}) + + vcpkg_msbuild_install( + SOURCE_PATH "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-tmp" + PROJECT_SUBPATH vpx.vcxproj + ) + + if (VCPKG_TARGET_ARCHITECTURE STREQUAL arm64) + set(LIBVPX_INCLUDE_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vpx-vp8-vp9-nopost-nodocs-${LIBVPX_TARGET_ARCH}${LIBVPX_CRT_SUFFIX}-${LIBVPX_TARGET_VS}-v${VERSION}/include/vpx") + elseif (VCPKG_TARGET_ARCHITECTURE STREQUAL arm) + set(LIBVPX_INCLUDE_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vpx-vp8-vp9-nopost-nomt-nodocs-${LIBVPX_TARGET_ARCH}${LIBVPX_CRT_SUFFIX}-${LIBVPX_TARGET_VS}-v${VERSION}/include/vpx") + else() + set(LIBVPX_INCLUDE_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vpx-vp8-vp9-nodocs-${LIBVPX_TARGET_ARCH}${LIBVPX_CRT_SUFFIX}-${LIBVPX_TARGET_VS}-v${VERSION}/include/vpx") + endif() + file( + INSTALL + "${LIBVPX_INCLUDE_DIR}" + DESTINATION + "${CURRENT_PACKAGES_DIR}/include" + RENAME + "vpx") + if (NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + set(LIBVPX_PREFIX "${CURRENT_INSTALLED_DIR}") + configure_file("${CMAKE_CURRENT_LIST_DIR}/vpx.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/vpx.pc" @ONLY) + endif() + + if (NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + set(LIBVPX_PREFIX "${CURRENT_INSTALLED_DIR}/debug") + configure_file("${CMAKE_CURRENT_LIST_DIR}/vpx.pc.in" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/vpx.pc" @ONLY) + endif() + +else() + vcpkg_find_acquire_program(YASM) + get_filename_component(YASM_EXE_PATH ${YASM} DIRECTORY) + vcpkg_add_to_path(${YASM_EXE_PATH}) + + set(OPTIONS "--disable-examples --disable-tools --disable-docs --disable-unit-tests --enable-pic") + + set(OPTIONS_DEBUG "--enable-debug-libs --enable-debug --prefix=${CURRENT_PACKAGES_DIR}/debug") + set(OPTIONS_RELEASE "--prefix=${CURRENT_PACKAGES_DIR}") + + if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + set(OPTIONS "${OPTIONS} --disable-static --enable-shared") + else() + set(OPTIONS "${OPTIONS} --enable-static --disable-shared") + endif() + + if("realtime" IN_LIST FEATURES) + set(OPTIONS "${OPTIONS} --enable-realtime-only") + endif() + + if("highbitdepth" IN_LIST FEATURES) + set(OPTIONS "${OPTIONS} --enable-vp9-highbitdepth") + endif() + + if(VCPKG_TARGET_ARCHITECTURE STREQUAL x86) + set(LIBVPX_TARGET_ARCH "x86") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL x64) + set(LIBVPX_TARGET_ARCH "x86_64") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL arm) + set(LIBVPX_TARGET_ARCH "armv7") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL arm64) + set(LIBVPX_TARGET_ARCH "arm64") + else() + message(FATAL_ERROR "libvpx does not support architecture ${VCPKG_TARGET_ARCHITECTURE}") + endif() + + if(VCPKG_TARGET_IS_MINGW) + if(LIBVPX_TARGET_ARCH STREQUAL "x86") + set(LIBVPX_TARGET "x86-win32-gcc") + else() + set(LIBVPX_TARGET "x86_64-win64-gcc") + endif() + elseif(VCPKG_TARGET_IS_LINUX) + set(LIBVPX_TARGET "${LIBVPX_TARGET_ARCH}-linux-gcc") + include($ENV{VCPKG_ROOT}/buildtrees/detect_compiler/${VCPKG_TARGET_ARCHITECTURE}-linux-rel/CMakeFiles/${CMAKE_VERSION}/CMakeCCompiler.cmake) + set(ENV{CROSS} "${CMAKE_LIBRARY_ARCHITECTURE}-") + elseif(VCPKG_TARGET_IS_ANDROID) + set(LIBVPX_TARGET "${LIBVPX_TARGET_ARCH}-android-gcc") + set(ANDROID_API 21) + # From ndk android.toolchsin.cmake + if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux) + set(ANDROID_HOST_TAG linux-x86_64) + elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin) + set(ANDROID_HOST_TAG darwin-x86_64) + elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows) + set(ANDROID_HOST_TAG windows-x86_64) + endif() + set(ANDROID_TOOLCHAIN_ROOT + "$ENV{ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/${ANDROID_HOST_TAG}") + # Settings + if(VCPKG_TARGET_ARCHITECTURE STREQUAL x86) + set(ANDROID_TARGET_TRIPLET i686-linux-android) + set(OPTIONS "${OPTIONS} --disable-sse4_1 --disable-avx --disable-avx2 --disable-avx512") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL x64) + set(ANDROID_TARGET_TRIPLET x86_64-linux-android) + set(OPTIONS "${OPTIONS} --disable-avx --disable-avx2 --disable-avx512") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL arm) + set(ANDROID_TARGET_TRIPLET armv7a-linux-androideabi) + set(OPTIONS "${OPTIONS} --enable-thumb --disable-neon") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL arm64) + set(ANDROID_TARGET_TRIPLET aarch64-linux-android) + set(OPTIONS "${OPTIONS} --enable-thumb --disable-neon") + endif() + # Set environment variables for configure + set(ENV{CC} "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TARGET_TRIPLET}${ANDROID_API}-clang") + set(ENV{CXX} "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TARGET_TRIPLET}${ANDROID_API}-clang++") + set(ENV{AR} "${ANDROID_TOOLCHAIN_ROOT}/bin/llvm-ar") + set(ENV{AS} "${CMAKE_C_COMPILER}") + set(ENV{LD} "${ANDROID_TOOLCHAIN_ROOT}/bin/ld") + set(ENV{RANLIB} "${ANDROID_TOOLCHAIN_ROOT}/bin/llvm-ranlib") + set(ENV{STRIP} "${ANDROID_TOOLCHAIN_ROOT}/bin/llvm-strip") + elseif(VCPKG_TARGET_IS_OSX) + if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") + set(LIBVPX_TARGET "arm64-darwin20-gcc") + if(DEFINED VCPKG_OSX_DEPLOYMENT_TARGET) + set(MAC_OSX_MIN_VERSION_CFLAGS --extra-cflags=-mmacosx-version-min=${VCPKG_OSX_DEPLOYMENT_TARGET} --extra-cxxflags=-mmacosx-version-min=${VCPKG_OSX_DEPLOYMENT_TARGET}) + endif() + else() + set(LIBVPX_TARGET "${LIBVPX_TARGET_ARCH}-darwin17-gcc") # enable latest CPU instructions for best performance and less CPU usage on MacOS + endif() + elseif(VCPKG_TARGET_IS_IOS) + if(VCPKG_TARGET_ARCHITECTURE STREQUAL arm) + set(LIBVPX_TARGET "armv7-darwin-gcc") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL arm64) + set(LIBVPX_TARGET "arm64-darwin-gcc") + else() + message(FATAL_ERROR "libvpx does not support architecture ${VCPKG_TARGET_ARCHITECTURE} on iOS") + endif() + else() + set(LIBVPX_TARGET "generic-gnu") # use default target + endif() + + message(STATUS "Build info. Target: ${LIBVPX_TARGET}; Options: ${OPTIONS}") + + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + message(STATUS "Configuring libvpx for Release") + file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") + vcpkg_execute_required_process( + COMMAND + ${BASH} --noprofile --norc + "${SOURCE_PATH}/configure" + --target=${LIBVPX_TARGET} + ${OPTIONS} + ${OPTIONS_RELEASE} + ${MAC_OSX_MIN_VERSION_CFLAGS} + WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" + LOGNAME configure-${TARGET_TRIPLET}-rel) + + message(STATUS "Building libvpx for Release") + vcpkg_execute_required_process( + COMMAND + ${BASH} --noprofile --norc -c "make -j" + WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" + LOGNAME build-${TARGET_TRIPLET}-rel + ) + + message(STATUS "Installing libvpx for Release") + vcpkg_execute_required_process( + COMMAND + ${BASH} --noprofile --norc -c "make install" + WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" + LOGNAME install-${TARGET_TRIPLET}-rel + ) + endif() + + # --- --- --- + + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + message(STATUS "Configuring libvpx for Debug") + file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") + vcpkg_execute_required_process( + COMMAND + ${BASH} --noprofile --norc + "${SOURCE_PATH}/configure" + --target=${LIBVPX_TARGET} + ${OPTIONS} + ${OPTIONS_DEBUG} + ${MAC_OSX_MIN_VERSION_CFLAGS} + WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" + LOGNAME configure-${TARGET_TRIPLET}-dbg) + + message(STATUS "Building libvpx for Debug") + vcpkg_execute_required_process( + COMMAND + ${BASH} --noprofile --norc -c "make -j" + WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" + LOGNAME build-${TARGET_TRIPLET}-dbg + ) + + message(STATUS "Installing libvpx for Debug") + vcpkg_execute_required_process( + COMMAND + ${BASH} --noprofile --norc -c "make install" + WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" + LOGNAME install-${TARGET_TRIPLET}-dbg + ) + + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libvpx_g.a") + endif() +endif() + +vcpkg_fixup_pkgconfig() + +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + set(LIBVPX_CONFIG_DEBUG ON) +else() + set(LIBVPX_CONFIG_DEBUG OFF) +endif() + +configure_file("${CMAKE_CURRENT_LIST_DIR}/unofficial-libvpx-config.cmake.in" "${CURRENT_PACKAGES_DIR}/share/unofficial-libvpx/unofficial-libvpx-config.cmake" @ONLY) + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/res/vcpkg/libvpx/unofficial-libvpx-config.cmake.in b/res/vcpkg/libvpx/unofficial-libvpx-config.cmake.in new file mode 100644 index 000000000000..d3844d36612f --- /dev/null +++ b/res/vcpkg/libvpx/unofficial-libvpx-config.cmake.in @@ -0,0 +1,49 @@ +if(NOT TARGET unofficial::libvpx::libvpx) + # Compute the installation prefix relative to this file. + get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) + get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) + get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) + + # Add library target (note: vpx always has a static build in vcpkg). + add_library(unofficial::libvpx::libvpx STATIC IMPORTED) + + # Add interface include directories and link interface languages (applies to all configurations). + set_target_properties(unofficial::libvpx::libvpx PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + ) + list(APPEND _IMPORT_CHECK_FILES "${_IMPORT_PREFIX}/include/vpx/vpx_codec.h") + + # Add release configuration properties. + find_library(_LIBFILE_RELEASE NAMES vpx PATHS "${_IMPORT_PREFIX}/lib/" NO_DEFAULT_PATH) + set_property(TARGET unofficial::libvpx::libvpx + APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(unofficial::libvpx::libvpx PROPERTIES + IMPORTED_LOCATION_RELEASE ${_LIBFILE_RELEASE}) + list(APPEND _IMPORT_CHECK_FILES ${_LIBFILE_RELEASE}) + unset(_LIBFILE_RELEASE CACHE) + + # Add debug configuration properties. + if(@LIBVPX_CONFIG_DEBUG@) + find_library(_LIBFILE_DEBUG NAMES vpx PATHS "${_IMPORT_PREFIX}/debug/lib/" NO_DEFAULT_PATH) + set_property(TARGET unofficial::libvpx::libvpx + APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(unofficial::libvpx::libvpx PROPERTIES + IMPORTED_LOCATION_DEBUG ${_LIBFILE_DEBUG}) + list(APPEND _IMPORT_CHECK_FILES ${_LIBFILE_DEBUG}) + unset(_LIBFILE_DEBUG CACHE) + endif() + + # Check header and library files are present. + foreach(file ${_IMPORT_CHECK_FILES} ) + if(NOT EXISTS "${file}" ) + message(FATAL_ERROR "unofficial::libvpx::libvpx references the file + \"${file}\" +but this file does not exist. Possible reasons include: +* The file was deleted, renamed, or moved to another location. +* An install or uninstall procedure did not complete successfully. +") + endif() + endforeach() + unset(_IMPORT_CHECK_FILES) +endif() diff --git a/res/vcpkg/libvpx/vcpkg.json b/res/vcpkg/libvpx/vcpkg.json new file mode 100644 index 000000000000..b2cb8dff6173 --- /dev/null +++ b/res/vcpkg/libvpx/vcpkg.json @@ -0,0 +1,22 @@ +{ + "name": "libvpx", + "version": "1.13.1", + "description": "The reference software implementation for the video coding formats VP8 and VP9.", + "homepage": "https://github.com/webmproject/libvpx", + "license": "BSD-3-Clause", + "dependencies": [ + { + "name": "vcpkg-msbuild", + "host": true, + "platform": "windows" + } + ], + "features": { + "highbitdepth": { + "description": "use VP9 high bit depth (10/12) profiles" + }, + "realtime": { + "description": "enable this option while building for real-time encoding" + } + } +} diff --git a/res/vcpkg/libvpx/vpx.pc.in b/res/vcpkg/libvpx/vpx.pc.in new file mode 100644 index 000000000000..6df64d4b4dbd --- /dev/null +++ b/res/vcpkg/libvpx/vpx.pc.in @@ -0,0 +1,12 @@ +prefix=@LIBVPX_PREFIX@ +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: vpx +Description: WebM Project VPx codec implementation +Version: @VERSION@ +Requires: +Conflicts: +Libs: -L"${libdir}" -lvpx +Cflags: -I"${includedir}" diff --git a/res/vcpkg/opus/fix-pkgconfig-version.patch b/res/vcpkg/opus/fix-pkgconfig-version.patch new file mode 100644 index 000000000000..ef9f7229c419 --- /dev/null +++ b/res/vcpkg/opus/fix-pkgconfig-version.patch @@ -0,0 +1,15 @@ +diff --git a/cmake/OpusPackageVersion.cmake b/cmake/OpusPackageVersion.cmake +index 447ce3b..15ebd8e 100644 +--- a/cmake/OpusPackageVersion.cmake ++++ b/cmake/OpusPackageVersion.cmake +@@ -4,7 +4,9 @@ endif() + set(__opus_version INCLUDED) + + function(get_package_version PACKAGE_VERSION PROJECT_VERSION) +- ++ set(PACKAGE_VERSION "0" CACHE STRING "opus package version") ++ set(PROJECT_VERSION "0" CACHE STRING "opus project version") ++ return() + find_package(Git) + if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git") + execute_process(COMMAND ${GIT_EXECUTABLE} diff --git a/res/vcpkg/opus/portfile.cmake b/res/vcpkg/opus/portfile.cmake new file mode 100644 index 000000000000..34b038db64c3 --- /dev/null +++ b/res/vcpkg/opus/portfile.cmake @@ -0,0 +1,58 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO xiph/opus + REF "v${VERSION}" + SHA512 86df35cd62ebf3551b2739effb8f818d635656d91d386d7d600a424a92c4c0d6bfbc3986f1ec6cf4950910ac87b28dc9640b9df3b9a6a5a75eb37ae71782b72e + HEAD_REF master + PATCHES fix-pkgconfig-version.patch + reinstate-opus-use-neon.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + avx AVX_SUPPORTED +) + +set(ADDITIONAL_OPUS_OPTIONS "") +if(VCPKG_TARGET_IS_MINGW) + set(STACK_PROTECTOR OFF) + string(APPEND VCPKG_C_FLAGS "-D_FORTIFY_SOURCE=0") + string(APPEND VCPKG_CXX_FLAGS "-D_FORTIFY_SOURCE=0") +elseif(VCPKG_TARGET_IS_EMSCRIPTEN) + set(STACK_PROTECTOR OFF) +else() + set(STACK_PROTECTOR ON) +endif() + +# Fix build on mingw arm{,64}-* and arm-linux +if(VCPKG_TARGET_ARCHITECTURE MATCHES "^(ARM|arm)") + list(APPEND ADDITIONAL_OPUS_OPTIONS "-DOPUS_USE_NEON=OFF") # for version 1.3.1 (remove for future Opus release) + list(APPEND ADDITIONAL_OPUS_OPTIONS "-DOPUS_DISABLE_INTRINSICS=ON") # for HEAD (and future Opus release) +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS ${FEATURE_OPTIONS} + -DPACKAGE_VERSION=${VERSION} + -DOPUS_STACK_PROTECTOR=${STACK_PROTECTOR} + -DOPUS_INSTALL_PKG_CONFIG_MODULE=ON + -DOPUS_INSTALL_CMAKE_CONFIG_MODULE=ON + -DOPUS_BUILD_PROGRAMS=OFF + -DOPUS_BUILD_TESTING=OFF + ${ADDITIONAL_OPUS_OPTIONS} + MAYBE_UNUSED_VARIABLES + OPUS_USE_NEON + OPUS_DISABLE_INTRINSICS +) +vcpkg_cmake_install() +vcpkg_copy_pdbs() + +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/Opus) +vcpkg_fixup_pkgconfig(SYSTEM_LIBRARIES m) + + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/lib/cmake" + "${CURRENT_PACKAGES_DIR}/lib/cmake" + "${CURRENT_PACKAGES_DIR}/debug/include") + +file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/res/vcpkg/opus/reinstate-opus-use-neon.patch b/res/vcpkg/opus/reinstate-opus-use-neon.patch new file mode 100644 index 000000000000..ce213a9885c5 --- /dev/null +++ b/res/vcpkg/opus/reinstate-opus-use-neon.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 9d824cd..8ff44a0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -467,7 +467,7 @@ if(NOT OPUS_DISABLE_INTRINSICS) + endif() + endif() + +- if(COMPILER_SUPPORT_NEON) ++ if(COMPILER_SUPPORT_NEON AND OPUS_USE_NEON) + if(OPUS_MAY_HAVE_NEON) + if(RUNTIME_CPU_CAPABILITY_DETECTION) + message(STATUS "OPUS_MAY_HAVE_NEON enabling runtime detection") diff --git a/res/vcpkg/opus/vcpkg.json b/res/vcpkg/opus/vcpkg.json new file mode 100644 index 000000000000..1b23ca5375c9 --- /dev/null +++ b/res/vcpkg/opus/vcpkg.json @@ -0,0 +1,23 @@ +{ + "name": "opus", + "version": "1.4", + "port-version": 1, + "description": "Totally open, royalty-free, highly versatile audio codec", + "homepage": "https://github.com/xiph/opus", + "license": "BSD-3-Clause", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "features": { + "avx": { + "description": "Builds the library with avx instruction set" + } + } +} diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 000000000000..0cf2e1fc2294 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,59 @@ +{ + "dependencies": [ + { + "name": "aom", + "host": true + }, + { + "name": "aom", + "host": false + }, + { + "name": "cpu-features", + "platform": "android" + }, + { + "name": "libjpeg-turbo", + "host": true + }, + { + "name": "libjpeg-turbo", + "host": false + }, + { + "name": "oboe", + "platform": "android" + }, + { + "name": "opus", + "host": true + }, + { + "name": "opus", + "host": false + }, + { + "name": "libvpx", + "host": true + }, + { + "name": "libvpx", + "host": false + }, + { + "name": "libyuv", + "host": true + }, + { + "name": "libyuv", + "host": false + } + ], + "vcpkg-configuration": { + "default-registry": { + "kind": "builtin", + "baseline": "" + }, + "overlay-ports": [ "./res/vcpkg" ] + } +}