From a56b1d2a1378d0559a6174b4392fe49b245268df Mon Sep 17 00:00:00 2001 From: Giang Dao Date: Mon, 7 Oct 2024 19:07:57 +0800 Subject: [PATCH 1/4] fix missing rustfmt and clippy for msi --- src/bootstrap/src/core/build_steps/dist.rs | 31 +++++++++++++++- src/etc/installer/msi/rust.wxs | 41 +++++++++++++++++++++- 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 2354fe1ebafbe..177696b922e05 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -1627,6 +1627,8 @@ impl Step for Extended { "rust-analyzer-preview".to_string() } else if name == "clippy" { "clippy-preview".to_string() + } else if name == "rustfmt" { + "rustfmt-preview".to_string() } else if name == "miri" { "miri-preview".to_string() } else if name == "rustc-codegen-cranelift" { @@ -1646,7 +1648,7 @@ impl Step for Extended { prepare("cargo"); prepare("rust-analysis"); prepare("rust-std"); - for tool in &["clippy", "rust-analyzer", "rust-docs", "miri"] { + for tool in &["clippy", "rustfmt", "rust-analyzer", "rust-docs", "miri"] { if built_tools.contains(tool) { prepare(tool); } @@ -1764,6 +1766,24 @@ impl Step for Extended { .arg(etc.join("msi/remove-duplicates.xsl")) .run(builder); } + if built_tools.contains("rustfmt") { + command(&heat) + .current_dir(&exe) + .arg("dir") + .arg("rustfmt") + .args(heat_flags) + .arg("-cg") + .arg("RustFmtGroup") + .arg("-dr") + .arg("RustFmt") + .arg("-var") + .arg("var.RustFmtDir") + .arg("-out") + .arg(exe.join("RustFmtGroup.wxs")) + .arg("-t") + .arg(etc.join("msi/remove-duplicates.xsl")) + .run(builder); + } if built_tools.contains("miri") { command(&heat) .current_dir(&exe) @@ -1835,6 +1855,9 @@ impl Step for Extended { if built_tools.contains("clippy") { cmd.arg("-dClippyDir=clippy"); } + if built_tools.contains("rustfmt") { + cmd.arg("-dRustFmtDir=rustfmt"); + } if built_tools.contains("rust-docs") { cmd.arg("-dDocsDir=rust-docs"); } @@ -1861,6 +1884,9 @@ impl Step for Extended { if built_tools.contains("clippy") { candle("ClippyGroup.wxs".as_ref()); } + if built_tools.contains("rustfmt") { + candle("RustFmtGroup.wxs".as_ref()); + } if built_tools.contains("miri") { candle("MiriGroup.wxs".as_ref()); } @@ -1899,6 +1925,9 @@ impl Step for Extended { if built_tools.contains("clippy") { cmd.arg("ClippyGroup.wixobj"); } + if built_tools.contains("rustfmt") { + cmd.arg("RustFmtGroup.wixobj"); + } if built_tools.contains("miri") { cmd.arg("MiriGroup.wixobj"); } diff --git a/src/etc/installer/msi/rust.wxs b/src/etc/installer/msi/rust.wxs index f29e1e4d27a27..2d155bf0b1019 100644 --- a/src/etc/installer/msi/rust.wxs +++ b/src/etc/installer/msi/rust.wxs @@ -172,6 +172,11 @@ + + + + + @@ -279,7 +284,41 @@ - + + + + + + + + + + + + + + + From a0abd613d031407c5d17bb1e7debebddf748d468 Mon Sep 17 00:00:00 2001 From: Giang Dao Date: Mon, 7 Oct 2024 19:10:18 +0800 Subject: [PATCH 2/4] fix missing rustfmt for apple darwin --- src/bootstrap/src/core/build_steps/dist.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 177696b922e05..b6c5a5add01c3 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -1585,9 +1585,15 @@ impl Step for Extended { prepare("cargo"); prepare("rust-std"); prepare("rust-analysis"); - prepare("clippy"); - prepare("rust-analyzer"); - for tool in &["rust-docs", "miri", "rustc-codegen-cranelift"] { + + for tool in &[ + "clippy", + "rustfmt", + "rust-analyzer", + "rust-docs", + "miri", + "rustc-codegen-cranelift", + ] { if built_tools.contains(tool) { prepare(tool); } From 43152ad47bb15e46c001820df854d4f65964e74a Mon Sep 17 00:00:00 2001 From: klensy Date: Sat, 16 Nov 2024 11:31:34 +0300 Subject: [PATCH 3/4] wix: allow to skip more components --- src/bootstrap/src/core/build_steps/dist.rs | 32 ++++++++- src/etc/installer/msi/rust.wxs | 80 +++++++++++++--------- 2 files changed, 78 insertions(+), 34 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index b6c5a5add01c3..33155ab379595 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -1856,7 +1856,7 @@ impl Step for Extended { .arg("-out") .arg(&output) .arg(input); - add_env(builder, &mut cmd, target); + add_env(builder, &mut cmd, target, &built_tools); if built_tools.contains("clippy") { cmd.arg("-dClippyDir=clippy"); @@ -1960,7 +1960,14 @@ impl Step for Extended { } } -fn add_env(builder: &Builder<'_>, cmd: &mut BootstrapCommand, target: TargetSelection) { +fn add_env( + builder: &Builder<'_>, + cmd: &mut BootstrapCommand, + target: TargetSelection, + built_tools: &HashSet<&'static str>, +) { + // envs for wix should be always defined, even if not used + // FIXME: is they affect ccache? let mut parts = builder.version.split('.'); cmd.env("CFG_RELEASE_INFO", builder.rust_version()) .env("CFG_RELEASE_NUM", &builder.version) @@ -1981,6 +1988,27 @@ fn add_env(builder: &Builder<'_>, cmd: &mut BootstrapCommand, target: TargetSele } else { cmd.env("CFG_MINGW", "0").env("CFG_ABI", "MSVC"); } + + if built_tools.contains("rustfmt") { + cmd.env("CFG_RUSTFMT", "1"); + } else { + cmd.env("CFG_RUSTFMT", "0"); + } + if built_tools.contains("clippy") { + cmd.env("CFG_CLIPPY", "1"); + } else { + cmd.env("CFG_CLIPPY", "0"); + } + if built_tools.contains("miri") { + cmd.env("CFG_MIRI", "1"); + } else { + cmd.env("CFG_MIRI", "0"); + } + if built_tools.contains("rust-analyzer") { + cmd.env("CFG_RA", "1"); + } else { + cmd.env("CFG_RA", "0"); + } } fn install_llvm_file( diff --git a/src/etc/installer/msi/rust.wxs b/src/etc/installer/msi/rust.wxs index 2d155bf0b1019..64cceccc97582 100644 --- a/src/etc/installer/msi/rust.wxs +++ b/src/etc/installer/msi/rust.wxs @@ -172,11 +172,19 @@ - - - + + + + + + + + + - + + + @@ -284,34 +292,42 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + Date: Mon, 17 Mar 2025 18:34:28 +0800 Subject: [PATCH 4/4] adjust comment --- src/bootstrap/src/core/build_steps/dist.rs | 30 ++++++---------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 33155ab379595..a4a9cb7ef3155 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -1966,8 +1966,6 @@ fn add_env( target: TargetSelection, built_tools: &HashSet<&'static str>, ) { - // envs for wix should be always defined, even if not used - // FIXME: is they affect ccache? let mut parts = builder.version.split('.'); cmd.env("CFG_RELEASE_INFO", builder.rust_version()) .env("CFG_RELEASE_NUM", &builder.version) @@ -1989,26 +1987,14 @@ fn add_env( cmd.env("CFG_MINGW", "0").env("CFG_ABI", "MSVC"); } - if built_tools.contains("rustfmt") { - cmd.env("CFG_RUSTFMT", "1"); - } else { - cmd.env("CFG_RUSTFMT", "0"); - } - if built_tools.contains("clippy") { - cmd.env("CFG_CLIPPY", "1"); - } else { - cmd.env("CFG_CLIPPY", "0"); - } - if built_tools.contains("miri") { - cmd.env("CFG_MIRI", "1"); - } else { - cmd.env("CFG_MIRI", "0"); - } - if built_tools.contains("rust-analyzer") { - cmd.env("CFG_RA", "1"); - } else { - cmd.env("CFG_RA", "0"); - } + // ensure these variables are defined + let mut define_optional_tool = |tool_name: &str, env_name: &str| { + cmd.env(env_name, if built_tools.contains(tool_name) { "1" } else { "0" }); + }; + define_optional_tool("rustfmt", "CFG_RUSTFMT"); + define_optional_tool("clippy", "CFG_CLIPPY"); + define_optional_tool("miri", "CFG_MIRI"); + define_optional_tool("rust-analyzer", "CFG_RA"); } fn install_llvm_file(