aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/codegen
diff options
context:
space:
mode:
authorDmitry <[email protected]>2020-08-14 19:25:08 +0100
committerDmitry <[email protected]>2020-08-14 19:25:08 +0100
commit06ff8e6c760ff05f10e868b5d1f9d79e42fbb49c (patch)
tree7c9c0502dfd402fa48296d17b09feac24a4031f2 /xtask/src/codegen
parente7899625e64262512c37b42da19fe520dd6c76f2 (diff)
refactor requirements put forward mkladov
Diffstat (limited to 'xtask/src/codegen')
-rw-r--r--xtask/src/codegen/gen_unstable_future_descriptor.rs40
1 files changed, 20 insertions, 20 deletions
diff --git a/xtask/src/codegen/gen_unstable_future_descriptor.rs b/xtask/src/codegen/gen_unstable_future_descriptor.rs
index 56065f17d..3f3beb591 100644
--- a/xtask/src/codegen/gen_unstable_future_descriptor.rs
+++ b/xtask/src/codegen/gen_unstable_future_descriptor.rs
@@ -2,27 +2,13 @@
2 2
3use crate::codegen::update; 3use crate::codegen::update;
4use crate::codegen::{self, project_root, Mode, Result}; 4use crate::codegen::{self, project_root, Mode, Result};
5use crate::not_bash::{fs2, pushd, run};
6use proc_macro2::TokenStream;
5use quote::quote; 7use quote::quote;
6use std::fs; 8use std::path::PathBuf;
7use std::process::Command;
8use walkdir::WalkDir; 9use walkdir::WalkDir;
9 10
10pub fn generate_unstable_future_descriptor(mode: Mode) -> Result<()> { 11fn generate_descriptor(src_dir: PathBuf) -> Result<TokenStream> {
11 let path = project_root().join(codegen::STORAGE);
12 fs::create_dir_all(path.clone())?;
13
14 Command::new("git").current_dir(path.clone()).arg("init").output()?;
15 Command::new("git")
16 .current_dir(path.clone())
17 .args(&["remote", "add", "-f", "origin", codegen::REPOSITORY_URL])
18 .output()?;
19 Command::new("git")
20 .current_dir(path.clone())
21 .args(&["sparse-checkout", "set", "/src/doc/unstable-book/src/"])
22 .output()?;
23 Command::new("git").current_dir(path.clone()).args(&["pull", "origin", "master"]).output()?;
24
25 let src_dir = path.join("src/doc/unstable-book/src");
26 let files = WalkDir::new(src_dir.join("language-features")) 12 let files = WalkDir::new(src_dir.join("language-features"))
27 .into_iter() 13 .into_iter()
28 .chain(WalkDir::new(src_dir.join("library-features"))) 14 .chain(WalkDir::new(src_dir.join("library-features")))
@@ -49,13 +35,27 @@ pub fn generate_unstable_future_descriptor(mode: Mode) -> Result<()> {
49 let ts = quote! { 35 let ts = quote! {
50 use crate::completion::LintCompletion; 36 use crate::completion::LintCompletion;
51 37
52 pub const UNSTABLE_FEATURE_DESCRIPTOR: &[LintCompletion] = &[ 38 pub(crate) const UNSTABLE_FEATURE_DESCRIPTOR: &[LintCompletion] = &[
53 #(#definitions),* 39 #(#definitions),*
54 ]; 40 ];
55 }; 41 };
42 Ok(ts)
43}
44
45pub fn generate_unstable_future_descriptor(mode: Mode) -> Result<()> {
46 let path = project_root().join(codegen::STORAGE);
47 fs2::create_dir_all(path.clone())?;
48
49 let _d = pushd(path.clone());
50 run!("git init")?;
51 run!("git remote add -f origin {}", codegen::REPOSITORY_URL)?;
52 run!("git pull origin master")?;
53
54 let src_dir = path.join(codegen::REPO_PATH);
55 let content = generate_descriptor(src_dir)?.to_string();
56 56
57 let contents = crate::reformat(content)?;
57 let destination = project_root().join(codegen::UNSTABLE_FEATURE); 58 let destination = project_root().join(codegen::UNSTABLE_FEATURE);
58 let contents = crate::reformat(ts.to_string())?;
59 update(destination.as_path(), &contents, mode)?; 59 update(destination.as_path(), &contents, mode)?;
60 60
61 Ok(()) 61 Ok(())