Skip to content

Commit

Permalink
Merge pull request #2335 from Vollbrecht/relative-path
Browse files Browse the repository at this point in the history
  • Loading branch information
fzyzcjy authored Oct 2, 2024
2 parents 6e4e284 + cb742eb commit a313aec
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frb_codegen/src/binary/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ pub(crate) struct CreateOrIntegrateCommandCommonArgs {
#[arg(long)]
pub rust_crate_name: Option<String>,

/// The directory of the generated Rust crate
/// The directory of the generated Rust crate, relative to the project path
#[arg(long)]
pub rust_crate_dir: Option<String>,

Expand Down
10 changes: 8 additions & 2 deletions frb_codegen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ use clap::Parser;
use lib_flutter_rust_bridge_codegen::integration::{CreateConfig, IntegrateConfig};
use lib_flutter_rust_bridge_codegen::utils::logs::configure_opinionated_logging;
use lib_flutter_rust_bridge_codegen::*;
use log::debug;
use log::{debug, warn};
use std::path::Path;

fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
Expand Down Expand Up @@ -52,7 +53,12 @@ fn main_given_cli(cli: Cli) -> anyhow::Result<()> {
}

fn compute_rust_crate_dir(config: &CreateOrIntegrateCommandCommonArgs) -> String {
config.rust_crate_dir.clone().unwrap_or("rust".to_owned())
let rust_crate_dir = config.rust_crate_dir.clone().unwrap_or("rust".to_owned());
let path = Path::new(&rust_crate_dir);
if path.is_absolute() {
warn!("Argument given to --rust-crate-dir was an absolute Path. It will still be interpreted as relative to the new project root.")
}
rust_crate_dir
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion website/docs/generated/_frb-codegen-command-create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Options:
The name of the generated Rust crate
--rust-crate-dir <RUST_CRATE_DIR>
The directory of the generated Rust crate
The directory of the generated Rust crate, relative to the project path
-t, --template <TEMPLATE>
The template type to use to generate the flutter files
Expand Down
2 changes: 1 addition & 1 deletion website/docs/generated/_frb-codegen-command-integrate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Options:
The name of the generated Rust crate
--rust-crate-dir <RUST_CRATE_DIR>
The directory of the generated Rust crate
The directory of the generated Rust crate, relative to the project path
-t, --template <TEMPLATE>
The template type to use for integration. This should usually match the type of flutter project being integrating with
Expand Down

0 comments on commit a313aec

Please sign in to comment.