diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2017-11-10 15:09:39 +1300 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2017-11-13 10:51:29 +1300 |
| commit | 63d854acf2ddcf127700940e4762393af4baabbf (patch) | |
| tree | 03c7b2c33d31ce38e113ac94842cb763b21b42cf /src/bootstrap | |
| parent | fb5ba4ef90bda82b4aa7328927d4413c7f33683d (diff) | |
| download | rust-63d854acf2ddcf127700940e4762393af4baabbf.tar.gz rust-63d854acf2ddcf127700940e4762393af4baabbf.zip | |
Distribute Rustfmt
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/builder.rs | 3 | ||||
| -rw-r--r-- | src/bootstrap/dist.rs | 89 | ||||
| -rw-r--r-- | src/bootstrap/lib.rs | 8 |
3 files changed, 99 insertions, 1 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index cf9659350c1..4e2898bd665 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -261,7 +261,8 @@ impl<'a> Builder<'a> { doc::Reference, doc::Rustdoc, doc::CargoBook), Kind::Dist => describe!(dist::Docs, dist::Mingw, dist::Rustc, dist::DebuggerScripts, dist::Std, dist::Analysis, dist::Src, dist::PlainSourceTarball, dist::Cargo, - dist::Rls, dist::Extended, dist::HashSign, dist::DontDistWithMiriEnabled), + dist::Rls, dist::Rustfmt, dist::Extended, dist::HashSign, + dist::DontDistWithMiriEnabled), Kind::Install => describe!(install::Docs, install::Std, install::Cargo, install::Rls, install::Analysis, install::Src, install::Rustc), } diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 090fb6c778c..cafdaef121d 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -39,6 +39,8 @@ pub fn pkgname(build: &Build, component: &str) -> String { format!("{}-{}", component, build.cargo_package_vers()) } else if component == "rls" { format!("{}-{}", component, build.rls_package_vers()) + } else if component == "rustfmt" { + format!("{}-{}", component, build.rustfmt_package_vers()) } else { assert!(component.starts_with("rust")); format!("{}-{}", component, build.rust_package_vers()) @@ -1113,6 +1115,92 @@ impl Step for Rls { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct Rustfmt { + pub stage: u32, + pub target: Interned<String>, +} + +impl Step for Rustfmt { + type Output = Option<PathBuf>; + const ONLY_BUILD_TARGETS: bool = true; + const ONLY_HOSTS: bool = true; + + fn should_run(run: ShouldRun) -> ShouldRun { + run.path("rustfmt") + } + + fn make_run(run: RunConfig) { + run.builder.ensure(Rustfmt { + stage: run.builder.top_stage, + target: run.target, + }); + } + + fn run(self, builder: &Builder) -> Option<PathBuf> { + let build = builder.build; + let stage = self.stage; + let target = self.target; + assert!(build.config.extended); + + if !builder.config.toolstate.rustfmt.testing() { + println!("skipping Dist Rustfmt stage{} ({})", stage, target); + return None + } + + println!("Dist Rustfmt stage{} ({})", stage, target); + let src = build.src.join("src/tools/rustfmt"); + let release_num = build.release_num("rustfmt"); + let name = pkgname(build, "rustfmt"); + let version = build.rustfmt_info.version(build, &release_num); + + let tmp = tmpdir(build); + let image = tmp.join("rustfmt-image"); + drop(fs::remove_dir_all(&image)); + t!(fs::create_dir_all(&image)); + + // Prepare the image directory + // We expect RLS to build, because we've exited this step above if tool + // state for RLS isn't testing. + let rustfmt = builder.ensure(tool::Rls { + compiler: builder.compiler(stage, build.build), + target + }).expect("Rustfmt to build: toolstate is testing"); + install(&rustfmt, &image.join("bin"), 0o755); + let doc = image.join("share/doc/rustfmt"); + install(&src.join("README.md"), &doc, 0o644); + install(&src.join("LICENSE-MIT"), &doc, 0o644); + install(&src.join("LICENSE-APACHE"), &doc, 0o644); + + // Prepare the overlay + let overlay = tmp.join("rustfmt-overlay"); + drop(fs::remove_dir_all(&overlay)); + t!(fs::create_dir_all(&overlay)); + install(&src.join("README.md"), &overlay, 0o644); + install(&src.join("LICENSE-MIT"), &overlay, 0o644); + install(&src.join("LICENSE-APACHE"), &overlay, 0o644); + t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes())); + + // Generate the installer tarball + let mut cmd = rust_installer(builder); + cmd.arg("generate") + .arg("--product-name=Rust") + .arg("--rel-manifest-dir=rustlib") + .arg("--success-message=rustfmt-ready-to-fmt.") + .arg("--image-dir").arg(&image) + .arg("--work-dir").arg(&tmpdir(build)) + .arg("--output-dir").arg(&distdir(build)) + .arg("--non-installed-overlay").arg(&overlay) + .arg(format!("--package-name={}-{}", name, target)) + .arg("--legacy-manifest-dirs=rustlib,cargo") + .arg("--component-name=rustfmt-preview"); + + build.run(&mut cmd); + Some(distdir(build).join(format!("{}-{}.tar.gz", name, target))) + } +} + + +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct DontDistWithMiriEnabled; impl Step for DontDistWithMiriEnabled { @@ -1606,6 +1694,7 @@ impl Step for HashSign { cmd.arg(build.rust_package_vers()); cmd.arg(build.package_vers(&build.release_num("cargo"))); cmd.arg(build.package_vers(&build.release_num("rls"))); + cmd.arg(build.package_vers(&build.release_num("rustfmt"))); cmd.arg(addr); t!(fs::create_dir_all(distdir(build))); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 479283b3595..68329922592 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -222,6 +222,7 @@ pub struct Build { rust_info: channel::GitInfo, cargo_info: channel::GitInfo, rls_info: channel::GitInfo, + rustfmt_info: channel::GitInfo, local_rebuild: bool, fail_fast: bool, verbosity: usize, @@ -304,6 +305,7 @@ impl Build { let rust_info = channel::GitInfo::new(&config, &src); let cargo_info = channel::GitInfo::new(&config, &src.join("src/tools/cargo")); let rls_info = channel::GitInfo::new(&config, &src.join("src/tools/rls")); + let rustfmt_info = channel::GitInfo::new(&config, &src.join("src/tools/rustfmt")); Build { initial_rustc: config.initial_rustc.clone(), @@ -323,6 +325,7 @@ impl Build { rust_info, cargo_info, rls_info, + rustfmt_info, cc: HashMap::new(), cxx: HashMap::new(), ar: HashMap::new(), @@ -814,6 +817,11 @@ impl Build { self.package_vers(&self.release_num("rls")) } + /// Returns the value of `package_vers` above for rustfmt + fn rustfmt_package_vers(&self) -> String { + self.package_vers(&self.release_num("rustfmt")) + } + /// Returns the `version` string associated with this compiler for Rust /// itself. /// |
