diff options
author | Mikhail Rakhmanov <[email protected]> | 2020-06-13 07:42:15 +0100 |
---|---|---|
committer | Mikhail Rakhmanov <[email protected]> | 2020-06-13 07:42:15 +0100 |
commit | 16bbf4ab7f132e6e5e5318dccdef9a5d71afdd7f (patch) | |
tree | 4b79fa8c046be56b02427ba843e70cdf3ac05767 /xtask/src | |
parent | eeb8b9e236796da8734ba81a49164864497f7226 (diff) | |
parent | b56ad148db0c69eb279c225f45d324b4e80e7367 (diff) |
Merge branch 'master' into keyword_completion
# Conflicts:
# docs/user/generated_features.adoc
Diffstat (limited to 'xtask/src')
-rw-r--r-- | xtask/src/ast_src.rs | 2 | ||||
-rw-r--r-- | xtask/src/codegen.rs | 6 | ||||
-rw-r--r-- | xtask/src/codegen/gen_assists_docs.rs | 11 | ||||
-rw-r--r-- | xtask/src/codegen/gen_syntax.rs | 6 | ||||
-rw-r--r-- | xtask/src/lib.rs | 55 | ||||
-rw-r--r-- | xtask/src/main.rs | 8 | ||||
-rw-r--r-- | xtask/src/release.rs | 67 |
7 files changed, 88 insertions, 67 deletions
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index f60f0fb16..392648d71 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs | |||
@@ -1707,7 +1707,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { | |||
1707 | /// ``` | 1707 | /// ``` |
1708 | /// | 1708 | /// |
1709 | /// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses) | 1709 | /// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses) |
1710 | struct WherePred: TypeBoundsOwner { T![lifetime], TypeRef } | 1710 | struct WherePred: TypeBoundsOwner { T![for], TypeParamList, T![lifetime], TypeRef } |
1711 | 1711 | ||
1712 | /// Where clause. | 1712 | /// Where clause. |
1713 | /// | 1713 | /// |
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs index 5511c01d5..f5f4b964a 100644 --- a/xtask/src/codegen.rs +++ b/xtask/src/codegen.rs | |||
@@ -18,8 +18,10 @@ use std::{ | |||
18 | use crate::{not_bash::fs2, project_root, Result}; | 18 | use crate::{not_bash::fs2, project_root, Result}; |
19 | 19 | ||
20 | pub use self::{ | 20 | pub use self::{ |
21 | gen_assists_docs::generate_assists_docs, gen_feature_docs::generate_feature_docs, | 21 | gen_assists_docs::{generate_assists_docs, generate_assists_tests}, |
22 | gen_parser_tests::generate_parser_tests, gen_syntax::generate_syntax, | 22 | gen_feature_docs::generate_feature_docs, |
23 | gen_parser_tests::generate_parser_tests, | ||
24 | gen_syntax::generate_syntax, | ||
23 | }; | 25 | }; |
24 | 26 | ||
25 | const GRAMMAR_DIR: &str = "crates/ra_parser/src/grammar"; | 27 | const GRAMMAR_DIR: &str = "crates/ra_parser/src/grammar"; |
diff --git a/xtask/src/codegen/gen_assists_docs.rs b/xtask/src/codegen/gen_assists_docs.rs index 6c1be5350..526941f73 100644 --- a/xtask/src/codegen/gen_assists_docs.rs +++ b/xtask/src/codegen/gen_assists_docs.rs | |||
@@ -7,16 +7,17 @@ use crate::{ | |||
7 | project_root, rust_files, 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_tests(mode: Mode) -> Result<()> { |
11 | let assists = Assist::collect()?; | 11 | let assists = Assist::collect()?; |
12 | generate_tests(&assists, mode)?; | 12 | generate_tests(&assists, mode) |
13 | } | ||
13 | 14 | ||
15 | pub fn generate_assists_docs(mode: Mode) -> Result<()> { | ||
16 | let assists = Assist::collect()?; | ||
14 | let contents = assists.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n"); | 17 | let contents = assists.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n"); |
15 | let contents = contents.trim().to_string() + "\n"; | 18 | let contents = contents.trim().to_string() + "\n"; |
16 | let dst = project_root().join("docs/user/generated_assists.adoc"); | 19 | let dst = project_root().join("docs/user/generated_assists.adoc"); |
17 | codegen::update(&dst, &contents, mode)?; | 20 | codegen::update(&dst, &contents, mode) |
18 | |||
19 | Ok(()) | ||
20 | } | 21 | } |
21 | 22 | ||
22 | #[derive(Debug)] | 23 | #[derive(Debug)] |
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index 19d5594f5..745a25862 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs | |||
@@ -40,7 +40,7 @@ fn generate_tokens(grammar: AstSrc<'_>) -> Result<String> { | |||
40 | pub(crate) syntax: SyntaxToken, | 40 | pub(crate) syntax: SyntaxToken, |
41 | } | 41 | } |
42 | impl std::fmt::Display for #name { | 42 | impl std::fmt::Display for #name { |
43 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | 43 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
44 | std::fmt::Display::fmt(&self.syntax, f) | 44 | std::fmt::Display::fmt(&self.syntax, f) |
45 | } | 45 | } |
46 | } | 46 | } |
@@ -68,7 +68,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> { | |||
68 | .iter() | 68 | .iter() |
69 | .map(|node| { | 69 | .map(|node| { |
70 | let name = format_ident!("{}", node.name); | 70 | let name = format_ident!("{}", node.name); |
71 | let kind = format_ident!("{}", to_upper_snake_case(&name.to_string())); | 71 | let kind = format_ident!("{}", to_upper_snake_case(node.name)); |
72 | let traits = node.traits.iter().map(|trait_name| { | 72 | let traits = node.traits.iter().map(|trait_name| { |
73 | let trait_name = format_ident!("{}", trait_name); | 73 | let trait_name = format_ident!("{}", trait_name); |
74 | quote!(impl ast::#trait_name for #name {}) | 74 | quote!(impl ast::#trait_name for #name {}) |
@@ -199,7 +199,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> { | |||
199 | enum_names.chain(node_names.clone()).map(|it| format_ident!("{}", it)).map(|name| { | 199 | enum_names.chain(node_names.clone()).map(|it| format_ident!("{}", it)).map(|name| { |
200 | quote! { | 200 | quote! { |
201 | impl std::fmt::Display for #name { | 201 | impl std::fmt::Display for #name { |
202 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | 202 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
203 | std::fmt::Display::fmt(self.syntax(), f) | 203 | std::fmt::Display::fmt(self.syntax(), f) |
204 | } | 204 | } |
205 | } | 205 | } |
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 874957885..747654c1f 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs | |||
@@ -4,6 +4,7 @@ | |||
4 | 4 | ||
5 | pub mod not_bash; | 5 | pub mod not_bash; |
6 | pub mod install; | 6 | pub mod install; |
7 | pub mod release; | ||
7 | pub mod dist; | 8 | pub mod dist; |
8 | pub mod pre_commit; | 9 | pub mod pre_commit; |
9 | 10 | ||
@@ -19,7 +20,7 @@ use walkdir::{DirEntry, WalkDir}; | |||
19 | 20 | ||
20 | use crate::{ | 21 | use crate::{ |
21 | codegen::Mode, | 22 | codegen::Mode, |
22 | not_bash::{date_iso, fs2, pushd, pushenv, rm_rf, run}, | 23 | not_bash::{fs2, pushd, pushenv, rm_rf, run}, |
23 | }; | 24 | }; |
24 | 25 | ||
25 | pub use anyhow::{bail, Context as _, Result}; | 26 | pub use anyhow::{bail, Context as _, Result}; |
@@ -153,58 +154,6 @@ pub fn run_pre_cache() -> Result<()> { | |||
153 | Ok(()) | 154 | Ok(()) |
154 | } | 155 | } |
155 | 156 | ||
156 | pub fn run_release(dry_run: bool) -> Result<()> { | ||
157 | if !dry_run { | ||
158 | run!("git switch release")?; | ||
159 | run!("git fetch upstream --tags --force")?; | ||
160 | run!("git reset --hard tags/nightly")?; | ||
161 | run!("git push")?; | ||
162 | } | ||
163 | |||
164 | let website_root = project_root().join("../rust-analyzer.github.io"); | ||
165 | let changelog_dir = website_root.join("./thisweek/_posts"); | ||
166 | |||
167 | let today = date_iso()?; | ||
168 | let commit = run!("git rev-parse HEAD")?; | ||
169 | let changelog_n = fs2::read_dir(changelog_dir.as_path())?.count(); | ||
170 | |||
171 | let contents = format!( | ||
172 | "\ | ||
173 | = Changelog #{} | ||
174 | :sectanchors: | ||
175 | :page-layout: post | ||
176 | |||
177 | Commit: commit:{}[] + | ||
178 | Release: release:{}[] | ||
179 | |||
180 | == New Features | ||
181 | |||
182 | * pr:[] . | ||
183 | |||
184 | == Fixes | ||
185 | |||
186 | == Internal Improvements | ||
187 | ", | ||
188 | changelog_n, commit, today | ||
189 | ); | ||
190 | |||
191 | let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n)); | ||
192 | fs2::write(&path, &contents)?; | ||
193 | |||
194 | for &adoc in ["manual.adoc", "generated_features.adoc", "generated_assists.adoc"].iter() { | ||
195 | let src = project_root().join("./docs/user/").join(adoc); | ||
196 | let dst = website_root.join(adoc); | ||
197 | fs2::copy(src, dst)?; | ||
198 | } | ||
199 | |||
200 | let tags = run!("git tag --list"; echo = false)?; | ||
201 | let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap(); | ||
202 | |||
203 | println!("\n git log {}..HEAD --merges --reverse", prev_tag); | ||
204 | |||
205 | Ok(()) | ||
206 | } | ||
207 | |||
208 | fn is_release_tag(tag: &str) -> bool { | 157 | fn is_release_tag(tag: &str) -> bool { |
209 | tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit()) | 158 | tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit()) |
210 | } | 159 | } |
diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 9d7cdd114..f7a79362d 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs | |||
@@ -16,8 +16,9 @@ use xtask::{ | |||
16 | dist::run_dist, | 16 | dist::run_dist, |
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, |
20 | Result, | 20 | release::ReleaseCmd, |
21 | run_clippy, run_fuzzer, run_pre_cache, run_rustfmt, Result, | ||
21 | }; | 22 | }; |
22 | 23 | ||
23 | fn main() -> Result<()> { | 24 | fn main() -> Result<()> { |
@@ -74,6 +75,7 @@ FLAGS: | |||
74 | args.finish()?; | 75 | args.finish()?; |
75 | codegen::generate_syntax(Mode::Overwrite)?; | 76 | codegen::generate_syntax(Mode::Overwrite)?; |
76 | codegen::generate_parser_tests(Mode::Overwrite)?; | 77 | codegen::generate_parser_tests(Mode::Overwrite)?; |
78 | codegen::generate_assists_tests(Mode::Overwrite)?; | ||
77 | codegen::generate_assists_docs(Mode::Overwrite)?; | 79 | codegen::generate_assists_docs(Mode::Overwrite)?; |
78 | codegen::generate_feature_docs(Mode::Overwrite)?; | 80 | codegen::generate_feature_docs(Mode::Overwrite)?; |
79 | Ok(()) | 81 | Ok(()) |
@@ -101,7 +103,7 @@ FLAGS: | |||
101 | "release" => { | 103 | "release" => { |
102 | let dry_run = args.contains("--dry-run"); | 104 | let dry_run = args.contains("--dry-run"); |
103 | args.finish()?; | 105 | args.finish()?; |
104 | run_release(dry_run) | 106 | ReleaseCmd { dry_run }.run() |
105 | } | 107 | } |
106 | "dist" => { | 108 | "dist" => { |
107 | let nightly = args.contains("--nightly"); | 109 | let nightly = args.contains("--nightly"); |
diff --git a/xtask/src/release.rs b/xtask/src/release.rs new file mode 100644 index 000000000..36c912184 --- /dev/null +++ b/xtask/src/release.rs | |||
@@ -0,0 +1,67 @@ | |||
1 | use crate::{ | ||
2 | codegen, is_release_tag, | ||
3 | not_bash::{date_iso, fs2, run}, | ||
4 | project_root, Mode, Result, | ||
5 | }; | ||
6 | |||
7 | pub struct ReleaseCmd { | ||
8 | pub dry_run: bool, | ||
9 | } | ||
10 | |||
11 | impl ReleaseCmd { | ||
12 | pub fn run(self) -> Result<()> { | ||
13 | if !self.dry_run { | ||
14 | run!("git switch release")?; | ||
15 | run!("git fetch upstream --tags --force")?; | ||
16 | run!("git reset --hard tags/nightly")?; | ||
17 | run!("git push")?; | ||
18 | } | ||
19 | codegen::generate_assists_docs(Mode::Overwrite)?; | ||
20 | codegen::generate_feature_docs(Mode::Overwrite)?; | ||
21 | |||
22 | let website_root = project_root().join("../rust-analyzer.github.io"); | ||
23 | let changelog_dir = website_root.join("./thisweek/_posts"); | ||
24 | |||
25 | let today = date_iso()?; | ||
26 | let commit = run!("git rev-parse HEAD")?; | ||
27 | let changelog_n = fs2::read_dir(changelog_dir.as_path())?.count(); | ||
28 | |||
29 | let contents = format!( | ||
30 | "\ | ||
31 | = Changelog #{} | ||
32 | :sectanchors: | ||
33 | :page-layout: post | ||
34 | |||
35 | Commit: commit:{}[] + | ||
36 | Release: release:{}[] | ||
37 | |||
38 | == New Features | ||
39 | |||
40 | * pr:[] . | ||
41 | |||
42 | == Fixes | ||
43 | |||
44 | == Internal Improvements | ||
45 | ", | ||
46 | changelog_n, commit, today | ||
47 | ); | ||
48 | |||
49 | let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n)); | ||
50 | fs2::write(&path, &contents)?; | ||
51 | |||
52 | for &adoc in ["manual.adoc", "generated_features.adoc", "generated_assists.adoc"].iter() { | ||
53 | let src = project_root().join("./docs/user/").join(adoc); | ||
54 | let dst = website_root.join(adoc); | ||
55 | fs2::copy(src, dst)?; | ||
56 | } | ||
57 | |||
58 | let tags = run!("git tag --list"; echo = false)?; | ||
59 | let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap(); | ||
60 | |||
61 | let git_log = run!("git log {}..HEAD --merges --reverse", prev_tag; echo = false)?; | ||
62 | let git_log_dst = website_root.join("git.log"); | ||
63 | fs2::write(git_log_dst, &git_log)?; | ||
64 | |||
65 | Ok(()) | ||
66 | } | ||
67 | } | ||