2032: rename tools -> xtask r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2019-10-17 20:14:31 +00:00 committed by GitHub
commit 6b9bd7bdd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 50 additions and 82 deletions

View File

@ -1,23 +1,4 @@
[alias]
# Automatically generates the ast and syntax kinds files
gen-syntax = "run --package ra_tools --bin ra_tools -- gen-syntax"
xtask = "run --package xtask --bin xtask --"
# Extracts the tests from
gen-tests = "run --package ra_tools --bin ra_tools -- gen-tests"
# Installs the visual studio code extension
install-ra = "run --package ra_tools --bin ra_tools -- install-ra"
install-code = "run --package ra_tools --bin ra_tools -- install-ra" # just an alias
# Formats the full repository or installs the git hook to do it automatically.
format = "run --package ra_tools --bin ra_tools -- format"
format-hook = "run --package ra_tools --bin ra_tools -- format-hook"
# Run clippy
lint = "run --package ra_tools --bin ra_tools -- lint"
# Runs the fuzzing test suite (currently only parser)
fuzz-tests = "run --package ra_tools --bin ra_tools -- fuzz-tests"
# Parse a file. This should be piped the file contents
parse = "run --package ra_cli -- parse"
install-ra = "run --package xtask --bin xtask -- install" # for backwards compat

33
Cargo.lock generated
View File

