WIP: move to xtasks

This commit is contained in:
Aleksey Kladov 2019-10-17 19:36:55 +03:00
parent 65ab81e358
commit 7b15c4f7ae
15 changed files with 37 additions and 62 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 -- install" # for backwards compat

26
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"
@ -1784,6 +1771,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/", "website/website-gen" ]
[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

@ -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

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

@ -12,15 +12,15 @@
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

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> {

View File

@ -5,11 +5,11 @@
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(());