mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
ci: add logs
This commit is contained in:
parent
837666d36d
commit
832db73410
@ -25,6 +25,7 @@ brew install protobuf
|
||||
|
||||
echo "Install protoc_plugin (Dart)"
|
||||
dart pub global activate protoc_plugin
|
||||
export PATH="$PATH":"$HOME/.pub-cache/bin"
|
||||
"""
|
||||
script_runner = "@shell"
|
||||
|
||||
@ -34,6 +35,7 @@ sudo apt-get install protobuf-compiler
|
||||
|
||||
echo "Install protoc_plugin (Dart)"
|
||||
dart pub global activate protoc_plugin
|
||||
export PATH="$PATH":"$HOME/.pub-cache/bin"
|
||||
"""
|
||||
script_runner = "@shell"
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
#![allow(clippy::all)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_attributes)]
|
||||
#![allow(dead_code)]
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::process::Command;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
pub fn gen(name: &str, root: &str) {
|
||||
@ -19,6 +22,7 @@ pub fn gen(name: &str, root: &str) {
|
||||
file_names.push(file_name);
|
||||
}
|
||||
}
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
|
||||
#[cfg(feature = "dart")]
|
||||
gen_pb_for_dart(name, root, &paths, &file_names);
|
||||
@ -32,7 +36,6 @@ pub fn gen(name: &str, root: &str) {
|
||||
}
|
||||
|
||||
#[cfg(feature = "dart")]
|
||||
#[allow(dead_code)]
|
||||
fn gen_pb_for_dart(name: &str, root: &str, paths: &Vec<String>, file_names: &Vec<String>) {
|
||||
let output = format!(
|
||||
"{}/{}/{}",
|
||||
@ -43,6 +46,10 @@ fn gen_pb_for_dart(name: &str, root: &str, paths: &Vec<String>, file_names: &Vec
|
||||
if !std::path::Path::new(&output).exists() {
|
||||
std::fs::create_dir_all(&output).unwrap();
|
||||
}
|
||||
check_pb_compiler();
|
||||
|
||||
check_pb_dart_plugin();
|
||||
|
||||
paths.iter().for_each(|path| {
|
||||
if cmd_lib::run_cmd! {
|
||||
protoc --dart_out=${output} --proto_path=${root} ${path}
|
||||
@ -77,3 +84,31 @@ fn gen_pb_for_dart(name: &str, root: &str, paths: &Vec<String>, file_names: &Vec
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn check_pb_compiler() {
|
||||
assert!(run_command("command -v protoc"), "protoc was not installed correctly");
|
||||
}
|
||||
|
||||
fn check_pb_dart_plugin() {
|
||||
assert!(
|
||||
run_command("command -v protoc-gen-dart"),
|
||||
"protoc-gen-dart was not installed correctly"
|
||||
);
|
||||
}
|
||||
|
||||
fn run_command(cmd: &str) -> bool {
|
||||
let output = if cfg!(target_os = "windows") {
|
||||
Command::new("cmd")
|
||||
.arg("/C")
|
||||
.arg(cmd)
|
||||
.status()
|
||||
.expect("failed to execute process")
|
||||
} else {
|
||||
Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(cmd)
|
||||
.status()
|
||||
.expect("failed to execute process")
|
||||
};
|
||||
output.success()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user