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]
Arguments:
[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.
Options:
-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]
--dart-enums-style
The generated Dart enums will have their variant names camelCased
--skip-add-mod-to-lib
Skip automatically adding `mod bridge_generated;` to `lib.rs`
--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
--no-build-runner
Skip running build_runner even when codegen-required code is detected
--no-use-bridge-in-method
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 'ffi.io.dart' if (dart.library.js_interop) 'ffi.web.dart'`.
-v, --verbose
Show debug messages
--wasm
Enable WASM module generation. Requires: --dart-decl-output
--inline-rust
Inline declaration of Rust bridge modules
--skip-deps-check
Skip dependencies check
--dump [<DUMP>...]
A list of data to be dumped. If specified without a value, defaults to all
[possible values: config, ir]
--no-dart3
Disable language features introduced in Dart 3
--keep-going
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
flutter_rust_bridge_serve
$ dart run flutter_rust_bridge_serve --help
flutter_rust_bridge_serve 1.82.6
Develop Rust WASM modules with cross-origin isolation.
USAGE:
flutter_rust_bridge_serve [OPTIONS] [..REST]
flutter_rust_bridge_serve --dart-input <ENTRY> --root <ROOT> [OPTIONS] [..REST]
OPTIONS:
-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
rust_input:
- path/to/api.rs
dart_output:
- 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
flutter_rust_bridge:
rust_input:
- path/to/api.rs
dart_output:
- lib/src/bridge_generated.dart