diff --git a/pilota-build/src/codegen/mod.rs b/pilota-build/src/codegen/mod.rs index 741767dd..09b73899 100644 --- a/pilota-build/src/codegen/mod.rs +++ b/pilota-build/src/codegen/mod.rs @@ -507,9 +507,21 @@ where file.flush().unwrap(); fmt_file(full_path); - stream.push_str( - format!("include!(\"{}\");\n", file_name).as_str(), - ); + match &*this.mode { + Mode::Workspace(_) => { + stream.push_str( + format!("include!(\"{}\");\n", file_name).as_str(), + ); + }, + + Mode::SingleFile { .. } => { + let base_dir_local_path = base_dir.iter().last().unwrap().to_str().unwrap(); + + stream.push_str( + format!("include!(\"{}/{}\");\n", base_dir_local_path, file_name).as_str(), + ); + } + } } else { this.write_item(&mut stream, *def_id, &mut dup) } diff --git a/pilota-build/test_data/thrift_workspace_with_split/output/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/output/Cargo.toml index cf98ef15..f88e4700 100644 --- a/pilota-build/test_data/thrift_workspace_with_split/output/Cargo.toml +++ b/pilota-build/test_data/thrift_workspace_with_split/output/Cargo.toml @@ -1,7 +1,7 @@ [workspace] members = [ "article", - "author", + "author", "common", "image", ]