Skip to content

Commit

Permalink
Add an option to split generated pilota files
Browse files Browse the repository at this point in the history
  • Loading branch information
missingdays committed Oct 18, 2024
1 parent 70e89bd commit 2367a8b
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 15 deletions.
14 changes: 5 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ license = "MIT OR Apache-2.0"
rust-version = "1.80.0"

[workspace.dependencies]
pilota = "0.11"
pilota-build = "0.11"
pilota-thrift-parser = "0.11"
# pilota = { git = "https://github.com/cloudwego/pilota", branch = "main" }
# pilota-build = { git = "https://github.com/cloudwego/pilota", branch = "main" }
# pilota-thrift-parser = { git = "https://github.com/cloudwego/pilota", branch = "main" }
#pilota = "0.11"
#pilota-build = "0.11"
#pilota-thrift-parser = "0.11"
pilota = { git = "https://github.com/cloudwego/pilota", branch = "main" }
pilota-build = { git = "https://github.com/cloudwego/pilota", branch = "main" }
pilota-thrift-parser = { git = "https://github.com/cloudwego/pilota", branch = "main" }

motore = "0.4"
# motore = { git = "https://github.com/cloudwego/motore", branch = "main" }
Expand Down
1 change: 1 addition & 0 deletions examples/volo-gen/volo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ entries:
thrift:
filename: thrift_gen.rs
protocol: thrift
split_generated_files: true
services:
- idl:
source: local
Expand Down
10 changes: 10 additions & 0 deletions volo-build/src/config_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ impl InnerBuilder {
}
}

pub fn split_generated_files(self, split_generated_files: bool) -> Self {
match self {
InnerBuilder::Protobuf(inner) => {
InnerBuilder::Protobuf(inner.split_generated_files(split_generated_files))
}
InnerBuilder::Thrift(inner) => InnerBuilder::Thrift(inner.split_generated_files(split_generated_files)),
}
}

pub fn common_crate_name(self, name: FastStr) -> Self {
match self {
InnerBuilder::Protobuf(inner) => InnerBuilder::Protobuf(inner.common_crate_name(name)),
Expand Down Expand Up @@ -192,6 +201,7 @@ impl ConfigBuilder {
.add_services(service_builders)
.ignore_unused(!entry.common_option.touch_all)
.special_namings(entry.common_option.special_namings)
.split_generated_files(entry.common_option.split_generated_files)
.dedup(entry.common_option.dedups)
.write()?;

Expand Down
8 changes: 8 additions & 0 deletions volo-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ impl<MkB, Parser> Builder<MkB, Parser> {
self
}

pub fn split_generated_files(
mut self,
split_generated_files: bool
) -> Self {
self.pilota_builder = self.pilota_builder.split_generated_files(split_generated_files);
self
}

pub fn special_namings(mut self, namings: impl IntoIterator<Item = FastStr>) -> Self {
self.pilota_builder = self.pilota_builder.special_namings(namings);
self
Expand Down
2 changes: 2 additions & 0 deletions volo-build/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub struct CommonOption {
pub dedups: Vec<FastStr>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub special_namings: Vec<FastStr>,
#[serde(default, skip_serializing_if = "is_false")]
pub split_generated_files: bool,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down
6 changes: 6 additions & 0 deletions volo-build/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ where
.dedup(config.common_option.dedups)
.special_namings(config.common_option.special_namings)
.common_crate_name(config.common_crate_name)
.split_generated_files(config.common_option.split_generated_files)
.pilota_builder
.compile_with_config(idl_services, pilota_build::Output::Workspace(work_dir));
}
Expand Down Expand Up @@ -148,6 +149,11 @@ where
self
}

pub fn split_generated_files(mut self, split_generated_files: bool) -> Self {
self.pilota_builder = self.pilota_builder.split_generated_files(split_generated_files);
self
}

pub fn touch(
mut self,
items: impl IntoIterator<Item = (PathBuf, Vec<impl Into<String>>)>,
Expand Down

0 comments on commit 2367a8b

Please sign in to comment.