fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.12k stars 283 forks source link

[Bug] code generation can't be compiled with v1.49.0 of multi blocks of modules. #777

Closed dbsxdbsx closed 1 year ago

dbsxdbsx commented 1 year ago

Describe the bug

With frb 1.49.0 on win10, Flutter 3.4.4, the project I test with generation code in justfile:

gen:
    flutter pub get
    flutter_rust_bridge_codegen \
        --rust-input \
        "native/src/rule_api.rs" \
        "native/src/ucci_api.rs" \
        "native/src/util_api.rs" \
        --dart-output \
        "lib/gened_rule_api.dart" \
        "lib/gened_ucci_api.dart" \
        "lib/gened_util_api.dart" \
        --rust-output \
        "native/src/gened_rule_api.rs" \
        "native/src/gened_ucci_api.rs" \
        "native/src/gened_util_api.rs" \
        --class-name \
        "RuleApi" \
        "UcciApi" \
        "UtilApi" \
        --dart-decl-output lib/bridge_definitions.dart \
        --wasm

It is easy to see there are 3 blocks of rust modules. But it seems that it can't generate code successfully with the command just:

[SEVERE] : Header C:\WINDOWS\TEMP\.tmpGHyO0z.h: Total errors/warnings: 2.
[SEVERE] :     C:\WINDOWS\TEMP\.tmpGHyO0z.h:20:16: error: redefinition of 'wire_uint_8_list' [Semantic Issue]
[SEVERE] :     C:\WINDOWS\TEMP\.tmpGHyO0z.h:23:3: error: typedef redefinition with different types ('struct (unnamed struct at C:\WINDOWS\TEMP\.tmpGHyO0z.h:20:16)' vs 'struct wire_uint_8_list') [Semantic Issue]

The command indeed finished, but with the log above during generation, I guess these should not appear, right? Moreover, when checking the generated dart code, say class of RuleApi in gened_rule_api.dart:

class RuleApiImpl implements RuleApi {
  final RuleApiPlatform _platform;
  factory RuleApiImpl(ExternalLibrary dylib) =>
      RuleApiImpl.raw(RuleApiPlatform(dylib));
...
}

It raised an issue on word RuleApi, saying: `"Classes and mixins can only implement other classes and mixins. Try specifying a class or mixin, or remove the name from the list." And there are many other issues: issue frb

Codegen logs with RUST_LOG=debug environment variable

[SEVERE] : Header C:\WINDOWS\TEMP\.tmpGHyO0z.h: Total errors/warnings: 2.
[SEVERE] :     C:\WINDOWS\TEMP\.tmpGHyO0z.h:20:16: error: redefinition of 'wire_uint_8_list' [Semantic Issue]
[SEVERE] :     C:\WINDOWS\TEMP\.tmpGHyO0z.h:23:3: error: typedef redefinition with different types ('struct (unnamed struct at C:\WINDOWS\TEMP\.tmpGHyO0z.h:20:16)' vs 'struct wire_uint_8_list') [Semantic Issue]

To Reproduce

No response

Expected behavior

No response

Generated binding code

No response

OS

win10

Version of flutter_rust_bridge_codegen

1.49.0

Flutter info

Flutter 3.4.4

Version of clang++

No response

Version of ffigen

6.1.2

Additional context

Since the SEVERE ISSUE is related to wire_uint_8_list, and this is the inner type of rust String. I hope someone could test the multi_test with API contains String as input parameter, to see if CI test passed or not.

fzyzcjy commented 1 year ago

I hope someone could test the multi_test with API contains String as input parameter, to see if CI test passed or not.

Feel free to add a test into the CI, so next time nobody can break the feature you have created :) (I always ensure CI passes before merging any PR.)

fzyzcjy commented 1 year ago

As for the bug itself, maybe we can bisect frb so we will know which commit/PR cause the regression

dbsxdbsx commented 1 year ago

As for the bug itself, maybe we can bisect frb so we will know which commit/PR cause the regression

I think it needed to check if the string parameter is ok with the multiple blocks example, first. But I have no idea what is wrong here with the CI test. I just added some API with string parameters.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 1 year ago

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.