From 8ad55cd238a20064b987505327cfc9cd11179f41 Mon Sep 17 00:00:00 2001 From: Michal Witek Date: Mon, 27 Feb 2023 20:06:24 +0100 Subject: [PATCH 1/3] Android - init --- content/dev/build/android/_index.en.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/content/dev/build/android/_index.en.md b/content/dev/build/android/_index.en.md index 6f1ac75..03d2830 100644 --- a/content/dev/build/android/_index.en.md +++ b/content/dev/build/android/_index.en.md @@ -4,9 +4,32 @@ weight: 22 --- {{% notice note %}} -This tutorial is based on **Linux**, and supposing you are **familiar** with [Android NDK](https://developer.android.com/ndk/downloads), [Rust](https://rustup.rs/) and [Flutter](https://flutter.dev/). If you are not, please skip. +This tutorial suppose that you are **familiar** with [Android NDK](https://developer.android.com/ndk/downloads), [Rust](https://rustup.rs/) and [Flutter](https://flutter.dev/). If you are not, please skip. Or you can go further but at your own risk {{% /notice %}} +{{% notice note %}} +It is possible to build, run end edit Android version on Windows, but it requires patched `flutter` directory + +By "patched" I mean directory in state like before running `flutter build` on Linux machine. + +Developing RustDesk on **Windows** and **MacOS** instruction is still under active development +{{% /notice %}} + +# Introduction + +Here you will learn how to prepare your environment to such an extent that you will be able to successfully build the application and enable yourself to work on the code through, for example, Android Studio. + +This tutorial is based on latest working workflow file, to ensuree that everything will just works, if you encounter any problems feel free to contact us on our [Discord](https://discord.com/invite/nDceKgxnkV) or by other communication channel. + +# Linux + +## Assumptions +- You are using **Ubuntu 20.04** or later ( due to fact that this tutorial is based on this version) +- You have working internet connection +- You already installed [**Flutter**](https://docs.flutter.dev/get-started/install/linux), [**vcpkg**]() and [**Rust**](https://www.rust-lang.org/tools/install) +- You cloned [RustDesk repository](https://github.com/rustdesk/rustdesk) +- You know what are you doing + ## Build Rust ``` cd From 399744d69f36ef5781fd119d0f7749371fe8a9bf Mon Sep 17 00:00:00 2001 From: "MICHAL\\mwitek" Date: Mon, 27 Feb 2023 20:47:29 +0100 Subject: [PATCH 2/3] up --- content/dev/build/android/_index.en.md | 50 +++++++++++++++----------- content/dev/build/docker/_index.en.md | 1 + 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/content/dev/build/android/_index.en.md b/content/dev/build/android/_index.en.md index 6f1ac75..221a33b 100644 --- a/content/dev/build/android/_index.en.md +++ b/content/dev/build/android/_index.en.md @@ -7,30 +7,40 @@ weight: 22 This tutorial is based on **Linux**, and supposing you are **familiar** with [Android NDK](https://developer.android.com/ndk/downloads), [Rust](https://rustup.rs/) and [Flutter](https://flutter.dev/). If you are not, please skip. {{% /notice %}} -## Build Rust +{{% notice note %}} +It is possible to build RustDesk Android on **Windows** +{{% /notice %}} + +## Generating Bridge + +Due to fact that this project is based on [Flutter Rust Bridge](https://cjycode.com/flutter_rust_bridge/index.html) you should first generate it, you can achieve it by running following commands: + +- Change your current directory into `rustdesk` directory, if you did not have one, clone [RustDesk repository](https://github.com/rustdesk/rustdesk), you can achieve that by running: `git clone https://github.com/rustdesk/rustdesk` + ``` -cd -# For saving your time and our time, we prepared dependent files for you. -wget https://github.com/rustdesk/doc.rustdesk.com/releases/download/console/dep.tar.gz -tar xzf dep.tar.gz -# please use r22b, new NDK has below problem -# https://stackoverflow.com/questions/68873570/how-do-i-fix-ld-error-unable-to-find-library-lgcc-when-cross-compiling-rust -wget https://dl.google.com/android/repository/android-ndk-r22b-linux-x86_64.zip -unzip android-ndk-r22b-linux-x86_64.zip - -# install ffigen and llvm -dart pub global activate ffigen 5.0.1 -# on Ubuntu 18, it is: sudo apt install libclang-9-dev -sudo apt-get install libclang-dev -sudo apt install gcc-multilib - -git clone https://github.com/rustdesk/rustdesk cd rustdesk -rustup target add aarch64-linux-android +``` -cargo install cargo-ndk +You also might be required to install some prerequisites if you are doing this first time +``` +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 +``` +## Installing Flutter Rust Bridge dependencies +At this step you'll install additional dependencies required by [Flutter Rust Bridge](https://cjycode.com/flutter_rust_bridge/index.html) also you'll download flutter dependencies from `pubspec.yaml` file. -VCPKG_ROOT=$HOME/vcpkg ANDROID_NDK_HOME=$HOME/android-ndk-r22b flutter/ndk_arm64.sh +This might take some time depending on your internet connection speed and overall desktop performance +``` +cargo install flutter_rust_bridge_codegen +pushd flutter && flutter pub get && popd +``` + +## Running Flutter Rust Bridge +This step will generate flutter bridge file (`generated_bridge.dart`), you'll use it later + +This should take approximately 2 - 5 minutes +``` +~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart ``` ## Build Flutter diff --git a/content/dev/build/docker/_index.en.md b/content/dev/build/docker/_index.en.md index 5d84c2e..4041a6c 100644 --- a/content/dev/build/docker/_index.en.md +++ b/content/dev/build/docker/_index.en.md @@ -5,6 +5,7 @@ weight: 30 ## How to build with Docker +### This won't work on Windows Begin by cloning the repository and building the docker container: From d6b30bfc9977b4e2f90a02a9beafc47872b95be4 Mon Sep 17 00:00:00 2001 From: "MICHAL\\mwitek" Date: Mon, 27 Feb 2023 22:45:06 +0100 Subject: [PATCH 3/3] final touches --- content/dev/build/android/_index.en.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/content/dev/build/android/_index.en.md b/content/dev/build/android/_index.en.md index c1c2ab0..bf10bed 100644 --- a/content/dev/build/android/_index.en.md +++ b/content/dev/build/android/_index.en.md @@ -94,6 +94,11 @@ At this step you might require some additional dependencies, you could install t sudo apt update -y 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 libclang-dev llvm-dev libclang-10-dev llvm-10-dev pkg-config tree g++ libc6-dev gcc-multilib g++-multilib openjdk-11-jdk-headless ``` +You might also need to activate ffigen +``` +dart pub global activate ffigen 5.0.1 +``` + ### Downloading additional dependencies For this tutorial we prepared some dependencies for you, feel free to use them. It requires `vcpkg` to be installed, in this case at `/opt` @@ -199,7 +204,9 @@ pushd flutter flutter build apk --release --target-platform android-arm64 --split-per-abi ``` {{% notice note %}} -At this step you might see some errors in terminal, this is normal as long as they about kotlin or +At this step you might see some errors in terminal, this is normal as long as they about incompatible version of Kotlin or Runtime JAR files in the classpath should have the same version. + +If your result is `✓ Built build/app` then ignore it {{% /notice %}} ### Optional