diff --git a/.github/workflows/flutter-nightly.yml b/.github/workflows/flutter-nightly.yml index e9fd70568..f798459e1 100644 --- a/.github/workflows/flutter-nightly.yml +++ b/.github/workflows/flutter-nightly.yml @@ -182,7 +182,7 @@ jobs: rm res/icon.ico && cp flutter/windows/runner/resources/app_icon.ico res/icon.ico cargo build --features inline --target=${{ matrix.job.target }} --release mkdir -p ./Release - mv ./target/release/rustdesk.exe ./Release/rustdesk.exe + mv ./target/${{ matrix.job.target }}/release/rustdesk.exe ./Release/rustdesk.exe wget -O ./Release/sciter.dll https://github.com/c-smile/sciter-sdk/raw/master/bin.win/x32/sciter.dll echo "output_folder=./Release" >> $GITHUB_OUTPUT @@ -716,7 +716,7 @@ jobs: # use-cross: true, # extra-build-features: "", # } - # - { arch: armv7, target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true, extra-build-features: "flatpak" } + # - { arch: armv7, target: arm-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: Maximize build space @@ -846,11 +846,11 @@ jobs: cargo build --lib --features flutter,${{ matrix.job.extra-build-features }} --release ;; armv7) - cp -r /opt/artifacts/vcpkg/installed/lib/* /usr/lib/arm-linux-gnueabihf/ - cp -r /opt/artifacts/vcpkg/installed/include/* /usr/include/ - mkdir -p /vcpkg/installed/arm-linux - ln -s /usr/lib/arm-linux-gnueabihf /vcpkg/installed/arm-linux/lib - ln -s /usr/include /vcpkg/installed/arm-linux/include + # cp -r /opt/artifacts/vcpkg/installed/lib/* /usr/lib/arm-linux-gnueabihf/ + # cp -r /opt/artifacts/vcpkg/installed/include/* /usr/include/ + # mkdir -p /vcpkg/installed/arm-linux + # ln -s /usr/lib/arm-linux-gnueabihf /vcpkg/installed/arm-linux/lib + # ln -s /usr/include /vcpkg/installed/arm-linux/include export VCPKG_ROOT=/vcpkg # disable hwcodec for compilation cargo build --lib --features flutter,${{ matrix.job.extra-build-features }} --release @@ -863,6 +863,90 @@ jobs: name: librustdesk-${{ matrix.job.arch }}-${{ matrix.job.extra-build-features }}.so path: target/release/liblibrustdesk.so + build-rustdesk-sciter-arm: + needs: [build-vcpkg-deps-linux] + name: build-rustdesk(sciter) ${{ matrix.job.target }} (${{ matrix.job.os }}) [${{ matrix.job.extra-build-features }}] + runs-on: ${{ matrix.job.os }} + strategy: + fail-fast: false + matrix: + # use a high level qemu-user-static + job: + - { + arch: armv7, + target: arm-unknown-linux-gnueabihf, + deb-arch: armhf, + os: ubuntu-latest, + use-cross: true, + extra-build-features: "", + } + # - { arch: armv7, target: arm-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: Checkout source code + uses: actions/checkout@v3 + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: ${{ matrix.job.target }} + override: true + profile: minimal # minimal component installation (ie, no documentation) + + - uses: Swatinem/rust-cache@v2 + with: + prefix-key: rustdesk-lib-cache + key: ${{ matrix.job.target }}-${{ matrix.job.extra-build-features }} + cache-directories: "/opt/rust-registry" + + - name: Restore vcpkg files + uses: actions/download-artifact@master + with: + name: vcpkg-artifact-${{ matrix.job.arch }} + path: /opt/artifacts/vcpkg/installed + + - name: Install cross tool + run: | + wget https://github.com/cross-rs/cross/releases/download/v0.2.5/cross-x86_64-unknown-linux-gnu.tar.gz + tar -zxvf cross-x86_64-unknown-linux-gnu.tar.gz + mv cross* /usr/local/bin/ + + - name: Build RustDesk + env: + ARCH: ${{ matrix.job.deb-arch }} + VCPKG_ROOT: /opt/artifacts/vcpkg + run: | + python3 ./res/inline-sciter.py + cross build --target ${{ matrix.job.target }} --features inline --release + wget -O ./target/${{ matrix.job.target }}/release/libsciter-gtk.so https://github.com/c-smile/sciter-sdk/blob/master/bin.lnx/arm32/libsciter-gtk.so + ./build.py --package ./target/${{ matrix.job.target }}/release + + - name: Rename rustdesk + shell: bash + run: | + for name in rustdesk*??.deb; do + # use cp to duplicate deb files to fit other packages. + cp "$name" "${name%%.deb}-${{ matrix.job.target }}-${{ matrix.job.os }}.deb" + done + + - name: Publish debian package + if: ${{ matrix.job.extra-build-features == '' }} + uses: softprops/action-gh-release@v1 + with: + prerelease: true + tag_name: ${{ env.TAG_NAME }} + files: | + rustdesk-${{ env.VERSION }}-${{ matrix.job.target }}-${{ matrix.job.os }}.deb + + - name: Upload Artifact + uses: actions/upload-artifact@master + if: ${{ contains(matrix.job.extra-build-features, 'flatpak') }} + with: + name: rustdesk-${{ env.VERSION }}-${{ matrix.job.target }}-${{ matrix.job.os }}.deb + path: rustdesk-${{ env.VERSION }}-${{ matrix.job.target }}-${{ matrix.job.os }}.deb + build-rustdesk-linux-arm: needs: [build-rustdesk-lib-linux-arm] name: build-rustdesk ${{ matrix.job.target }} (${{ matrix.job.os }}) [${{ matrix.job.extra-build-features }}] @@ -893,7 +977,7 @@ jobs: # extra-build-features: "flatpak", # } # - { arch: armv7, target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true, extra-build-features: "" } - # - { arch: armv7, target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true, extra-build-features: "flatpak" } + # - { arch: armv7, target: arm-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: Checkout source code diff --git a/.github/workflows/vcpkg-deps-linux.yml b/.github/workflows/vcpkg-deps-linux.yml index 89381114a..8eee01011 100644 --- a/.github/workflows/vcpkg-deps-linux.yml +++ b/.github/workflows/vcpkg-deps-linux.yml @@ -10,7 +10,7 @@ jobs: fail-fast: true matrix: job: - # - { arch: armv7, os: ubuntu-20.04 } + - { arch: armv7, os: ubuntu-20.04 } - { arch: x86_64, os: ubuntu-20.04 } - { arch: aarch64, os: ubuntu-20.04 } steps: @@ -46,12 +46,12 @@ jobs: wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null apt update -y apt install -y curl zip unzip tar git cmake g++ gcc build-essential pkg-config wget nasm yasm ninja-build libjpeg8-dev + cmake --version + gcc -v ;; aarch64|armv7) - apt install -y curl zip unzip tar git cmake g++ gcc build-essential pkg-config wget nasm yasm ninja-build libjpeg8-dev automake libtool + apt install -y curl zip unzip git esac - cmake --version - gcc -v run: | # disable git safe.directory git config --global --add safe.directory "*" @@ -65,25 +65,19 @@ jobs: ./bootstrap-vcpkg.sh ./vcpkg install libvpx libyuv opus ;; - aarch64|armv7) + aarch64) pushd /artifacts - # libyuv - git clone https://chromium.googlesource.com/libyuv/libyuv || true - pushd libyuv - git pull - mkdir -p build - pushd build + rm -rf rustdesk_thirdparty_lib + git clone https://github.com/Kingtous/rustdesk_thirdparty_lib.git --depth=1 mkdir -p /artifacts/vcpkg/installed - cmake .. -DCMAKE_INSTALL_PREFIX=/artifacts/vcpkg/installed - make -j4 && make install - popd - popd - # libopus, ubuntu 18.04 prebuilt is not be compiled with -fPIC - wget -O opus.tar.gz http://archive.ubuntu.com/ubuntu/pool/main/o/opus/opus_1.1.2.orig.tar.gz - tar -zxvf opus.tar.gz; ls -l - pushd opus-1.1.2 - ./autogen.sh; ./configure --prefix=/artifacts/vcpkg/installed - make -j4; make install + 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 diff --git a/Cargo.lock b/Cargo.lock index 6fdb513e4..908f32a8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4674,7 +4674,7 @@ dependencies = [ [[package]] name = "rdev" version = "0.5.0-2" -source = "git+https://github.com/fufesou/rdev#89d2cb5c4bac81da4aafaedcf78af6af7c80c9d0" +source = "git+https://github.com/fufesou/rdev#aeea78dec3e731dd616da09668bbbd835a773d6c" dependencies = [ "cocoa", "core-foundation 0.9.3", @@ -5885,7 +5885,7 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "tfc" version = "0.6.1" -source = "git+https://github.com/fufesou/The-Fat-Controller#1dba9a39c089ac9a7853b9dd5399c1d4aa3157d3" +source = "git+https://github.com/fufesou/The-Fat-Controller#9dd86151525fd010dc93f6bc9b6aedd1a75cc342" dependencies = [ "anyhow", "core-graphics 0.22.3", diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 000000000..952e753a2 --- /dev/null +++ b/Cross.toml @@ -0,0 +1,21 @@ +[build] +build-std = false # do not build the std library. has precedence over xargo +xargo = true # enable the use of xargo by default +# zig = false # do not use zig cc for the builds +default-target = "x86_64-unknown-linux-gnu" # use this target if none is explicitly provided + +[build.env] +volumes = ["VCPKG_ROOT"] # "VOL2_ARG=/path/to/volume" +passthrough = ["VCPKG_ROOT"] + +[target.aarch64-unknown-linux-gnu] +# pre-build = ["env ARCH=arm64 ./res/install-rust-deps.sh"] +# build-std = false # always build the std library. has precedence over xargo +# xargo = false # disable the use of xargo +# image = "test-image" # use a different image for the target +# runner = "qemu-user" # wrapper to run the binary (must be `qemu-system`, `qemu-user`, or `native`). + +[target.arm-unknown-linux-gnueabihf] +pre-build = "./res/install-rust-deps-arm.sh" +# volumes = ["VCPKG_ROOT"] # "VOL2_ARG=/path/to/volume" +# passthrough = ["VCPKG_ROOT"] \ No newline at end of file diff --git a/build.py b/build.py index 4a39f596d..7acf97a7d 100755 --- a/build.py +++ b/build.py @@ -18,6 +18,12 @@ exe_path = 'target/release/' + hbb_name flutter_win_target_dir = 'flutter/build/windows/runner/Release/' skip_cargo = False +def get_arch() -> str: + custom_arch = os.environ.get("ARCH") + if custom_arch is None: + return "amd64" + return custom_arch + def system2(cmd): err = os.system(cmd) if err != 0: @@ -106,6 +112,10 @@ def make_parser(): action='store_true', help='Skip cargo build process, only flutter version + Linux supported currently' ) + parser.add_argument( + "--package", + type=str + ) return parser @@ -251,13 +261,13 @@ def generate_control_file(version): content = """Package: rustdesk Version: %s -Architecture: amd64 +Architecture: %s Maintainer: open-trade Homepage: https://rustdesk.com Depends: libgtk-3-0, libxcb-randr0, libxdo3, libxfixes3, libxcb-shape0, libxcb-xfixes0, libasound2, libsystemd0, curl, libva-drm2, libva-x11-2, libvdpau1, libgstreamer-plugins-base1.0-0 Description: A remote control software. -""" % version +""" % (version, get_arch()) file = open(control_file_path, "w") file.write(content) file.close() @@ -307,6 +317,39 @@ def build_flutter_deb(version, features): os.rename('rustdesk.deb', '../rustdesk-%s.deb' % version) os.chdir("..") +def build_deb_from_folder(version, binary_folder): + os.chdir('flutter') + system2('mkdir -p tmpdeb/usr/bin/') + system2('mkdir -p tmpdeb/usr/lib/rustdesk') + system2('mkdir -p tmpdeb/usr/share/rustdesk/files/systemd/') + system2('mkdir -p tmpdeb/usr/share/applications/') + system2('mkdir -p tmpdeb/usr/share/polkit-1/actions') + system2('rm tmpdeb/usr/bin/rustdesk || true') + system2( + f'cp -r ../{binary_folder}/* tmpdeb/usr/lib/rustdesk/') + system2( + 'cp ../res/rustdesk.service tmpdeb/usr/share/rustdesk/files/systemd/') + system2( + 'cp ../res/128x128@2x.png tmpdeb/usr/share/rustdesk/files/rustdesk.png') + system2( + 'cp ../res/rustdesk.desktop tmpdeb/usr/share/applications/rustdesk.desktop') + system2( + 'cp ../res/rustdesk-link.desktop tmpdeb/usr/share/applications/rustdesk-link.desktop') + system2( + 'cp ../res/com.rustdesk.RustDesk.policy tmpdeb/usr/share/polkit-1/actions/') + system2( + "echo \"#!/bin/sh\" >> tmpdeb/usr/share/rustdesk/files/polkit && chmod a+x tmpdeb/usr/share/rustdesk/files/polkit") + + system2('mkdir -p tmpdeb/DEBIAN') + generate_control_file(version) + system2('cp -a ../res/DEBIAN/* tmpdeb/DEBIAN/') + md5_file('usr/share/rustdesk/files/systemd/rustdesk.service') + system2('dpkg-deb -b tmpdeb rustdesk.deb;') + + system2('/bin/rm -rf tmpdeb/') + system2('/bin/rm -rf ../res/DEBIAN/control') + os.rename('rustdesk.deb', '../rustdesk-%s.deb' % version) + os.chdir("..") def build_flutter_dmg(version, features): if not skip_cargo: @@ -381,6 +424,10 @@ def main(): if args.skip_cargo: skip_cargo = True portable = args.portable + package = args.package + if package: + build_deb_from_folder(version, package) + return if windows: # build virtual display dynamic library os.chdir('libs/virtual_display/dylib') diff --git a/res/install-rust-deps-arm.sh b/res/install-rust-deps-arm.sh new file mode 100644 index 000000000..14cf772fd --- /dev/null +++ b/res/install-rust-deps-arm.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# apt-get 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 libclang-dev llvm-dev pkg-config g++ gcc libvpx-dev + +# For developers in China, we use sources from ustc. +# sed -i 's/archive.archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list +# sed -i 's/security.archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list + +dpkg --add-architecture armhf + +apt update -y +apt install -y libdbus-1-dev:armhf pkg-config nasm yasm libglib2.0-dev:armhf libxcb-randr0-dev:armhf libxdo-dev:armhf libxfixes-dev:armhf libxcb-shape0-dev:armhf libxcb-xfixes0-dev:armhf libasound2-dev:armhf libpulse-dev:armhf libgstreamer1.0-dev:armhf libgstreamer-plugins-base1.0-dev:armhf libappindicator3-dev:armhf libvpx-dev:armhf libvdpau-dev:armhf libva-dev:armhf libgtk-3-dev:armhf clang gcc libclang-dev