Closed TBG-FR closed 7 months ago
Hi! Thanks for opening your first issue here! :smile:
Hi, thanks! I guess currently this is not supported yet (since this has not been proposed before IIRC), but it may not be hard (e.g. maybe it is something in https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_codegen/src/library/commands/cargo_expand.rs#L119, or maybe something in the module parsing logic).
So the first thing is, could you please paste the debug logs (RUST_LOG=debug flutter_rust_bridge_codegen generate
) - then it would be easier to see which line has this error.
Thanks for clarifying that, and for pointing out the right code !
Here are the debug logs (I just removed the code output that makes it huge)
[2024-03-22T16:37:00.868Z DEBUG /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.0.0-dev.28/src/main.rs:24] cli=Cli { verbose: false, command: Generate(GenerateCommandArgs { watch: false, primary: GenerateCommandArgsPrimary { config_file: Some("flutter_rust_bridge.yaml"), rust_input: None, dart_output: None, c_output: None, duplicated_c_output: None, rust_root: None, rust_output: None, dart_entrypoint_class_name: None, dart_format_line_length: None, no_dart_enums_style: false, no_add_mod_to_lib: false, llvm_path: None, llvm_compiler_opts: None, dart_root: None, no_build_runner: false, extra_headers: None, no_web: false, no_deps_check: false, default_external_library_loader_web_prefix: None, no_dart3: false, full_dep: false, local: false, dump: None, dump_all: false } }) }
[2024-03-22T16:37:00.868Z DEBUG /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.0.0-dev.28/src/binary/commands_parser.rs:13] compute_codegen_config: mode=config_file
[2024-03-22T16:37:00.869Z DEBUG /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.0.0-dev.28/src/library/codegen/config/config_parser.rs:45] Found config file flutter_rust_bridge.yaml
[2024-03-22T16:37:00.869Z DEBUG /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.0.0-dev.28/src/library/codegen/mod.rs:24] config=Config { base_dir: Some(""), rust_input: "../src/**/*.rs", dart_output: "lib/src/rust", c_output: None, duplicated_c_output: None, rust_root: None, rust_output: None, dart_entrypoint_class_name: None, dart_format_line_length: None, dart_enums_style: None, add_mod_to_lib: None, llvm_path: None, llvm_compiler_opts: None, dart_root: None, build_runner: None, extra_headers: None, web: None, deps_check: None, dart3: None, full_dep: None, local: None, default_external_library_loader_web_prefix: None, dump: None, dump_all: None } meta_config=MetaConfig { watch: false }
[2024-03-22T16:37:00.869Z DEBUG /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.0.0-dev.28/src/library/codegen/config/internal_config_parser.rs:42] InternalConfig.parse base_dir="/app/flutter"
[2024-03-22T16:37:02.326Z DEBUG /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.0.0-dev.28/src/library/codegen/mod.rs:27] internal_config=InternalConfig { controller: ControllerInternalConfig { watch: false, watching_paths: ["/app/src"], exclude_paths: ["/app/src/frb_generated.rs", "/app/src/frb_generated.io.rs", "/app/src/frb_generated.web.rs"], max_count: None }, preparer: PreparerInternalConfig { dart_root: "/app/flutter", deps_check: true, needs_ffigen: false }, parser: ParserInternalConfig { rust_input_path_pack: RustInputPathPack { rust_input_paths: ["/app/src/auth_2fa.rs", "/app/src/cli.rs", "/app/src/client/file_trait.rs", "/app/src/client/helper.rs", "/app/src/client/io_loop.rs", "/app/src/client.rs", "/app/src/clipboard_file.rs", "/app/src/common.rs", "/app/src/core_main.rs", "/app/src/custom_server.rs", "/app/src/flutter.rs", "/app/src/flutter_ffi.rs", "/app/src/hbbs_http/account.rs", "/app/src/hbbs_http/record_upload.rs", "/app/src/hbbs_http/sync.rs", "/app/src/hbbs_http.rs", "/app/src/ipc.rs", "/app/src/keyboard.rs", "/app/src/lan.rs", "/app/src/lang/ar.rs", "/app/src/lang/bg.rs", "/app/src/lang/ca.rs", "/app/src/lang/cn.rs", "/app/src/lang/cs.rs", "/app/src/lang/da.rs", "/app/src/lang/de.rs", "/app/src/lang/el.rs", "/app/src/lang/en.rs", "/app/src/lang/eo.rs", "/app/src/lang/es.rs", "/app/src/lang/et.rs", "/app/src/lang/fa.rs", "/app/src/lang/fr.rs", "/app/src/lang/he.rs", "/app/src/lang/hu.rs", "/app/src/lang/id.rs", "/app/src/lang/it.rs", "/app/src/lang/ja.rs", "/app/src/lang/ko.rs", "/app/src/lang/kz.rs", "/app/src/lang/lt.rs", "/app/src/lang/lv.rs", "/app/src/lang/nb.rs", "/app/src/lang/nl.rs", "/app/src/lang/pl.rs", "/app/src/lang/pt_PT.rs", "/app/src/lang/ptbr.rs", "/app/src/lang/ro.rs", "/app/src/lang/ru.rs", "/app/src/lang/sk.rs", "/app/src/lang/sl.rs", "/app/src/lang/sq.rs", "/app/src/lang/sr.rs", "/app/src/lang/sv.rs", "/app/src/lang/template.rs", "/app/src/lang/th.rs", "/app/src/lang/tr.rs", "/app/src/lang/tw.rs", "/app/src/lang/ua.rs", "/app/src/lang/vn.rs", "/app/src/lang.rs", "/app/src/librustdesk.rs", "/app/src/main.rs", "/app/src/naming.rs", "/app/src/platform/delegate.rs", "/app/src/platform/linux.rs", "/app/src/platform/linux_desktop_manager.rs", "/app/src/platform/macos.rs", "/app/src/platform/windows.rs", "/app/src/plugin/callback_ext.rs", "/app/src/plugin/callback_msg.rs", "/app/src/plugin/config.rs", "/app/src/plugin/desc.rs", "/app/src/plugin/errno.rs", "/app/src/plugin/ipc.rs", "/app/src/plugin/manager.rs", "/app/src/plugin/native.rs", "/app/src/plugin/native_handlers/macros.rs", "/app/src/plugin/native_handlers/session.rs", "/app/src/plugin/native_handlers/ui.rs", "/app/src/plugin/plog.rs", "/app/src/plugin/plugins.rs", "/app/src/port_forward.rs", "/app/src/privacy_mode/win_exclude_from_capture.rs", "/app/src/privacy_mode/win_input.rs", "/app/src/privacy_mode/win_mag.rs", "/app/src/privacy_mode/win_topmost_window.rs", "/app/src/privacy_mode/win_virtual_display.rs", "/app/src/privacy_mode.rs", "/app/src/rendezvous_mediator.rs", "/app/src/server/audio_service.rs", "/app/src/server/clipboard_service.rs", "/app/src/server/connection.rs", "/app/src/server/dbus.rs", "/app/src/server/display_service.rs", "/app/src/server/input_service.rs", "/app/src/server/portable_service.rs", "/app/src/server/rdp_input.rs", "/app/src/server/service.rs", "/app/src/server/uinput.rs", "/app/src/server/video_qos.rs", "/app/src/server/video_service.rs", "/app/src/server/wayland.rs", "/app/src/server.rs", "/app/src/tray.rs", "/app/src/ui/cm.rs", "/app/src/ui/remote.rs", "/app/src/ui.rs", "/app/src/ui_cm_interface.rs", "/app/src/ui_interface.rs", "/app/src/ui_session_interface.rs", "/app/src/version.rs", "/app/src/virtual_display_manager.rs"] }, rust_crate_dir: "/app", force_codec_mode_pack: Some(CodecModePack { dart2rust: Pde, rust2dart: Pde }), default_rust_opaque_codec: Moi }, generator: GeneratorInternalConfig { api_dart: GeneratorApiDartInternalConfig { dart_enums_style: true, dart3: true, dart_decl_base_output_path: "/app/flutter/lib/src/rust", dart_entrypoint_class_name: "RustLib" }, wire: GeneratorWireInternalConfig { dart: GeneratorWireDartInternalConfig { has_ffigen: false, web_enabled: true, 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: "", dart_root: "/app/flutter", extra_headers: "", dart_impl_output_path: TargetOrCommonMap { common: "/app/flutter/lib/src/rust/frb_generated.dart", io: "/app/flutter/lib/src/rust/frb_generated.io.dart", web: "/app/flutter/lib/src/rust/frb_generated.web.dart" }, dart_output_class_name_pack: DartOutputClassNamePack { entrypoint_class_name: "RustLib", api_class_name: "RustLibApi", api_impl_class_name: "RustLibApiImpl", api_impl_platform_class_name: "RustLibApiImplPlatform", wire_class_name: "RustLibWire", wasm_module_name: "RustLibWasmModule" }, default_external_library_loader: GeneratorWireDartDefaultExternalLibraryLoaderInternalConfig { stem: "librustdesk", io_directory: "../target/release/", web_prefix: "pkg/" }, c_symbol_prefix: "frbgen_flutter_hbb_" }, rust: GeneratorWireRustInternalConfig { rust_input_path_pack: RustInputPathPack { rust_input_paths: ["/app/src/auth_2fa.rs", "/app/src/cli.rs", "/app/src/client/file_trait.rs", "/app/src/client/helper.rs", "/app/src/client/io_loop.rs", "/app/src/client.rs", "/app/src/clipboard_file.rs", "/app/src/common.rs", "/app/src/core_main.rs", "/app/src/custom_server.rs", "/app/src/flutter.rs", "/app/src/flutter_ffi.rs", "/app/src/hbbs_http/account.rs", "/app/src/hbbs_http/record_upload.rs", "/app/src/hbbs_http/sync.rs", "/app/src/hbbs_http.rs", "/app/src/ipc.rs", "/app/src/keyboard.rs", "/app/src/lan.rs", "/app/src/lang/ar.rs", "/app/src/lang/bg.rs", "/app/src/lang/ca.rs", "/app/src/lang/cn.rs", "/app/src/lang/cs.rs", "/app/src/lang/da.rs", "/app/src/lang/de.rs", "/app/src/lang/el.rs", "/app/src/lang/en.rs", "/app/src/lang/eo.rs", "/app/src/lang/es.rs", "/app/src/lang/et.rs", "/app/src/lang/fa.rs", "/app/src/lang/fr.rs", "/app/src/lang/he.rs", "/app/src/lang/hu.rs", "/app/src/lang/id.rs", "/app/src/lang/it.rs", "/app/src/lang/ja.rs", "/app/src/lang/ko.rs", "/app/src/lang/kz.rs", "/app/src/lang/lt.rs", "/app/src/lang/lv.rs", "/app/src/lang/nb.rs", "/app/src/lang/nl.rs", "/app/src/lang/pl.rs", "/app/src/lang/pt_PT.rs", "/app/src/lang/ptbr.rs", "/app/src/lang/ro.rs", "/app/src/lang/ru.rs", "/app/src/lang/sk.rs", "/app/src/lang/sl.rs", "/app/src/lang/sq.rs", "/app/src/lang/sr.rs", "/app/src/lang/sv.rs", "/app/src/lang/template.rs", "/app/src/lang/th.rs", "/app/src/lang/tr.rs", "/app/src/lang/tw.rs", "/app/src/lang/ua.rs", "/app/src/lang/vn.rs", "/app/src/lang.rs", "/app/src/librustdesk.rs", "/app/src/main.rs", "/app/src/naming.rs", "/app/src/platform/delegate.rs", "/app/src/platform/linux.rs", "/app/src/platform/linux_desktop_manager.rs", "/app/src/platform/macos.rs", "/app/src/platform/windows.rs", "/app/src/plugin/callback_ext.rs", "/app/src/plugin/callback_msg.rs", "/app/src/plugin/config.rs", "/app/src/plugin/desc.rs", "/app/src/plugin/errno.rs", "/app/src/plugin/ipc.rs", "/app/src/plugin/manager.rs", "/app/src/plugin/native.rs", "/app/src/plugin/native_handlers/macros.rs", "/app/src/plugin/native_handlers/session.rs", "/app/src/plugin/native_handlers/ui.rs", "/app/src/plugin/plog.rs", "/app/src/plugin/plugins.rs", "/app/src/port_forward.rs", "/app/src/privacy_mode/win_exclude_from_capture.rs", "/app/src/privacy_mode/win_input.rs", "/app/src/privacy_mode/win_mag.rs", "/app/src/privacy_mode/win_topmost_window.rs", "/app/src/privacy_mode/win_virtual_display.rs", "/app/src/privacy_mode.rs", "/app/src/rendezvous_mediator.rs", "/app/src/server/audio_service.rs", "/app/src/server/clipboard_service.rs", "/app/src/server/connection.rs", "/app/src/server/dbus.rs", "/app/src/server/display_service.rs", "/app/src/server/input_service.rs", "/app/src/server/portable_service.rs", "/app/src/server/rdp_input.rs", "/app/src/server/service.rs", "/app/src/server/uinput.rs", "/app/src/server/video_qos.rs", "/app/src/server/video_service.rs", "/app/src/server/wayland.rs", "/app/src/server.rs", "/app/src/tray.rs", "/app/src/ui/cm.rs", "/app/src/ui/remote.rs", "/app/src/ui.rs", "/app/src/ui_cm_interface.rs", "/app/src/ui_interface.rs", "/app/src/ui_session_interface.rs", "/app/src/version.rs", "/app/src/virtual_display_manager.rs"] }, rust_crate_dir: "/app", web_enabled: true, rust_output_path: TargetOrCommonMap { common: "/app/src/frb_generated.rs", io: "/app/src/frb_generated.io.rs", web: "/app/src/frb_generated.web.rs" }, c_symbol_prefix: "frbgen_flutter_hbb_", has_ffigen: false, default_stream_sink_codec: Sse, default_rust_opaque_codec: Moi }, c: GeneratorWireCInternalConfig { enable: false, rust_crate_dir: "/app", rust_output_path: TargetOrCommonMap { common: "/app/src/frb_generated.rs", io: "/app/src/frb_generated.io.rs", web: "/app/src/frb_generated.web.rs" }, c_output_path: None, c_symbol_prefix: "frbgen_flutter_hbb_" } } }, polisher: PolisherInternalConfig { duplicated_c_output_path: [], dart_format_line_length: 80, add_mod_to_lib: true, build_runner: true, web_enabled: true, dart_root: "/app/flutter", rust_crate_dir: "/app", rust_output_path: TargetOrCommonMap { common: "/app/src/frb_generated.rs", io: "/app/src/frb_generated.io.rs", web: "/app/src/frb_generated.web.rs" }, c_output_path: None, enable_auto_upgrade: true }, dumper: DumperInternalConfig { dump_contents: [], dump_directory: "/app/target/frb_dump" } }
[2024-03-22T16:37:02.327Z DEBUG /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.0.0-dev.28/src/library/utils/dart_repository/dart_repo.rs:22] Guessing toolchain the runner is run into
[2024-03-22T16:37:02.331Z DEBUG /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.0.0-dev.28/src/library/commands/command_runner.rs:129] execute command: bin=sh args="-c \"flutter\" \"--version\"" current_dir=None cmd="sh" "-c" "\"flutter\" \"--version\""
[2024-03-22T16:37:02.567Z DEBUG /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.0.0-dev.28/src/library/commands/command_runner.rs:140] command="sh" "-c" "\"flutter\" \"--version\"" stdout=Flutter 3.19.0 β’ channel [user-branch] β’ unknown source
Framework β’ revision bae5e49bc2 (5 weeks ago) β’ 2024-02-13 17:46:18 -0800
Engine β’ revision 04817c99c9
Tools β’ Dart 3.3.0 β’ DevTools 2.31.1
stderr=
[2024-03-22T16:37:02.568Z DEBUG /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.0.0-dev.28/src/library/codegen/parser/reader.rs:22] read_rust_file rust_file_path="/app/src/auth_2fa.rs" module=Some("auth_2fa")
[2024-03-22T16:37:02.569Z DEBUG /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.0.0-dev.28/src/library/commands/cargo_expand.rs:31] CachedCargoExpand execute manifest_dir= rust_crate_dir="/app"
[2024-03-22T16:37:02.569Z DEBUG /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.0.0-dev.28/src/library/commands/cargo_expand.rs:117] Running cargo expand in '"/app"'
[2024-03-22T16:37:02.569Z DEBUG /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.0.0-dev.28/src/library/commands/command_runner.rs:129] execute command: bin=cargo args="expand --lib --theme=none --ugly" current_dir=Some("/app") cmd=cd "/app" && RUSTFLAGS="--cfg frb_expand" "cargo" "expand" "--lib" "--theme=none" "--ugly"
[2024-03-22T16:37:05.374Z DEBUG /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.0.0-dev.28/src/library/commands/command_runner.rs:140] command=cd "/app" && RUSTFLAGS="--cfg frb_expand" "cargo" "expand" "--lib" "--theme=none" "--ugly" stdout=#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
[...]
stderr= Updating git repository `https://github.com/rustdesk-org/reqwest`
warning: unused import: `self::vp9e_temporal_layering_mode as VP9E_TEMPORAL_LAYERING_MODE`
--> /app/target/debug/build/scrap-4e0f3f00e845be69/out/vpx_ffi.rs:823:9
|
823 | pub use self::vp9e_temporal_layering_mode as VP9E_TEMPORAL_LAYERING_MODE;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
Checking rustdesk v1.2.4 (/app)
warning: unused imports: `BufReader`, `fs::File`
--> src/platform/linux.rs:20:5
|
20 | fs::File,
| ^^^^^^^^
21 | io::{BufRead, BufReader, Write},
| ^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused import: `anyhow`
--> src/client.rs:33:14
|
33 | anyhow::{anyhow, Context},
| ^^^^^^
warning: unused import: `HARD_SETTINGS`
--> src/ui_interface.rs:7:65
|
7 | self, Config, LocalConfig, PeerConfig, CONNECT_TIMEOUT, HARD_SETTINGS, RENDEZVOUS_PORT,
| ^^^^^^^^^^^^^
warning: unused imports: `MOUSE_BUTTON_LEFT`, `MOUSE_TYPE_DOWN`, `MOUSE_TYPE_UP`, `MOUSE_TYPE_WHEEL`
--> src/ui_session_interface.rs:3:13
|
3 | input::{MOUSE_BUTTON_LEFT, MOUSE_TYPE_DOWN, MOUSE_TYPE_UP, MOUSE_TYPE_WHEEL},
| ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
Finished dev [unoptimized + debuginfo] target(s) in 2.60s
[2024-03-22T16:37:05.451Z DEBUG /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.0.0-dev.28/src/library/codegen/parser/reader.rs:22] read_rust_file rust_file_path="/app/src/cli.rs" module=Some("cli")
[2024-03-22T16:37:05.451Z DEBUG /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.0.0-dev.28/src/library/commands/cargo_expand.rs:31] CachedCargoExpand execute manifest_dir= rust_crate_dir="/app"
[2.9s] Parse
βββ [2.9s] Run cargo expand Error: Module not found: cli
You are welcome! It is weird it does not output full stack trace... What if adding RUST_BACKTRACE=1
?
Anyway I guess it is because https://github.com/fzyzcjy/flutter_rust_bridge/blob/9e1a40c06920fd48191d9ed5785ff99ea42dca3b/frb_codegen/src/library/commands/cargo_expand.rs#L74
Without stack trace, I guess our https://github.com/fzyzcjy/flutter_rust_bridge/tree/9e1a40c06920fd48191d9ed5785ff99ea42dca3b/frb_codegen/src/library/codegen/parser/source_graph should be modified to understand the conditional compilation.
Feel free to PR for this! Alternatively, I will work on it in the next batch (hopefully within a week, ping me if I do not)
I found it quite weird too... RUST_LOG=debug
helped me to fix my setup earlier but now it's not giving my any more clues
Here's the result with RUST_BACKTRACE=1
[3.0s] Parse
βββ [3.0s] Run cargo expand
Error: Module not found: cli
Stack backtrace:
0: lib_flutter_rust_bridge_codegen::library::commands::cargo_expand::CachedCargoExpand::execute
1: lib_flutter_rust_bridge_codegen::library::codegen::parser::reader::CachedRustReader::read_rust_file
2: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
3: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
4: core::iter::adapters::try_process
5: lib_flutter_rust_bridge_codegen::library::codegen::parser::parse
6: lib_flutter_rust_bridge_codegen::library::codegen::generate::{{closure}}
7: lib_flutter_rust_bridge_codegen::library::codegen::generate
8: flutter_rust_bridge_codegen::main
9: std::sys_common::backtrace::__rust_begin_short_backtrace
10: std::rt::lang_start::{{closure}}
11: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:284:13
std::panicking::try::do_call
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
std::panicking::try
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
std::panic::catch_unwind
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
std::rt::lang_start_internal::{{closure}}
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:48
std::panicking::try::do_call
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
std::panicking::try
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
std::panic::catch_unwind
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
std::rt::lang_start_internal
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:20
12: std::rt::lang_start
13: <unknown>
14: __libc_start_main
15: _start
Thanks for pointing out the right code section, again ! I'd love to contribute/PR for this, but I'm afraid my lack of Rust knowledge will not help... I'll check the code and see if I feel I can do it, and will tell you !
Thanks a lot anyway π
You are welcome! I checked it a little bit, and one easiest way to workaround it may be that, at https://github.com/fzyzcjy/flutter_rust_bridge/blob/9e1a40c06920fd48191d9ed5785ff99ea42dca3b/frb_codegen/src/library/commands/cargo_expand.rs#L74, instead of immediately fail, we just log and return an empty string. After the change, just submit PR and see whether CI is happy about that. I guess this is a good-first-issue if you want to play with Rust a little bit - no super hard Rust things.
Sorry I have been taken by other tasks in the meantime π Thanks for adding that feature π
It's OK, you are welcome!
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.
Describe the bug
Hello there ! First of all, congratulations for making such an amazing tool, and a very clear and useful documentation π
I am trying to update a project using it, and I am facing an issue : inside the Rust code, some modules are imported/selected conditionnally, based on the
target_os
or somefeature
. So when I runflutter_rust_bridge_codegen generate
, it fails (Error when running code generator: Module not found: xxxx
) because it expects to find all modules, and some of them are not published because theirpub mod xxxx
instruction is right after a#[cfg(all(feature = "flutter", feature = "plugin_framework"))]
instructionHow can I provide a
target_os
and/or somefeature
to the generator to fix this ? Thanks in advance !PS : I am a complete newbie in Rust π€‘ So feel free to tell me if my understanding is wrong !
Steps to reproduce
Here's the repo of the project
git clone https://github.com/rustdesk/rustdesk
, where I upgradedflutter_rust_bridge
from v1 to v2Inside
flutter
directory, I ranflutter_rust_bridge_codegen integrate
I then renamed
lib.rs
tolibrustdesk.rs
and modified bothCargo.toml
andflutter_rust_bridge.yaml
Cargo.toml
flutter/flutter_rust_bridge.yaml
I ran
flutter_rust_bridge_codegen generate --config-file flutter_rust_bridge.yaml
to generated dart files and got error about missing modules, though these modules exist (file path displayed in DEBUG is correct) and if I uncomment#cfg
instructions, it works (until giving me an error for another module which as a#cfg
instruction, and so on)Logs
Before commenting the line
#[cfg(feature = "cli")]
beforepub mod cli;
After commenting the line
#[cfg(feature = "cli")]
beforepub mod cli;
Expected behavior
Avoid all
Error when running code generator: Module not found
without having to comment every#cfg
line in the rust codeGenerated binding code
No response
OS
Linux (Debian WSL)
Version of
flutter_rust_bridge_codegen
2.0.0-dev.28
Flutter info
Version of
clang++
1:14.0-55.7~deb12u1
Additional context
No response