diff --git a/Cargo.lock b/Cargo.lock index 60496ff2ccd..a1534ecd913 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,6 +4,7 @@ version = "0.0.1" dependencies = [ "diff 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "strings 0.0.1 (git+https://github.com/nrc/strings.rs.git)", + "toml 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -11,8 +12,21 @@ name = "diff" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "rustc-serialize" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "strings" version = "0.0.1" source = "git+https://github.com/nrc/strings.rs.git#551331d01911b7e8da056a4a019eb367cfaf03bd" +[[package]] +name = "toml" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + diff --git a/Cargo.toml b/Cargo.toml index a78a31d11c3..acf53b77e7c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ description = "Tool to find and fix Rust formatting issues" repository = "https://github.com/nick29581/rustfmt" readme = "README.md" license = "Apache-2.0/MIT" +build = "build.rs" [dependencies.strings] strings = "0.0.1" @@ -14,3 +15,4 @@ git = "https://github.com/nrc/strings.rs.git" [dev-dependencies] diff = "0.1.0" +toml = "0.1.20" diff --git a/build.rs b/build.rs new file mode 100644 index 00000000000..ac27db56493 --- /dev/null +++ b/build.rs @@ -0,0 +1,28 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Build script. Just copies default.toml from the src to the target dir. + +use std::env; +use std::path::{Path, PathBuf}; + +fn main() { + let in_file = Path::new("src/default.toml"); + + let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + let profile = env::var("PROFILE").unwrap(); + let mut out_file = PathBuf::new(); + out_file.push(manifest_dir); + out_file.push("target"); + out_file.push(profile); + out_file.push("default.toml"); + + std::fs::copy(in_file, out_file).unwrap(); +} diff --git a/src/default.toml b/src/default.toml new file mode 100644 index 00000000000..e049dfa59ba --- /dev/null +++ b/src/default.toml @@ -0,0 +1,2 @@ +max-width = 100 +ideal-width = 80