Bladeren bron

chore: add codegen crate

nathan 2 jaren geleden
bovenliggende
commit
44f9254c0a
50 gewijzigde bestanden met toevoegingen van 151 en 145 verwijderingen
  1. 35 22
      frontend/rust-lib/Cargo.lock
  2. 3 2
      frontend/rust-lib/dart-ffi/Cargo.toml
  3. 1 3
      frontend/rust-lib/dart-ffi/build.rs
  4. 2 2
      frontend/rust-lib/dart-notify/Cargo.toml
  5. 1 3
      frontend/rust-lib/dart-notify/build.rs
  6. 3 2
      frontend/rust-lib/flowy-document/Cargo.toml
  7. 2 4
      frontend/rust-lib/flowy-document/build.rs
  8. 2 2
      frontend/rust-lib/flowy-error/Cargo.toml
  9. 1 3
      frontend/rust-lib/flowy-error/build.rs
  10. 3 2
      frontend/rust-lib/flowy-folder/Cargo.toml
  11. 2 4
      frontend/rust-lib/flowy-folder/build.rs
  12. 3 2
      frontend/rust-lib/flowy-grid/Cargo.toml
  13. 2 4
      frontend/rust-lib/flowy-grid/build.rs
  14. 2 2
      frontend/rust-lib/flowy-net/Cargo.toml
  15. 2 4
      frontend/rust-lib/flowy-net/build.rs
  16. 2 2
      frontend/rust-lib/flowy-user/Cargo.toml
  17. 2 4
      frontend/rust-lib/flowy-user/build.rs
  18. 1 1
      frontend/scripts/makefile/tool.toml
  19. 1 0
      shared-lib/Cargo.toml
  20. 49 0
      shared-lib/flowy-codegen/Cargo.toml
  21. 2 2
      shared-lib/flowy-codegen/src/dart_event/dart_event.rs
  22. 1 1
      shared-lib/flowy-codegen/src/dart_event/event_template.rs
  23. 0 0
      shared-lib/flowy-codegen/src/dart_event/event_template.tera
  24. 0 0
      shared-lib/flowy-codegen/src/dart_event/mod.rs
  25. 0 0
      shared-lib/flowy-codegen/src/flowy_toml.rs
  26. 0 0
      shared-lib/flowy-codegen/src/lib.rs
  27. 3 3
      shared-lib/flowy-codegen/src/protobuf_file/ast.rs
  28. 1 1
      shared-lib/flowy-codegen/src/protobuf_file/mod.rs
  29. 5 5
      shared-lib/flowy-codegen/src/protobuf_file/proto_gen.rs
  30. 2 2
      shared-lib/flowy-codegen/src/protobuf_file/proto_info.rs
  31. 1 1
      shared-lib/flowy-codegen/src/protobuf_file/template/derive_meta/derive_meta.rs
  32. 0 0
      shared-lib/flowy-codegen/src/protobuf_file/template/derive_meta/derive_meta.tera
  33. 0 0
      shared-lib/flowy-codegen/src/protobuf_file/template/derive_meta/mod.rs
  34. 0 0
      shared-lib/flowy-codegen/src/protobuf_file/template/mod.rs
  35. 0 0
      shared-lib/flowy-codegen/src/protobuf_file/template/proto_file/enum.tera
  36. 2 2
      shared-lib/flowy-codegen/src/protobuf_file/template/proto_file/enum_template.rs
  37. 0 0
      shared-lib/flowy-codegen/src/protobuf_file/template/proto_file/mod.rs
  38. 0 0
      shared-lib/flowy-codegen/src/protobuf_file/template/proto_file/struct.tera
  39. 1 1
      shared-lib/flowy-codegen/src/protobuf_file/template/proto_file/struct_template.rs
  40. 1 1
      shared-lib/flowy-codegen/src/util.rs
  41. 1 1
      shared-lib/flowy-derive/Cargo.toml
  42. 2 2
      shared-lib/flowy-derive/src/proto_buf/util.rs
  43. 3 2
      shared-lib/flowy-error-code/Cargo.toml
  44. 1 3
      shared-lib/flowy-error-code/build.rs
  45. 2 1
      shared-lib/flowy-http-model/Cargo.toml
  46. 1 3
      shared-lib/flowy-http-model/build.rs
  47. 0 40
      shared-lib/lib-infra/Cargo.toml
  48. 0 1
      shared-lib/lib-infra/src/lib.rs
  49. 2 2
      shared-lib/lib-ws/Cargo.toml
  50. 1 3
      shared-lib/lib-ws/build.rs

