2016-05-02 15:16:15 -07:00
|
|
|
//! Implementation of the various distribution aspects of the compiler.
|
|
|
|
//!
|
|
|
|
//! This module is responsible for creating tarballs of the standard library,
|
|
|
|
//! compiler, and documentation. This ends up being what we distribute to
|
|
|
|
//! everyone as well.
|
|
|
|
//!
|
|
|
|
//! No tarball is actually created literally in this file, but rather we shell
|
|
|
|
//! out to `rust-installer` still. This may one day be replaced with bits and
|
|
|
|
//! pieces of `rustup.rs`!
|
|
|
|
|
2017-01-20 17:03:06 -08:00
|
|
|
use std::env;
|
2018-11-16 16:22:06 -05:00
|
|
|
use std::fs;
|
|
|
|
use std::io::Write;
|
2019-12-22 17:42:04 -05:00
|
|
|
use std::path::{Path, PathBuf};
|
2017-01-24 14:37:04 -08:00
|
|
|
use std::process::{Command, Stdio};
|
2016-03-13 16:52:19 -07:00
|
|
|
|
2019-05-09 12:03:13 -04:00
|
|
|
use build_helper::{output, t};
|
2017-01-20 17:03:06 -08:00
|
|
|
|
2018-12-07 13:21:05 +01:00
|
|
|
use crate::builder::{Builder, RunConfig, ShouldRun, Step};
|
2019-12-22 17:42:04 -05:00
|
|
|
use crate::cache::{Interned, INTERNER};
|
|
|
|
use crate::channel;
|
2018-12-07 13:21:05 +01:00
|
|
|
use crate::compile;
|
2020-07-17 10:08:04 -04:00
|
|
|
use crate::config::TargetSelection;
|
2018-12-07 13:21:05 +01:00
|
|
|
use crate::tool::{self, Tool};
|
2019-12-22 17:42:04 -05:00
|
|
|
use crate::util::{exe, is_dylib, timeit};
|
2020-06-03 00:56:27 +02:00
|
|
|
use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS};
|
2019-01-26 12:54:09 -05:00
|
|
|
use time::{self, Timespec};
|
2016-03-13 16:52:19 -07:00
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
pub fn pkgname(builder: &Builder<'_>, component: &str) -> String {
|
2017-03-13 19:49:36 -07:00
|
|
|
if component == "cargo" {
|
2018-04-14 17:27:57 -06:00
|
|
|
format!("{}-{}", component, builder.cargo_package_vers())
|
2017-04-10 11:22:38 -07:00
|
|
|
} else if component == "rls" {
|
2018-04-14 17:27:57 -06:00
|
|
|
format!("{}-{}", component, builder.rls_package_vers())
|
Add rust-analyzer submodule
The current plan is that submodule tracks the `release` branch of
rust-analyzer, which is updated once a week.
rust-analyzer is a workspace (with a virtual manifest), the actual
binary is provide by `crates/rust-analyzer` package.
Note that we intentionally don't add rust-analyzer to `Kind::Test`,
for two reasons.
*First*, at the moment rust-analyzer's test suite does a couple of
things which might not work in the context of rust repository. For
example, it shells out directly to `rustup` and `rustfmt`. So, making
this work requires non-trivial efforts.
*Second*, it seems unlikely that running tests in rust-lang/rust repo
would provide any additional guarantees. rust-analyzer builds with
stable and does not depend on the specifics of the compiler, so
changes to compiler can't break ra, unless they break stability
guarantee. Additionally, rust-analyzer itself is gated on bors, so we
are pretty confident that test suite passes.
2020-06-04 13:11:15 +02:00
|
|
|
} else if component == "rust-analyzer" {
|
|
|
|
format!("{}-{}", component, builder.rust_analyzer_package_vers())
|
2018-05-28 13:34:29 +02:00
|
|
|
} else if component == "clippy" {
|
|
|
|
format!("{}-{}", component, builder.clippy_package_vers())
|
2018-12-23 21:31:45 +01:00
|
|
|
} else if component == "miri" {
|
|
|
|
format!("{}-{}", component, builder.miri_package_vers())
|
2017-11-10 15:09:39 +13:00
|
|
|
} else if component == "rustfmt" {
|
2018-04-14 17:27:57 -06:00
|
|
|
format!("{}-{}", component, builder.rustfmt_package_vers())
|
2018-05-30 08:01:35 +02:00
|
|
|
} else if component == "llvm-tools" {
|
2018-06-23 05:49:02 -04:00
|
|
|
format!("{}-{}", component, builder.llvm_tools_package_vers())
|
2017-03-13 19:49:36 -07:00
|
|
|
} else {
|
2017-04-10 11:22:38 -07:00
|
|
|
assert!(component.starts_with("rust"));
|
2018-04-14 17:27:57 -06:00
|
|
|
format!("{}-{}", component, builder.rust_package_vers())
|
2017-03-13 19:49:36 -07:00
|
|
|
}
|
2017-01-20 17:03:06 -08:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn distdir(builder: &Builder<'_>) -> PathBuf {
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.out.join("dist")
|
2016-03-13 16:52:19 -07:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
pub fn tmpdir(builder: &Builder<'_>) -> PathBuf {
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.out.join("tmp/dist")
|
2016-03-13 16:52:19 -07:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn rust_installer(builder: &Builder<'_>) -> Command {
|
2017-07-05 10:46:41 -06:00
|
|
|
builder.tool_cmd(Tool::RustInstaller)
|
2017-05-08 15:01:13 -07:00
|
|
|
}
|
|
|
|
|
2018-09-28 00:19:56 -05:00
|
|
|
fn missing_tool(tool_name: &str, skip: bool) {
|
|
|
|
if skip {
|
|
|
|
println!("Unable to build {}, skipping dist", tool_name)
|
|
|
|
} else {
|
|
|
|
panic!("Unable to build {}", tool_name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-10 07:01:06 -07:00
|
|
|
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
2017-07-13 18:48:44 -06:00
|
|
|
pub struct Docs {
|
2020-07-17 10:08:04 -04:00
|
|
|
pub host: TargetSelection,
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2016-03-13 16:52:19 -07:00
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
impl Step for Docs {
|
2017-07-23 10:03:40 -06:00
|
|
|
type Output = PathBuf;
|
2017-07-05 06:41:27 -06:00
|
|
|
const DEFAULT: bool = true;
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2017-07-18 18:03:38 -06:00
|
|
|
run.path("src/doc")
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2019-12-22 17:42:04 -05:00
|
|
|
run.builder.ensure(Docs { host: run.target });
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
/// Builds the `rust-docs` installer component.
|
2019-02-25 19:30:32 +09:00
|
|
|
fn run(self, builder: &Builder<'_>) -> PathBuf {
|
2017-07-23 10:03:40 -06:00
|
|
|
let host = self.host;
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
let name = pkgname(builder, "rust-docs");
|
2017-07-05 06:41:27 -06:00
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
if !builder.config.docs {
|
2020-07-18 14:06:20 -04:00
|
|
|
return distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple));
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2016-03-13 16:52:19 -07:00
|
|
|
|
2017-07-23 10:03:40 -06:00
|
|
|
builder.default_doc(None);
|
|
|
|
|
2019-09-19 11:22:55 -07:00
|
|
|
builder.info(&format!("Dist docs ({})", host));
|
|
|
|
let _time = timeit(builder);
|
|
|
|
|
2020-07-18 14:06:20 -04:00
|
|
|
let image = tmpdir(builder).join(format!("{}-{}-image", name, host.triple));
|
2017-07-04 19:41:43 -06:00
|
|
|
let _ = fs::remove_dir_all(&image);
|
2016-03-13 16:52:19 -07:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
let dst = image.join("share/doc/rust/html");
|
2016-04-05 10:01:31 -07:00
|
|
|
t!(fs::create_dir_all(&dst));
|
2018-04-14 17:27:57 -06:00
|
|
|
let src = builder.doc_out(host);
|
|
|
|
builder.cp_r(&src, &dst);
|
2020-01-30 15:24:56 -05:00
|
|
|
builder.install(&builder.src.join("src/doc/robots.txt"), &dst, 0o644);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2017-07-05 10:46:41 -06:00
|
|
|
let mut cmd = rust_installer(builder);
|
2017-07-04 19:41:43 -06:00
|
|
|
cmd.arg("generate")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--product-name=Rust-Documentation")
|
|
|
|
.arg("--rel-manifest-dir=rustlib")
|
|
|
|
.arg("--success-message=Rust-documentation-is-installed.")
|
|
|
|
.arg("--image-dir")
|
|
|
|
.arg(&image)
|
|
|
|
.arg("--work-dir")
|
|
|
|
.arg(&tmpdir(builder))
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
2020-07-18 14:06:20 -04:00
|
|
|
.arg(format!("--package-name={}-{}", name, host.triple))
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--component-name=rust-docs")
|
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo")
|
|
|
|
.arg("--bulk-dirs=share/doc/rust/html");
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.run(&mut cmd);
|
|
|
|
builder.remove_dir(&image);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2020-07-18 14:06:20 -04:00
|
|
|
distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple))
|
2018-03-20 02:06:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
|
|
|
pub struct RustcDocs {
|
2020-07-17 10:08:04 -04:00
|
|
|
pub host: TargetSelection,
|
2018-03-20 02:06:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Step for RustcDocs {
|
|
|
|
type Output = PathBuf;
|
|
|
|
const DEFAULT: bool = true;
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2018-03-20 02:06:38 +00:00
|
|
|
run.path("src/librustc")
|
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2019-12-22 17:42:04 -05:00
|
|
|
run.builder.ensure(RustcDocs { host: run.target });
|
2018-03-20 02:06:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Builds the `rustc-docs` installer component.
|
2019-02-25 19:30:32 +09:00
|
|
|
fn run(self, builder: &Builder<'_>) -> PathBuf {
|
2018-03-20 02:06:38 +00:00
|
|
|
let host = self.host;
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
let name = pkgname(builder, "rustc-docs");
|
2018-03-20 02:06:38 +00:00
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
if !builder.config.compiler_docs {
|
2020-07-18 14:06:20 -04:00
|
|
|
return distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple));
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2017-07-12 18:52:31 -06:00
|
|
|
|
2018-03-20 02:06:38 +00:00
|
|
|
builder.default_doc(None);
|
|
|
|
|
2020-07-18 14:06:20 -04:00
|
|
|
let image = tmpdir(builder).join(format!("{}-{}-image", name, host.triple));
|
2018-03-20 02:06:38 +00:00
|
|
|
let _ = fs::remove_dir_all(&image);
|
|
|
|
|
2020-08-16 11:38:46 -04:00
|
|
|
let dst = image.join("share/doc/rust/html/rustc");
|
2018-03-20 02:06:38 +00:00
|
|
|
t!(fs::create_dir_all(&dst));
|
2018-04-14 17:27:57 -06:00
|
|
|
let src = builder.compiler_doc_out(host);
|
|
|
|
builder.cp_r(&src, &dst);
|
2018-03-20 02:06:38 +00:00
|
|
|
|
|
|
|
let mut cmd = rust_installer(builder);
|
|
|
|
cmd.arg("generate")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--product-name=Rustc-Documentation")
|
|
|
|
.arg("--rel-manifest-dir=rustlib")
|
|
|
|
.arg("--success-message=Rustc-documentation-is-installed.")
|
|
|
|
.arg("--image-dir")
|
|
|
|
.arg(&image)
|
|
|
|
.arg("--work-dir")
|
|
|
|
.arg(&tmpdir(builder))
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
2020-07-18 14:06:20 -04:00
|
|
|
.arg(format!("--package-name={}-{}", name, host.triple))
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--component-name=rustc-docs")
|
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo")
|
2020-08-16 11:38:46 -04:00
|
|
|
.arg("--bulk-dirs=share/doc/rust/html/rustc");
|
2019-09-19 11:22:55 -07:00
|
|
|
|
|
|
|
builder.info(&format!("Dist compiler docs ({})", host));
|
|
|
|
let _time = timeit(builder);
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.run(&mut cmd);
|
|
|
|
builder.remove_dir(&image);
|
2018-03-20 02:06:38 +00:00
|
|
|
|
2020-07-18 14:06:20 -04:00
|
|
|
distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple))
|
2016-04-05 10:01:31 -07:00
|
|
|
}
|
2016-03-13 16:52:19 -07:00
|
|
|
}
|
|
|
|
|
2017-05-06 14:29:37 -04:00
|
|
|
fn find_files(files: &[&str], path: &[PathBuf]) -> Vec<PathBuf> {
|
2017-06-27 09:05:47 -06:00
|
|
|
let mut found = Vec::with_capacity(files.len());
|
2017-05-06 14:29:37 -04:00
|
|
|
|
|
|
|
for file in files {
|
2019-12-22 17:42:04 -05:00
|
|
|
let file_path = path.iter().map(|dir| dir.join(file)).find(|p| p.exists());
|
2017-05-06 14:29:37 -04:00
|
|
|
|
|
|
|
if let Some(file_path) = file_path {
|
|
|
|
found.push(file_path);
|
|
|
|
} else {
|
|
|
|
panic!("Could not find '{}' in {:?}", file, path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
found
|
|
|
|
}
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
fn make_win_dist(
|
2019-12-22 17:42:04 -05:00
|
|
|
rust_root: &Path,
|
|
|
|
plat_root: &Path,
|
2020-07-17 10:08:04 -04:00
|
|
|
target: TargetSelection,
|
2019-12-22 17:42:04 -05:00
|
|
|
builder: &Builder<'_>,
|
2017-07-13 18:48:44 -06:00
|
|
|
) {
|
2017-05-06 14:29:37 -04:00
|
|
|
//Ask gcc where it keeps its stuff
|
2020-07-17 10:08:04 -04:00
|
|
|
let mut cmd = Command::new(builder.cc(target));
|
2017-05-06 14:29:37 -04:00
|
|
|
cmd.arg("-print-search-dirs");
|
2017-06-27 09:05:47 -06:00
|
|
|
let gcc_out = output(&mut cmd);
|
|
|
|
|
|
|
|
let mut bin_path: Vec<_> = env::split_paths(&env::var_os("PATH").unwrap_or_default()).collect();
|
2017-05-06 14:29:37 -04:00
|
|
|
let mut lib_path = Vec::new();
|
|
|
|
|
|
|
|
for line in gcc_out.lines() {
|
|
|
|
let idx = line.find(':').unwrap();
|
|
|
|
let key = &line[..idx];
|
|
|
|
let trim_chars: &[_] = &[' ', '='];
|
2020-08-17 14:53:24 +02:00
|
|
|
let value = env::split_paths(line[(idx + 1)..].trim_start_matches(trim_chars));
|
2017-05-06 14:29:37 -04:00
|
|
|
|
|
|
|
if key == "programs" {
|
|
|
|
bin_path.extend(value);
|
|
|
|
} else if key == "libraries" {
|
|
|
|
lib_path.extend(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-17 10:08:04 -04:00
|
|
|
let compiler = if target == "i686-pc-windows-gnu" {
|
2020-02-28 14:15:06 +01:00
|
|
|
"i686-w64-mingw32-gcc.exe"
|
2020-07-17 10:08:04 -04:00
|
|
|
} else if target == "x86_64-pc-windows-gnu" {
|
2020-02-28 14:15:06 +01:00
|
|
|
"x86_64-w64-mingw32-gcc.exe"
|
|
|
|
} else {
|
|
|
|
"gcc.exe"
|
|
|
|
};
|
2020-02-29 11:54:33 +01:00
|
|
|
let target_tools = [compiler, "ld.exe", "dlltool.exe", "libwinpthread-1.dll"];
|
2019-10-28 21:43:37 +01:00
|
|
|
let mut rustc_dlls = vec!["libwinpthread-1.dll"];
|
2020-07-17 10:08:04 -04:00
|
|
|
if target.starts_with("i686-") {
|
2017-05-06 14:29:37 -04:00
|
|
|
rustc_dlls.push("libgcc_s_dw2-1.dll");
|
|
|
|
} else {
|
|
|
|
rustc_dlls.push("libgcc_s_seh-1.dll");
|
|
|
|
}
|
|
|
|
|
2019-12-22 17:42:04 -05:00
|
|
|
let target_libs = [
|
|
|
|
//MinGW libs
|
2017-05-06 14:29:37 -04:00
|
|
|
"libgcc.a",
|
|
|
|
"libgcc_eh.a",
|
|
|
|
"libgcc_s.a",
|
|
|
|
"libm.a",
|
|
|
|
"libmingw32.a",
|
|
|
|
"libmingwex.a",
|
|
|
|
"libstdc++.a",
|
|
|
|
"libiconv.a",
|
|
|
|
"libmoldname.a",
|
|
|
|
"libpthread.a",
|
|
|
|
//Windows import libs
|
|
|
|
"libadvapi32.a",
|
|
|
|
"libbcrypt.a",
|
|
|
|
"libcomctl32.a",
|
|
|
|
"libcomdlg32.a",
|
2018-03-15 11:35:07 -07:00
|
|
|
"libcredui.a",
|
2017-05-06 14:29:37 -04:00
|
|
|
"libcrypt32.a",
|
2018-03-15 11:35:07 -07:00
|
|
|
"libdbghelp.a",
|
2017-05-06 14:29:37 -04:00
|
|
|
"libgdi32.a",
|
|
|
|
"libimagehlp.a",
|
|
|
|
"libiphlpapi.a",
|
|
|
|
"libkernel32.a",
|
2018-03-15 11:35:07 -07:00
|
|
|
"libmsimg32.a",
|
2017-05-06 14:29:37 -04:00
|
|
|
"libmsvcrt.a",
|
|
|
|
"libodbc32.a",
|
|
|
|
"libole32.a",
|
|
|
|
"liboleaut32.a",
|
|
|
|
"libopengl32.a",
|
|
|
|
"libpsapi.a",
|
|
|
|
"librpcrt4.a",
|
2018-03-15 11:35:07 -07:00
|
|
|
"libsecur32.a",
|
2017-05-06 14:29:37 -04:00
|
|
|
"libsetupapi.a",
|
|
|
|
"libshell32.a",
|
2018-03-18 03:05:00 +02:00
|
|
|
"libsynchronization.a",
|
2017-05-06 14:29:37 -04:00
|
|
|
"libuser32.a",
|
|
|
|
"libuserenv.a",
|
|
|
|
"libuuid.a",
|
|
|
|
"libwinhttp.a",
|
|
|
|
"libwinmm.a",
|
|
|
|
"libwinspool.a",
|
|
|
|
"libws2_32.a",
|
|
|
|
"libwsock32.a",
|
|
|
|
];
|
|
|
|
|
|
|
|
//Find mingw artifacts we want to bundle
|
|
|
|
let target_tools = find_files(&target_tools, &bin_path);
|
|
|
|
let rustc_dlls = find_files(&rustc_dlls, &bin_path);
|
|
|
|
let target_libs = find_files(&target_libs, &lib_path);
|
|
|
|
|
2018-03-27 16:06:47 +02:00
|
|
|
// Copy runtime dlls next to rustc.exe
|
2017-05-06 14:29:37 -04:00
|
|
|
let dist_bin_dir = rust_root.join("bin/");
|
2017-05-22 21:32:27 -04:00
|
|
|
fs::create_dir_all(&dist_bin_dir).expect("creating dist_bin_dir failed");
|
2017-05-06 14:29:37 -04:00
|
|
|
for src in rustc_dlls {
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.copy_to_folder(&src, &dist_bin_dir);
|
2017-05-06 14:29:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//Copy platform tools to platform-specific bin directory
|
2020-06-08 13:20:26 +02:00
|
|
|
let target_bin_dir = plat_root
|
|
|
|
.join("lib")
|
|
|
|
.join("rustlib")
|
2020-07-17 10:08:04 -04:00
|
|
|
.join(target.triple)
|
2020-06-08 13:20:26 +02:00
|
|
|
.join("bin")
|
|
|
|
.join("self-contained");
|
2017-05-06 14:29:37 -04:00
|
|
|
fs::create_dir_all(&target_bin_dir).expect("creating target_bin_dir failed");
|
|
|
|
for src in target_tools {
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.copy_to_folder(&src, &target_bin_dir);
|
2017-05-06 14:29:37 -04:00
|
|
|
}
|
|
|
|
|
2018-07-09 15:28:12 +02:00
|
|
|
// Warn windows-gnu users that the bundled GCC cannot compile C files
|
|
|
|
builder.create(
|
2018-07-09 21:25:16 +02:00
|
|
|
&target_bin_dir.join("GCC-WARNING.txt"),
|
2020-09-08 12:20:49 +03:00
|
|
|
"gcc.exe contained in this folder cannot be used for compiling C files - it is only \
|
|
|
|
used as a linker. In order to be able to compile projects containing C code use \
|
2019-12-22 17:42:04 -05:00
|
|
|
the GCC provided by MinGW or Cygwin.",
|
2018-07-09 15:28:12 +02:00
|
|
|
);
|
|
|
|
|
2017-05-06 14:29:37 -04:00
|
|
|
//Copy platform libs to platform-specific lib directory
|
2020-06-11 18:12:19 +02:00
|
|
|
let target_lib_dir = plat_root
|
|
|
|
.join("lib")
|
|
|
|
.join("rustlib")
|
2020-07-17 10:08:04 -04:00
|
|
|
.join(target.triple)
|
2020-06-11 18:12:19 +02:00
|
|
|
.join("lib")
|
|
|
|
.join("self-contained");
|
2017-05-06 14:29:37 -04:00
|
|
|
fs::create_dir_all(&target_lib_dir).expect("creating target_lib_dir failed");
|
|
|
|
for src in target_libs {
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.copy_to_folder(&src, &target_lib_dir);
|
2017-05-06 14:29:37 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-10 07:01:06 -07:00
|
|
|
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
2017-07-13 18:48:44 -06:00
|
|
|
pub struct Mingw {
|
2020-07-17 10:08:04 -04:00
|
|
|
pub host: TargetSelection,
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2016-03-13 16:52:19 -07:00
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
impl Step for Mingw {
|
2017-07-12 18:52:31 -06:00
|
|
|
type Output = Option<PathBuf>;
|
2017-07-05 06:41:27 -06:00
|
|
|
const DEFAULT: bool = true;
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2017-07-18 18:03:38 -06:00
|
|
|
run.never()
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2017-07-23 10:03:40 -06:00
|
|
|
run.builder.ensure(Mingw { host: run.target });
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2019-02-08 14:53:55 +01:00
|
|
|
/// Builds the `rust-mingw` installer component.
|
2017-07-04 19:41:43 -06:00
|
|
|
///
|
|
|
|
/// This contains all the bits and pieces to run the MinGW Windows targets
|
2018-11-27 02:59:49 +00:00
|
|
|
/// without any extra installed software (e.g., we bundle gcc, libraries, etc).
|
2019-02-25 19:30:32 +09:00
|
|
|
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
|
2017-07-23 10:03:40 -06:00
|
|
|
let host = self.host;
|
2017-07-05 06:41:27 -06:00
|
|
|
|
2017-07-23 10:03:40 -06:00
|
|
|
if !host.contains("pc-windows-gnu") {
|
2017-07-12 18:52:31 -06:00
|
|
|
return None;
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.info(&format!("Dist mingw ({})", host));
|
2019-09-19 11:22:55 -07:00
|
|
|
let _time = timeit(builder);
|
2018-04-14 17:27:57 -06:00
|
|
|
let name = pkgname(builder, "rust-mingw");
|
2020-07-18 14:06:20 -04:00
|
|
|
let image = tmpdir(builder).join(format!("{}-{}-image", name, host.triple));
|
2017-07-04 19:41:43 -06:00
|
|
|
let _ = fs::remove_dir_all(&image);
|
|
|
|
t!(fs::create_dir_all(&image));
|
|
|
|
|
|
|
|
// The first argument is a "temporary directory" which is just
|
|
|
|
// thrown away (this contains the runtime DLLs included in the rustc package
|
|
|
|
// above) and the second argument is where to place all the MinGW components
|
|
|
|
// (which is what we want).
|
2018-04-14 17:27:57 -06:00
|
|
|
make_win_dist(&tmpdir(builder), &image, host, &builder);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2017-07-05 10:46:41 -06:00
|
|
|
let mut cmd = rust_installer(builder);
|
2017-07-04 19:41:43 -06:00
|
|
|
cmd.arg("generate")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--product-name=Rust-MinGW")
|
|
|
|
.arg("--rel-manifest-dir=rustlib")
|
|
|
|
.arg("--success-message=Rust-MinGW-is-installed.")
|
|
|
|
.arg("--image-dir")
|
|
|
|
.arg(&image)
|
|
|
|
.arg("--work-dir")
|
|
|
|
.arg(&tmpdir(builder))
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
2020-07-18 14:06:20 -04:00
|
|
|
.arg(format!("--package-name={}-{}", name, host.triple))
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--component-name=rust-mingw")
|
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo");
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.run(&mut cmd);
|
2017-07-04 19:41:43 -06:00
|
|
|
t!(fs::remove_dir_all(&image));
|
2020-07-18 14:06:20 -04:00
|
|
|
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple)))
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2016-03-13 16:52:19 -07:00
|
|
|
}
|
|
|
|
|
2018-03-10 07:01:06 -07:00
|
|
|
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
2017-07-13 18:48:44 -06:00
|
|
|
pub struct Rustc {
|
2017-07-23 10:03:40 -06:00
|
|
|
pub compiler: Compiler,
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2016-03-13 16:52:19 -07:00
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
impl Step for Rustc {
|
2017-07-12 18:52:31 -06:00
|
|
|
type Output = PathBuf;
|
2017-07-05 06:41:27 -06:00
|
|
|
const DEFAULT: bool = true;
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2017-07-18 18:03:38 -06:00
|
|
|
run.path("src/librustc")
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2019-12-22 17:42:04 -05:00
|
|
|
run.builder
|
|
|
|
.ensure(Rustc { compiler: run.builder.compiler(run.builder.top_stage, run.target) });
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
/// Creates the `rustc` installer component.
|
2019-02-25 19:30:32 +09:00
|
|
|
fn run(self, builder: &Builder<'_>) -> PathBuf {
|
2017-07-23 10:03:40 -06:00
|
|
|
let compiler = self.compiler;
|
|
|
|
let host = self.compiler.host;
|
2017-07-12 18:52:31 -06:00
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
let name = pkgname(builder, "rustc");
|
2020-07-18 14:06:20 -04:00
|
|
|
let image = tmpdir(builder).join(format!("{}-{}-image", name, host.triple));
|
2017-07-04 19:41:43 -06:00
|
|
|
let _ = fs::remove_dir_all(&image);
|
2020-07-18 14:06:20 -04:00
|
|
|
let overlay = tmpdir(builder).join(format!("{}-{}-overlay", name, host.triple));
|
2017-07-04 19:41:43 -06:00
|
|
|
let _ = fs::remove_dir_all(&overlay);
|
|
|
|
|
|
|
|
// Prepare the rustc "image", what will actually end up getting installed
|
2017-07-23 10:03:40 -06:00
|
|
|
prepare_image(builder, compiler, &image);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// Prepare the overlay which is part of the tarball but won't actually be
|
|
|
|
// installed
|
2016-03-13 16:52:19 -07:00
|
|
|
let cp = |file: &str| {
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&builder.src.join(file), &overlay, 0o644);
|
2016-03-13 16:52:19 -07:00
|
|
|
};
|
|
|
|
cp("COPYRIGHT");
|
|
|
|
cp("LICENSE-APACHE");
|
|
|
|
cp("LICENSE-MIT");
|
|
|
|
cp("README.md");
|
2017-07-04 19:41:43 -06:00
|
|
|
// tiny morsel of metadata is used by rust-packaging
|
2018-04-14 17:27:57 -06:00
|
|
|
let version = builder.rust_version();
|
|
|
|
builder.create(&overlay.join("version"), &version);
|
|
|
|
if let Some(sha) = builder.rust_sha() {
|
|
|
|
builder.create(&overlay.join("git-commit-hash"), &sha);
|
2017-09-04 16:29:57 +02:00
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// On MinGW we've got a few runtime DLL dependencies that we need to
|
|
|
|
// include. The first argument to this script is where to put these DLLs
|
|
|
|
// (the image we're creating), and the second argument is a junk directory
|
|
|
|
// to ignore all other MinGW stuff the script creates.
|
|
|
|
//
|
|
|
|
// On 32-bit MinGW we're always including a DLL which needs some extra
|
|
|
|
// licenses to distribute. On 64-bit MinGW we don't actually distribute
|
|
|
|
// anything requiring us to distribute a license, but it's likely the
|
|
|
|
// install will *also* include the rust-mingw package, which also needs
|
|
|
|
// licenses, so to be safe we just include it here in all MinGW packages.
|
2017-07-23 10:03:40 -06:00
|
|
|
if host.contains("pc-windows-gnu") {
|
2018-04-14 17:27:57 -06:00
|
|
|
make_win_dist(&image, &tmpdir(builder), host, builder);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
let dst = image.join("share/doc");
|
|
|
|
t!(fs::create_dir_all(&dst));
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.cp_r(&builder.src.join("src/etc/third-party"), &dst);
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Finally, wrap everything up in a nice tarball!
|
2017-07-05 10:46:41 -06:00
|
|
|
let mut cmd = rust_installer(builder);
|
2017-07-04 19:41:43 -06:00
|
|
|
cmd.arg("generate")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--product-name=Rust")
|
|
|
|
.arg("--rel-manifest-dir=rustlib")
|
|
|
|
.arg("--success-message=Rust-is-ready-to-roll.")
|
|
|
|
.arg("--image-dir")
|
|
|
|
.arg(&image)
|
|
|
|
.arg("--work-dir")
|
|
|
|
.arg(&tmpdir(builder))
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
|
|
|
.arg("--non-installed-overlay")
|
|
|
|
.arg(&overlay)
|
2020-07-18 14:06:20 -04:00
|
|
|
.arg(format!("--package-name={}-{}", name, host.triple))
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--component-name=rustc")
|
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo");
|
2019-09-19 11:22:55 -07:00
|
|
|
|
2020-07-18 14:06:20 -04:00
|
|
|
builder.info(&format!("Dist rustc stage{} ({})", compiler.stage, host.triple));
|
2019-09-19 11:22:55 -07:00
|
|
|
let _time = timeit(builder);
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.run(&mut cmd);
|
|
|
|
builder.remove_dir(&image);
|
|
|
|
builder.remove_dir(&overlay);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2020-07-18 14:06:20 -04:00
|
|
|
return distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple));
|
2017-07-12 18:52:31 -06:00
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) {
|
2017-07-23 10:03:40 -06:00
|
|
|
let host = compiler.host;
|
2017-07-12 18:52:31 -06:00
|
|
|
let src = builder.sysroot(compiler);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// Copy rustc/rustdoc binaries
|
|
|
|
t!(fs::create_dir_all(image.join("bin")));
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.cp_r(&src.join("bin"), &image.join("bin"));
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2019-03-03 09:50:56 -07:00
|
|
|
builder.install(&builder.rustdoc(compiler), &image.join("bin"), 0o755);
|
2017-07-22 20:01:58 -06:00
|
|
|
|
2019-03-31 22:28:12 +03:00
|
|
|
let libdir_relative = builder.libdir_relative(compiler);
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
// Copy runtime DLLs needed by the compiler
|
2019-03-31 22:28:12 +03:00
|
|
|
if libdir_relative.to_str() != Some("bin") {
|
2019-08-07 23:37:55 +03:00
|
|
|
let libdir = builder.rustc_libdir(compiler);
|
2019-03-31 22:28:12 +03:00
|
|
|
for entry in builder.read_dir(&libdir) {
|
2017-07-04 19:41:43 -06:00
|
|
|
let name = entry.file_name();
|
|
|
|
if let Some(s) = name.to_str() {
|
|
|
|
if is_dylib(s) {
|
2019-08-07 23:37:55 +03:00
|
|
|
// Don't use custom libdir here because ^lib/ will be resolved again
|
|
|
|
// with installer
|
|
|
|
builder.install(&entry.path(), &image.join("lib"), 0o644);
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-30 09:43:15 -07:00
|
|
|
// Copy libLLVM.so to the lib dir as well, if needed. While not
|
|
|
|
// technically needed by rustc itself it's needed by lots of other
|
|
|
|
// components like the llvm tools and LLD. LLD is included below and
|
|
|
|
// tools/LLDB come later, so let's just throw it in the rustc
|
|
|
|
// component for now.
|
2020-05-07 17:27:08 -07:00
|
|
|
maybe_install_llvm_runtime(builder, host, image);
|
2018-08-30 09:43:15 -07:00
|
|
|
|
rust: Import LLD for linking wasm objects
This commit imports the LLD project from LLVM to serve as the default linker for
the `wasm32-unknown-unknown` target. The `binaryen` submoule is consequently
removed along with "binaryen linker" support in rustc.
Moving to LLD brings with it a number of benefits for wasm code:
* LLD is itself an actual linker, so there's no need to compile all wasm code
with LTO any more. As a result builds should be *much* speedier as LTO is no
longer forcibly enabled for all builds of the wasm target.
* LLD is quickly becoming an "official solution" for linking wasm code together.
This, I believe at least, is intended to be the main supported linker for
native code and wasm moving forward. Picking up support early on should help
ensure that we can help LLD identify bugs and otherwise prove that it works
great for all our use cases!
* Improvements to the wasm toolchain are currently primarily focused around LLVM
and LLD (from what I can tell at least), so it's in general much better to be
on this bandwagon for bugfixes and new features.
* Historical "hacks" like `wasm-gc` will soon no longer be necessary, LLD
will [natively implement][gc] `--gc-sections` (better than `wasm-gc`!) which
means a postprocessor is no longer needed to show off Rust's "small wasm
binary size".
LLD is added in a pretty standard way to rustc right now. A new rustbuild target
was defined for building LLD, and this is executed when a compiler's sysroot is
being assembled. LLD is compiled against the LLVM that we've got in tree, which
means we're currently on the `release_60` branch, but this may get upgraded in
the near future!
LLD is placed into rustc's sysroot in a `bin` directory. This is similar to
where `gcc.exe` can be found on Windows. This directory is automatically added
to `PATH` whenever rustc executes the linker, allowing us to define a `WasmLd`
linker which implements the interface that `wasm-ld`, LLD's frontend, expects.
Like Emscripten the LLD target is currently only enabled for Tier 1 platforms,
notably OSX/Windows/Linux, and will need to be installed manually for compiling
to wasm on other platforms. LLD is by default turned off in rustbuild, and
requires a `config.toml` option to be enabled to turn it on.
Finally the unstable `#![wasm_import_memory]` attribute was also removed as LLD
has a native option for controlling this.
[gc]: https://reviews.llvm.org/D42511
2017-08-26 18:30:12 -07:00
|
|
|
// Copy over lld if it's there
|
|
|
|
if builder.config.lld_enabled {
|
2020-07-17 10:08:04 -04:00
|
|
|
let exe = exe("rust-lld", compiler.host);
|
2019-12-22 17:42:04 -05:00
|
|
|
let src =
|
|
|
|
builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin").join(&exe);
|
2018-06-29 22:20:00 -05:00
|
|
|
// for the rationale about this rename check `compile::copy_lld_to_sysroot`
|
2020-07-17 10:08:04 -04:00
|
|
|
let dst = image.join("lib/rustlib").join(&*host.triple).join("bin").join(&exe);
|
rust: Import LLD for linking wasm objects
This commit imports the LLD project from LLVM to serve as the default linker for
the `wasm32-unknown-unknown` target. The `binaryen` submoule is consequently
removed along with "binaryen linker" support in rustc.
Moving to LLD brings with it a number of benefits for wasm code:
* LLD is itself an actual linker, so there's no need to compile all wasm code
with LTO any more. As a result builds should be *much* speedier as LTO is no
longer forcibly enabled for all builds of the wasm target.
* LLD is quickly becoming an "official solution" for linking wasm code together.
This, I believe at least, is intended to be the main supported linker for
native code and wasm moving forward. Picking up support early on should help
ensure that we can help LLD identify bugs and otherwise prove that it works
great for all our use cases!
* Improvements to the wasm toolchain are currently primarily focused around LLVM
and LLD (from what I can tell at least), so it's in general much better to be
on this bandwagon for bugfixes and new features.
* Historical "hacks" like `wasm-gc` will soon no longer be necessary, LLD
will [natively implement][gc] `--gc-sections` (better than `wasm-gc`!) which
means a postprocessor is no longer needed to show off Rust's "small wasm
binary size".
LLD is added in a pretty standard way to rustc right now. A new rustbuild target
was defined for building LLD, and this is executed when a compiler's sysroot is
being assembled. LLD is compiled against the LLVM that we've got in tree, which
means we're currently on the `release_60` branch, but this may get upgraded in
the near future!
LLD is placed into rustc's sysroot in a `bin` directory. This is similar to
where `gcc.exe` can be found on Windows. This directory is automatically added
to `PATH` whenever rustc executes the linker, allowing us to define a `WasmLd`
linker which implements the interface that `wasm-ld`, LLD's frontend, expects.
Like Emscripten the LLD target is currently only enabled for Tier 1 platforms,
notably OSX/Windows/Linux, and will need to be installed manually for compiling
to wasm on other platforms. LLD is by default turned off in rustbuild, and
requires a `config.toml` option to be enabled to turn it on.
Finally the unstable `#![wasm_import_memory]` attribute was also removed as LLD
has a native option for controlling this.
[gc]: https://reviews.llvm.org/D42511
2017-08-26 18:30:12 -07:00
|
|
|
t!(fs::create_dir_all(&dst.parent().unwrap()));
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.copy(&src, &dst);
|
rust: Import LLD for linking wasm objects
This commit imports the LLD project from LLVM to serve as the default linker for
the `wasm32-unknown-unknown` target. The `binaryen` submoule is consequently
removed along with "binaryen linker" support in rustc.
Moving to LLD brings with it a number of benefits for wasm code:
* LLD is itself an actual linker, so there's no need to compile all wasm code
with LTO any more. As a result builds should be *much* speedier as LTO is no
longer forcibly enabled for all builds of the wasm target.
* LLD is quickly becoming an "official solution" for linking wasm code together.
This, I believe at least, is intended to be the main supported linker for
native code and wasm moving forward. Picking up support early on should help
ensure that we can help LLD identify bugs and otherwise prove that it works
great for all our use cases!
* Improvements to the wasm toolchain are currently primarily focused around LLVM
and LLD (from what I can tell at least), so it's in general much better to be
on this bandwagon for bugfixes and new features.
* Historical "hacks" like `wasm-gc` will soon no longer be necessary, LLD
will [natively implement][gc] `--gc-sections` (better than `wasm-gc`!) which
means a postprocessor is no longer needed to show off Rust's "small wasm
binary size".
LLD is added in a pretty standard way to rustc right now. A new rustbuild target
was defined for building LLD, and this is executed when a compiler's sysroot is
being assembled. LLD is compiled against the LLVM that we've got in tree, which
means we're currently on the `release_60` branch, but this may get upgraded in
the near future!
LLD is placed into rustc's sysroot in a `bin` directory. This is similar to
where `gcc.exe` can be found on Windows. This directory is automatically added
to `PATH` whenever rustc executes the linker, allowing us to define a `WasmLd`
linker which implements the interface that `wasm-ld`, LLD's frontend, expects.
Like Emscripten the LLD target is currently only enabled for Tier 1 platforms,
notably OSX/Windows/Linux, and will need to be installed manually for compiling
to wasm on other platforms. LLD is by default turned off in rustbuild, and
requires a `config.toml` option to be enabled to turn it on.
Finally the unstable `#![wasm_import_memory]` attribute was also removed as LLD
has a native option for controlling this.
[gc]: https://reviews.llvm.org/D42511
2017-08-26 18:30:12 -07:00
|
|
|
}
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
// Man pages
|
|
|
|
t!(fs::create_dir_all(image.join("share/man/man1")));
|
2018-04-14 17:27:57 -06:00
|
|
|
let man_src = builder.src.join("src/doc/man");
|
2017-12-04 21:36:57 -08:00
|
|
|
let man_dst = image.join("share/man/man1");
|
2019-01-26 12:54:09 -05:00
|
|
|
|
|
|
|
// Reproducible builds: If SOURCE_DATE_EPOCH is set, use that as the time.
|
|
|
|
let time = env::var("SOURCE_DATE_EPOCH")
|
|
|
|
.map(|timestamp| {
|
2019-12-22 17:42:04 -05:00
|
|
|
let epoch = timestamp
|
|
|
|
.parse()
|
|
|
|
.map_err(|err| format!("could not parse SOURCE_DATE_EPOCH: {}", err))
|
|
|
|
.unwrap();
|
2019-01-26 12:54:09 -05:00
|
|
|
|
|
|
|
time::at(Timespec::new(epoch, 0))
|
|
|
|
})
|
|
|
|
.unwrap_or_else(|_| time::now());
|
|
|
|
|
|
|
|
let month_year = t!(time::strftime("%B %Y", &time));
|
2017-12-04 21:36:57 -08:00
|
|
|
// don't use our `bootstrap::util::{copy, cp_r}`, because those try
|
|
|
|
// to hardlink, and we don't want to edit the source templates
|
2018-04-14 17:27:57 -06:00
|
|
|
for file_entry in builder.read_dir(&man_src) {
|
2017-12-04 21:36:57 -08:00
|
|
|
let page_src = file_entry.path();
|
|
|
|
let page_dst = man_dst.join(file_entry.file_name());
|
|
|
|
t!(fs::copy(&page_src, &page_dst));
|
|
|
|
// template in month/year and version number
|
2019-12-22 17:42:04 -05:00
|
|
|
builder.replace_in_file(
|
|
|
|
&page_dst,
|
|
|
|
&[
|
|
|
|
("<INSERT DATE HERE>", &month_year),
|
|
|
|
("<INSERT VERSION HERE>", channel::CFG_RELEASE_NUM),
|
|
|
|
],
|
|
|
|
);
|
2017-12-04 21:36:57 -08:00
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// Debugger scripts
|
2019-12-22 17:42:04 -05:00
|
|
|
builder
|
|
|
|
.ensure(DebuggerScripts { sysroot: INTERNER.intern_path(image.to_owned()), host });
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// Misc license info
|
|
|
|
let cp = |file: &str| {
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&builder.src.join(file), &image.join("share/doc/rust"), 0o644);
|
2017-07-04 19:41:43 -06:00
|
|
|
};
|
|
|
|
cp("COPYRIGHT");
|
|
|
|
cp("LICENSE-APACHE");
|
|
|
|
cp("LICENSE-MIT");
|
|
|
|
cp("README.md");
|
|
|
|
}
|
2016-03-13 16:52:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
|
|
|
pub struct DebuggerScripts {
|
|
|
|
pub sysroot: Interned<PathBuf>,
|
2020-07-17 10:08:04 -04:00
|
|
|
pub host: TargetSelection,
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2016-04-05 11:34:23 -07:00
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
impl Step for DebuggerScripts {
|
2017-07-04 19:41:43 -06:00
|
|
|
type Output = ();
|
2016-04-08 19:10:56 +00:00
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2017-07-18 18:03:38 -06:00
|
|
|
run.path("src/lldb_batchmode.py")
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2017-07-20 17:51:07 -06:00
|
|
|
run.builder.ensure(DebuggerScripts {
|
|
|
|
sysroot: run.builder.sysroot(run.builder.compiler(run.builder.top_stage, run.host)),
|
2017-07-23 10:03:40 -06:00
|
|
|
host: run.target,
|
2017-07-05 06:41:27 -06:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-07-12 18:52:31 -06:00
|
|
|
/// Copies debugger scripts for `target` into the `sysroot` specified.
|
2019-02-25 19:30:32 +09:00
|
|
|
fn run(self, builder: &Builder<'_>) {
|
2017-07-23 10:03:40 -06:00
|
|
|
let host = self.host;
|
2017-07-04 19:41:43 -06:00
|
|
|
let sysroot = self.sysroot;
|
|
|
|
let dst = sysroot.join("lib/rustlib/etc");
|
|
|
|
t!(fs::create_dir_all(&dst));
|
|
|
|
let cp_debugger_script = |file: &str| {
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644);
|
2017-07-04 19:41:43 -06:00
|
|
|
};
|
2017-07-23 10:03:40 -06:00
|
|
|
if host.contains("windows-msvc") {
|
2017-07-04 19:41:43 -06:00
|
|
|
// windbg debugger scripts
|
2019-12-22 17:42:04 -05:00
|
|
|
builder.install(
|
|
|
|
&builder.src.join("src/etc/rust-windbg.cmd"),
|
|
|
|
&sysroot.join("bin"),
|
|
|
|
0o755,
|
|
|
|
);
|
2016-04-08 19:10:56 +00:00
|
|
|
|
2017-12-17 23:23:10 +01:00
|
|
|
cp_debugger_script("natvis/intrinsic.natvis");
|
2017-07-04 19:41:43 -06:00
|
|
|
cp_debugger_script("natvis/liballoc.natvis");
|
|
|
|
cp_debugger_script("natvis/libcore.natvis");
|
2019-11-20 19:27:42 -08:00
|
|
|
cp_debugger_script("natvis/libstd.natvis");
|
2017-07-04 19:41:43 -06:00
|
|
|
} else {
|
2019-05-14 15:50:58 +03:00
|
|
|
cp_debugger_script("rust_types.py");
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// gdb debugger scripts
|
2019-12-22 17:42:04 -05:00
|
|
|
builder.install(&builder.src.join("src/etc/rust-gdb"), &sysroot.join("bin"), 0o755);
|
|
|
|
builder.install(&builder.src.join("src/etc/rust-gdbgui"), &sysroot.join("bin"), 0o755);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
cp_debugger_script("gdb_load_rust_pretty_printers.py");
|
2019-05-14 15:50:58 +03:00
|
|
|
cp_debugger_script("gdb_lookup.py");
|
|
|
|
cp_debugger_script("gdb_providers.py");
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// lldb debugger scripts
|
2019-12-22 17:42:04 -05:00
|
|
|
builder.install(&builder.src.join("src/etc/rust-lldb"), &sysroot.join("bin"), 0o755);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2019-05-14 15:50:58 +03:00
|
|
|
cp_debugger_script("lldb_lookup.py");
|
|
|
|
cp_debugger_script("lldb_providers.py");
|
2020-08-28 09:29:45 +03:00
|
|
|
cp_debugger_script("lldb_commands")
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2016-04-05 11:34:23 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-26 14:44:08 -07:00
|
|
|
fn skip_host_target_lib(builder: &Builder<'_>, compiler: Compiler) -> bool {
|
|
|
|
// The only true set of target libraries came from the build triple, so
|
|
|
|
// let's reduce redundant work by only producing archives from that host.
|
|
|
|
if compiler.host != builder.config.build {
|
|
|
|
builder.info("\tskipping, not a build host");
|
|
|
|
true
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Copy stamped files into an image's `target/lib` directory.
|
2020-07-17 10:08:04 -04:00
|
|
|
fn copy_target_libs(builder: &Builder<'_>, target: TargetSelection, image: &Path, stamp: &Path) {
|
|
|
|
let dst = image.join("lib/rustlib").join(target.triple).join("lib");
|
2020-06-11 18:12:19 +02:00
|
|
|
let self_contained_dst = dst.join("self-contained");
|
2019-09-26 14:44:08 -07:00
|
|
|
t!(fs::create_dir_all(&dst));
|
2020-06-11 18:12:19 +02:00
|
|
|
t!(fs::create_dir_all(&self_contained_dst));
|
2020-06-03 00:56:27 +02:00
|
|
|
for (path, dependency_type) in builder.read_stamp_file(stamp) {
|
2020-06-11 18:12:19 +02:00
|
|
|
if dependency_type == DependencyType::TargetSelfContained {
|
|
|
|
builder.copy(&path, &self_contained_dst.join(path.file_name().unwrap()));
|
|
|
|
} else if dependency_type == DependencyType::Target || builder.config.build == target {
|
2019-09-26 14:44:08 -07:00
|
|
|
builder.copy(&path, &dst.join(path.file_name().unwrap()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-10 07:01:06 -07:00
|
|
|
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
2017-07-13 18:48:44 -06:00
|
|
|
pub struct Std {
|
|
|
|
pub compiler: Compiler,
|
2020-07-17 10:08:04 -04:00
|
|
|
pub target: TargetSelection,
|
2017-07-12 09:15:00 -06:00
|
|
|
}
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
impl Step for Std {
|
2017-07-23 10:03:40 -06:00
|
|
|
type Output = PathBuf;
|
2017-07-12 09:15:00 -06:00
|
|
|
const DEFAULT: bool = true;
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2020-06-11 21:31:49 -05:00
|
|
|
run.path("library/std")
|
2017-07-12 09:15:00 -06:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2017-07-20 17:51:07 -06:00
|
|
|
run.builder.ensure(Std {
|
2019-05-28 10:00:53 -07:00
|
|
|
compiler: run.builder.compiler_for(
|
|
|
|
run.builder.top_stage,
|
|
|
|
run.builder.config.build,
|
|
|
|
run.target,
|
|
|
|
),
|
2017-07-20 17:51:07 -06:00
|
|
|
target: run.target,
|
2017-07-12 09:15:00 -06:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn run(self, builder: &Builder<'_>) -> PathBuf {
|
2017-07-12 09:15:00 -06:00
|
|
|
let compiler = self.compiler;
|
|
|
|
let target = self.target;
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
let name = pkgname(builder, "rust-std");
|
2020-07-18 14:06:20 -04:00
|
|
|
let archive = distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple));
|
2019-09-26 14:44:08 -07:00
|
|
|
if skip_host_target_lib(builder, compiler) {
|
|
|
|
return archive;
|
2017-07-12 09:15:00 -06:00
|
|
|
}
|
|
|
|
|
2019-09-26 14:44:08 -07:00
|
|
|
builder.ensure(compile::Std { compiler, target });
|
2019-09-26 14:44:08 -07:00
|
|
|
|
2020-07-18 14:06:20 -04:00
|
|
|
let image = tmpdir(builder).join(format!("{}-{}-image", name, target.triple));
|
2019-09-26 14:44:08 -07:00
|
|
|
let _ = fs::remove_dir_all(&image);
|
|
|
|
|
2019-09-26 14:44:08 -07:00
|
|
|
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
|
|
|
|
let stamp = compile::libstd_stamp(builder, compiler_to_use, target);
|
2020-07-17 10:08:04 -04:00
|
|
|
copy_target_libs(builder, target, &image, &stamp);
|
2019-09-26 14:44:08 -07:00
|
|
|
|
|
|
|
let mut cmd = rust_installer(builder);
|
|
|
|
cmd.arg("generate")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--product-name=Rust")
|
|
|
|
.arg("--rel-manifest-dir=rustlib")
|
|
|
|
.arg("--success-message=std-is-standing-at-the-ready.")
|
|
|
|
.arg("--image-dir")
|
|
|
|
.arg(&image)
|
|
|
|
.arg("--work-dir")
|
|
|
|
.arg(&tmpdir(builder))
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
2020-07-18 14:06:20 -04:00
|
|
|
.arg(format!("--package-name={}-{}", name, target.triple))
|
|
|
|
.arg(format!("--component-name=rust-std-{}", target.triple))
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo");
|
|
|
|
|
|
|
|
builder
|
|
|
|
.info(&format!("Dist std stage{} ({} -> {})", compiler.stage, &compiler.host, target));
|
2019-09-26 14:44:08 -07:00
|
|
|
let _time = timeit(builder);
|
|
|
|
builder.run(&mut cmd);
|
|
|
|
builder.remove_dir(&image);
|
2019-09-26 14:44:08 -07:00
|
|
|
archive
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
|
|
|
pub struct RustcDev {
|
|
|
|
pub compiler: Compiler,
|
2020-07-17 10:08:04 -04:00
|
|
|
pub target: TargetSelection,
|
2019-09-26 14:44:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Step for RustcDev {
|
|
|
|
type Output = PathBuf;
|
|
|
|
const DEFAULT: bool = true;
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
|
|
|
run.path("rustc-dev")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn make_run(run: RunConfig<'_>) {
|
|
|
|
run.builder.ensure(RustcDev {
|
|
|
|
compiler: run.builder.compiler_for(
|
|
|
|
run.builder.top_stage,
|
|
|
|
run.builder.config.build,
|
|
|
|
run.target,
|
|
|
|
),
|
|
|
|
target: run.target,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run(self, builder: &Builder<'_>) -> PathBuf {
|
|
|
|
let compiler = self.compiler;
|
|
|
|
let target = self.target;
|
|
|
|
|
|
|
|
let name = pkgname(builder, "rustc-dev");
|
2020-07-18 14:06:20 -04:00
|
|
|
let archive = distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple));
|
2019-09-26 14:44:08 -07:00
|
|
|
if skip_host_target_lib(builder, compiler) {
|
|
|
|
return archive;
|
|
|
|
}
|
|
|
|
|
|
|
|
builder.ensure(compile::Rustc { compiler, target });
|
|
|
|
|
2020-07-18 14:06:20 -04:00
|
|
|
let image = tmpdir(builder).join(format!("{}-{}-image", name, target.triple));
|
2019-09-26 14:44:08 -07:00
|
|
|
let _ = fs::remove_dir_all(&image);
|
|
|
|
|
|
|
|
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
|
|
|
|
let stamp = compile::librustc_stamp(builder, compiler_to_use, target);
|
2020-07-17 10:08:04 -04:00
|
|
|
copy_target_libs(builder, target, &image, &stamp);
|
2019-09-26 14:44:08 -07:00
|
|
|
|
|
|
|
let mut cmd = rust_installer(builder);
|
|
|
|
cmd.arg("generate")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--product-name=Rust")
|
|
|
|
.arg("--rel-manifest-dir=rustlib")
|
|
|
|
.arg("--success-message=Rust-is-ready-to-develop.")
|
|
|
|
.arg("--image-dir")
|
|
|
|
.arg(&image)
|
|
|
|
.arg("--work-dir")
|
|
|
|
.arg(&tmpdir(builder))
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
2020-07-18 14:06:20 -04:00
|
|
|
.arg(format!("--package-name={}-{}", name, target.triple))
|
|
|
|
.arg(format!("--component-name=rustc-dev-{}", target.triple))
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo");
|
|
|
|
|
|
|
|
builder.info(&format!(
|
|
|
|
"Dist rustc-dev stage{} ({} -> {})",
|
|
|
|
compiler.stage, &compiler.host, target
|
|
|
|
));
|
2019-09-26 14:44:08 -07:00
|
|
|
let _time = timeit(builder);
|
|
|
|
builder.run(&mut cmd);
|
|
|
|
builder.remove_dir(&image);
|
|
|
|
archive
|
2017-07-12 09:15:00 -06:00
|
|
|
}
|
2016-03-13 16:52:19 -07:00
|
|
|
}
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
|
|
|
pub struct Analysis {
|
|
|
|
pub compiler: Compiler,
|
2020-07-17 10:08:04 -04:00
|
|
|
pub target: TargetSelection,
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2017-01-02 04:12:49 +08:00
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
impl Step for Analysis {
|
2017-07-23 10:03:40 -06:00
|
|
|
type Output = PathBuf;
|
2017-07-05 06:41:27 -06:00
|
|
|
const DEFAULT: bool = true;
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2017-07-20 17:24:11 -06:00
|
|
|
let builder = run.builder;
|
2018-04-14 17:27:57 -06:00
|
|
|
run.path("analysis").default_condition(builder.config.extended)
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2017-07-20 17:51:07 -06:00
|
|
|
run.builder.ensure(Analysis {
|
2019-05-28 11:50:05 -07:00
|
|
|
// Find the actual compiler (handling the full bootstrap option) which
|
|
|
|
// produced the save-analysis data because that data isn't copied
|
|
|
|
// through the sysroot uplifting.
|
|
|
|
compiler: run.builder.compiler_for(
|
|
|
|
run.builder.top_stage,
|
|
|
|
run.builder.config.build,
|
|
|
|
run.target,
|
|
|
|
),
|
2017-07-20 17:51:07 -06:00
|
|
|
target: run.target,
|
2017-07-05 06:41:27 -06:00
|
|
|
});
|
|
|
|
}
|
2016-10-27 11:41:56 +13:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
/// Creates a tarball of save-analysis metadata, if available.
|
2019-02-25 19:30:32 +09:00
|
|
|
fn run(self, builder: &Builder<'_>) -> PathBuf {
|
2017-07-04 19:41:43 -06:00
|
|
|
let compiler = self.compiler;
|
|
|
|
let target = self.target;
|
2018-04-14 17:27:57 -06:00
|
|
|
assert!(builder.config.extended);
|
|
|
|
let name = pkgname(builder, "rust-analysis");
|
2016-10-27 11:41:56 +13:00
|
|
|
|
2020-02-03 20:13:30 +01:00
|
|
|
if compiler.host != builder.config.build {
|
2020-07-18 14:06:20 -04:00
|
|
|
return distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple));
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2016-10-27 11:41:56 +13:00
|
|
|
|
2019-09-19 07:46:24 -07:00
|
|
|
builder.ensure(compile::Std { compiler, target });
|
2017-07-23 10:03:40 -06:00
|
|
|
|
2020-07-18 14:06:20 -04:00
|
|
|
let image = tmpdir(builder).join(format!("{}-{}-image", name, target.triple));
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2019-12-22 17:42:04 -05:00
|
|
|
let src = builder
|
|
|
|
.stage_out(compiler, Mode::Std)
|
2020-07-17 10:08:04 -04:00
|
|
|
.join(target.triple)
|
2019-12-22 17:42:04 -05:00
|
|
|
.join(builder.cargo_dir())
|
|
|
|
.join("deps");
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
let image_src = src.join("save-analysis");
|
2020-07-17 10:08:04 -04:00
|
|
|
let dst = image.join("lib/rustlib").join(target.triple).join("analysis");
|
2017-07-04 19:41:43 -06:00
|
|
|
t!(fs::create_dir_all(&dst));
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.info(&format!("image_src: {:?}, dst: {:?}", image_src, dst));
|
|
|
|
builder.cp_r(&image_src, &dst);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2017-07-05 10:46:41 -06:00
|
|
|
let mut cmd = rust_installer(builder);
|
2017-07-04 19:41:43 -06:00
|
|
|
cmd.arg("generate")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--product-name=Rust")
|
|
|
|
.arg("--rel-manifest-dir=rustlib")
|
|
|
|
.arg("--success-message=save-analysis-saved.")
|
|
|
|
.arg("--image-dir")
|
|
|
|
.arg(&image)
|
|
|
|
.arg("--work-dir")
|
|
|
|
.arg(&tmpdir(builder))
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
2020-07-18 14:06:20 -04:00
|
|
|
.arg(format!("--package-name={}-{}", name, target.triple))
|
|
|
|
.arg(format!("--component-name=rust-analysis-{}", target.triple))
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo");
|
2019-09-19 11:22:55 -07:00
|
|
|
|
|
|
|
builder.info("Dist analysis");
|
|
|
|
let _time = timeit(builder);
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.run(&mut cmd);
|
|
|
|
builder.remove_dir(&image);
|
2020-07-18 14:06:20 -04:00
|
|
|
distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple))
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2016-10-27 11:41:56 +13:00
|
|
|
}
|
|
|
|
|
2020-06-11 21:31:49 -05:00
|
|
|
/// Use the `builder` to make a filtered copy of `base`/X for X in (`src_dirs` - `exclude_dirs`) to
|
|
|
|
/// `dst_dir`.
|
|
|
|
fn copy_src_dirs(
|
|
|
|
builder: &Builder<'_>,
|
|
|
|
base: &Path,
|
|
|
|
src_dirs: &[&str],
|
|
|
|
exclude_dirs: &[&str],
|
|
|
|
dst_dir: &Path,
|
|
|
|
) {
|
2017-05-24 18:31:05 -07:00
|
|
|
fn filter_fn(exclude_dirs: &[&str], dir: &str, path: &Path) -> bool {
|
2016-10-07 12:26:45 -07:00
|
|
|
let spath = match path.to_str() {
|
|
|
|
Some(path) => path,
|
|
|
|
None => return false,
|
|
|
|
};
|
2020-02-03 20:13:30 +01:00
|
|
|
if spath.ends_with('~') || spath.ends_with(".pyc") {
|
2019-12-22 17:42:04 -05:00
|
|
|
return false;
|
2016-07-09 13:33:03 +01:00
|
|
|
}
|
2019-01-16 09:59:03 -08:00
|
|
|
|
|
|
|
const LLVM_PROJECTS: &[&str] = &[
|
2019-12-22 17:42:04 -05:00
|
|
|
"llvm-project/clang",
|
|
|
|
"llvm-project\\clang",
|
|
|
|
"llvm-project/libunwind",
|
|
|
|
"llvm-project\\libunwind",
|
|
|
|
"llvm-project/lld",
|
|
|
|
"llvm-project\\lld",
|
|
|
|
"llvm-project/lldb",
|
|
|
|
"llvm-project\\lldb",
|
|
|
|
"llvm-project/llvm",
|
|
|
|
"llvm-project\\llvm",
|
|
|
|
"llvm-project/compiler-rt",
|
|
|
|
"llvm-project\\compiler-rt",
|
2019-01-16 09:59:03 -08:00
|
|
|
];
|
2019-12-22 17:42:04 -05:00
|
|
|
if spath.contains("llvm-project")
|
|
|
|
&& !spath.ends_with("llvm-project")
|
2019-01-16 09:59:03 -08:00
|
|
|
&& !LLVM_PROJECTS.iter().any(|path| spath.contains(path))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-12-22 17:42:04 -05:00
|
|
|
const LLVM_TEST: &[&str] = &["llvm-project/llvm/test", "llvm-project\\llvm\\test"];
|
|
|
|
if LLVM_TEST.iter().any(|path| spath.contains(path))
|
|
|
|
&& (spath.ends_with(".ll") || spath.ends_with(".td") || spath.ends_with(".s"))
|
|
|
|
{
|
|
|
|
return false;
|
2016-10-07 12:26:45 -07:00
|
|
|
}
|
|
|
|
|
2017-05-24 18:31:05 -07:00
|
|
|
let full_path = Path::new(dir).join(path);
|
|
|
|
if exclude_dirs.iter().any(|excl| full_path == Path::new(excl)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-10-07 12:26:45 -07:00
|
|
|
let excludes = [
|
2019-12-22 17:42:04 -05:00
|
|
|
"CVS",
|
|
|
|
"RCS",
|
|
|
|
"SCCS",
|
|
|
|
".git",
|
|
|
|
".gitignore",
|
|
|
|
".gitmodules",
|
|
|
|
".gitattributes",
|
|
|
|
".cvsignore",
|
|
|
|
".svn",
|
|
|
|
".arch-ids",
|
|
|
|
"{arch}",
|
|
|
|
"=RELEASE-ID",
|
|
|
|
"=meta-update",
|
|
|
|
"=update",
|
|
|
|
".bzr",
|
|
|
|
".bzrignore",
|
|
|
|
".bzrtags",
|
|
|
|
".hg",
|
|
|
|
".hgignore",
|
|
|
|
".hgrags",
|
|
|
|
"_darcs",
|
2016-10-07 12:26:45 -07:00
|
|
|
];
|
2019-12-22 17:42:04 -05:00
|
|
|
!path.iter().map(|s| s.to_str().unwrap()).any(|s| excludes.contains(&s))
|
2017-05-24 18:31:05 -07:00
|
|
|
}
|
2016-07-09 13:33:03 +01:00
|
|
|
|
|
|
|
// Copy the directories using our filter
|
2017-05-18 22:48:14 +02:00
|
|
|
for item in src_dirs {
|
|
|
|
let dst = &dst_dir.join(item);
|
|
|
|
t!(fs::create_dir_all(dst));
|
2020-06-11 21:31:49 -05:00
|
|
|
builder.cp_filtered(&base.join(item), dst, &|path| filter_fn(exclude_dirs, item, path));
|
2016-07-09 13:33:03 +01:00
|
|
|
}
|
2017-05-18 22:48:14 +02:00
|
|
|
}
|
2017-04-25 15:34:31 -07:00
|
|
|
|
2018-03-10 07:01:06 -07:00
|
|
|
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
2017-07-04 19:41:43 -06:00
|
|
|
pub struct Src;
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
impl Step for Src {
|
2017-07-12 18:52:31 -06:00
|
|
|
/// The output path of the src installer tarball
|
|
|
|
type Output = PathBuf;
|
2017-07-05 06:41:27 -06:00
|
|
|
const DEFAULT: bool = true;
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2017-07-18 18:03:38 -06:00
|
|
|
run.path("src")
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2017-07-20 17:51:07 -06:00
|
|
|
run.builder.ensure(Src);
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
/// Creates the `rust-src` installer component
|
2019-02-25 19:30:32 +09:00
|
|
|
fn run(self, builder: &Builder<'_>) -> PathBuf {
|
2018-04-14 17:27:57 -06:00
|
|
|
let name = pkgname(builder, "rust-src");
|
|
|
|
let image = tmpdir(builder).join(format!("{}-image", name));
|
2017-07-04 19:41:43 -06:00
|
|
|
let _ = fs::remove_dir_all(&image);
|
|
|
|
|
2020-06-11 21:31:49 -05:00
|
|
|
// A lot of tools expect the rust-src component to be entirely in this directory, so if you
|
|
|
|
// change that (e.g. by adding another directory `lib/rustlib/src/foo` or
|
|
|
|
// `lib/rustlib/src/rust/foo`), you will need to go around hunting for implicit assumptions
|
|
|
|
// and fix them...
|
|
|
|
//
|
|
|
|
// NOTE: if you update the paths here, you also should update the "virtual" path
|
|
|
|
// translation code in `imported_source_files` in `src/librustc_metadata/rmeta/decoder.rs`
|
|
|
|
let dst_src = image.join("lib/rustlib/src/rust");
|
2017-07-04 19:41:43 -06:00
|
|
|
t!(fs::create_dir_all(&dst_src));
|
|
|
|
|
2019-12-22 17:42:04 -05:00
|
|
|
let src_files = ["Cargo.lock"];
|
2017-07-04 19:41:43 -06:00
|
|
|
// This is the reduced set of paths which will become the rust-src component
|
2020-06-11 21:31:49 -05:00
|
|
|
// (essentially libstd and all of its path dependencies).
|
std: Switch from libbacktrace to gimli
This commit is a proof-of-concept for switching the standard library's
backtrace symbolication mechanism on most platforms from libbacktrace to
gimli. The standard library's support for `RUST_BACKTRACE=1` requires
in-process parsing of object files and DWARF debug information to
interpret it and print the filename/line number of stack frames as part
of a backtrace.
Historically this support in the standard library has come from a
library called "libbacktrace". The libbacktrace library seems to have
been extracted from gcc at some point and is written in C. We've had a
lot of issues with libbacktrace over time, unfortunately, though. The
library does not appear to be actively maintained since we've had
patches sit for months-to-years without comments. We have discovered a
good number of soundness issues with the library itself, both when
parsing valid DWARF as well as invalid DWARF. This is enough of an issue
that the libs team has previously decided that we cannot feed untrusted
inputs to libbacktrace. This also doesn't take into account the
portability of libbacktrace which has been difficult to manage and
maintain over time. While possible there are lots of exceptions and it's
the main C dependency of the standard library right now.
For years it's been the desire to switch over to a Rust-based solution
for symbolicating backtraces. It's been assumed that we'll be using the
Gimli family of crates for this purpose, which are targeted at safely
and efficiently parsing DWARF debug information. I've been working
recently to shore up the Gimli support in the `backtrace` crate. As of a
few weeks ago the `backtrace` crate, by default, uses Gimli when loaded
from crates.io. This transition has gone well enough that I figured it
was time to start talking seriously about this change to the standard
library.
This commit is a preview of what's probably the best way to integrate
the `backtrace` crate into the standard library with the Gimli feature
turned on. While today it's used as a crates.io dependency, this commit
switches the `backtrace` crate to a submodule of this repository which
will need to be updated manually. This is not done lightly, but is
thought to be the best solution. The primary reason for this is that the
`backtrace` crate needs to do some pretty nontrivial filesystem
interactions to locate debug information. Working without `std::fs` is
not an option, and while it might be possible to do some sort of
trait-based solution when prototyped it was found to be too unergonomic.
Using a submodule allows the `backtrace` crate to build as a submodule
of the `std` crate itself, enabling it to use `std::fs` and such.
Otherwise this adds new dependencies to the standard library. This step
requires extra attention because this means that these crates are now
going to be included with all Rust programs by default. It's important
to note, however, that we're already shipping libbacktrace with all Rust
programs by default and it has a bunch of C code implementing all of
this internally anyway, so we're basically already switching
already-shipping functionality to Rust from C.
* `object` - this crate is used to parse object file headers and
contents. Very low-level support is used from this crate and almost
all of it is disabled. Largely we're just using struct definitions as
well as convenience methods internally to read bytes and such.
* `addr2line` - this is the main meat of the implementation for
symbolication. This crate depends on `gimli` for DWARF parsing and
then provides interfaces needed by the `backtrace` crate to turn an
address into a filename / line number. This crate is actually pretty
small (fits in a single file almost!) and mirrors most of what
`dwarf.c` does for libbacktrace.
* `miniz_oxide` - the libbacktrace crate transparently handles
compressed debug information which is compressed with zlib. This crate
is used to decompress compressed debug sections.
* `gimli` - not actually used directly, but a dependency of `addr2line`.
* `adler32`- not used directly either, but a dependency of
`miniz_oxide`.
The goal of this change is to improve the safety of backtrace
symbolication in the standard library, especially in the face of
possibly malformed DWARF debug information. Even to this day we're still
seeing segfaults in libbacktrace which could possibly become security
vulnerabilities. This change should almost entirely eliminate this
possibility whilc also paving the way forward to adding more features
like split debug information.
Some references for those interested are:
* Original addition of libbacktrace - #12602
* OOM with libbacktrace - #24231
* Backtrace failure due to use of uninitialized value - #28447
* Possibility to feed untrusted data to libbacktrace - #21889
* Soundness fix for libbacktrace - #33729
* Crash in libbacktrace - #39468
* Support for macOS, never merged - ianlancetaylor/libbacktrace#2
* Performance issues with libbacktrace - #29293, #37477
* Update procedure is quite complicated due to how many patches we
need to carry - #50955
* Libbacktrace doesn't work on MinGW with dynamic libs - #71060
* Segfault in libbacktrace on macOS - #71397
Switching to Rust will not make us immune to all of these issues. The
crashes are expected to go away, but correctness and performance may
still have bugs arise. The gimli and `backtrace` crates, however, are
actively maintained unlike libbacktrace, so this should enable us to at
least efficiently apply fixes as situations come up.
2020-05-13 14:22:37 -07:00
|
|
|
copy_src_dirs(
|
|
|
|
builder,
|
|
|
|
&builder.src,
|
|
|
|
&["library"],
|
|
|
|
&[
|
|
|
|
// not needed and contains symlinks which rustup currently
|
|
|
|
// chokes on when unpacking.
|
|
|
|
"library/backtrace/crates",
|
|
|
|
],
|
|
|
|
&dst_src,
|
|
|
|
);
|
2017-08-24 23:25:35 +02:00
|
|
|
for file in src_files.iter() {
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.copy(&builder.src.join(file), &dst_src.join(file));
|
2017-08-24 23:25:35 +02:00
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// Create source tarball in rust-installer format
|
2017-07-05 10:46:41 -06:00
|
|
|
let mut cmd = rust_installer(builder);
|
2017-07-04 19:41:43 -06:00
|
|
|
cmd.arg("generate")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--product-name=Rust")
|
|
|
|
.arg("--rel-manifest-dir=rustlib")
|
|
|
|
.arg("--success-message=Awesome-Source.")
|
|
|
|
.arg("--image-dir")
|
|
|
|
.arg(&image)
|
|
|
|
.arg("--work-dir")
|
|
|
|
.arg(&tmpdir(builder))
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
|
|
|
.arg(format!("--package-name={}", name))
|
|
|
|
.arg("--component-name=rust-src")
|
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo");
|
2019-09-19 11:22:55 -07:00
|
|
|
|
|
|
|
builder.info("Dist src");
|
|
|
|
let _time = timeit(builder);
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.run(&mut cmd);
|
2016-07-09 13:33:03 +01:00
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.remove_dir(&image);
|
|
|
|
distdir(builder).join(&format!("{}.tar.gz", name))
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2017-05-18 22:48:14 +02:00
|
|
|
}
|
|
|
|
|
2018-03-10 07:01:06 -07:00
|
|
|
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
2017-07-04 19:41:43 -06:00
|
|
|
pub struct PlainSourceTarball;
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
impl Step for PlainSourceTarball {
|
2017-07-12 18:52:31 -06:00
|
|
|
/// Produces the location of the tarball generated
|
|
|
|
type Output = PathBuf;
|
2017-07-05 06:41:27 -06:00
|
|
|
const DEFAULT: bool = true;
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2017-07-20 17:24:11 -06:00
|
|
|
let builder = run.builder;
|
|
|
|
run.path("src").default_condition(builder.config.rust_dist_src)
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2017-07-20 17:51:07 -06:00
|
|
|
run.builder.ensure(PlainSourceTarball);
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
/// Creates the plain source tarball
|
2019-02-25 19:30:32 +09:00
|
|
|
fn run(self, builder: &Builder<'_>) -> PathBuf {
|
2017-07-04 19:41:43 -06:00
|
|
|
// Make sure that the root folder of tarball has the correct name
|
2018-04-14 17:27:57 -06:00
|
|
|
let plain_name = format!("{}-src", pkgname(builder, "rustc"));
|
|
|
|
let plain_dst_src = tmpdir(builder).join(&plain_name);
|
2017-07-04 19:41:43 -06:00
|
|
|
let _ = fs::remove_dir_all(&plain_dst_src);
|
|
|
|
t!(fs::create_dir_all(&plain_dst_src));
|
|
|
|
|
|
|
|
// This is the set of root paths which will become part of the source package
|
|
|
|
let src_files = [
|
|
|
|
"COPYRIGHT",
|
|
|
|
"LICENSE-APACHE",
|
|
|
|
"LICENSE-MIT",
|
|
|
|
"CONTRIBUTING.md",
|
|
|
|
"README.md",
|
|
|
|
"RELEASES.md",
|
|
|
|
"configure",
|
|
|
|
"x.py",
|
2017-08-26 15:01:48 -07:00
|
|
|
"config.toml.example",
|
2018-08-22 05:50:46 +03:00
|
|
|
"Cargo.toml",
|
|
|
|
"Cargo.lock",
|
2017-07-04 19:41:43 -06:00
|
|
|
];
|
2020-08-27 22:58:48 -05:00
|
|
|
let src_dirs = ["src", "compiler", "library"];
|
2017-05-18 22:48:14 +02:00
|
|
|
|
2020-06-11 21:31:49 -05:00
|
|
|
copy_src_dirs(builder, &builder.src, &src_dirs, &[], &plain_dst_src);
|
2017-05-18 22:48:14 +02:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
// Copy the files normally
|
|
|
|
for item in &src_files {
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.copy(&builder.src.join(item), &plain_dst_src.join(item));
|
2017-05-18 22:48:14 +02:00
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// Create the version file
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.create(&plain_dst_src.join("version"), &builder.rust_version());
|
|
|
|
if let Some(sha) = builder.rust_sha() {
|
|
|
|
builder.create(&plain_dst_src.join("git-commit-hash"), &sha);
|
2017-09-04 16:29:57 +02:00
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// If we're building from git sources, we need to vendor a complete distribution.
|
2018-04-14 17:27:57 -06:00
|
|
|
if builder.rust_info.is_git() {
|
2017-07-04 19:41:43 -06:00
|
|
|
// Vendor all Cargo dependencies
|
2018-04-14 17:27:57 -06:00
|
|
|
let mut cmd = Command::new(&builder.initial_cargo);
|
Add rust-analyzer submodule
The current plan is that submodule tracks the `release` branch of
rust-analyzer, which is updated once a week.
rust-analyzer is a workspace (with a virtual manifest), the actual
binary is provide by `crates/rust-analyzer` package.
Note that we intentionally don't add rust-analyzer to `Kind::Test`,
for two reasons.
*First*, at the moment rust-analyzer's test suite does a couple of
things which might not work in the context of rust repository. For
example, it shells out directly to `rustup` and `rustfmt`. So, making
this work requires non-trivial efforts.
*Second*, it seems unlikely that running tests in rust-lang/rust repo
would provide any additional guarantees. rust-analyzer builds with
stable and does not depend on the specifics of the compiler, so
changes to compiler can't break ra, unless they break stability
guarantee. Additionally, rust-analyzer itself is gated on bors, so we
are pretty confident that test suite passes.
2020-06-04 13:11:15 +02:00
|
|
|
cmd.arg("vendor")
|
|
|
|
.arg("--sync")
|
|
|
|
.arg(builder.src.join("./src/tools/rust-analyzer/Cargo.toml"))
|
|
|
|
.current_dir(&plain_dst_src);
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.run(&mut cmd);
|
2017-05-18 22:48:14 +02:00
|
|
|
}
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
// Create plain source tarball
|
2018-04-14 17:27:57 -06:00
|
|
|
let plain_name = format!("rustc-{}-src", builder.rust_package_vers());
|
|
|
|
let mut tarball = distdir(builder).join(&format!("{}.tar.gz", plain_name));
|
2017-07-04 19:41:43 -06:00
|
|
|
tarball.set_extension(""); // strip .gz
|
|
|
|
tarball.set_extension(""); // strip .tar
|
2017-07-22 10:48:29 -06:00
|
|
|
if let Some(dir) = tarball.parent() {
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.create_dir(&dir);
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2018-07-28 14:40:32 +02:00
|
|
|
builder.info("running installer");
|
2017-07-05 10:46:41 -06:00
|
|
|
let mut cmd = rust_installer(builder);
|
2017-07-04 19:41:43 -06:00
|
|
|
cmd.arg("tarball")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--input")
|
|
|
|
.arg(&plain_name)
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&tarball)
|
|
|
|
.arg("--work-dir=.")
|
|
|
|
.current_dir(tmpdir(builder));
|
2019-09-19 11:22:55 -07:00
|
|
|
|
|
|
|
builder.info("Create plain source tarball");
|
|
|
|
let _time = timeit(builder);
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.run(&mut cmd);
|
|
|
|
distdir(builder).join(&format!("{}.tar.gz", plain_name))
|
2017-05-18 22:48:14 +02:00
|
|
|
}
|
2016-07-09 13:33:03 +01:00
|
|
|
}
|
|
|
|
|
2016-03-13 16:52:19 -07:00
|
|
|
// We have to run a few shell scripts, which choke quite a bit on both `\`
|
|
|
|
// characters and on `C:\` paths, so normalize both of them away.
|
2016-10-05 21:19:01 -07:00
|
|
|
pub fn sanitize_sh(path: &Path) -> String {
|
2016-03-13 16:52:19 -07:00
|
|
|
let path = path.to_str().unwrap().replace("\\", "/");
|
|
|
|
return change_drive(&path).unwrap_or(path);
|
|
|
|
|
|
|
|
fn change_drive(s: &str) -> Option<String> {
|
|
|
|
let mut ch = s.chars();
|
|
|
|
let drive = ch.next().unwrap_or('C');
|
|
|
|
if ch.next() != Some(':') {
|
2019-12-22 17:42:04 -05:00
|
|
|
return None;
|
2016-03-13 16:52:19 -07:00
|
|
|
}
|
|
|
|
if ch.next() != Some('/') {
|
2019-12-22 17:42:04 -05:00
|
|
|
return None;
|
2016-03-13 16:52:19 -07:00
|
|
|
}
|
|
|
|
Some(format!("/{}/{}", drive, &s[drive.len_utf8() + 2..]))
|
|
|
|
}
|
|
|
|
}
|
2016-09-02 11:15:56 +01:00
|
|
|
|
2018-03-10 07:01:06 -07:00
|
|
|
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
2017-07-13 18:48:44 -06:00
|
|
|
pub struct Cargo {
|
2019-05-28 11:50:05 -07:00
|
|
|
pub compiler: Compiler,
|
2020-07-17 10:08:04 -04:00
|
|
|
pub target: TargetSelection,
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
impl Step for Cargo {
|
2017-07-12 18:52:31 -06:00
|
|
|
type Output = PathBuf;
|
2017-07-05 06:41:27 -06:00
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2017-07-18 18:03:38 -06:00
|
|
|
run.path("cargo")
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2017-07-20 17:51:07 -06:00
|
|
|
run.builder.ensure(Cargo {
|
2019-05-28 11:50:05 -07:00
|
|
|
compiler: run.builder.compiler_for(
|
|
|
|
run.builder.top_stage,
|
|
|
|
run.builder.config.build,
|
|
|
|
run.target,
|
|
|
|
),
|
2017-07-20 17:51:07 -06:00
|
|
|
target: run.target,
|
2017-07-05 06:41:27 -06:00
|
|
|
});
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn run(self, builder: &Builder<'_>) -> PathBuf {
|
2019-05-28 11:50:05 -07:00
|
|
|
let compiler = self.compiler;
|
2017-07-04 19:41:43 -06:00
|
|
|
let target = self.target;
|
2017-07-05 06:41:27 -06:00
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
let src = builder.src.join("src/tools/cargo");
|
2017-07-04 19:41:43 -06:00
|
|
|
let etc = src.join("src/etc");
|
2018-04-14 17:27:57 -06:00
|
|
|
let release_num = builder.release_num("cargo");
|
|
|
|
let name = pkgname(builder, "cargo");
|
|
|
|
let version = builder.cargo_info.version(builder, &release_num);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
let tmp = tmpdir(builder);
|
2017-07-04 19:41:43 -06:00
|
|
|
let image = tmp.join("cargo-image");
|
|
|
|
drop(fs::remove_dir_all(&image));
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.create_dir(&image);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// Prepare the image directory
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.create_dir(&image.join("share/zsh/site-functions"));
|
|
|
|
builder.create_dir(&image.join("etc/bash_completion.d"));
|
2019-05-28 11:50:05 -07:00
|
|
|
let cargo = builder.ensure(tool::Cargo { compiler, target });
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&cargo, &image.join("bin"), 0o755);
|
2017-07-04 19:41:43 -06:00
|
|
|
for man in t!(etc.join("man").read_dir()) {
|
|
|
|
let man = t!(man);
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&man.path(), &image.join("share/man/man1"), 0o644);
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&etc.join("_cargo"), &image.join("share/zsh/site-functions"), 0o644);
|
2019-12-22 17:42:04 -05:00
|
|
|
builder.copy(&etc.join("cargo.bashcomp.sh"), &image.join("etc/bash_completion.d/cargo"));
|
2017-07-04 19:41:43 -06:00
|
|
|
let doc = image.join("share/doc/cargo");
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&src.join("README.md"), &doc, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-MIT"), &doc, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-THIRD-PARTY"), &doc, 0o644);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// Prepare the overlay
|
|
|
|
let overlay = tmp.join("cargo-overlay");
|
|
|
|
drop(fs::remove_dir_all(&overlay));
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.create_dir(&overlay);
|
|
|
|
builder.install(&src.join("README.md"), &overlay, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-MIT"), &overlay, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-APACHE"), &overlay, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-THIRD-PARTY"), &overlay, 0o644);
|
|
|
|
builder.create(&overlay.join("version"), &version);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// Generate the installer tarball
|
2017-07-05 10:46:41 -06:00
|
|
|
let mut cmd = rust_installer(builder);
|
2017-07-04 19:41:43 -06:00
|
|
|
cmd.arg("generate")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--product-name=Rust")
|
|
|
|
.arg("--rel-manifest-dir=rustlib")
|
|
|
|
.arg("--success-message=Rust-is-ready-to-roll.")
|
|
|
|
.arg("--image-dir")
|
|
|
|
.arg(&image)
|
|
|
|
.arg("--work-dir")
|
|
|
|
.arg(&tmpdir(builder))
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
|
|
|
.arg("--non-installed-overlay")
|
|
|
|
.arg(&overlay)
|
2020-07-18 14:06:20 -04:00
|
|
|
.arg(format!("--package-name={}-{}", name, target.triple))
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--component-name=cargo")
|
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo");
|
2019-09-19 11:22:55 -07:00
|
|
|
|
|
|
|
builder.info(&format!("Dist cargo stage{} ({})", compiler.stage, target));
|
|
|
|
let _time = timeit(builder);
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.run(&mut cmd);
|
2020-07-18 14:06:20 -04:00
|
|
|
distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple))
|
2017-02-15 15:57:06 -08:00
|
|
|
}
|
2017-01-20 17:03:06 -08:00
|
|
|
}
|
|
|
|
|
2018-03-10 07:01:06 -07:00
|
|
|
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
2017-07-13 18:48:44 -06:00
|
|
|
pub struct Rls {
|
2019-05-28 11:50:05 -07:00
|
|
|
pub compiler: Compiler,
|
2020-07-17 10:08:04 -04:00
|
|
|
pub target: TargetSelection,
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
impl Step for Rls {
|
2017-09-19 13:04:17 -07:00
|
|
|
type Output = Option<PathBuf>;
|
2017-07-05 06:41:27 -06:00
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2017-07-18 18:03:38 -06:00
|
|
|
run.path("rls")
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2017-07-20 17:51:07 -06:00
|
|
|
run.builder.ensure(Rls {
|
2019-05-28 11:50:05 -07:00
|
|
|
compiler: run.builder.compiler_for(
|
|
|
|
run.builder.top_stage,
|
|
|
|
run.builder.config.build,
|
|
|
|
run.target,
|
|
|
|
),
|
2017-07-20 17:51:07 -06:00
|
|
|
target: run.target,
|
2017-07-05 06:41:27 -06:00
|
|
|
});
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
|
2019-05-28 11:50:05 -07:00
|
|
|
let compiler = self.compiler;
|
2017-07-04 19:41:43 -06:00
|
|
|
let target = self.target;
|
2018-04-14 17:27:57 -06:00
|
|
|
assert!(builder.config.extended);
|
2017-07-05 06:41:27 -06:00
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
let src = builder.src.join("src/tools/rls");
|
|
|
|
let release_num = builder.release_num("rls");
|
|
|
|
let name = pkgname(builder, "rls");
|
|
|
|
let version = builder.rls_info.version(builder, &release_num);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
let tmp = tmpdir(builder);
|
2017-07-04 19:41:43 -06:00
|
|
|
let image = tmp.join("rls-image");
|
|
|
|
drop(fs::remove_dir_all(&image));
|
|
|
|
t!(fs::create_dir_all(&image));
|
|
|
|
|
|
|
|
// Prepare the image directory
|
2017-10-19 17:30:37 -06:00
|
|
|
// We expect RLS to build, because we've exited this step above if tool
|
|
|
|
// state for RLS isn't testing.
|
2019-12-22 17:42:04 -05:00
|
|
|
let rls = builder
|
|
|
|
.ensure(tool::Rls { compiler, target, extra_features: Vec::new() })
|
|
|
|
.or_else(|| {
|
|
|
|
missing_tool("RLS", builder.build.config.missing_tools);
|
|
|
|
None
|
|
|
|
})?;
|
2017-11-20 01:40:02 +08:00
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&rls, &image.join("bin"), 0o755);
|
2017-07-04 19:41:43 -06:00
|
|
|
let doc = image.join("share/doc/rls");
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&src.join("README.md"), &doc, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-MIT"), &doc, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// Prepare the overlay
|
|
|
|
let overlay = tmp.join("rls-overlay");
|
|
|
|
drop(fs::remove_dir_all(&overlay));
|
|
|
|
t!(fs::create_dir_all(&overlay));
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&src.join("README.md"), &overlay, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-MIT"), &overlay, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-APACHE"), &overlay, 0o644);
|
|
|
|
builder.create(&overlay.join("version"), &version);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// Generate the installer tarball
|
2017-07-05 10:46:41 -06:00
|
|
|
let mut cmd = rust_installer(builder);
|
2017-07-04 19:41:43 -06:00
|
|
|
cmd.arg("generate")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--product-name=Rust")
|
|
|
|
.arg("--rel-manifest-dir=rustlib")
|
|
|
|
.arg("--success-message=RLS-ready-to-serve.")
|
|
|
|
.arg("--image-dir")
|
|
|
|
.arg(&image)
|
|
|
|
.arg("--work-dir")
|
|
|
|
.arg(&tmpdir(builder))
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
|
|
|
.arg("--non-installed-overlay")
|
|
|
|
.arg(&overlay)
|
2020-07-18 14:06:20 -04:00
|
|
|
.arg(format!("--package-name={}-{}", name, target.triple))
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo")
|
|
|
|
.arg("--component-name=rls-preview");
|
2017-09-06 08:28:15 +12:00
|
|
|
|
2020-07-18 14:06:20 -04:00
|
|
|
builder.info(&format!("Dist RLS stage{} ({})", compiler.stage, target.triple));
|
2019-09-19 11:22:55 -07:00
|
|
|
let _time = timeit(builder);
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.run(&mut cmd);
|
2020-07-18 14:06:20 -04:00
|
|
|
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)))
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2017-03-17 09:52:12 +13:00
|
|
|
}
|
|
|
|
|
Add rust-analyzer submodule
The current plan is that submodule tracks the `release` branch of
rust-analyzer, which is updated once a week.
rust-analyzer is a workspace (with a virtual manifest), the actual
binary is provide by `crates/rust-analyzer` package.
Note that we intentionally don't add rust-analyzer to `Kind::Test`,
for two reasons.
*First*, at the moment rust-analyzer's test suite does a couple of
things which might not work in the context of rust repository. For
example, it shells out directly to `rustup` and `rustfmt`. So, making
this work requires non-trivial efforts.
*Second*, it seems unlikely that running tests in rust-lang/rust repo
would provide any additional guarantees. rust-analyzer builds with
stable and does not depend on the specifics of the compiler, so
changes to compiler can't break ra, unless they break stability
guarantee. Additionally, rust-analyzer itself is gated on bors, so we
are pretty confident that test suite passes.
2020-06-04 13:11:15 +02:00
|
|
|
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
|
|
|
pub struct RustAnalyzer {
|
|
|
|
pub compiler: Compiler,
|
2020-07-17 10:08:04 -04:00
|
|
|
pub target: TargetSelection,
|
Add rust-analyzer submodule
The current plan is that submodule tracks the `release` branch of
rust-analyzer, which is updated once a week.
rust-analyzer is a workspace (with a virtual manifest), the actual
binary is provide by `crates/rust-analyzer` package.
Note that we intentionally don't add rust-analyzer to `Kind::Test`,
for two reasons.
*First*, at the moment rust-analyzer's test suite does a couple of
things which might not work in the context of rust repository. For
example, it shells out directly to `rustup` and `rustfmt`. So, making
this work requires non-trivial efforts.
*Second*, it seems unlikely that running tests in rust-lang/rust repo
would provide any additional guarantees. rust-analyzer builds with
stable and does not depend on the specifics of the compiler, so
changes to compiler can't break ra, unless they break stability
guarantee. Additionally, rust-analyzer itself is gated on bors, so we
are pretty confident that test suite passes.
2020-06-04 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Step for RustAnalyzer {
|
2020-08-03 10:11:30 -04:00
|
|
|
type Output = Option<PathBuf>;
|
Add rust-analyzer submodule
The current plan is that submodule tracks the `release` branch of
rust-analyzer, which is updated once a week.
rust-analyzer is a workspace (with a virtual manifest), the actual
binary is provide by `crates/rust-analyzer` package.
Note that we intentionally don't add rust-analyzer to `Kind::Test`,
for two reasons.
*First*, at the moment rust-analyzer's test suite does a couple of
things which might not work in the context of rust repository. For
example, it shells out directly to `rustup` and `rustfmt`. So, making
this work requires non-trivial efforts.
*Second*, it seems unlikely that running tests in rust-lang/rust repo
would provide any additional guarantees. rust-analyzer builds with
stable and does not depend on the specifics of the compiler, so
changes to compiler can't break ra, unless they break stability
guarantee. Additionally, rust-analyzer itself is gated on bors, so we
are pretty confident that test suite passes.
2020-06-04 13:11:15 +02:00
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
|
|
|
run.path("rust-analyzer")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn make_run(run: RunConfig<'_>) {
|
|
|
|
run.builder.ensure(RustAnalyzer {
|
|
|
|
compiler: run.builder.compiler_for(
|
|
|
|
run.builder.top_stage,
|
|
|
|
run.builder.config.build,
|
|
|
|
run.target,
|
|
|
|
),
|
|
|
|
target: run.target,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-08-03 10:11:30 -04:00
|
|
|
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
|
Add rust-analyzer submodule
The current plan is that submodule tracks the `release` branch of
rust-analyzer, which is updated once a week.
rust-analyzer is a workspace (with a virtual manifest), the actual
binary is provide by `crates/rust-analyzer` package.
Note that we intentionally don't add rust-analyzer to `Kind::Test`,
for two reasons.
*First*, at the moment rust-analyzer's test suite does a couple of
things which might not work in the context of rust repository. For
example, it shells out directly to `rustup` and `rustfmt`. So, making
this work requires non-trivial efforts.
*Second*, it seems unlikely that running tests in rust-lang/rust repo
would provide any additional guarantees. rust-analyzer builds with
stable and does not depend on the specifics of the compiler, so
changes to compiler can't break ra, unless they break stability
guarantee. Additionally, rust-analyzer itself is gated on bors, so we
are pretty confident that test suite passes.
2020-06-04 13:11:15 +02:00
|
|
|
let compiler = self.compiler;
|
|
|
|
let target = self.target;
|
|
|
|
assert!(builder.config.extended);
|
|
|
|
|
2020-08-03 10:11:30 -04:00
|
|
|
if target.contains("riscv64") {
|
|
|
|
// riscv64 currently has an LLVM bug that makes rust-analyzer unable
|
|
|
|
// to build. See #74813 for details.
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
Add rust-analyzer submodule
The current plan is that submodule tracks the `release` branch of
rust-analyzer, which is updated once a week.
rust-analyzer is a workspace (with a virtual manifest), the actual
binary is provide by `crates/rust-analyzer` package.
Note that we intentionally don't add rust-analyzer to `Kind::Test`,
for two reasons.
*First*, at the moment rust-analyzer's test suite does a couple of
things which might not work in the context of rust repository. For
example, it shells out directly to `rustup` and `rustfmt`. So, making
this work requires non-trivial efforts.
*Second*, it seems unlikely that running tests in rust-lang/rust repo
would provide any additional guarantees. rust-analyzer builds with
stable and does not depend on the specifics of the compiler, so
changes to compiler can't break ra, unless they break stability
guarantee. Additionally, rust-analyzer itself is gated on bors, so we
are pretty confident that test suite passes.
2020-06-04 13:11:15 +02:00
|
|
|
let src = builder.src.join("src/tools/rust-analyzer");
|
|
|
|
let release_num = builder.release_num("rust-analyzer/crates/rust-analyzer");
|
|
|
|
let name = pkgname(builder, "rust-analyzer");
|
|
|
|
let version = builder.rust_analyzer_info.version(builder, &release_num);
|
|
|
|
|
|
|
|
let tmp = tmpdir(builder);
|
|
|
|
let image = tmp.join("rust-analyzer-image");
|
|
|
|
drop(fs::remove_dir_all(&image));
|
|
|
|
builder.create_dir(&image);
|
|
|
|
|
|
|
|
// Prepare the image directory
|
|
|
|
// We expect rust-analyer to always build, as it doesn't depend on rustc internals
|
|
|
|
// and doesn't have associated toolstate.
|
|
|
|
let rust_analyzer = builder
|
|
|
|
.ensure(tool::RustAnalyzer { compiler, target, extra_features: Vec::new() })
|
|
|
|
.expect("rust-analyzer always builds");
|
|
|
|
|
|
|
|
builder.install(&rust_analyzer, &image.join("bin"), 0o755);
|
|
|
|
let doc = image.join("share/doc/rust-analyzer");
|
|
|
|
builder.install(&src.join("README.md"), &doc, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-MIT"), &doc, 0o644);
|
|
|
|
|
|
|
|
// Prepare the overlay
|
|
|
|
let overlay = tmp.join("rust-analyzer-overlay");
|
|
|
|
drop(fs::remove_dir_all(&overlay));
|
|
|
|
t!(fs::create_dir_all(&overlay));
|
|
|
|
builder.install(&src.join("README.md"), &overlay, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-MIT"), &doc, 0o644);
|
|
|
|
builder.create(&overlay.join("version"), &version);
|
|
|
|
|
|
|
|
// 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=rust-analyzer-ready-to-serve.")
|
|
|
|
.arg("--image-dir")
|
|
|
|
.arg(&image)
|
|
|
|
.arg("--work-dir")
|
|
|
|
.arg(&tmpdir(builder))
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
|
|
|
.arg("--non-installed-overlay")
|
|
|
|
.arg(&overlay)
|
2020-07-18 14:06:20 -04:00
|
|
|
.arg(format!("--package-name={}-{}", name, target.triple))
|
Add rust-analyzer submodule
The current plan is that submodule tracks the `release` branch of
rust-analyzer, which is updated once a week.
rust-analyzer is a workspace (with a virtual manifest), the actual
binary is provide by `crates/rust-analyzer` package.
Note that we intentionally don't add rust-analyzer to `Kind::Test`,
for two reasons.
*First*, at the moment rust-analyzer's test suite does a couple of
things which might not work in the context of rust repository. For
example, it shells out directly to `rustup` and `rustfmt`. So, making
this work requires non-trivial efforts.
*Second*, it seems unlikely that running tests in rust-lang/rust repo
would provide any additional guarantees. rust-analyzer builds with
stable and does not depend on the specifics of the compiler, so
changes to compiler can't break ra, unless they break stability
guarantee. Additionally, rust-analyzer itself is gated on bors, so we
are pretty confident that test suite passes.
2020-06-04 13:11:15 +02:00
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo")
|
|
|
|
.arg("--component-name=rust-analyzer-preview");
|
|
|
|
|
|
|
|
builder.info(&format!("Dist rust-analyzer stage{} ({})", compiler.stage, target));
|
|
|
|
let _time = timeit(builder);
|
|
|
|
builder.run(&mut cmd);
|
2020-08-03 10:11:30 -04:00
|
|
|
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)))
|
Add rust-analyzer submodule
The current plan is that submodule tracks the `release` branch of
rust-analyzer, which is updated once a week.
rust-analyzer is a workspace (with a virtual manifest), the actual
binary is provide by `crates/rust-analyzer` package.
Note that we intentionally don't add rust-analyzer to `Kind::Test`,
for two reasons.
*First*, at the moment rust-analyzer's test suite does a couple of
things which might not work in the context of rust repository. For
example, it shells out directly to `rustup` and `rustfmt`. So, making
this work requires non-trivial efforts.
*Second*, it seems unlikely that running tests in rust-lang/rust repo
would provide any additional guarantees. rust-analyzer builds with
stable and does not depend on the specifics of the compiler, so
changes to compiler can't break ra, unless they break stability
guarantee. Additionally, rust-analyzer itself is gated on bors, so we
are pretty confident that test suite passes.
2020-06-04 13:11:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-28 13:34:29 +02:00
|
|
|
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
|
|
|
pub struct Clippy {
|
2019-05-28 11:50:05 -07:00
|
|
|
pub compiler: Compiler,
|
2020-07-17 10:08:04 -04:00
|
|
|
pub target: TargetSelection,
|
2018-05-28 13:34:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Step for Clippy {
|
2020-04-01 13:18:06 +02:00
|
|
|
type Output = PathBuf;
|
2018-05-28 13:34:29 +02:00
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2018-05-28 13:34:29 +02:00
|
|
|
run.path("clippy")
|
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2018-05-28 13:34:29 +02:00
|
|
|
run.builder.ensure(Clippy {
|
2019-05-28 11:50:05 -07:00
|
|
|
compiler: run.builder.compiler_for(
|
|
|
|
run.builder.top_stage,
|
|
|
|
run.builder.config.build,
|
|
|
|
run.target,
|
|
|
|
),
|
2018-05-28 13:34:29 +02:00
|
|
|
target: run.target,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-04-01 13:18:06 +02:00
|
|
|
fn run(self, builder: &Builder<'_>) -> PathBuf {
|
2019-05-28 11:50:05 -07:00
|
|
|
let compiler = self.compiler;
|
2018-05-28 13:34:29 +02:00
|
|
|
let target = self.target;
|
|
|
|
assert!(builder.config.extended);
|
|
|
|
|
|
|
|
let src = builder.src.join("src/tools/clippy");
|
|
|
|
let release_num = builder.release_num("clippy");
|
|
|
|
let name = pkgname(builder, "clippy");
|
|
|
|
let version = builder.clippy_info.version(builder, &release_num);
|
|
|
|
|
|
|
|
let tmp = tmpdir(builder);
|
|
|
|
let image = tmp.join("clippy-image");
|
|
|
|
drop(fs::remove_dir_all(&image));
|
2018-07-09 10:15:30 +02:00
|
|
|
builder.create_dir(&image);
|
2018-05-28 13:34:29 +02:00
|
|
|
|
|
|
|
// Prepare the image directory
|
|
|
|
// We expect clippy to build, because we've exited this step above if tool
|
|
|
|
// state for clippy isn't testing.
|
2019-12-22 17:42:04 -05:00
|
|
|
let clippy = builder
|
|
|
|
.ensure(tool::Clippy { compiler, target, extra_features: Vec::new() })
|
2020-04-01 13:18:06 +02:00
|
|
|
.expect("clippy expected to build - essential tool");
|
2019-12-22 17:42:04 -05:00
|
|
|
let cargoclippy = builder
|
|
|
|
.ensure(tool::CargoClippy { compiler, target, extra_features: Vec::new() })
|
2020-04-01 13:18:06 +02:00
|
|
|
.expect("clippy expected to build - essential tool");
|
2018-05-28 13:34:29 +02:00
|
|
|
|
|
|
|
builder.install(&clippy, &image.join("bin"), 0o755);
|
2018-07-09 10:15:30 +02:00
|
|
|
builder.install(&cargoclippy, &image.join("bin"), 0o755);
|
2018-05-28 13:34:29 +02:00
|
|
|
let doc = image.join("share/doc/clippy");
|
|
|
|
builder.install(&src.join("README.md"), &doc, 0o644);
|
2018-10-13 20:38:49 +02:00
|
|
|
builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-MIT"), &doc, 0o644);
|
2018-05-28 13:34:29 +02:00
|
|
|
|
|
|
|
// Prepare the overlay
|
|
|
|
let overlay = tmp.join("clippy-overlay");
|
|
|
|
drop(fs::remove_dir_all(&overlay));
|
|
|
|
t!(fs::create_dir_all(&overlay));
|
|
|
|
builder.install(&src.join("README.md"), &overlay, 0o644);
|
2018-10-13 20:38:49 +02:00
|
|
|
builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-MIT"), &doc, 0o644);
|
2018-05-28 13:34:29 +02:00
|
|
|
builder.create(&overlay.join("version"), &version);
|
|
|
|
|
|
|
|
// Generate the installer tarball
|
|
|
|
let mut cmd = rust_installer(builder);
|
|
|
|
cmd.arg("generate")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--product-name=Rust")
|
|
|
|
.arg("--rel-manifest-dir=rustlib")
|
|
|
|
.arg("--success-message=clippy-ready-to-serve.")
|
|
|
|
.arg("--image-dir")
|
|
|
|
.arg(&image)
|
|
|
|
.arg("--work-dir")
|
|
|
|
.arg(&tmpdir(builder))
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
|
|
|
.arg("--non-installed-overlay")
|
|
|
|
.arg(&overlay)
|
2020-07-18 14:06:20 -04:00
|
|
|
.arg(format!("--package-name={}-{}", name, target.triple))
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo")
|
|
|
|
.arg("--component-name=clippy-preview");
|
2018-05-28 13:34:29 +02:00
|
|
|
|
2019-09-19 11:22:55 -07:00
|
|
|
builder.info(&format!("Dist clippy stage{} ({})", compiler.stage, target));
|
|
|
|
let _time = timeit(builder);
|
2018-05-28 13:34:29 +02:00
|
|
|
builder.run(&mut cmd);
|
2020-07-18 14:06:20 -04:00
|
|
|
distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple))
|
2018-05-28 13:34:29 +02:00
|
|
|
}
|
|
|
|
}
|
2017-09-10 11:48:56 +02:00
|
|
|
|
2018-12-23 21:20:35 +01:00
|
|
|
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
|
|
|
pub struct Miri {
|
2019-05-28 11:50:05 -07:00
|
|
|
pub compiler: Compiler,
|
2020-07-17 10:08:04 -04:00
|
|
|
pub target: TargetSelection,
|
2018-12-23 21:20:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Step for Miri {
|
|
|
|
type Output = Option<PathBuf>;
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2018-12-23 21:20:35 +01:00
|
|
|
run.path("miri")
|
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2018-12-23 21:20:35 +01:00
|
|
|
run.builder.ensure(Miri {
|
2019-05-28 11:50:05 -07:00
|
|
|
compiler: run.builder.compiler_for(
|
|
|
|
run.builder.top_stage,
|
|
|
|
run.builder.config.build,
|
|
|
|
run.target,
|
|
|
|
),
|
2018-12-23 21:20:35 +01:00
|
|
|
target: run.target,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
|
2019-05-28 11:50:05 -07:00
|
|
|
let compiler = self.compiler;
|
2018-12-23 21:20:35 +01:00
|
|
|
let target = self.target;
|
|
|
|
assert!(builder.config.extended);
|
|
|
|
|
|
|
|
let src = builder.src.join("src/tools/miri");
|
|
|
|
let release_num = builder.release_num("miri");
|
|
|
|
let name = pkgname(builder, "miri");
|
|
|
|
let version = builder.miri_info.version(builder, &release_num);
|
|
|
|
|
|
|
|
let tmp = tmpdir(builder);
|
|
|
|
let image = tmp.join("miri-image");
|
|
|
|
drop(fs::remove_dir_all(&image));
|
|
|
|
builder.create_dir(&image);
|
|
|
|
|
|
|
|
// Prepare the image directory
|
|
|
|
// We expect miri to build, because we've exited this step above if tool
|
|
|
|
// state for miri isn't testing.
|
2019-12-22 17:42:04 -05:00
|
|
|
let miri = builder
|
|
|
|
.ensure(tool::Miri { compiler, target, extra_features: Vec::new() })
|
|
|
|
.or_else(|| {
|
|
|
|
missing_tool("miri", builder.build.config.missing_tools);
|
|
|
|
None
|
|
|
|
})?;
|
|
|
|
let cargomiri = builder
|
|
|
|
.ensure(tool::CargoMiri { compiler, target, extra_features: Vec::new() })
|
|
|
|
.or_else(|| {
|
|
|
|
missing_tool("cargo miri", builder.build.config.missing_tools);
|
|
|
|
None
|
|
|
|
})?;
|
2018-12-23 21:20:35 +01:00
|
|
|
|
|
|
|
builder.install(&miri, &image.join("bin"), 0o755);
|
|
|
|
builder.install(&cargomiri, &image.join("bin"), 0o755);
|
|
|
|
let doc = image.join("share/doc/miri");
|
|
|
|
builder.install(&src.join("README.md"), &doc, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-MIT"), &doc, 0o644);
|
|
|
|
|
|
|
|
// Prepare the overlay
|
|
|
|
let overlay = tmp.join("miri-overlay");
|
|
|
|
drop(fs::remove_dir_all(&overlay));
|
|
|
|
t!(fs::create_dir_all(&overlay));
|
|
|
|
builder.install(&src.join("README.md"), &overlay, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-MIT"), &doc, 0o644);
|
|
|
|
builder.create(&overlay.join("version"), &version);
|
|
|
|
|
|
|
|
// Generate the installer tarball
|
|
|
|
let mut cmd = rust_installer(builder);
|
|
|
|
cmd.arg("generate")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--product-name=Rust")
|
|
|
|
.arg("--rel-manifest-dir=rustlib")
|
|
|
|
.arg("--success-message=miri-ready-to-serve.")
|
|
|
|
.arg("--image-dir")
|
|
|
|
.arg(&image)
|
|
|
|
.arg("--work-dir")
|
|
|
|
.arg(&tmpdir(builder))
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
|
|
|
.arg("--non-installed-overlay")
|
|
|
|
.arg(&overlay)
|
2020-07-18 14:06:20 -04:00
|
|
|
.arg(format!("--package-name={}-{}", name, target.triple))
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo")
|
|
|
|
.arg("--component-name=miri-preview");
|
2018-12-23 21:20:35 +01:00
|
|
|
|
2019-09-19 11:22:55 -07:00
|
|
|
builder.info(&format!("Dist miri stage{} ({})", compiler.stage, target));
|
|
|
|
let _time = timeit(builder);
|
2018-12-23 21:20:35 +01:00
|
|
|
builder.run(&mut cmd);
|
2020-07-18 14:06:20 -04:00
|
|
|
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)))
|
2018-12-23 21:20:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-10 07:01:06 -07:00
|
|
|
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
2017-11-10 15:09:39 +13:00
|
|
|
pub struct Rustfmt {
|
2019-05-28 11:50:05 -07:00
|
|
|
pub compiler: Compiler,
|
2020-07-17 10:08:04 -04:00
|
|
|
pub target: TargetSelection,
|
2017-11-10 15:09:39 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Step for Rustfmt {
|
|
|
|
type Output = Option<PathBuf>;
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2017-11-10 15:09:39 +13:00
|
|
|
run.path("rustfmt")
|
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2017-11-10 15:09:39 +13:00
|
|
|
run.builder.ensure(Rustfmt {
|
2019-05-28 11:50:05 -07:00
|
|
|
compiler: run.builder.compiler_for(
|
|
|
|
run.builder.top_stage,
|
|
|
|
run.builder.config.build,
|
|
|
|
run.target,
|
|
|
|
),
|
2017-11-10 15:09:39 +13:00
|
|
|
target: run.target,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
|
2019-05-28 11:50:05 -07:00
|
|
|
let compiler = self.compiler;
|
2017-11-10 15:09:39 +13:00
|
|
|
let target = self.target;
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
let src = builder.src.join("src/tools/rustfmt");
|
|
|
|
let release_num = builder.release_num("rustfmt");
|
|
|
|
let name = pkgname(builder, "rustfmt");
|
|
|
|
let version = builder.rustfmt_info.version(builder, &release_num);
|
2017-11-10 15:09:39 +13:00
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
let tmp = tmpdir(builder);
|
2017-11-10 15:09:39 +13:00
|
|
|
let image = tmp.join("rustfmt-image");
|
|
|
|
drop(fs::remove_dir_all(&image));
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.create_dir(&image);
|
2017-11-10 15:09:39 +13:00
|
|
|
|
|
|
|
// Prepare the image directory
|
2019-12-22 17:42:04 -05:00
|
|
|
let rustfmt = builder
|
|
|
|
.ensure(tool::Rustfmt { compiler, target, extra_features: Vec::new() })
|
|
|
|
.or_else(|| {
|
|
|
|
missing_tool("Rustfmt", builder.build.config.missing_tools);
|
|
|
|
None
|
|
|
|
})?;
|
|
|
|
let cargofmt = builder
|
|
|
|
.ensure(tool::Cargofmt { compiler, target, extra_features: Vec::new() })
|
|
|
|
.or_else(|| {
|
|
|
|
missing_tool("Cargofmt", builder.build.config.missing_tools);
|
|
|
|
None
|
|
|
|
})?;
|
2017-11-20 01:40:02 +08:00
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&rustfmt, &image.join("bin"), 0o755);
|
|
|
|
builder.install(&cargofmt, &image.join("bin"), 0o755);
|
2017-11-10 15:09:39 +13:00
|
|
|
let doc = image.join("share/doc/rustfmt");
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&src.join("README.md"), &doc, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-MIT"), &doc, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644);
|
2017-11-10 15:09:39 +13:00
|
|
|
|
|
|
|
// Prepare the overlay
|
|
|
|
let overlay = tmp.join("rustfmt-overlay");
|
|
|
|
drop(fs::remove_dir_all(&overlay));
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.create_dir(&overlay);
|
|
|
|
builder.install(&src.join("README.md"), &overlay, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-MIT"), &overlay, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE-APACHE"), &overlay, 0o644);
|
|
|
|
builder.create(&overlay.join("version"), &version);
|
2017-11-10 15:09:39 +13:00
|
|
|
|
|
|
|
// Generate the installer tarball
|
|
|
|
let mut cmd = rust_installer(builder);
|
|
|
|
cmd.arg("generate")
|
2019-12-22 17:42:04 -05:00
|
|
|
.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(builder))
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
|
|
|
.arg("--non-installed-overlay")
|
|
|
|
.arg(&overlay)
|
2020-07-18 14:06:20 -04:00
|
|
|
.arg(format!("--package-name={}-{}", name, target.triple))
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo")
|
|
|
|
.arg("--component-name=rustfmt-preview");
|
2017-11-10 15:09:39 +13:00
|
|
|
|
2019-09-19 11:22:55 -07:00
|
|
|
builder.info(&format!("Dist Rustfmt stage{} ({})", compiler.stage, target));
|
|
|
|
let _time = timeit(builder);
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.run(&mut cmd);
|
2020-07-18 14:06:20 -04:00
|
|
|
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)))
|
2017-11-10 15:09:39 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-10 07:01:06 -07:00
|
|
|
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
2017-07-13 18:48:44 -06:00
|
|
|
pub struct Extended {
|
2017-07-04 19:41:43 -06:00
|
|
|
stage: u32,
|
2020-07-17 10:08:04 -04:00
|
|
|
host: TargetSelection,
|
|
|
|
target: TargetSelection,
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2017-01-20 17:03:06 -08:00
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
impl Step for Extended {
|
2017-07-04 19:41:43 -06:00
|
|
|
type Output = ();
|
2017-07-05 06:41:27 -06:00
|
|
|
const DEFAULT: bool = true;
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2017-07-20 17:24:11 -06:00
|
|
|
let builder = run.builder;
|
2017-07-23 10:03:40 -06:00
|
|
|
run.path("extended").default_condition(builder.config.extended)
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2017-07-20 17:51:07 -06:00
|
|
|
run.builder.ensure(Extended {
|
|
|
|
stage: run.builder.top_stage,
|
2018-04-14 17:27:57 -06:00
|
|
|
host: run.builder.config.build,
|
2017-07-20 17:51:07 -06:00
|
|
|
target: run.target,
|
2017-07-05 06:41:27 -06:00
|
|
|
});
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
/// Creates a combined installer for the specified target in the provided stage.
|
2019-02-25 19:30:32 +09:00
|
|
|
fn run(self, builder: &Builder<'_>) {
|
2017-07-04 19:41:43 -06:00
|
|
|
let target = self.target;
|
2019-05-28 11:50:05 -07:00
|
|
|
let stage = self.stage;
|
|
|
|
let compiler = builder.compiler_for(self.stage, self.host, self.target);
|
2017-07-05 06:41:27 -06:00
|
|
|
|
2019-05-28 11:50:05 -07:00
|
|
|
builder.info(&format!("Dist extended stage{} ({})", compiler.stage, target));
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2019-12-22 17:42:04 -05:00
|
|
|
let rustc_installer = builder.ensure(Rustc { compiler: builder.compiler(stage, target) });
|
2019-05-28 11:50:05 -07:00
|
|
|
let cargo_installer = builder.ensure(Cargo { compiler, target });
|
|
|
|
let rustfmt_installer = builder.ensure(Rustfmt { compiler, target });
|
|
|
|
let rls_installer = builder.ensure(Rls { compiler, target });
|
Add rust-analyzer submodule
The current plan is that submodule tracks the `release` branch of
rust-analyzer, which is updated once a week.
rust-analyzer is a workspace (with a virtual manifest), the actual
binary is provide by `crates/rust-analyzer` package.
Note that we intentionally don't add rust-analyzer to `Kind::Test`,
for two reasons.
*First*, at the moment rust-analyzer's test suite does a couple of
things which might not work in the context of rust repository. For
example, it shells out directly to `rustup` and `rustfmt`. So, making
this work requires non-trivial efforts.
*Second*, it seems unlikely that running tests in rust-lang/rust repo
would provide any additional guarantees. rust-analyzer builds with
stable and does not depend on the specifics of the compiler, so
changes to compiler can't break ra, unless they break stability
guarantee. Additionally, rust-analyzer itself is gated on bors, so we
are pretty confident that test suite passes.
2020-06-04 13:11:15 +02:00
|
|
|
let rust_analyzer_installer = builder.ensure(RustAnalyzer { compiler, target });
|
2019-05-28 11:50:05 -07:00
|
|
|
let llvm_tools_installer = builder.ensure(LlvmTools { target });
|
|
|
|
let clippy_installer = builder.ensure(Clippy { compiler, target });
|
|
|
|
let miri_installer = builder.ensure(Miri { compiler, target });
|
2017-07-23 10:03:40 -06:00
|
|
|
let mingw_installer = builder.ensure(Mingw { host: target });
|
2019-05-28 11:50:05 -07:00
|
|
|
let analysis_installer = builder.ensure(Analysis { compiler, target });
|
2017-07-23 10:03:40 -06:00
|
|
|
|
2019-12-22 17:42:04 -05:00
|
|
|
let docs_installer = builder.ensure(Docs { host: target });
|
|
|
|
let std_installer =
|
|
|
|
builder.ensure(Std { compiler: builder.compiler(stage, target), target });
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
let tmp = tmpdir(builder);
|
2017-07-04 19:41:43 -06:00
|
|
|
let overlay = tmp.join("extended-overlay");
|
2018-04-14 17:27:57 -06:00
|
|
|
let etc = builder.src.join("src/etc/installer");
|
2017-07-04 19:41:43 -06:00
|
|
|
let work = tmp.join("work");
|
|
|
|
|
|
|
|
let _ = fs::remove_dir_all(&overlay);
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&builder.src.join("COPYRIGHT"), &overlay, 0o644);
|
|
|
|
builder.install(&builder.src.join("LICENSE-APACHE"), &overlay, 0o644);
|
|
|
|
builder.install(&builder.src.join("LICENSE-MIT"), &overlay, 0o644);
|
|
|
|
let version = builder.rust_version();
|
|
|
|
builder.create(&overlay.join("version"), &version);
|
|
|
|
if let Some(sha) = builder.rust_sha() {
|
|
|
|
builder.create(&overlay.join("git-commit-hash"), &sha);
|
2017-09-04 16:29:57 +02:00
|
|
|
}
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&etc.join("README.md"), &overlay, 0o644);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// When rust-std package split from rustc, we needed to ensure that during
|
|
|
|
// upgrades rustc was upgraded before rust-std. To avoid rustc clobbering
|
|
|
|
// the std files during uninstall. To do this ensure that rustc comes
|
|
|
|
// before rust-std in the list below.
|
2017-09-19 13:04:17 -07:00
|
|
|
let mut tarballs = Vec::new();
|
|
|
|
tarballs.push(rustc_installer);
|
|
|
|
tarballs.push(cargo_installer);
|
|
|
|
tarballs.extend(rls_installer.clone());
|
2020-08-03 10:11:30 -04:00
|
|
|
tarballs.extend(rust_analyzer_installer.clone());
|
2020-04-01 13:18:06 +02:00
|
|
|
tarballs.push(clippy_installer);
|
2018-12-23 21:31:45 +01:00
|
|
|
tarballs.extend(miri_installer.clone());
|
2017-11-16 16:02:18 +13:00
|
|
|
tarballs.extend(rustfmt_installer.clone());
|
2018-10-26 03:11:11 +09:00
|
|
|
tarballs.extend(llvm_tools_installer);
|
2017-09-19 13:04:17 -07:00
|
|
|
tarballs.push(analysis_installer);
|
|
|
|
tarballs.push(std_installer);
|
2018-04-14 17:27:57 -06:00
|
|
|
if builder.config.docs {
|
2017-09-04 15:41:55 -05:00
|
|
|
tarballs.push(docs_installer);
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
if target.contains("pc-windows-gnu") {
|
2017-07-12 18:52:31 -06:00
|
|
|
tarballs.push(mingw_installer.unwrap());
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
|
|
|
let mut input_tarballs = tarballs[0].as_os_str().to_owned();
|
|
|
|
for tarball in &tarballs[1..] {
|
|
|
|
input_tarballs.push(",");
|
|
|
|
input_tarballs.push(tarball);
|
|
|
|
}
|
2017-01-20 17:03:06 -08:00
|
|
|
|
2019-09-19 11:22:55 -07:00
|
|
|
builder.info("building combined installer");
|
2017-07-05 10:46:41 -06:00
|
|
|
let mut cmd = rust_installer(builder);
|
2017-07-04 19:41:43 -06:00
|
|
|
cmd.arg("combine")
|
|
|
|
.arg("--product-name=Rust")
|
|
|
|
.arg("--rel-manifest-dir=rustlib")
|
|
|
|
.arg("--success-message=Rust-is-ready-to-roll.")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--work-dir")
|
|
|
|
.arg(&work)
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
2020-07-18 14:06:20 -04:00
|
|
|
.arg(format!("--package-name={}-{}", pkgname(builder, "rust"), target.triple))
|
2017-07-04 19:41:43 -06:00
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--input-tarballs")
|
|
|
|
.arg(input_tarballs)
|
|
|
|
.arg("--non-installed-overlay")
|
|
|
|
.arg(&overlay);
|
2019-09-19 11:22:55 -07:00
|
|
|
let time = timeit(&builder);
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.run(&mut cmd);
|
2019-09-19 11:22:55 -07:00
|
|
|
drop(time);
|
2017-01-20 17:03:06 -08:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
let mut license = String::new();
|
2018-04-14 17:27:57 -06:00
|
|
|
license += &builder.read(&builder.src.join("COPYRIGHT"));
|
|
|
|
license += &builder.read(&builder.src.join("LICENSE-APACHE"));
|
|
|
|
license += &builder.read(&builder.src.join("LICENSE-MIT"));
|
2017-07-04 19:41:43 -06:00
|
|
|
license.push_str("\n");
|
|
|
|
license.push_str("\n");
|
|
|
|
|
|
|
|
let rtf = r"{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Arial;}}\nowwrap\fs18";
|
|
|
|
let mut rtf = rtf.to_string();
|
|
|
|
rtf.push_str("\n");
|
|
|
|
for line in license.lines() {
|
|
|
|
rtf.push_str(line);
|
|
|
|
rtf.push_str("\\line ");
|
2017-01-20 17:03:06 -08:00
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
rtf.push_str("}");
|
|
|
|
|
2017-09-19 13:04:17 -07:00
|
|
|
fn filter(contents: &str, marker: &str) -> String {
|
|
|
|
let start = format!("tool-{}-start", marker);
|
|
|
|
let end = format!("tool-{}-end", marker);
|
|
|
|
let mut lines = Vec::new();
|
|
|
|
let mut omitted = false;
|
|
|
|
for line in contents.lines() {
|
|
|
|
if line.contains(&start) {
|
|
|
|
omitted = true;
|
|
|
|
} else if line.contains(&end) {
|
|
|
|
omitted = false;
|
|
|
|
} else if !omitted {
|
|
|
|
lines.push(line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lines.join("\n")
|
|
|
|
}
|
|
|
|
|
|
|
|
let xform = |p: &Path| {
|
2018-11-16 16:22:06 -05:00
|
|
|
let mut contents = t!(fs::read_to_string(p));
|
2017-09-19 13:04:17 -07:00
|
|
|
if rls_installer.is_none() {
|
|
|
|
contents = filter(&contents, "rls");
|
|
|
|
}
|
2020-08-03 10:11:30 -04:00
|
|
|
if rust_analyzer_installer.is_none() {
|
|
|
|
contents = filter(&contents, "rust-analyzer");
|
|
|
|
}
|
2018-12-23 21:31:45 +01:00
|
|
|
if miri_installer.is_none() {
|
|
|
|
contents = filter(&contents, "miri");
|
|
|
|
}
|
2017-11-16 16:02:18 +13:00
|
|
|
if rustfmt_installer.is_none() {
|
|
|
|
contents = filter(&contents, "rustfmt");
|
|
|
|
}
|
2017-09-19 13:04:17 -07:00
|
|
|
let ret = tmp.join(p.file_name().unwrap());
|
2018-11-16 16:22:06 -05:00
|
|
|
t!(fs::write(&ret, &contents));
|
|
|
|
ret
|
2017-09-19 13:04:17 -07:00
|
|
|
};
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
if target.contains("apple-darwin") {
|
2019-09-19 11:22:55 -07:00
|
|
|
builder.info("building pkg installer");
|
2017-07-04 19:41:43 -06:00
|
|
|
let pkg = tmp.join("pkg");
|
|
|
|
let _ = fs::remove_dir_all(&pkg);
|
|
|
|
|
|
|
|
let pkgbuild = |component: &str| {
|
|
|
|
let mut cmd = Command::new("pkgbuild");
|
2019-12-22 17:42:04 -05:00
|
|
|
cmd.arg("--identifier")
|
|
|
|
.arg(format!("org.rust-lang.{}", component))
|
|
|
|
.arg("--scripts")
|
|
|
|
.arg(pkg.join(component))
|
2017-07-04 19:41:43 -06:00
|
|
|
.arg("--nopayload")
|
|
|
|
.arg(pkg.join(component).with_extension("pkg"));
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.run(&mut cmd);
|
2017-07-04 19:41:43 -06:00
|
|
|
};
|
2017-09-19 13:04:17 -07:00
|
|
|
|
|
|
|
let prepare = |name: &str| {
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.create_dir(&pkg.join(name));
|
2019-12-22 17:42:04 -05:00
|
|
|
builder.cp_r(
|
2020-07-18 14:06:20 -04:00
|
|
|
&work.join(&format!("{}-{}", pkgname(builder, name), target.triple)),
|
2019-12-22 17:42:04 -05:00
|
|
|
&pkg.join(name),
|
|
|
|
);
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&etc.join("pkg/postinstall"), &pkg.join(name), 0o755);
|
2017-09-19 13:04:17 -07:00
|
|
|
pkgbuild(name);
|
|
|
|
};
|
|
|
|
prepare("rustc");
|
|
|
|
prepare("cargo");
|
|
|
|
prepare("rust-docs");
|
|
|
|
prepare("rust-std");
|
|
|
|
prepare("rust-analysis");
|
2020-04-01 13:18:06 +02:00
|
|
|
prepare("clippy");
|
2017-09-19 13:04:17 -07:00
|
|
|
|
|
|
|
if rls_installer.is_some() {
|
|
|
|
prepare("rls");
|
|
|
|
}
|
2020-08-03 10:11:30 -04:00
|
|
|
if rust_analyzer_installer.is_some() {
|
|
|
|
prepare("rust-analyzer");
|
|
|
|
}
|
2018-12-23 21:31:45 +01:00
|
|
|
if miri_installer.is_some() {
|
|
|
|
prepare("miri");
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// create an 'uninstall' package
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&etc.join("pkg/postinstall"), &pkg.join("uninstall"), 0o755);
|
2017-07-04 19:41:43 -06:00
|
|
|
pkgbuild("uninstall");
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.create_dir(&pkg.join("res"));
|
|
|
|
builder.create(&pkg.join("res/LICENSE.txt"), &license);
|
|
|
|
builder.install(&etc.join("gfx/rust-logo.png"), &pkg.join("res"), 0o644);
|
2017-07-04 19:41:43 -06:00
|
|
|
let mut cmd = Command::new("productbuild");
|
2019-12-22 17:42:04 -05:00
|
|
|
cmd.arg("--distribution")
|
|
|
|
.arg(xform(&etc.join("pkg/Distribution.xml")))
|
|
|
|
.arg("--resources")
|
|
|
|
.arg(pkg.join("res"))
|
2020-07-18 14:06:20 -04:00
|
|
|
.arg(distdir(builder).join(format!(
|
|
|
|
"{}-{}.pkg",
|
|
|
|
pkgname(builder, "rust"),
|
|
|
|
target.triple
|
|
|
|
)))
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--package-path")
|
|
|
|
.arg(&pkg);
|
2019-09-19 11:22:55 -07:00
|
|
|
let _time = timeit(builder);
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.run(&mut cmd);
|
2017-01-20 17:03:06 -08:00
|
|
|
}
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
if target.contains("windows") {
|
|
|
|
let exe = tmp.join("exe");
|
|
|
|
let _ = fs::remove_dir_all(&exe);
|
|
|
|
|
2017-09-19 13:04:17 -07:00
|
|
|
let prepare = |name: &str| {
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.create_dir(&exe.join(name));
|
2017-09-19 13:04:17 -07:00
|
|
|
let dir = if name == "rust-std" || name == "rust-analysis" {
|
2020-07-18 14:06:20 -04:00
|
|
|
format!("{}-{}", name, target.triple)
|
2017-09-19 13:04:17 -07:00
|
|
|
} else if name == "rls" {
|
|
|
|
"rls-preview".to_string()
|
Add rust-analyzer submodule
The current plan is that submodule tracks the `release` branch of
rust-analyzer, which is updated once a week.
rust-analyzer is a workspace (with a virtual manifest), the actual
binary is provide by `crates/rust-analyzer` package.
Note that we intentionally don't add rust-analyzer to `Kind::Test`,
for two reasons.
*First*, at the moment rust-analyzer's test suite does a couple of
things which might not work in the context of rust repository. For
example, it shells out directly to `rustup` and `rustfmt`. So, making
this work requires non-trivial efforts.
*Second*, it seems unlikely that running tests in rust-lang/rust repo
would provide any additional guarantees. rust-analyzer builds with
stable and does not depend on the specifics of the compiler, so
changes to compiler can't break ra, unless they break stability
guarantee. Additionally, rust-analyzer itself is gated on bors, so we
are pretty confident that test suite passes.
2020-06-04 13:11:15 +02:00
|
|
|
} else if name == "rust-analyzer" {
|
|
|
|
"rust-analyzer-preview".to_string()
|
2018-05-28 13:34:29 +02:00
|
|
|
} else if name == "clippy" {
|
|
|
|
"clippy-preview".to_string()
|
2018-12-23 21:31:45 +01:00
|
|
|
} else if name == "miri" {
|
|
|
|
"miri-preview".to_string()
|
2017-09-19 13:04:17 -07:00
|
|
|
} else {
|
|
|
|
name.to_string()
|
|
|
|
};
|
2019-12-22 17:42:04 -05:00
|
|
|
builder.cp_r(
|
2020-07-18 14:06:20 -04:00
|
|
|
&work.join(&format!("{}-{}", pkgname(builder, name), target.triple)).join(dir),
|
2019-12-22 17:42:04 -05:00
|
|
|
&exe.join(name),
|
|
|
|
);
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.remove(&exe.join(name).join("manifest.in"));
|
2017-09-19 13:04:17 -07:00
|
|
|
};
|
|
|
|
prepare("rustc");
|
|
|
|
prepare("cargo");
|
|
|
|
prepare("rust-analysis");
|
|
|
|
prepare("rust-docs");
|
|
|
|
prepare("rust-std");
|
2020-04-01 13:18:06 +02:00
|
|
|
prepare("clippy");
|
2017-09-19 13:04:17 -07:00
|
|
|
if rls_installer.is_some() {
|
|
|
|
prepare("rls");
|
|
|
|
}
|
2020-08-03 10:11:30 -04:00
|
|
|
if rust_analyzer_installer.is_some() {
|
|
|
|
prepare("rust-analyzer");
|
|
|
|
}
|
2018-12-23 21:31:45 +01:00
|
|
|
if miri_installer.is_some() {
|
|
|
|
prepare("miri");
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
if target.contains("windows-gnu") {
|
2017-09-19 13:04:17 -07:00
|
|
|
prepare("rust-mingw");
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.install(&etc.join("gfx/rust-logo.ico"), &exe, 0o644);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// Generate msi installer
|
|
|
|
let wix = PathBuf::from(env::var_os("WIX").unwrap());
|
|
|
|
let heat = wix.join("bin/heat.exe");
|
|
|
|
let candle = wix.join("bin/candle.exe");
|
|
|
|
let light = wix.join("bin/light.exe");
|
|
|
|
|
|
|
|
let heat_flags = ["-nologo", "-gg", "-sfrag", "-srd", "-sreg"];
|
2019-12-22 17:42:04 -05:00
|
|
|
builder.run(
|
|
|
|
Command::new(&heat)
|
|
|
|
.current_dir(&exe)
|
|
|
|
.arg("dir")
|
|
|
|
.arg("rustc")
|
|
|
|
.args(&heat_flags)
|
|
|
|
.arg("-cg")
|
|
|
|
.arg("RustcGroup")
|
|
|
|
.arg("-dr")
|
|
|
|
.arg("Rustc")
|
|
|
|
.arg("-var")
|
|
|
|
.arg("var.RustcDir")
|
|
|
|
.arg("-out")
|
|
|
|
.arg(exe.join("RustcGroup.wxs")),
|
|
|
|
);
|
|
|
|
builder.run(
|
|
|
|
Command::new(&heat)
|
|
|
|
.current_dir(&exe)
|
|
|
|
.arg("dir")
|
|
|
|
.arg("rust-docs")
|
|
|
|
.args(&heat_flags)
|
|
|
|
.arg("-cg")
|
|
|
|
.arg("DocsGroup")
|
|
|
|
.arg("-dr")
|
|
|
|
.arg("Docs")
|
|
|
|
.arg("-var")
|
|
|
|
.arg("var.DocsDir")
|
|
|
|
.arg("-out")
|
|
|
|
.arg(exe.join("DocsGroup.wxs"))
|
|
|
|
.arg("-t")
|
|
|
|
.arg(etc.join("msi/squash-components.xsl")),
|
|
|
|
);
|
|
|
|
builder.run(
|
|
|
|
Command::new(&heat)
|
|
|
|
.current_dir(&exe)
|
|
|
|
.arg("dir")
|
|
|
|
.arg("cargo")
|
|
|
|
.args(&heat_flags)
|
|
|
|
.arg("-cg")
|
|
|
|
.arg("CargoGroup")
|
|
|
|
.arg("-dr")
|
|
|
|
.arg("Cargo")
|
|
|
|
.arg("-var")
|
|
|
|
.arg("var.CargoDir")
|
|
|
|
.arg("-out")
|
|
|
|
.arg(exe.join("CargoGroup.wxs"))
|
|
|
|
.arg("-t")
|
|
|
|
.arg(etc.join("msi/remove-duplicates.xsl")),
|
|
|
|
);
|
|
|
|
builder.run(
|
|
|
|
Command::new(&heat)
|
|
|
|
.current_dir(&exe)
|
|
|
|
.arg("dir")
|
|
|
|
.arg("rust-std")
|
|
|
|
.args(&heat_flags)
|
|
|
|
.arg("-cg")
|
|
|
|
.arg("StdGroup")
|
|
|
|
.arg("-dr")
|
|
|
|
.arg("Std")
|
|
|
|
.arg("-var")
|
|
|
|
.arg("var.StdDir")
|
|
|
|
.arg("-out")
|
|
|
|
.arg(exe.join("StdGroup.wxs")),
|
|
|
|
);
|
2017-09-19 13:04:17 -07:00
|
|
|
if rls_installer.is_some() {
|
2019-12-22 17:42:04 -05:00
|
|
|
builder.run(
|
|
|
|
Command::new(&heat)
|
|
|
|
.current_dir(&exe)
|
|
|
|
.arg("dir")
|
|
|
|
.arg("rls")
|
|
|
|
.args(&heat_flags)
|
|
|
|
.arg("-cg")
|
|
|
|
.arg("RlsGroup")
|
|
|
|
.arg("-dr")
|
|
|
|
.arg("Rls")
|
|
|
|
.arg("-var")
|
|
|
|
.arg("var.RlsDir")
|
|
|
|
.arg("-out")
|
|
|
|
.arg(exe.join("RlsGroup.wxs"))
|
|
|
|
.arg("-t")
|
|
|
|
.arg(etc.join("msi/remove-duplicates.xsl")),
|
|
|
|
);
|
2017-09-19 13:04:17 -07:00
|
|
|
}
|
2020-08-03 10:11:30 -04:00
|
|
|
if rust_analyzer_installer.is_some() {
|
|
|
|
builder.run(
|
|
|
|
Command::new(&heat)
|
|
|
|
.current_dir(&exe)
|
|
|
|
.arg("dir")
|
|
|
|
.arg("rust-analyzer")
|
|
|
|
.args(&heat_flags)
|
|
|
|
.arg("-cg")
|
|
|
|
.arg("RustAnalyzerGroup")
|
|
|
|
.arg("-dr")
|
|
|
|
.arg("RustAnalyzer")
|
|
|
|
.arg("-var")
|
|
|
|
.arg("var.RustAnalyzerDir")
|
|
|
|
.arg("-out")
|
|
|
|
.arg(exe.join("RustAnalyzerGroup.wxs"))
|
|
|
|
.arg("-t")
|
|
|
|
.arg(etc.join("msi/remove-duplicates.xsl")),
|
|
|
|
);
|
|
|
|
}
|
2020-04-01 13:18:06 +02:00
|
|
|
builder.run(
|
|
|
|
Command::new(&heat)
|
|
|
|
.current_dir(&exe)
|
|
|
|
.arg("dir")
|
|
|
|
.arg("clippy")
|
|
|
|
.args(&heat_flags)
|
|
|
|
.arg("-cg")
|
|
|
|
.arg("ClippyGroup")
|
|
|
|
.arg("-dr")
|
|
|
|
.arg("Clippy")
|
|
|
|
.arg("-var")
|
|
|
|
.arg("var.ClippyDir")
|
|
|
|
.arg("-out")
|
|
|
|
.arg(exe.join("ClippyGroup.wxs"))
|
|
|
|
.arg("-t")
|
|
|
|
.arg(etc.join("msi/remove-duplicates.xsl")),
|
|
|
|
);
|
2018-12-23 21:31:45 +01:00
|
|
|
if miri_installer.is_some() {
|
2019-12-22 17:42:04 -05:00
|
|
|
builder.run(
|
|
|
|
Command::new(&heat)
|
|
|
|
.current_dir(&exe)
|
|
|
|
.arg("dir")
|
|
|
|
.arg("miri")
|
|
|
|
.args(&heat_flags)
|
|
|
|
.arg("-cg")
|
|
|
|
.arg("MiriGroup")
|
|
|
|
.arg("-dr")
|
|
|
|
.arg("Miri")
|
|
|
|
.arg("-var")
|
|
|
|
.arg("var.MiriDir")
|
|
|
|
.arg("-out")
|
|
|
|
.arg(exe.join("MiriGroup.wxs"))
|
|
|
|
.arg("-t")
|
|
|
|
.arg(etc.join("msi/remove-duplicates.xsl")),
|
|
|
|
);
|
2018-12-23 21:31:45 +01:00
|
|
|
}
|
2019-12-22 17:42:04 -05:00
|
|
|
builder.run(
|
|
|
|
Command::new(&heat)
|
|
|
|
.current_dir(&exe)
|
|
|
|
.arg("dir")
|
|
|
|
.arg("rust-analysis")
|
|
|
|
.args(&heat_flags)
|
|
|
|
.arg("-cg")
|
|
|
|
.arg("AnalysisGroup")
|
|
|
|
.arg("-dr")
|
|
|
|
.arg("Analysis")
|
|
|
|
.arg("-var")
|
|
|
|
.arg("var.AnalysisDir")
|
|
|
|
.arg("-out")
|
|
|
|
.arg(exe.join("AnalysisGroup.wxs"))
|
|
|
|
.arg("-t")
|
|
|
|
.arg(etc.join("msi/remove-duplicates.xsl")),
|
|
|
|
);
|
2017-07-04 19:41:43 -06:00
|
|
|
if target.contains("windows-gnu") {
|
2019-12-22 17:42:04 -05:00
|
|
|
builder.run(
|
|
|
|
Command::new(&heat)
|
|
|
|
.current_dir(&exe)
|
|
|
|
.arg("dir")
|
|
|
|
.arg("rust-mingw")
|
|
|
|
.args(&heat_flags)
|
|
|
|
.arg("-cg")
|
|
|
|
.arg("GccGroup")
|
|
|
|
.arg("-dr")
|
|
|
|
.arg("Gcc")
|
|
|
|
.arg("-var")
|
|
|
|
.arg("var.GccDir")
|
|
|
|
.arg("-out")
|
|
|
|
.arg(exe.join("GccGroup.wxs")),
|
|
|
|
);
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2017-01-20 17:03:06 -08:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
let candle = |input: &Path| {
|
2019-12-22 17:42:04 -05:00
|
|
|
let output = exe.join(input.file_stem().unwrap()).with_extension("wixobj");
|
|
|
|
let arch = if target.contains("x86_64") { "x64" } else { "x86" };
|
2017-07-04 19:41:43 -06:00
|
|
|
let mut cmd = Command::new(&candle);
|
|
|
|
cmd.current_dir(&exe)
|
|
|
|
.arg("-nologo")
|
|
|
|
.arg("-dRustcDir=rustc")
|
|
|
|
.arg("-dDocsDir=rust-docs")
|
|
|
|
.arg("-dCargoDir=cargo")
|
|
|
|
.arg("-dStdDir=rust-std")
|
|
|
|
.arg("-dAnalysisDir=rust-analysis")
|
2020-04-01 13:18:06 +02:00
|
|
|
.arg("-dClippyDir=clippy")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("-arch")
|
|
|
|
.arg(&arch)
|
|
|
|
.arg("-out")
|
|
|
|
.arg(&output)
|
2017-07-04 19:41:43 -06:00
|
|
|
.arg(&input);
|
2018-04-14 17:27:57 -06:00
|
|
|
add_env(builder, &mut cmd, target);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2017-09-19 13:04:17 -07:00
|
|
|
if rls_installer.is_some() {
|
|
|
|
cmd.arg("-dRlsDir=rls");
|
|
|
|
}
|
2020-08-03 10:11:30 -04:00
|
|
|
if rust_analyzer_installer.is_some() {
|
|
|
|
cmd.arg("-dRustAnalyzerDir=rust-analyzer");
|
|
|
|
}
|
2018-12-23 21:31:45 +01:00
|
|
|
if miri_installer.is_some() {
|
|
|
|
cmd.arg("-dMiriDir=miri");
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
if target.contains("windows-gnu") {
|
|
|
|
cmd.arg("-dGccDir=rust-mingw");
|
|
|
|
}
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.run(&mut cmd);
|
2017-07-04 19:41:43 -06:00
|
|
|
};
|
2017-09-19 13:04:17 -07:00
|
|
|
candle(&xform(&etc.join("msi/rust.wxs")));
|
2017-07-04 19:41:43 -06:00
|
|
|
candle(&etc.join("msi/ui.wxs"));
|
|
|
|
candle(&etc.join("msi/rustwelcomedlg.wxs"));
|
|
|
|
candle("RustcGroup.wxs".as_ref());
|
|
|
|
candle("DocsGroup.wxs".as_ref());
|
|
|
|
candle("CargoGroup.wxs".as_ref());
|
|
|
|
candle("StdGroup.wxs".as_ref());
|
2020-04-01 13:18:06 +02:00
|
|
|
candle("ClippyGroup.wxs".as_ref());
|
2017-09-19 13:04:17 -07:00
|
|
|
if rls_installer.is_some() {
|
|
|
|
candle("RlsGroup.wxs".as_ref());
|
|
|
|
}
|
2020-08-03 10:11:30 -04:00
|
|
|
if rust_analyzer_installer.is_some() {
|
|
|
|
candle("RustAnalyzerGroup.wxs".as_ref());
|
|
|
|
}
|
2018-12-23 21:31:45 +01:00
|
|
|
if miri_installer.is_some() {
|
|
|
|
candle("MiriGroup.wxs".as_ref());
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
candle("AnalysisGroup.wxs".as_ref());
|
2017-01-20 17:03:06 -08:00
|
|
|
|
|
|
|
if target.contains("windows-gnu") {
|
2017-07-04 19:41:43 -06:00
|
|
|
candle("GccGroup.wxs".as_ref());
|
2017-01-20 17:03:06 -08:00
|
|
|
}
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.create(&exe.join("LICENSE.rtf"), &rtf);
|
|
|
|
builder.install(&etc.join("gfx/banner.bmp"), &exe, 0o644);
|
|
|
|
builder.install(&etc.join("gfx/dialogbg.bmp"), &exe, 0o644);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2019-09-19 11:22:55 -07:00
|
|
|
builder.info(&format!("building `msi` installer with {:?}", light));
|
2020-07-18 14:06:20 -04:00
|
|
|
let filename = format!("{}-{}.msi", pkgname(builder, "rust"), target.triple);
|
2017-07-04 19:41:43 -06:00
|
|
|
let mut cmd = Command::new(&light);
|
|
|
|
cmd.arg("-nologo")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("-ext")
|
|
|
|
.arg("WixUIExtension")
|
|
|
|
.arg("-ext")
|
|
|
|
.arg("WixUtilExtension")
|
|
|
|
.arg("-out")
|
|
|
|
.arg(exe.join(&filename))
|
2017-07-04 19:41:43 -06:00
|
|
|
.arg("rust.wixobj")
|
|
|
|
.arg("ui.wixobj")
|
|
|
|
.arg("rustwelcomedlg.wixobj")
|
|
|
|
.arg("RustcGroup.wixobj")
|
|
|
|
.arg("DocsGroup.wixobj")
|
|
|
|
.arg("CargoGroup.wixobj")
|
|
|
|
.arg("StdGroup.wixobj")
|
|
|
|
.arg("AnalysisGroup.wixobj")
|
2020-04-01 13:18:06 +02:00
|
|
|
.arg("ClippyGroup.wixobj")
|
2017-07-04 19:41:43 -06:00
|
|
|
.current_dir(&exe);
|
2017-01-20 17:03:06 -08:00
|
|
|
|
2017-09-19 13:04:17 -07:00
|
|
|
if rls_installer.is_some() {
|
|
|
|
cmd.arg("RlsGroup.wixobj");
|
|
|
|
}
|
2020-08-03 10:11:30 -04:00
|
|
|
if rust_analyzer_installer.is_some() {
|
|
|
|
cmd.arg("RustAnalyzerGroup.wixobj");
|
|
|
|
}
|
2018-12-23 21:31:45 +01:00
|
|
|
if miri_installer.is_some() {
|
|
|
|
cmd.arg("MiriGroup.wixobj");
|
|
|
|
}
|
2017-09-19 13:04:17 -07:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
if target.contains("windows-gnu") {
|
|
|
|
cmd.arg("GccGroup.wixobj");
|
|
|
|
}
|
|
|
|
// ICE57 wrongly complains about the shortcuts
|
|
|
|
cmd.arg("-sice:ICE57");
|
|
|
|
|
2019-09-19 11:22:55 -07:00
|
|
|
let _time = timeit(builder);
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.run(&mut cmd);
|
2017-01-28 10:24:42 -08:00
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
if !builder.config.dry_run {
|
|
|
|
t!(fs::rename(exe.join(&filename), distdir(builder).join(&filename)));
|
2018-03-31 19:21:14 -06:00
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
2017-01-20 17:03:06 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-17 10:08:04 -04:00
|
|
|
fn add_env(builder: &Builder<'_>, cmd: &mut Command, target: TargetSelection) {
|
2017-02-15 15:57:06 -08:00
|
|
|
let mut parts = channel::CFG_RELEASE_NUM.split('.');
|
2018-04-14 17:27:57 -06:00
|
|
|
cmd.env("CFG_RELEASE_INFO", builder.rust_version())
|
2019-12-22 17:42:04 -05:00
|
|
|
.env("CFG_RELEASE_NUM", channel::CFG_RELEASE_NUM)
|
|
|
|
.env("CFG_RELEASE", builder.rust_release())
|
|
|
|
.env("CFG_VER_MAJOR", parts.next().unwrap())
|
|
|
|
.env("CFG_VER_MINOR", parts.next().unwrap())
|
|
|
|
.env("CFG_VER_PATCH", parts.next().unwrap())
|
|
|
|
.env("CFG_VER_BUILD", "0") // just needed to build
|
|
|
|
.env("CFG_PACKAGE_VERS", builder.rust_package_vers())
|
|
|
|
.env("CFG_PACKAGE_NAME", pkgname(builder, "rust"))
|
2020-07-17 10:08:04 -04:00
|
|
|
.env("CFG_BUILD", target.triple)
|
2019-12-22 17:42:04 -05:00
|
|
|
.env("CFG_CHANNEL", &builder.config.channel);
|
2017-01-20 17:03:06 -08:00
|
|
|
|
|
|
|
if target.contains("windows-gnu") {
|
2019-12-22 17:42:04 -05:00
|
|
|
cmd.env("CFG_MINGW", "1").env("CFG_ABI", "GNU");
|
2017-01-20 17:03:06 -08:00
|
|
|
} else {
|
2019-12-22 17:42:04 -05:00
|
|
|
cmd.env("CFG_MINGW", "0").env("CFG_ABI", "MSVC");
|
2017-01-20 17:03:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if target.contains("x86_64") {
|
2019-12-22 17:42:04 -05:00
|
|
|
cmd.env("CFG_PLATFORM", "x64");
|
2017-01-20 17:03:06 -08:00
|
|
|
} else {
|
2019-12-22 17:42:04 -05:00
|
|
|
cmd.env("CFG_PLATFORM", "x86");
|
2017-01-20 17:03:06 -08:00
|
|
|
}
|
|
|
|
}
|
2017-01-24 14:37:04 -08:00
|
|
|
|
2018-03-10 07:01:06 -07:00
|
|
|
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
2017-07-04 19:41:43 -06:00
|
|
|
pub struct HashSign;
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
impl Step for HashSign {
|
2017-07-04 19:41:43 -06:00
|
|
|
type Output = ();
|
2017-07-05 06:41:27 -06:00
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2017-07-18 18:03:38 -06:00
|
|
|
run.path("hash-and-sign")
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2017-07-20 17:51:07 -06:00
|
|
|
run.builder.ensure(HashSign);
|
2017-07-05 06:41:27 -06:00
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn run(self, builder: &Builder<'_>) {
|
2019-09-17 10:39:26 +02:00
|
|
|
// This gets called by `promote-release`
|
|
|
|
// (https://github.com/rust-lang/rust-central-station/tree/master/promote-release).
|
2017-07-05 06:41:27 -06:00
|
|
|
let mut cmd = builder.tool_cmd(Tool::BuildManifest);
|
2018-04-14 17:27:57 -06:00
|
|
|
if builder.config.dry_run {
|
2018-03-31 19:21:14 -06:00
|
|
|
return;
|
|
|
|
}
|
2018-04-14 17:27:57 -06:00
|
|
|
let sign = builder.config.dist_sign_folder.as_ref().unwrap_or_else(|| {
|
2017-07-04 19:41:43 -06:00
|
|
|
panic!("\n\nfailed to specify `dist.sign-folder` in `config.toml`\n\n")
|
|
|
|
});
|
2018-04-14 17:27:57 -06:00
|
|
|
let addr = builder.config.dist_upload_addr.as_ref().unwrap_or_else(|| {
|
2017-07-04 19:41:43 -06:00
|
|
|
panic!("\n\nfailed to specify `dist.upload-addr` in `config.toml`\n\n")
|
|
|
|
});
|
2019-09-17 10:39:26 +02:00
|
|
|
let pass = if env::var("BUILD_MANIFEST_DISABLE_SIGNING").is_err() {
|
|
|
|
let file = builder.config.dist_gpg_password_file.as_ref().unwrap_or_else(|| {
|
|
|
|
panic!("\n\nfailed to specify `dist.gpg-password-file` in `config.toml`\n\n")
|
|
|
|
});
|
|
|
|
t!(fs::read_to_string(&file))
|
|
|
|
} else {
|
|
|
|
String::new()
|
|
|
|
};
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
let today = output(Command::new("date").arg("+%Y-%m-%d"));
|
|
|
|
|
|
|
|
cmd.arg(sign);
|
2018-04-14 17:27:57 -06:00
|
|
|
cmd.arg(distdir(builder));
|
2017-07-04 19:41:43 -06:00
|
|
|
cmd.arg(today.trim());
|
2018-04-14 17:27:57 -06:00
|
|
|
cmd.arg(builder.rust_package_vers());
|
2019-01-09 17:14:11 -08:00
|
|
|
cmd.arg(addr);
|
2018-04-14 17:27:57 -06:00
|
|
|
cmd.arg(builder.package_vers(&builder.release_num("cargo")));
|
|
|
|
cmd.arg(builder.package_vers(&builder.release_num("rls")));
|
Add rust-analyzer submodule
The current plan is that submodule tracks the `release` branch of
rust-analyzer, which is updated once a week.
rust-analyzer is a workspace (with a virtual manifest), the actual
binary is provide by `crates/rust-analyzer` package.
Note that we intentionally don't add rust-analyzer to `Kind::Test`,
for two reasons.
*First*, at the moment rust-analyzer's test suite does a couple of
things which might not work in the context of rust repository. For
example, it shells out directly to `rustup` and `rustfmt`. So, making
this work requires non-trivial efforts.
*Second*, it seems unlikely that running tests in rust-lang/rust repo
would provide any additional guarantees. rust-analyzer builds with
stable and does not depend on the specifics of the compiler, so
changes to compiler can't break ra, unless they break stability
guarantee. Additionally, rust-analyzer itself is gated on bors, so we
are pretty confident that test suite passes.
2020-06-04 13:11:15 +02:00
|
|
|
cmd.arg(builder.package_vers(&builder.release_num("rust-analyzer/crates/rust-analyzer")));
|
2018-05-28 13:34:29 +02:00
|
|
|
cmd.arg(builder.package_vers(&builder.release_num("clippy")));
|
2018-12-23 21:31:45 +01:00
|
|
|
cmd.arg(builder.package_vers(&builder.release_num("miri")));
|
2018-04-14 17:27:57 -06:00
|
|
|
cmd.arg(builder.package_vers(&builder.release_num("rustfmt")));
|
2018-06-23 05:49:02 -04:00
|
|
|
cmd.arg(builder.llvm_tools_package_vers());
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
builder.create_dir(&distdir(builder));
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
let mut child = t!(cmd.stdin(Stdio::piped()).spawn());
|
|
|
|
t!(child.stdin.take().unwrap().write_all(pass.as_bytes()));
|
|
|
|
let status = t!(child.wait());
|
|
|
|
assert!(status.success());
|
|
|
|
}
|
2017-01-24 14:37:04 -08:00
|
|
|
}
|
2018-05-30 08:01:35 +02:00
|
|
|
|
2020-05-07 17:27:08 -07:00
|
|
|
/// Maybe add libLLVM.so to the given destination lib-dir. It will only have
|
|
|
|
/// been built if LLVM tools are linked dynamically.
|
|
|
|
///
|
|
|
|
/// Note: This function does not yet support Windows, but we also don't support
|
|
|
|
/// linking LLVM tools dynamically on Windows yet.
|
2020-07-17 10:08:04 -04:00
|
|
|
fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir: &Path) {
|
2019-12-22 17:42:04 -05:00
|
|
|
let src_libdir = builder.llvm_out(target).join("lib");
|
2018-09-06 19:06:09 -07:00
|
|
|
|
|
|
|
if target.contains("apple-darwin") {
|
|
|
|
let llvm_dylib_path = src_libdir.join("libLLVM.dylib");
|
|
|
|
if llvm_dylib_path.exists() {
|
2020-05-07 17:27:08 -07:00
|
|
|
builder.install(&llvm_dylib_path, dst_libdir, 0o644);
|
2018-09-06 19:06:09 -07:00
|
|
|
}
|
2019-12-22 17:42:04 -05:00
|
|
|
return;
|
2018-09-06 19:06:09 -07:00
|
|
|
}
|
2018-08-14 14:31:12 +02:00
|
|
|
|
|
|
|
// Usually libLLVM.so is a symlink to something like libLLVM-6.0.so.
|
|
|
|
// Since tools link to the latter rather than the former, we have to
|
|
|
|
// follow the symlink to find out what to distribute.
|
|
|
|
let llvm_dylib_path = src_libdir.join("libLLVM.so");
|
|
|
|
if llvm_dylib_path.exists() {
|
|
|
|
let llvm_dylib_path = llvm_dylib_path.canonicalize().unwrap_or_else(|e| {
|
2019-12-22 17:42:04 -05:00
|
|
|
panic!("dist: Error calling canonicalize path `{}`: {}", llvm_dylib_path.display(), e);
|
2018-08-14 14:31:12 +02:00
|
|
|
});
|
|
|
|
|
2020-05-07 17:27:08 -07:00
|
|
|
builder.install(&llvm_dylib_path, dst_libdir, 0o644);
|
2018-08-14 14:31:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-07 17:27:08 -07:00
|
|
|
/// Maybe add libLLVM.so to the target lib-dir for linking.
|
2020-07-17 10:08:04 -04:00
|
|
|
pub fn maybe_install_llvm_target(builder: &Builder<'_>, target: TargetSelection, sysroot: &Path) {
|
|
|
|
let dst_libdir = sysroot.join("lib/rustlib").join(&*target.triple).join("lib");
|
2020-05-07 17:27:08 -07:00
|
|
|
maybe_install_llvm(builder, target, &dst_libdir);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Maybe add libLLVM.so to the runtime lib-dir for rustc itself.
|
2020-07-17 10:08:04 -04:00
|
|
|
pub fn maybe_install_llvm_runtime(builder: &Builder<'_>, target: TargetSelection, sysroot: &Path) {
|
2020-05-07 17:27:08 -07:00
|
|
|
let dst_libdir =
|
|
|
|
sysroot.join(builder.sysroot_libdir_relative(Compiler { stage: 1, host: target }));
|
|
|
|
maybe_install_llvm(builder, target, &dst_libdir);
|
|
|
|
}
|
|
|
|
|
2018-05-30 08:01:35 +02:00
|
|
|
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
|
|
|
pub struct LlvmTools {
|
2020-07-17 10:08:04 -04:00
|
|
|
pub target: TargetSelection,
|
2018-05-30 08:01:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Step for LlvmTools {
|
|
|
|
type Output = Option<PathBuf>;
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
2018-05-30 08:01:35 +02:00
|
|
|
run.path("llvm-tools")
|
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn make_run(run: RunConfig<'_>) {
|
2019-12-22 17:42:04 -05:00
|
|
|
run.builder.ensure(LlvmTools { target: run.target });
|
2018-05-30 08:01:35 +02:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:30:32 +09:00
|
|
|
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
|
2018-06-23 17:32:25 -04:00
|
|
|
let target = self.target;
|
2018-05-30 08:01:35 +02:00
|
|
|
assert!(builder.config.extended);
|
|
|
|
|
2018-07-15 09:23:36 +02:00
|
|
|
/* run only if llvm-config isn't used */
|
|
|
|
if let Some(config) = builder.config.target_config.get(&target) {
|
|
|
|
if let Some(ref _s) = config.llvm_config {
|
2019-12-22 17:42:04 -05:00
|
|
|
builder.info(&format!("Skipping LlvmTools ({}): external LLVM", target));
|
2018-07-15 09:23:36 +02:00
|
|
|
return None;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-28 11:50:05 -07:00
|
|
|
builder.info(&format!("Dist LlvmTools ({})", target));
|
2019-09-19 11:22:55 -07:00
|
|
|
let _time = timeit(builder);
|
2019-01-16 09:59:03 -08:00
|
|
|
let src = builder.src.join("src/llvm-project/llvm");
|
2018-05-30 08:01:35 +02:00
|
|
|
let name = pkgname(builder, "llvm-tools");
|
|
|
|
|
|
|
|
let tmp = tmpdir(builder);
|
|
|
|
let image = tmp.join("llvm-tools-image");
|
|
|
|
drop(fs::remove_dir_all(&image));
|
|
|
|
|
|
|
|
// Prepare the image directory
|
2019-12-22 17:42:04 -05:00
|
|
|
let src_bindir = builder.llvm_out(target).join("bin");
|
2020-07-17 10:08:04 -04:00
|
|
|
let dst_bindir = image.join("lib/rustlib").join(&*target.triple).join("bin");
|
2018-08-14 14:31:12 +02:00
|
|
|
t!(fs::create_dir_all(&dst_bindir));
|
2018-05-30 08:01:35 +02:00
|
|
|
for tool in LLVM_TOOLS {
|
2020-07-17 10:08:04 -04:00
|
|
|
let exe = src_bindir.join(exe(tool, target));
|
2018-08-14 14:31:12 +02:00
|
|
|
builder.install(&exe, &dst_bindir, 0o755);
|
2018-05-30 08:01:35 +02:00
|
|
|
}
|
|
|
|
|
2020-05-07 17:27:08 -07:00
|
|
|
// Copy libLLVM.so to the target lib dir as well, so the RPATH like
|
|
|
|
// `$ORIGIN/../lib` can find it. It may also be used as a dependency
|
|
|
|
// of `rustc-dev` to support the inherited `-lLLVM` when using the
|
|
|
|
// compiler libraries.
|
|
|
|
maybe_install_llvm_target(builder, target, &image);
|
|
|
|
|
2018-05-30 08:01:35 +02:00
|
|
|
// Prepare the overlay
|
|
|
|
let overlay = tmp.join("llvm-tools-overlay");
|
|
|
|
drop(fs::remove_dir_all(&overlay));
|
|
|
|
builder.create_dir(&overlay);
|
|
|
|
builder.install(&src.join("README.txt"), &overlay, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE.TXT"), &overlay, 0o644);
|
2018-06-23 05:49:02 -04:00
|
|
|
builder.create(&overlay.join("version"), &builder.llvm_tools_vers());
|
2018-05-30 08:01:35 +02:00
|
|
|
|
|
|
|
// 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=llvm-tools-installed.")
|
2019-12-22 17:42:04 -05:00
|
|
|
.arg("--image-dir")
|
|
|
|
.arg(&image)
|
|
|
|
.arg("--work-dir")
|
|
|
|
.arg(&tmpdir(builder))
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
|
|
|
.arg("--non-installed-overlay")
|
|
|
|
.arg(&overlay)
|
2020-07-18 14:06:20 -04:00
|
|
|
.arg(format!("--package-name={}-{}", name, target.triple))
|
2018-05-30 08:01:35 +02:00
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo")
|
2018-06-29 16:13:40 -05:00
|
|
|
.arg("--component-name=llvm-tools-preview");
|
2018-05-30 08:01:35 +02:00
|
|
|
|
|
|
|
builder.run(&mut cmd);
|
2020-07-18 14:06:20 -04:00
|
|
|
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)))
|
2018-05-30 08:01:35 +02:00
|
|
|
}
|
|
|
|
}
|
2020-09-04 13:59:14 -04:00
|
|
|
|
|
|
|
// Tarball intended for internal consumption to ease rustc/std development.
|
|
|
|
//
|
|
|
|
// Should not be considered stable by end users.
|
|
|
|
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
|
|
|
pub struct RustDev {
|
|
|
|
pub target: TargetSelection,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Step for RustDev {
|
|
|
|
type Output = Option<PathBuf>;
|
|
|
|
const DEFAULT: bool = true;
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
|
|
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
|
|
|
run.path("rust-dev")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn make_run(run: RunConfig<'_>) {
|
|
|
|
run.builder.ensure(RustDev { target: run.target });
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
|
|
|
|
let target = self.target;
|
|
|
|
|
|
|
|
builder.info(&format!("Dist RustDev ({})", target));
|
|
|
|
let _time = timeit(builder);
|
|
|
|
let src = builder.src.join("src/llvm-project/llvm");
|
|
|
|
let name = pkgname(builder, "rust-dev");
|
|
|
|
|
|
|
|
let tmp = tmpdir(builder);
|
|
|
|
let image = tmp.join("rust-dev-image");
|
|
|
|
drop(fs::remove_dir_all(&image));
|
|
|
|
|
|
|
|
// Prepare the image directory
|
|
|
|
let dst_bindir = image.join("bin");
|
|
|
|
t!(fs::create_dir_all(&dst_bindir));
|
|
|
|
let exe = builder.llvm_out(target).join("bin").join(exe("llvm-config", target));
|
|
|
|
builder.install(&exe, &dst_bindir, 0o755);
|
|
|
|
builder.install(&builder.llvm_filecheck(target), &dst_bindir, 0o755);
|
|
|
|
|
|
|
|
// Copy the include directory as well; needed mostly to build
|
|
|
|
// librustc_llvm properly (e.g., llvm-config.h is in here). But also
|
|
|
|
// just broadly useful to be able to link against the bundled LLVM.
|
|
|
|
builder.cp_r(&builder.llvm_out(target).join("include"), &image.join("include"));
|
|
|
|
|
|
|
|
// Copy libLLVM.so to the target lib dir as well, so the RPATH like
|
|
|
|
// `$ORIGIN/../lib` can find it. It may also be used as a dependency
|
|
|
|
// of `rustc-dev` to support the inherited `-lLLVM` when using the
|
|
|
|
// compiler libraries.
|
|
|
|
maybe_install_llvm(builder, target, &image.join("lib"));
|
|
|
|
|
|
|
|
// Prepare the overlay
|
|
|
|
let overlay = tmp.join("rust-dev-overlay");
|
|
|
|
drop(fs::remove_dir_all(&overlay));
|
|
|
|
builder.create_dir(&overlay);
|
|
|
|
builder.install(&src.join("README.txt"), &overlay, 0o644);
|
|
|
|
builder.install(&src.join("LICENSE.TXT"), &overlay, 0o644);
|
|
|
|
builder.create(&overlay.join("version"), &builder.rust_version());
|
|
|
|
|
|
|
|
// 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=rust-dev-installed.")
|
|
|
|
.arg("--image-dir")
|
|
|
|
.arg(&image)
|
|
|
|
.arg("--work-dir")
|
|
|
|
.arg(&tmpdir(builder))
|
|
|
|
.arg("--output-dir")
|
|
|
|
.arg(&distdir(builder))
|
|
|
|
.arg("--non-installed-overlay")
|
|
|
|
.arg(&overlay)
|
|
|
|
.arg(format!("--package-name={}-{}", name, target.triple))
|
|
|
|
.arg("--legacy-manifest-dirs=rustlib,cargo")
|
|
|
|
.arg("--component-name=rust-dev");
|
|
|
|
|
|
|
|
builder.run(&mut cmd);
|
|
|
|
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)))
|
|
|
|
}
|
|
|
|
}
|