Command line arguments

Simply add --help to see full documentation. The following is a snapshot when running the command with --help:

$ flutter_rust_bridge_codegen --help
Usage: flutter_rust_bridge_codegen [OPTIONS] --rust-input <RUST_INPUT>... --dart-output <DART_OUTPUT>...
       flutter_rust_bridge_codegen [CONFIG_FILE]

          Path to a YAML config file.
          If present, other options and flags will be ignored. Accepts the same options as the CLI, but uses snake_case keys.

  -r, --rust-input <RUST_INPUT>...
          Path of input Rust code

  -d, --dart-output <DART_OUTPUT>...
          Path of output generated Dart code

      --dart-decl-output <DART_DECL_OUTPUT>
          If provided, generated Dart declaration code to this separate file

  -c, --c-output <C_OUTPUT>
          Output path (including file name) of generated C header, each field corresponding to that of --rust-input

  -e, --extra-c-output-path <EXTRA_C_OUTPUT_PATH>
          Extra output path (excluding file name) of generated C header

      --rust-crate-dir <RUST_CRATE_DIR>...
          Crate directory for your Rust project

      --rust-output <RUST_OUTPUT>...
          Output path of generated Rust code

      --class-name <CLASS_NAME>...
          Generated class name

      --dart-format-line-length <DART_FORMAT_LINE_LENGTH>
          Line length for Dart formatting
          [default: 80]

          The generated Dart enums will have their variant names camelCased

          Skip automatically adding `mod bridge_generated;` to ``

      --llvm-path <LLVM_PATH>...
          Path to the installed LLVM

      --llvm-compiler-opts <LLVM_COMPILER_OPTS>
          LLVM compiler opts

      --dart-root <DART_ROOT>...
          Path to root of Dart project, otherwise inferred from --dart-output

          Skip running build_runner even when codegen-required code is detected

          No use bridge in Model

      --extra-headers <EXTRA_HEADERS>
          extra_headers is used to add dependencies header
          Note that when no_use_bridge_in_method=true and extra_headers is not set, the default is `import '' if (dart.library.html) 'ffi.web.dart'`.

  -v, --verbose
          Show debug messages

          Enable WASM module generation. Requires: --dart-decl-output

          Inline declaration of Rust bridge modules

          Skip dependencies check

      --dump [<DUMP>...]
          A list of data to be dumped. If specified without a value, defaults to all
          [possible values: config, ir]

          Disable language features introduced in Dart 3

          If set, the program will delay error reporting until all codegen operations have completed

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version


$ dart run flutter_rust_bridge_serve --help
flutter_rust_bridge_serve 1.82.4
Develop Rust WASM modules with cross-origin isolation.

	flutter_rust_bridge_serve [OPTIONS] [..REST]
	flutter_rust_bridge_serve --dart-input <ENTRY> --root <ROOT> [OPTIONS] [..REST]

-p, --port=<PORT>             HTTP port to listen to
                              (defaults to "8080")
-r, --root=<ROOT>             Root of the Flutter/Dart output
-c, --crate=<CRATE>           Directory of the crate
                              (defaults to "native")
-d, --dart-input=<ENTRY>      Run "dart compile" with the specified input instead of "flutter build"
-w, --wasm-output=<PKG>       WASM output path
-v, --[no-]verbose            Display more verbose information
    --[no-]relax-coep         Set COEP to credentialless
                              Defaults to true for Flutter
    --[no-]open               Open the webpage in a browser
                              (defaults to on)
    --run-tests               Run tests in headless Chromium
    --release                 Compile in release mode
    --[no-]weak-refs          Enable the weak references proposal
                              Requires wasm-bindgen in path
    --[no-]reference-types    Enable the reference types proposal
                              Requires wasm-bindgen in path
-h, --help                    Print this help message
    --[no-]build              Whether to build the library.
                              (defaults to on)
    --features                A comma-separated list of features to pass to `cargo build`.
    --no-default-features     Whether to disable all features, useful with --features

Configuration files

You can run flutter_rust_bridge_codegen with no arguments, provided any of these files exists in the working directory (in order of priority):

  • .flutter_rust_bridge.yml
  • .flutter_rust_bridge.yaml
  • .flutter_rust_bridge.json

The codegen will try to read a configuration from these files. Otherwise, you can pass to the CLI any YAML file that contains the config. The same arguments from the CLI are accepted, but they will be in snake_case.

# in .flutter_rust_bridge.yml
  - path/to/
  - path/to/bridge_generated.dart

Similarly, if you're calling flutter_rust_bridge_codegen from the root of your Dart project, you can also fill in your config under the flutter_rust_bridge entry in pubspec.yaml:

# put this somewhere in your pubspec.yaml
    - path/to/
    - lib/src/bridge_generated.dart