+ 35 - 22
frontend/rust-lib/Cargo.lock

@@ -570,10 +570,10 @@ dependencies = [
  "crossbeam-utils",
  "dart-notify",
  "ffi-support",
+ "flowy-codegen",
  "flowy-derive",
  "flowy-sdk",
  "lib-dispatch",
- "lib-infra",
  "log",
  "once_cell",
  "protobuf",
@@ -588,10 +588,10 @@ version = "0.1.0"
 dependencies = [
  "allo-isolate",
  "bytes",
+ "flowy-codegen",
  "flowy-derive",
  "lazy_static",
  "lib-dispatch",
- "lib-infra",
  "log",
  "protobuf",
 ]
@@ -816,6 +816,29 @@ dependencies = [
  "syn",
 ]
 
+[[package]]
+name = "flowy-codegen"
+version = "0.1.0"
+dependencies = [
+ "cmd_lib",
+ "console",
+ "fancy-regex",
+ "flowy-ast",
+ "itertools",
+ "lazy_static",
+ "log",
+ "phf 0.8.0",
+ "protoc-bin-vendored",
+ "protoc-rust",
+ "serde",
+ "serde_json",
+ "similar",
+ "syn",
+ "tera",
+ "toml",
+ "walkdir",
+]
+
 [[package]]
 name = "flowy-database"
 version = "0.1.0"
@@ -834,8 +857,8 @@ version = "0.1.0"
 dependencies = [
  "dashmap",
  "flowy-ast",
+ "flowy-codegen",
  "lazy_static",
- "lib-infra",
  "proc-macro2",
  "quote",
  "serde_json",
@@ -857,6 +880,7 @@ dependencies = [
  "derive_more",
  "diesel",
  "diesel_derives",
+ "flowy-codegen",
  "flowy-database",
  "flowy-derive",
  "flowy-document",
@@ -891,13 +915,13 @@ name = "flowy-error"
 version = "0.1.0"
 dependencies = [
  "bytes",
+ "flowy-codegen",
  "flowy-database",
  "flowy-derive",
  "flowy-error-code",
  "flowy-sync",
  "http-flowy",
  "lib-dispatch",
- "lib-infra",
  "lib-ot",
  "lib-sqlite",
  "protobuf",
@@ -910,8 +934,8 @@ name = "flowy-error-code"
 version = "0.1.0"
 dependencies = [
  "derive_more",
+ "flowy-codegen",
  "flowy-derive",
- "lib-infra",
  "protobuf",
 ]
 
@@ -923,6 +947,7 @@ dependencies = [
  "dart-notify",
  "diesel",
  "diesel_derives",
+ "flowy-codegen",
  "flowy-database",
  "flowy-derive",
  "flowy-document",
@@ -965,6 +990,7 @@ dependencies = [
  "dashmap",
  "diesel",
  "fancy-regex",
+ "flowy-codegen",
  "flowy-database",
  "flowy-derive",
  "flowy-error",
@@ -1002,6 +1028,7 @@ name = "flowy-http-model"
 version = "0.1.0"
 dependencies = [
  "bytes",
+ "flowy-codegen",
  "flowy-derive",
  "lib-infra",
  "md5",
@@ -1017,6 +1044,7 @@ dependencies = [
  "bytes",
  "config",
  "dashmap",
+ "flowy-codegen",
  "flowy-derive",
  "flowy-document",
  "flowy-error",
@@ -1178,6 +1206,7 @@ dependencies = [
  "diesel_derives",
  "fake",
  "fancy-regex",
+ "flowy-codegen",
  "flowy-database",
  "flowy-derive",
  "flowy-error",
@@ -1740,27 +1769,10 @@ version = "0.1.0"
 dependencies = [
  "bytes",
  "chrono",
- "cmd_lib",
- "console",
- "fancy-regex",
- "flowy-ast",
  "futures-core",
- "itertools",
- "lazy_static",
- "log",
- "phf 0.8.0",
  "pin-project",
- "protoc-bin-vendored",
- "protoc-rust",
  "rand 0.8.5",
- "serde",
- "serde_json",
- "similar",
- "syn",
- "tera",
  "tokio",
- "toml",
- "walkdir",
 ]
 
 [[package]]
@@ -1827,6 +1839,7 @@ version = "0.1.0"
 dependencies = [
  "bytes",
  "dashmap",
+ "flowy-codegen",
  "flowy-derive",
  "futures",
  "futures-channel",

+ 3 - 2
frontend/rust-lib/dart-ffi/Cargo.toml

@@ -37,6 +37,7 @@ http_sync = ["flowy-sdk/http_sync", "flowy-sdk/use_bunyan"]
 openssl_vendored = ["flowy-sdk/openssl_vendored"]
 
 [build-dependencies]
-lib-infra = { path = "../../../shared-lib/lib-infra", features = [
+flowy-codegen= { path = "../../../shared-lib/flowy-codegen", features = [
     "dart",
-] }
+]}
+

+ 1 - 3
frontend/rust-lib/dart-ffi/build.rs

@@ -1,5 +1,3 @@
-use lib_infra::code_gen;
-
 fn main() {
-    code_gen::protobuf_file::gen(env!("CARGO_PKG_NAME"));
+    flowy_codegen::protobuf_file::gen(env!("CARGO_PKG_NAME"));
 }

+ 2 - 2
frontend/rust-lib/dart-notify/Cargo.toml

@@ -16,7 +16,7 @@ flowy-derive = {path = "../../../shared-lib/flowy-derive" }
 lib-dispatch = {path = "../lib-dispatch" }
 
 [features]
-dart = ["lib-infra/dart"]
+dart = ["flowy-codegen/dart"]
 
 [build-dependencies]
-lib-infra = { path = "../../../shared-lib/lib-infra", features = ["proto_gen"] }
+flowy-codegen= { path = "../../../shared-lib/flowy-codegen"}

+ 1 - 3
frontend/rust-lib/dart-notify/build.rs

@@ -1,5 +1,3 @@
-use lib_infra::code_gen;
-
 fn main() {
-    code_gen::protobuf_file::gen(env!("CARGO_PKG_NAME"));
+    flowy_codegen::protobuf_file::gen(env!("CARGO_PKG_NAME"));
 }

+ 3 - 2
frontend/rust-lib/flowy-document/Cargo.toml

@@ -52,10 +52,11 @@ criterion = "0.3"
 rand = "0.8.5"
 
 [build-dependencies]
-lib-infra = { path = "../../../shared-lib/lib-infra", features = [ "proto_gen"] }
+flowy-codegen= { path = "../../../shared-lib/flowy-codegen"}
+
 
 [features]
 sync = []
 cloud_sync = ["sync"]
 flowy_unit_test = ["lib-ot/flowy_unit_test", "flowy-revision/flowy_unit_test"]
-dart = ["lib-infra/dart"]
+dart = ["flowy-codegen/dart"]

+ 2 - 4
frontend/rust-lib/flowy-document/build.rs

@@ -1,9 +1,7 @@
-use lib_infra::code_gen;
-
 fn main() {
     let crate_name = env!("CARGO_PKG_NAME");
-    code_gen::protobuf_file::gen(crate_name);
+    flowy_codegen::protobuf_file::gen(crate_name);
 
     #[cfg(feature = "dart")]
-    code_gen::dart_event::gen(crate_name);
+    flowy_codegen::dart_event::gen(crate_name);
 }

+ 2 - 2
frontend/rust-lib/flowy-error/Cargo.toml

@@ -27,7 +27,7 @@ ot = ["lib-ot"]
 serde = ["serde_json"]
 http_server = ["http-flowy"]
 db = ["flowy-database", "lib-sqlite", "r2d2"]
-dart = ["flowy-error-code/dart", "lib-infra/dart"]
+dart = ["flowy-error-code/dart", "flowy-codegen/dart"]
 
 [build-dependencies]
-lib-infra = { path = "../../../shared-lib/lib-infra", features = ["proto_gen"] }
+flowy-codegen= { path = "../../../shared-lib/flowy-codegen"}

+ 1 - 3
frontend/rust-lib/flowy-error/build.rs

@@ -1,5 +1,3 @@
-use lib_infra::code_gen;
-
 fn main() {
-    code_gen::protobuf_file::gen("flowy-error");
+    flowy_codegen::protobuf_file::gen("flowy-error");
 }

+ 3 - 2
frontend/rust-lib/flowy-folder/Cargo.toml

@@ -42,11 +42,12 @@ flowy-folder = { path = "../flowy-folder", features = ["flowy_unit_test"]}
 flowy-test = { path = "../flowy-test" }
 
 [build-dependencies]
-lib-infra = { path = "../../../shared-lib/lib-infra", features = [ "proto_gen"] }
+flowy-codegen= { path = "../../../shared-lib/flowy-codegen"}
+
 
 [features]
 default = []
 sync = []
 cloud_sync = ["sync"]
 flowy_unit_test = ["lib-ot/flowy_unit_test", "flowy-revision/flowy_unit_test"]
-dart = ["lib-infra/dart"]
+dart = ["flowy-codegen/dart"]

+ 2 - 4
frontend/rust-lib/flowy-folder/build.rs

@@ -1,9 +1,7 @@
-use lib_infra::code_gen;
-
 fn main() {
     let crate_name = env!("CARGO_PKG_NAME");
-    code_gen::protobuf_file::gen(crate_name);
+    flowy_codegen::protobuf_file::gen(crate_name);
 
     #[cfg(feature = "dart")]
-    code_gen::dart_event::gen(crate_name);
+    flowy_codegen::dart_event::gen(crate_name);
 }

+ 3 - 2
frontend/rust-lib/flowy-grid/Cargo.toml

@@ -51,10 +51,11 @@ flowy-test = { path = "../flowy-test" }
 flowy-grid = { path = "../flowy-grid", features = ["flowy_unit_test"]}
 
 [build-dependencies]
-lib-infra = { path = "../../../shared-lib/lib-infra", features = ["proto_gen"] }
+flowy-codegen= { path = "../../../shared-lib/flowy-codegen"}
+
 
 
 [features]
 default = []
-dart = ["lib-infra/dart"]
+dart = ["flowy-codegen/dart"]
 flowy_unit_test = ["flowy-revision/flowy_unit_test"]

+ 2 - 4
frontend/rust-lib/flowy-grid/build.rs

@@ -1,9 +1,7 @@
-use lib_infra::code_gen;
-
 fn main() {
     let crate_name = env!("CARGO_PKG_NAME");
-    code_gen::protobuf_file::gen(crate_name);
+    flowy_codegen::protobuf_file::gen(crate_name);
 
     #[cfg(feature = "dart")]
-    code_gen::dart_event::gen(crate_name);
+    flowy_codegen::dart_event::gen(crate_name);
 }

+ 2 - 2
frontend/rust-lib/flowy-net/Cargo.toml

@@ -42,10 +42,10 @@ nanoid = "0.4.0"
 [features]
 http_server = []
 dart = [
-    "lib-infra/dart",
+    "flowy-codegen/dart",
     "flowy-user/dart",
     "flowy-error/dart",
 ]
 
 [build-dependencies]
-lib-infra = { path = "../../../shared-lib/lib-infra", features = ["proto_gen"] }
+flowy-codegen = { path = "../../../shared-lib/flowy-codegen"}

+ 2 - 4
frontend/rust-lib/flowy-net/build.rs

@@ -1,9 +1,7 @@
-use lib_infra::code_gen;
-
 fn main() {
     let crate_name = env!("CARGO_PKG_NAME");
-    code_gen::protobuf_file::gen(crate_name);
+    flowy_codegen::protobuf_file::gen(crate_name);
 
     #[cfg(feature = "dart")]
-    code_gen::dart_event::gen(crate_name);
+    flowy_codegen::dart_event::gen(crate_name);
 }

+ 2 - 2
frontend/rust-lib/flowy-user/Cargo.toml

@@ -45,7 +45,7 @@ rand_core = "0.6.3"
 rand = "0.8.5"
 
 [features]
-dart = ["lib-infra/dart"]
+dart = ["flowy-codegen/dart"]
 
 [build-dependencies]
-lib-infra = { path = "../../../shared-lib/lib-infra", features = ["proto_gen"] }
+flowy-codegen= { path = "../../../shared-lib/flowy-codegen"}

+ 2 - 4
frontend/rust-lib/flowy-user/build.rs

@@ -1,9 +1,7 @@
-use lib_infra::code_gen;
-
 fn main() {
     let crate_name = env!("CARGO_PKG_NAME");
-    code_gen::protobuf_file::gen(crate_name);
+    flowy_codegen::protobuf_file::gen(crate_name);
 
     #[cfg(feature = "dart")]
-    code_gen::dart_event::gen(crate_name);
+    flowy_codegen::dart_event::gen(crate_name);
 }

+ 1 - 1
frontend/scripts/makefile/tool.toml

@@ -17,7 +17,7 @@ script_runner = "@shell"
 [tasks.rm_macro_build_cache]
 script = [
   """
-    path = canonicalize ../shared-lib/lib-infra/.cache
+    path = canonicalize ../shared-lib/flowy-codegen/.cache
     if is_path_exists ${path}
       rm -rf ${path}
     end

+ 1 - 0
shared-lib/Cargo.toml

@@ -8,6 +8,7 @@ members = [
   "lib-infra",
   "flowy-derive",
   "flowy-ast",
+  "flowy-codegen",
   "flowy-error-code",
   "grid-rev-model",
 ]

+ 49 - 0
shared-lib/flowy-codegen/Cargo.toml

@@ -0,0 +1,49 @@
+[package]
+name = "flowy-codegen"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+log = "0.4.14"
+serde = { version = "1.0", features = ["derive"]}
+serde_json = "1.0"
+flowy-ast = { path = "../flowy-ast"}
+
+cmd_lib = { version = "1", optional = true }
+protoc-rust = { version = "2", optional = true }
+walkdir = { version = "2", optional = true }
+similar = { version = "1.2.2", optional = true }
+syn = { version = "1.0.60", features = ["extra-traits", "parsing", "derive", "full"], optional = true }
+fancy-regex = { version = "0.10.0", optional = true }
+lazy_static = { version = "1.4.0", optional = true }
+tera = { version = "1.5.0", optional = true}
+itertools = { version = "0.10", optional = true }
+phf = { version = "0.8.0", features = ["macros"], optional = true }
+console = {version = "0.14.0", optional = true}
+protoc-bin-vendored = { version = "3.0", optional = true }
+toml = {version = "0.5.8", optional = true}
+
+
+
+
+[features]
+proto_gen = [
+    "similar",
+    "syn",
+    "fancy-regex",
+    "lazy_static",
+    "tera",
+    "itertools",
+    "phf",
+    "walkdir",
+    "console",
+    "toml",
+    "cmd_lib",
+    "protoc-rust",
+    "walkdir",
+    "protoc-bin-vendored",
+]
+dart_event = ["walkdir", "tera", "syn"]
+dart = ["proto_gen", "dart_event"]

+ 2 - 2
shared-lib/lib-infra/src/code_gen/dart_event/dart_event.rs → shared-lib/flowy-codegen/src/dart_event/dart_event.rs

@@ -1,6 +1,6 @@
 use super::event_template::*;
-use crate::code_gen::flowy_toml::{parse_crate_config_from, CrateConfig};
-use crate::code_gen::util::{is_crate_dir, is_hidden, path_string_with_component, read_file};
+use crate::flowy_toml::{parse_crate_config_from, CrateConfig};
+use crate::util::{is_crate_dir, is_hidden, path_string_with_component, read_file};
 use flowy_ast::{event_ast::*, *};
 use std::fs::File;
 use std::io::Write;

+ 1 - 1
shared-lib/lib-infra/src/code_gen/dart_event/event_template.rs → shared-lib/flowy-codegen/src/dart_event/event_template.rs

@@ -1,4 +1,4 @@
-use crate::code_gen::util::get_tera;
+use crate::util::get_tera;
 use tera::Context;
 
 pub struct EventTemplate {

+ 0 - 0
shared-lib/lib-infra/src/code_gen/dart_event/event_template.tera → shared-lib/flowy-codegen/src/dart_event/event_template.tera


+ 0 - 0
shared-lib/lib-infra/src/code_gen/dart_event/mod.rs → shared-lib/flowy-codegen/src/dart_event/mod.rs


+ 0 - 0
shared-lib/lib-infra/src/code_gen/flowy_toml.rs → shared-lib/flowy-codegen/src/flowy_toml.rs


+ 0 - 0
shared-lib/lib-infra/src/code_gen/mod.rs → shared-lib/flowy-codegen/src/lib.rs


+ 3 - 3
shared-lib/lib-infra/src/code_gen/protobuf_file/ast.rs → shared-lib/flowy-codegen/src/protobuf_file/ast.rs

@@ -2,9 +2,9 @@
 #![allow(dead_code)]
 #![allow(unused_imports)]
 #![allow(unused_results)]
-use crate::code_gen::protobuf_file::template::{EnumTemplate, StructTemplate, RUST_TYPE_MAP};
-use crate::code_gen::protobuf_file::{parse_crate_info_from_path, ProtoFile, ProtobufCrateContext};
-use crate::code_gen::util::*;
+use crate::protobuf_file::template::{EnumTemplate, StructTemplate, RUST_TYPE_MAP};
+use crate::protobuf_file::{parse_crate_info_from_path, ProtoFile, ProtobufCrateContext};
+use crate::util::*;
 use fancy_regex::Regex;
 use flowy_ast::*;
 use lazy_static::lazy_static;

+ 1 - 1
shared-lib/lib-infra/src/code_gen/protobuf_file/mod.rs → shared-lib/flowy-codegen/src/protobuf_file/mod.rs

@@ -6,7 +6,7 @@ mod proto_gen;
 mod proto_info;
 mod template;
 
-use crate::code_gen::util::path_string_with_component;
+use crate::util::path_string_with_component;
 use itertools::Itertools;
 use log::info;
 pub use proto_gen::*;

+ 5 - 5
shared-lib/lib-infra/src/code_gen/protobuf_file/proto_gen.rs → shared-lib/flowy-codegen/src/protobuf_file/proto_gen.rs

@@ -2,11 +2,11 @@
 #![allow(dead_code)]
 #![allow(unused_imports)]
 #![allow(unused_results)]
-use crate::code_gen::protobuf_file::ast::parse_protobuf_context_from;
-use crate::code_gen::protobuf_file::proto_info::ProtobufCrateContext;
-use crate::code_gen::protobuf_file::ProtoFile;
-use crate::code_gen::util::*;
-use crate::code_gen::ProtoCache;
+use crate::protobuf_file::ast::parse_protobuf_context_from;
+use crate::protobuf_file::proto_info::ProtobufCrateContext;
+use crate::protobuf_file::ProtoFile;
+use crate::util::*;
+use crate::ProtoCache;
 use std::collections::HashMap;
 use std::fs::File;
 use std::path::Path;

+ 2 - 2
shared-lib/lib-infra/src/code_gen/protobuf_file/proto_info.rs → shared-lib/flowy-codegen/src/protobuf_file/proto_info.rs

@@ -1,6 +1,6 @@
 #![allow(dead_code)]
-use crate::code_gen::flowy_toml::{parse_crate_config_from, CrateConfig, FlowyConfig};
-use crate::code_gen::util::*;
+use crate::flowy_toml::{parse_crate_config_from, CrateConfig, FlowyConfig};
+use crate::util::*;
 use std::fs::OpenOptions;
 use std::io::Write;
 use std::path::PathBuf;

+ 1 - 1
shared-lib/lib-infra/src/code_gen/protobuf_file/template/derive_meta/derive_meta.rs → shared-lib/flowy-codegen/src/protobuf_file/template/derive_meta/derive_meta.rs

@@ -1,4 +1,4 @@
-use crate::code_gen::util::get_tera;
+use crate::util::get_tera;
 use itertools::Itertools;
 use tera::Context;
 

+ 0 - 0
shared-lib/lib-infra/src/code_gen/protobuf_file/template/derive_meta/derive_meta.tera → shared-lib/flowy-codegen/src/protobuf_file/template/derive_meta/derive_meta.tera


+ 0 - 0
shared-lib/lib-infra/src/code_gen/protobuf_file/template/derive_meta/mod.rs → shared-lib/flowy-codegen/src/protobuf_file/template/derive_meta/mod.rs


+ 0 - 0
shared-lib/lib-infra/src/code_gen/protobuf_file/template/mod.rs → shared-lib/flowy-codegen/src/protobuf_file/template/mod.rs


+ 0 - 0
shared-lib/lib-infra/src/code_gen/protobuf_file/template/proto_file/enum.tera → shared-lib/flowy-codegen/src/protobuf_file/template/proto_file/enum.tera


+ 2 - 2
shared-lib/lib-infra/src/code_gen/protobuf_file/template/proto_file/enum_template.rs → shared-lib/flowy-codegen/src/protobuf_file/template/proto_file/enum_template.rs

@@ -1,5 +1,5 @@
-use crate::code_gen::protobuf_file::ast::FlowyEnum;
-use crate::code_gen::util::get_tera;
+use crate::protobuf_file::ast::FlowyEnum;
+use crate::util::get_tera;
 use tera::Context;
 
 pub struct EnumTemplate {

+ 0 - 0
shared-lib/lib-infra/src/code_gen/protobuf_file/template/proto_file/mod.rs → shared-lib/flowy-codegen/src/protobuf_file/template/proto_file/mod.rs


+ 0 - 0
shared-lib/lib-infra/src/code_gen/protobuf_file/template/proto_file/struct.tera → shared-lib/flowy-codegen/src/protobuf_file/template/proto_file/struct.tera


+ 1 - 1
shared-lib/lib-infra/src/code_gen/protobuf_file/template/proto_file/struct_template.rs → shared-lib/flowy-codegen/src/protobuf_file/template/proto_file/struct_template.rs

@@ -1,4 +1,4 @@
-use crate::code_gen::util::get_tera;
+use crate::util::get_tera;
 use flowy_ast::*;
 use phf::phf_map;
 use tera::Context;

+ 1 - 1
shared-lib/lib-infra/src/code_gen/util.rs → shared-lib/flowy-codegen/src/util.rs

@@ -142,7 +142,7 @@ pub fn suffix_relative_to_path(path: &str, base: &str) -> String {
 }
 
 pub fn get_tera(directory: &str) -> Tera {
-    let mut root = format!("{}/src/code_gen/", env!("CARGO_MANIFEST_DIR"));
+    let mut root = format!("{}/src/", env!("CARGO_MANIFEST_DIR"));
     root.push_str(directory);
 
     let root_absolute_path = match std::fs::canonicalize(&root) {

+ 1 - 1
shared-lib/flowy-derive/Cargo.toml

@@ -20,7 +20,7 @@ proc-macro2 = "1.0"
 flowy-ast = { path = "../flowy-ast" }
 lazy_static = {version = "1.4.0"}
 dashmap = "5"
-lib-infra = { path = "../lib-infra", features = ["proto_gen"]}
+flowy-codegen= { path = "../flowy-codegen"}
 serde_json = "1.0"
 walkdir = "2.3.1"
 

+ 2 - 2
shared-lib/flowy-derive/src/proto_buf/util.rs

@@ -1,7 +1,7 @@
 use dashmap::{DashMap, DashSet};
 use flowy_ast::{Ctxt, TyInfo};
+use flowy_codegen::ProtoCache;
 use lazy_static::lazy_static;
-use lib_infra::code_gen::ProtoCache;
 use std::fs::File;
 use std::io::Read;
 use std::sync::atomic::{AtomicBool, Ordering};
@@ -50,7 +50,7 @@ pub fn category_from_str(type_str: String) -> TypeCategory {
         IS_LOAD.store(true, Ordering::SeqCst);
         // Dependents on another crate file is not good, just leave it here.
         // Maybe find another way to read the .cache in the future.
-        let cache_dir = format!("{}/../lib-infra/.cache", env!("CARGO_MANIFEST_DIR"));
+        let cache_dir = format!("{}/../flowy-codegen/.cache", env!("CARGO_MANIFEST_DIR"));
         for path in WalkDir::new(cache_dir)
             .into_iter()
             .filter_map(|e| e.ok())

+ 3 - 2
shared-lib/flowy-error-code/Cargo.toml

@@ -11,7 +11,8 @@ protobuf = {version = "2.18.0"}
 derive_more = {version = "0.99", features = ["display"]}
 
 [build-dependencies]
-lib-infra = { path = "../lib-infra", features = ["proto_gen"] }
+flowy-codegen= { path = "../flowy-codegen"}
+
 
 [features]
-dart = ["lib-infra/dart"]
+dart = ["flowy-codegen/dart"]

+ 1 - 3
shared-lib/flowy-error-code/build.rs

@@ -1,5 +1,3 @@
-use lib_infra::code_gen;
-
 fn main() {
-    code_gen::protobuf_file::gen(env!("CARGO_PKG_NAME"));
+    flowy_codegen::protobuf_file::gen(env!("CARGO_PKG_NAME"));
 }

+ 2 - 1
shared-lib/flowy-http-model/Cargo.toml

@@ -13,5 +13,6 @@ protobuf = {version = "2.18.0"}
 md5 = "0.7.0"
 
 [build-dependencies]
-lib-infra = { path = "../lib-infra", features = ["proto_gen"] }
+flowy-codegen= { path = "../flowy-codegen"}
+
 

+ 1 - 3
shared-lib/flowy-http-model/build.rs

@@ -1,5 +1,3 @@
-use lib_infra::code_gen;
-
 fn main() {
-    code_gen::protobuf_file::gen(env!("CARGO_PKG_NAME"));
+    flowy_codegen::protobuf_file::gen(env!("CARGO_PKG_NAME"));
 }

+ 0 - 40
shared-lib/lib-infra/Cargo.toml

@@ -6,50 +6,10 @@ edition = "2018"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-log = "0.4.14"
 chrono = "0.4.19"
 bytes = { version = "1.0" }
 pin-project = "1.0"
 futures-core = { version = "0.3" }
 tokio = { version = "1.0", features = ["time", "rt"] }
 rand = "0.8.5"
-serde = { version = "1.0", features = ["derive"]}
-serde_json = "1.0"
 
-
-cmd_lib = { version = "1", optional = true }
-protoc-rust = { version = "2", optional = true }
-walkdir = { version = "2", optional = true }
-
-flowy-ast = { path = "../flowy-ast", optional = true}
-similar = { version = "1.2.2", optional = true }
-syn = { version = "1.0.60", features = ["extra-traits", "parsing", "derive", "full"], optional = true }
-fancy-regex = { version = "0.10.0", optional = true }
-lazy_static = { version = "1.4.0", optional = true }
-tera = { version = "1.5.0", optional = true}
-itertools = { version = "0.10", optional = true }
-phf = { version = "0.8.0", features = ["macros"], optional = true }
-console = {version = "0.14.0", optional = true}
-protoc-bin-vendored = { version = "3.0", optional = true }
-toml = {version = "0.5.8", optional = true}
-
-[features]
-proto_gen = [
-    "flowy-ast",
-    "similar",
-    "syn",
-    "fancy-regex",
-    "lazy_static",
-    "tera",
-    "itertools",
-    "phf",
-    "walkdir",
-    "console",
-    "toml",
-    "cmd_lib",
-    "protoc-rust",
-    "walkdir",
-    "protoc-bin-vendored",
-]
-dart_event = ["walkdir", "flowy-ast", "tera", "syn"]
-dart = ["proto_gen", "dart_event"]

+ 0 - 1
shared-lib/lib-infra/src/lib.rs

@@ -1,4 +1,3 @@
-pub mod code_gen;
 pub mod future;
 pub mod ref_map;
 pub mod retry;

+ 2 - 2
shared-lib/lib-ws/Cargo.toml

@@ -28,11 +28,11 @@ parking_lot = "0.12.1"
 dashmap = "5"
 
 [build-dependencies]
-lib-infra = { path = "../lib-infra", features = ["proto_gen"] }
+flowy-codegen= { path = "../flowy-codegen"}
 
 [dev-dependencies]
 tokio = {version = "1", features = ["full"]}
 env_logger = "0.8.2"
 
 [features]
-dart = ["lib-infra/dart"]
+dart = ["flowy-codegen/dart"]

+ 1 - 3
shared-lib/lib-ws/build.rs

@@ -1,5 +1,3 @@
-use lib_infra::code_gen;
-
 fn main() {
-    code_gen::protobuf_file::gen(env!("CARGO_PKG_NAME"));
+    flowy_codegen::protobuf_file::gen(env!("CARGO_PKG_NAME"));
 }