Skip to content

Commit 8f8ee9e

Browse files
authored
Merge pull request #2419 from topecongiro/core
Separate rustfmt into multiple crates
2 parents c9e250a + 5297e7c commit 8f8ee9e

File tree

602 files changed

+1366
-1096
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

602 files changed

+1366
-1096
lines changed

Cargo.lock

Lines changed: 84 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,9 @@
1-
[package]
2-
3-
name = "rustfmt-nightly"
4-
version = "0.3.8"
5-
authors = ["Nicholas Cameron <ncameron@mozilla.com>", "The Rustfmt developers"]
6-
description = "Tool to find and fix Rust formatting issues"
7-
repository = "https://github.com/rust-lang-nursery/rustfmt"
8-
readme = "README.md"
9-
license = "Apache-2.0/MIT"
10-
build = "build.rs"
11-
categories = ["development-tools"]
12-
13-
[lib]
14-
doctest = false
15-
16-
[[bin]]
17-
name = "rustfmt"
18-
19-
[[bin]]
20-
name = "cargo-fmt"
21-
22-
[[bin]]
23-
name = "rustfmt-format-diff"
24-
25-
[[bin]]
26-
name = "git-rustfmt"
27-
28-
[features]
29-
default = ["cargo-fmt", "rustfmt-format-diff"]
30-
cargo-fmt = []
31-
rustfmt-format-diff = []
32-
33-
[dependencies]
34-
toml = "0.4"
35-
serde = "1.0"
36-
serde_derive = "1.0"
37-
serde_json = "1.0"
38-
unicode-segmentation = "1.0.0"
39-
regex = "0.2"
40-
term = "0.4"
41-
diff = "0.1"
42-
log = "0.3"
43-
env_logger = "0.4"
44-
getopts = "0.2"
45-
derive-new = "0.5"
46-
cargo_metadata = "0.4"
47-
rustc-ap-syntax = "29.0.0"
48-
rustc-ap-rustc_errors = "29.0.0"
49-
50-
[dev-dependencies]
51-
lazy_static = "1.0.0"
52-
53-
[target.'cfg(unix)'.dependencies]
54-
libc = "0.2.11"
55-
56-
[target.'cfg(windows)'.dependencies]
57-
kernel32-sys = "0.2.2"
58-
winapi = "0.2.7"
1+
[workspace]
2+
members = [
3+
"cargo-fmt",
4+
"git-rustfmt",
5+
"rustfmt-bin",
6+
"rustfmt-config",
7+
"rustfmt-core",
8+
"rustfmt-format-diff",
9+
]

appveyor.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ install:
4747
# ???
4848
build: false
4949

50-
# Build rustfmt, run the executables as
5150
test_script:
5251
- cargo build --verbose
53-
- cargo run --bin rustfmt -- --help
54-
- cargo run --bin cargo-fmt -- --help
5552
- cargo test

cargo-fmt/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "cargo-fmt"
3+
version = "0.4.0"
4+
authors = ["Nicholas Cameron <ncameron@mozilla.com>", "The Rustfmt developers"]
5+
description = "Cargo frontend for rustfmt"
6+
repository = "https://github.com/rust-lang-nursery/rustfmt"
7+
readme = "README.md"
8+
license = "Apache-2.0/MIT"
9+
categories = ["development-tools"]
10+
11+
[[bin]]
12+
name = "cargo-fmt"
13+
14+
[dependencies]
15+
cargo_metadata = "0.4"
16+
getopts = "0.2"
17+
serde_json = "1.0"
File renamed without changes.

git-rustfmt/Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "git-rustfmt"
3+
version = "0.4.0"
4+
authors = ["Nicholas Cameron <ncameron@mozilla.com>", "The Rustfmt developers"]
5+
description = "Run rustfmt against git diff"
6+
repository = "https://github.com/rust-lang-nursery/rustfmt"
7+
readme = "README.md"
8+
license = "Apache-2.0/MIT"
9+
categories = ["development-tools"]
10+
11+
[[bin]]
12+
name = "git-rustfmt"
13+
14+
[dependencies]
15+
env_logger = "0.4"
16+
getopts = "0.2"
17+
log = "0.3"
18+
rustfmt-config = { path = "../rustfmt-config" }
19+
rustfmt-core = { path = "../rustfmt-core" }

src/bin/git-rustfmt.rs renamed to git-rustfmt/src/main.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
111
extern crate env_logger;
212
extern crate getopts;
313
#[macro_use]
414
extern crate log;
5-
extern crate rustfmt_nightly as rustfmt;
15+
extern crate rustfmt_config as config;
16+
extern crate rustfmt_core as rustfmt;
617

718
use std::env;
819
use std::path::{Path, PathBuf};
@@ -12,7 +23,6 @@ use std::str::FromStr;
1223
use getopts::{Matches, Options};
1324

1425
use rustfmt::{run, Input};
15-
use rustfmt::config;
1626

1727
fn prune_files(files: Vec<&str>) -> Vec<&str> {
1828
let prefixes: Vec<_> = files

rustfmt-bin/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "rustfmt-bin"
3+
version = "0.4.0"
4+
authors = ["Nicholas Cameron <ncameron@mozilla.com>", "The Rustfmt developers"]
5+
description = "Tool to find and fix Rust formatting issues"
6+
repository = "https://github.com/rust-lang-nursery/rustfmt"
7+
readme = "README.md"
8+
license = "Apache-2.0/MIT"
9+
build = "build.rs"
10+
categories = ["development-tools"]
11+
12+
[[bin]]
13+
name = "rustfmt"
14+
path = "src/main.rs"
15+
16+
[dependencies]
17+
env_logger = "0.4"
18+
getopts = "0.2"
19+
rustfmt-config = { path = "../rustfmt-config" }
20+
rustfmt-core = { path = "../rustfmt-core" }

rustfmt-bin/build.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::env;
12+
use std::fs::File;
13+
use std::io::Write;
14+
use std::path::PathBuf;
15+
use std::process::Command;
16+
17+
fn main() {
18+
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
19+
20+
File::create(out_dir.join("commit-info.txt"))
21+
.unwrap()
22+
.write_all(commit_info().as_bytes())
23+
.unwrap();
24+
}
25+
26+
// Try to get hash and date of the last commit on a best effort basis. If anything goes wrong
27+
// (git not installed or if this is not a git repository) just return an empty string.
28+
fn commit_info() -> String {
29+
match (commit_hash(), commit_date()) {
30+
(Some(hash), Some(date)) => format!(" ({} {})", hash.trim_right(), date),
31+
_ => String::new(),
32+
}
33+
}
34+
35+
fn commit_hash() -> Option<String> {
36+
Command::new("git")
37+
.args(&["rev-parse", "--short", "HEAD"])
38+
.output()
39+
.ok()
40+
.and_then(|r| String::from_utf8(r.stdout).ok())
41+
}
42+
43+
fn commit_date() -> Option<String> {
44+
Command::new("git")
45+
.args(&["log", "-1", "--date=short", "--pretty=format:%cd"])
46+
.output()
47+
.ok()
48+
.and_then(|r| String::from_utf8(r.stdout).ok())
49+
}

0 commit comments

Comments
 (0)