rustdesk / doc.rustdesk.com

Document of RustDesk
https://rustdesk.com/docs/
MIT License
356 stars 342 forks source link

building android app: error when running the step flutter_rust_bridge_codegen #213

Open changcw83 opened 1 year ago

changcw83 commented 1 year ago

~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart

2023/07/02 20:13:18 [WARN] Skipping unresolvable module inline (tried /home/victor/rustdesk/src/inline.rs, /home/victor/rustdesk/src/inline/mod.rs, /home/victor/rustdesk/src/ui/inline.rs, /home/victor/rustdesk/src/ui/inline/mod.rs, ) 2023/07/02 20:13:18 [WARN] Skipping unresolvable module version (tried /home/victor/rustdesk/src/version.rs, /home/victor/rustdesk/src/version/mod.rs, /home/victor/rustdesk/src/lib/version.rs, /home/victor/rustdesk/src/lib/version/mod.rs, ) 2023/07/02 20:13:18 [WARN] Skipping unresolvable module bridge_generated (tried /home/victor/rustdesk/src/bridge_generated.rs, /home/victor/rustdesk/src/bridge_generated/mod.rs, /home/victor/rustdesk/src/lib/bridge_generated.rs, /home/victor/rustdesk/src/lib/bridge_generated/mod.rs, ) 2023/07/02 20:13:18 [INFO] Phase: Validate config(s) 2023/07/02 20:13:18 [INFO] Picked config: Opts { rust_input_path: "/home/victor/rustdesk/./src/flutter_ffi.rs", dart_output_path: "/home/victor/rustdesk/./flutter/lib/generated_bridge.dart", dart_decl_output_path: None, c_output_path: ["/tmp/.tmppMgZ83.h"], rust_crate_dir: "/home/victor/rustdesk", rust_output_path: "/home/victor/rustdesk/./src/bridge_generated.rs", class_name: "Rustdesk", dart_format_line_length: 80, dart_enums_style: false, skip_add_mod_to_lib: false, llvm_path: ["/opt/homebrew/opt/llvm", "/usr/local/opt/llvm", "/usr/lib/llvm-9", "/usr/lib/llvm-10", "/usr/lib/llvm-11", "/usr/lib/llvm-12", "/usr/lib/llvm-13", "/usr/lib/llvm-14", "/usr/lib/", "/usr/lib64/", "C:/Program Files/llvm", "C:/msys64/mingw64"], llvm_compiler_opts: "", manifest_path: "/home/victor/rustdesk/Cargo.toml", dart_root: Some("/home/victor/rustdesk/./flutter"), build_runner: true, block_index: BlockIndex(0), skip_deps_check: false, wasm_enabled: false, inline_rust: false, bridge_in_method: true, extra_headers: "", dart3: true } 2023/07/02 20:13:18 [INFO] Phase: Parse source code to AST, then to IR 2023/07/02 20:13:19 [WARN] Skipping unresolvable module inline (tried /home/victor/rustdesk/src/inline.rs, /home/victor/rustdesk/src/inline/mod.rs, /home/victor/rustdesk/src/ui/inline.rs, /home/victor/rustdesk/src/ui/inline/mod.rs, ) 2023/07/02 20:13:19 [WARN] Skipping unresolvable module version (tried /home/victor/rustdesk/src/version.rs, /home/victor/rustdesk/src/version/mod.rs, /home/victor/rustdesk/src/lib/version.rs, /home/victor/rustdesk/src/lib/version/mod.rs, ) 2023/07/02 20:13:19 [WARN] Skipping unresolvable module bridge_generated (tried /home/victor/rustdesk/src/bridge_generated.rs, /home/victor/rustdesk/src/bridge_generated/mod.rs, /home/victor/rustdesk/src/lib/bridge_generated.rs, /home/victor/rustdesk/src/lib/bridge_generated/mod.rs, ) 2023/07/02 20:13:19 [INFO] Phase: Transform IR 2023/07/02 20:13:19 [INFO] Phase: Generate Rust code 2023/07/02 20:13:19 [INFO] Phase: Generate Dart code Flutter 3.10.5 • channel stable • https://github.com/flutter/flutter.git Framework • revision 796c8ef792 (3 weeks ago) • 2023-06-13 15:51:02 -0700 Engine • revision 45f6e00911 Tools • Dart 3.0.5 • DevTools 2.23.1 2023/07/02 20:13:20 [ERROR] fatal: please update version of ffigen in your dev_dependencies. (version >=8.0.0, <9.0.0)

changcw83 commented 1 year ago

edited flutter/pubspec.yaml

This builder requires Dart inputs without syntax errors. However, package:flutter_hbb/generated_bridge.dart (or an existing part) contains the following errors. generated_bridge.dart:896:17: This requires the 'sealed-class' language feature to be enabled. generated_bridge.dart:9016:1: Can't have modifier 'final' here. generated_bridge.dart:9020:1: Can't have modifier 'final' here. And 1 more...

