diff options
Diffstat (limited to 'xtask/src')
-rw-r--r-- | xtask/src/codegen/gen_assists_docs.rs | 10 | ||||
-rw-r--r-- | xtask/src/dist.rs | 11 | ||||
-rw-r--r-- | xtask/src/lib.rs | 16 | ||||
-rw-r--r-- | xtask/src/main.rs | 14 |
4 files changed, 37 insertions, 14 deletions
diff --git a/xtask/src/codegen/gen_assists_docs.rs b/xtask/src/codegen/gen_assists_docs.rs index 6da5ca89e..31d606535 100644 --- a/xtask/src/codegen/gen_assists_docs.rs +++ b/xtask/src/codegen/gen_assists_docs.rs | |||
@@ -4,7 +4,7 @@ use std::{fs, path::Path}; | |||
4 | 4 | ||
5 | use crate::{ | 5 | use crate::{ |
6 | codegen::{self, extract_comment_blocks_with_empty_lines, Mode}, | 6 | codegen::{self, extract_comment_blocks_with_empty_lines, Mode}, |
7 | project_root, Result, | 7 | project_root, rust_files, Result, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | pub fn generate_assists_docs(mode: Mode) -> Result<()> { | 10 | pub fn generate_assists_docs(mode: Mode) -> Result<()> { |
@@ -46,12 +46,8 @@ fn reveal_hash_comments(text: &str) -> String { | |||
46 | 46 | ||
47 | fn collect_assists() -> Result<Vec<Assist>> { | 47 | fn collect_assists() -> Result<Vec<Assist>> { |
48 | let mut res = Vec::new(); | 48 | let mut res = Vec::new(); |
49 | for entry in fs::read_dir(project_root().join(codegen::ASSISTS_DIR))? { | 49 | for path in rust_files(&project_root().join(codegen::ASSISTS_DIR)) { |
50 | let entry = entry?; | 50 | collect_file(&mut res, path.as_path())?; |
51 | let path = entry.path(); | ||
52 | if path.is_file() { | ||
53 | collect_file(&mut res, path.as_path())?; | ||
54 | } | ||
55 | } | 51 | } |
56 | res.sort_by(|lhs, rhs| lhs.id.cmp(&rhs.id)); | 52 | res.sort_by(|lhs, rhs| lhs.id.cmp(&rhs.id)); |
57 | return Ok(res); | 53 | return Ok(res); |
diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs index 2002d3e2a..3255eefb9 100644 --- a/xtask/src/dist.rs +++ b/xtask/src/dist.rs | |||
@@ -7,13 +7,18 @@ use crate::{ | |||
7 | project_root, | 7 | project_root, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | pub fn run_dist(version: &str, release_tag: &str) -> Result<()> { | 10 | pub struct ClientOpts { |
11 | pub version: String, | ||
12 | pub release_tag: String, | ||
13 | } | ||
14 | |||
15 | pub fn run_dist(client_opts: Option<ClientOpts>) -> Result<()> { | ||
11 | let dist = project_root().join("dist"); | 16 | let dist = project_root().join("dist"); |
12 | rm_rf(&dist)?; | 17 | rm_rf(&dist)?; |
13 | fs2::create_dir_all(&dist)?; | 18 | fs2::create_dir_all(&dist)?; |
14 | 19 | ||
15 | if cfg!(target_os = "linux") { | 20 | if let Some(ClientOpts { version, release_tag }) = client_opts { |
16 | dist_client(version, release_tag)?; | 21 | dist_client(&version, &release_tag)?; |
17 | } | 22 | } |
18 | dist_server()?; | 23 | dist_server()?; |
19 | Ok(()) | 24 | Ok(()) |
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index e1472e85d..4f01f84fb 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs | |||
@@ -17,6 +17,7 @@ use std::{ | |||
17 | path::{Path, PathBuf}, | 17 | path::{Path, PathBuf}, |
18 | process::{Command, Stdio}, | 18 | process::{Command, Stdio}, |
19 | }; | 19 | }; |
20 | use walkdir::{DirEntry, WalkDir}; | ||
20 | 21 | ||
21 | use crate::{ | 22 | use crate::{ |
22 | codegen::Mode, | 23 | codegen::Mode, |
@@ -37,6 +38,21 @@ pub fn project_root() -> PathBuf { | |||
37 | .to_path_buf() | 38 | .to_path_buf() |
38 | } | 39 | } |
39 | 40 | ||
41 | pub fn rust_files(path: &Path) -> impl Iterator<Item = PathBuf> { | ||
42 | let iter = WalkDir::new(path); | ||
43 | return iter | ||
44 | .into_iter() | ||
45 | .filter_entry(|e| !is_hidden(e)) | ||
46 | .map(|e| e.unwrap()) | ||
47 | .filter(|e| !e.file_type().is_dir()) | ||
48 | .map(|e| e.into_path()) | ||
49 | .filter(|path| path.extension().map(|it| it == "rs").unwrap_or(false)); | ||
50 | |||
51 | fn is_hidden(entry: &DirEntry) -> bool { | ||
52 | entry.file_name().to_str().map(|s| s.starts_with('.')).unwrap_or(false) | ||
53 | } | ||
54 | } | ||
55 | |||
40 | pub fn run_rustfmt(mode: Mode) -> Result<()> { | 56 | pub fn run_rustfmt(mode: Mode) -> Result<()> { |
41 | let _dir = pushd(project_root()); | 57 | let _dir = pushd(project_root()); |
42 | ensure_rustfmt()?; | 58 | ensure_rustfmt()?; |
diff --git a/xtask/src/main.rs b/xtask/src/main.rs index aafa73610..a9adcfba4 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs | |||
@@ -13,7 +13,7 @@ use std::env; | |||
13 | use pico_args::Arguments; | 13 | use pico_args::Arguments; |
14 | use xtask::{ | 14 | use xtask::{ |
15 | codegen::{self, Mode}, | 15 | codegen::{self, Mode}, |
16 | dist::run_dist, | 16 | dist::{run_dist, ClientOpts}, |
17 | install::{ClientOpt, InstallCmd, ServerOpt}, | 17 | install::{ClientOpt, InstallCmd, ServerOpt}, |
18 | not_bash::pushd, | 18 | not_bash::pushd, |
19 | pre_commit, project_root, run_clippy, run_fuzzer, run_pre_cache, run_release, run_rustfmt, | 19 | pre_commit, project_root, run_clippy, run_fuzzer, run_pre_cache, run_release, run_rustfmt, |
@@ -103,10 +103,16 @@ FLAGS: | |||
103 | run_release(dry_run) | 103 | run_release(dry_run) |
104 | } | 104 | } |
105 | "dist" => { | 105 | "dist" => { |
106 | let version: String = args.value_from_str("--version")?; | 106 | let client_opts = if args.contains("--client") { |
107 | let release_tag: String = args.value_from_str("--tag")?; | 107 | Some(ClientOpts { |
108 | version: args.value_from_str("--version")?, | ||
109 | release_tag: args.value_from_str("--tag")?, | ||
110 | }) | ||
111 | } else { | ||
112 | None | ||
113 | }; | ||
108 | args.finish()?; | 114 | args.finish()?; |
109 | run_dist(&version, &release_tag) | 115 | run_dist(client_opts) |
110 | } | 116 | } |
111 | _ => { | 117 | _ => { |
112 | eprintln!( | 118 | eprintln!( |