@ -1139,19 +1139,6 @@ dependencies = [
"text_unit 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ra_tools"
version = "0.1.0"
dependencies = [
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pico-args 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
"walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ra_tt"
version = "0.1.0"
@ -1731,13 +1718,6 @@ name = "wasi"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "website-gen"
version = "0.0.0"
dependencies = [
"walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi"
version = "0.2.8"
@ -1784,6 +1764,19 @@ dependencies = [
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "xtask"
version = "0.1.0"
dependencies = [
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pico-args 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
"walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "yaml-rust"
version = "0.4.3"

View File

@ -1,5 +1,5 @@
[workspace]
members = [ "crates/*" ]
members = [ "crates/*", "xtask/" ]
[profile.dev]
debug = 1 # only line info

View File

@ -33,10 +33,10 @@ To quickly install rust-analyzer with VS Code extension with standard setup
$ git clone https://github.com/rust-analyzer/rust-analyzer && cd rust-analyzer
# install both the language server and VS Code extension
$ cargo install-ra
$ cargo xtask install
# alternatively, install only the server. Binary name is `ra_lsp_server`.
$ cargo install-ra --server
$ cargo xtask install --server
```
For non-standard setup of VS Code and other editors, see [./docs/user](./docs/user).

View File

@ -1,5 +1,5 @@
// Stores definitions which must be used in multiple places
// See `cargo gen-syntax` (defined in crates/ra_tools/src/main.rs)
// See `cargo xtask codegen` (defined in xtasks/src/main.rs)
Grammar(
punct: [
(";", "SEMI"),

View File

@ -65,8 +65,8 @@ integrating with editors. Currently, it contains plugins for VS Code (in
typescript) and Emacs (in elisp). The `docs` top-level directory contains both
developer and user documentation.
We have some automation infra in Rust in the `crates/tool` package. It contains
stuff like formatting checking, code generation and powers `cargo install-ra`.
We have some automation infra in Rust in the `xtask` package. It contains
stuff like formatting checking, code generation and powers `cargo xtask install`.
The latter syntax is achieved with the help of cargo aliases (see `.cargo`
directory).
@ -84,7 +84,7 @@ However, launching a VS Code instance with locally build language server is
possible. There's even a VS Code task for this, so just <kbd>F5</kbd> should
work (thanks, [@andrew-w-ross](https://github.com/andrew-w-ross)!).
I often just install development version with `cargo install-ra --server --jemalloc` and
I often just install development version with `cargo xtask install --server --jemalloc` and
restart the host VS Code.
See [./debugging.md](./debugging.md) for how to attach to rust-analyzer with
@ -116,7 +116,7 @@ Due to the requirements of running the tests inside VS Code they are **not run
on CI**. When making changes to the extension please ensure the tests are not
broken locally before opening a Pull Request.
To install **only** the VS Code extension, use `cargo install-ra --client-code`.
To install **only** the VS Code extension, use `cargo xtask install --client-code`.
# Logging
@ -153,7 +153,7 @@ There's also two VS Code commands which might be of interest:
$ cargo install --path crates/ra_lsp_server --force --features jemalloc
```
There's an alias for this: `cargo install-ra --server --jemalloc`.
There's an alias for this: `cargo xtask install --server --jemalloc`.
* `Rust Analyzer: Syntax Tree` shows syntax tree of the current file/selection.

View File

@ -45,21 +45,15 @@ can be quickly updated for small modifications.
Some of the components of this repository are generated through automatic
processes. These are outlined below:
- `gen-syntax`: The kinds of tokens that are reused in several places, so a generator
is used. We use tera templates to generate the files listed below, based on
- `cargo xtask codegen`: The kinds of tokens that are reused in several places, so a generator
is used. We use `quote!` macro to generate the files listed below, based on
the grammar described in [grammar.ron]:
- [ast/generated.rs][ast generated] in `ra_syntax` based on
[ast/generated.tera.rs][ast source]
- [syntax_kind/generated.rs][syntax_kind generated] in `ra_syntax` based on
[syntax_kind/generated.tera.rs][syntax_kind source]
- [ast/generated.rs][ast generated]
- [syntax_kind/generated.rs][syntax_kind generated]
[tera]: https://tera.netlify.com/
[grammar.ron]: ../../crates/ra_syntax/src/grammar.ron
[ast generated]: ../../crates/ra_syntax/src/ast/generated.rs
[ast source]: ../../crates/ra_syntax/src/ast/generated.rs.tera
[syntax_kind generated]: ../../crates/ra_parser/src/syntax_kind/generated.rs
[syntax_kind source]: ../../crates/ra_parser/src/syntax_kind/generated.rs.tera
## Code Walk-Through
@ -77,7 +71,7 @@ Rust syntax tree structure and parser. See
This is the thing that turns a flat list of events into a tree (see `EventProcessor`)
- `ast` provides a type safe API on top of the raw `rowan` tree.
- `grammar.ron` RON description of the grammar, which is used to
generate `syntax_kinds` and `ast` modules, using `cargo gen-syntax` command.
generate `syntax_kinds` and `ast` modules, using `cargo xtask codegen` command.
- `algo`: generic tree algorithms, including `walk` for O(1) stack
space tree traversal (this is cool).

View File

@ -1,6 +1,6 @@
The main interface to rust-analyzer is the
[LSP](https://microsoft.github.io/language-server-protocol/) implementation. To
install lsp server, use `cargo install-ra --server`, which is a shorthand for `cargo
install lsp server, use `cargo xtask install --server`, which is a shorthand for `cargo
install --package ra_lsp_server`. The binary is named `ra_lsp_server`, you
should be able to use it with any LSP-compatible editor. We use custom
extensions to LSP, so special client-side support is required to take full
@ -33,7 +33,7 @@ following commands:
```
$ git clone https://github.com/rust-analyzer/rust-analyzer.git --depth 1
$ cd rust-analyzer
$ cargo install-ra
$ cargo xtask install
```
The automatic installation is expected to *just work* for common cases, if it
@ -58,7 +58,7 @@ Beyond basic LSP features, there are some extension commands which you can
invoke via <kbd>Ctrl+Shift+P</kbd> or bind to a shortcut. See [./features.md](./features.md)
for details.
For updates, pull the latest changes from the master branch, run `cargo install-ra` again, and **restart** VS Code instance.
For updates, pull the latest changes from the master branch, run `cargo xtask install` again, and **restart** VS Code instance.
See [microsoft/vscode#72308](https://github.com/microsoft/vscode/issues/72308) for why a full restart is needed.
### Settings

View File

@ -1,6 +1,6 @@
[package]
edition = "2018"
name = "ra_tools"
name = "xtask"
version = "0.1.0"
authors = ["rust-analyzer developers"]
publish = false

View File

@ -2,7 +2,7 @@
use std::process::Command;
use ra_tools::{project_root, run, run_rustfmt, Overwrite, Result};
use xtask::{project_root, run, run_rustfmt, Overwrite, Result};
fn main() -> Result<()> {
run_rustfmt(Overwrite)?;

View File

@ -12,15 +12,15 @@ SUBCOMMANDS:
format
format-hook
fuzz-tests
gen-syntax
codegen
gen-tests
install-ra
install
lint";
pub const INSTALL_RA_HELP: &str = "ra_tools-install-ra
pub const INSTALL_HELP: &str = "ra_tools-install
USAGE:
ra_tools.exe install-ra [FLAGS]
ra_tools.exe install [FLAGS]
FLAGS:
--client-code
@ -43,5 +43,5 @@ FLAGS:
pub const INSTALL_RA_CONFLICT: &str =
"error: The argument `--server` cannot be used with `--client-code`
For more information try --help";

View File

@ -78,7 +78,7 @@ pub fn collect_tests(s: &str) -> Vec<(usize, Test)> {
}
pub fn project_root() -> PathBuf {
Path::new(&env!("CARGO_MANIFEST_DIR")).ancestors().nth(2).unwrap().to_path_buf()
Path::new(&env!("CARGO_MANIFEST_DIR")).ancestors().nth(1).unwrap().to_path_buf()
}
pub struct Cmd<'a> {
@ -146,7 +146,7 @@ pub fn install_format_hook() -> Result<()> {
"./.git/hooks/pre-commit"
});
if !result_path.exists() {
run("cargo build --package ra_tools --bin pre-commit", ".")?;
run("cargo build --package xtask --bin pre-commit", ".")?;
if cfg!(windows) {
fs::copy("./target/debug/pre-commit.exe", result_path)?;
} else {

View File

@ -5,11 +5,11 @@ mod help;
use core::fmt::Write;
use core::str;
use pico_args::Arguments;
use ra_tools::{
use std::{env, path::PathBuf};
use xtask::{
gen_tests, generate_boilerplate, install_format_hook, run, run_clippy, run_fuzzer, run_rustfmt,
Cmd, Overwrite, Result,
};
use std::{env, path::PathBuf};
struct InstallOpt {
client: Option<ClientOpt>,
@ -35,9 +35,9 @@ fn main() -> Result<()> {
let mut matches = Arguments::from_vec(std::env::args_os().skip(2).collect());
let subcommand = &*subcommand.to_string_lossy();
match subcommand {
"install-ra" | "install-code" => {
"install" => {
if matches.contains(["-h", "--help"]) {
eprintln!("{}", help::INSTALL_RA_HELP);
eprintln!("{}", help::INSTALL_HELP);
return Ok(());
}
let server = matches.contains("--server");
@ -61,7 +61,7 @@ fn main() -> Result<()> {
}
gen_tests(Overwrite)?
}
"gen-syntax" => {
"codegen" => {
if matches.contains(["-h", "--help"]) {
help::print_no_param_subcommand_help(&subcommand);
return Ok(());

View File

@ -1,17 +1,17 @@
use ra_tools::{gen_tests, generate_boilerplate, project_root, run_rustfmt, Verify};
use walkdir::WalkDir;
use xtask::{gen_tests, generate_boilerplate, project_root, run_rustfmt, Verify};
#[test]
fn generated_grammar_is_fresh() {
if let Err(error) = generate_boilerplate(Verify) {
panic!("{}. Please update it by running `cargo gen-syntax`", error);
panic!("{}. Please update it by running `cargo xtask codegen`", error);
}
}
#[test]
fn generated_tests_are_fresh() {
if let Err(error) = gen_tests(Verify) {
panic!("{}. Please update tests by running `cargo gen-tests`", error);
panic!("{}. Please update tests by running `cargo xtask gen-tests`", error);
}
}

View File

@ -5,7 +5,7 @@ use std::path::Path;
use walkdir::{DirEntry, WalkDir};
use ra_tools::project_root;
use xtask::project_root;
fn is_exclude_dir(p: &Path) -> bool {
let exclude_dirs = ["tests", "test_data"];