Try fixing the errors and re-running the build.

[INFO] Running build completed, took 2.7s [INFO] Caching finalized dependency graph completed, took 196ms [SEVERE] Failed after 2.9s 2023/07/03 00:32:36 [WARN] command=cd "/home/victor/projects/rustdesk/./flutter" && "sh" "-c" "\"flutter\" \"pub\" \"run\" \"build_runner\" \"build\" \"--delete-conflicting-outputs\" \"--enable-experiment=class-modifiers\"" stdout= stderr= 2023/07/03 00:32:36 [ERROR] fatal: Failed to run build_runner for /home/victor/projects/rustdesk/./flutter:

changcw83 commented 1 year ago

edited flutter/lib/generated_bridge.dart replace every occurrence of sealed class and final class to class

bash -c 'cd flutter; flutter pub run build_runner build --delete-conflicting-outputs --enable-experiment=class-modifiers then you will get success

changcw83 commented 1 year ago

subsequently ran into error when I ran this command

flutter/ndk_arm64.sh

error: failed to run custom build command for libsodium-sys v0.2.7 Caused by: process didn't exit successfully: /home/victor/rustdesk/target/release/build/libsodium-sys-f335dcbaab663a20/build-script-build (exit status: 101) --- stdout cargo:rerun-if-env-changed=SODIUM_LIB_DIR cargo:rerun-if-env-changed=SODIUM_SHARED cargo:rerun-if-env-changed=SODIUM_USE_PKG_CONFIG cargo:rerun-if-env-changed=SODIUM_DISABLE_PIE OPT_LEVEL = Some("3") TARGET = Some("aarch64-linux-android") HOST = Some("x86_64-unknown-linux-gnu") cargo:rerun-if-env-changed=CC_aarch64-linux-android CC_aarch64-linux-android = Some("/home/victor/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/clang") cargo:rerun-if-env-changed=CFLAGS_aarch64-linux-android CFLAGS_aarch64-linux-android = None cargo:rerun-if-env-changed=CFLAGS_aarch64_linux_android CFLAGS_aarch64_linux_android = None cargo:rerun-if-env-changed=TARGET_CFLAGS TARGET_CFLAGS = None cargo:rerun-if-env-changed=CFLAGS CFLAGS = None cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = None DEBUG = Some("false") checking build system type... x86_64-pc-linux-gnu checking host system type... aarch64-unknown-linux-android checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for aarch64-linux-android-strip... no checking for strip... strip checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for gawk... no checking for mawk... mawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether UID '1000' is supported by ustar format... yes checking whether GID '1000' is supported by ustar format... yes checking how to create a ustar tar archive... gnutar checking whether make supports nested variables... (cached) yes checking whether to enable maintainer-specific portions of Makefiles... no checking whether make supports the include directive... yes (GNU style) checking for aarch64-linux-android-gcc... /home/victor/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/clang checking whether the C compiler works... no

--- stderr configure: error: in /home/victor/rustdesk/target/aarch64-linux-android/release/build/libsodium-sys-9ee262636cad44eb/out/source/libsodium': configure: error: C compiler cannot create executables Seeconfig.log' for more details thread 'main' panicked at ' Failed to configure libsodium using cd "/home/victor/rustdesk/target/aarch64-linux-android/release/build/libsodium-sys-9ee262636cad44eb/out/source/libsodium" && CC="/home/victor/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/clang" CFLAGS="-O3 -DANDROID -ffunction-sections -fdata-sections -fPIC --target=aarch64-linux-android -Wall -Wextra" "/home/victor/rustdesk/target/aarch64-linux-android/release/build/libsodium-sys-9ee262636cad44eb/out/source/libsodium/configure" "--prefix=/home/victor/rustdesk/target/aarch64-linux-android/release/build/libsodium-sys-9ee262636cad44eb/out/installed" "--libdir=/home/victor/rustdesk/target/aarch64-linux-android/release/build/libsodium-sys-9ee262636cad44eb/out/installed/lib" "--host=aarch64-linux-android" "--enable-shared=no" CFLAGS=-O3 -DANDROID -ffunction-sections -fdata-sections -fPIC --target=aarch64-linux-android -Wall -Wextra CC=/home/victor/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/clang


Possible missing dependencies. See https://github.com/sodiumoxide/sodiumoxide#cross-compiling


', /home/victor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libsodium-sys-0.2.7/build.rs:257:9 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace warning: build failed, waiting for other jobs to finish... [2023-07-02T17:20:20Z INFO cargo_ndk::cli] If the build failed due to a missing target, you can run this command: [2023-07-02T17:20:20Z INFO cargo_ndk::cli] [2023-07-02T17:20:20Z INFO cargo_ndk::cli] rustup target install aarch64-linux-android