AppFlowy/scripts/makefile/pb.toml
2021-06-19 23:41:19 +08:00

50 lines
1.9 KiB
TOML

[tasks.pb_init_setup_dev]
description = "Setup protobuf"
script = [
"""
brew tap dart-lang/dart
brew install dart
pub global activate protoc_plugin
cargo install --force --version 2.18.0 protobuf-codegen
""",
]
script_runner = "@shell"
[tasks.gen_pb_file]
script = [
"""
pb_gen_exec=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/scripts/tool/rust-tool/Cargo.toml
proto_source_file=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/flowy-store/src/entities/
proto_define_dir=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/flowy-protobuf/define
derive_file=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/flowy-ast/src/auto_gen_file/category_from_str.rs
rust_mod_file=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/flowy-protobuf/src/model/mod.rs
flutter_mod_file=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/flutter-lib/packages/flowy_protobuf/lib/all.dart
cargo run --manifest-path ${pb_gen_exec} pb-gen -i=${proto_source_file} --derive_file=${derive_file} --proto_define_dir=${proto_define_dir} --rust_mod_file=${rust_mod_file} --flutter_mod_file=${flutter_mod_file}
""",
]
script_runner = "@shell"
[tasks.gen_rust_pb]
script = [
"""
protoc --rust_out=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/flowy-protobuf/src/model \
--proto_path=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/flowy-protobuf/define \
${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/flowy-protobuf/define/*.proto
""",
]
script_runner = "@shell"
[tasks.gen_dart_pb]
script = [
"""
dart_path=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/flutter-lib/packages/flowy_protobuf/lib/model
pb_define_path=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/flowy-protobuf/define
pb_proto_files=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/flowy-protobuf/define/*.proto
rm -rf ${dart_path}/*
protoc --dart_out=${dart_path} --proto_path=${pb_define_path} ${pb_proto_files}
""",
]
script_runner = "@shell"