summaryrefslogtreecommitdiffstats
path: root/src/tools/replace-version-placeholder
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:06:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:06:37 +0000
commit246f239d9f40f633160f0c18f87a20922d4e77bb (patch)
tree5a88572663584b3d4d28e5a20e10abab1be40884 /src/tools/replace-version-placeholder
parentReleasing progress-linux version 1.64.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-246f239d9f40f633160f0c18f87a20922d4e77bb.tar.xz
rustc-246f239d9f40f633160f0c18f87a20922d4e77bb.zip
Merging debian version 1.65.0+dfsg1-2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/replace-version-placeholder')
-rw-r--r--src/tools/replace-version-placeholder/Cargo.toml10
-rw-r--r--src/tools/replace-version-placeholder/src/main.rs30
2 files changed, 40 insertions, 0 deletions
diff --git a/src/tools/replace-version-placeholder/Cargo.toml b/src/tools/replace-version-placeholder/Cargo.toml
new file mode 100644
index 000000000..346ce6bd1
--- /dev/null
+++ b/src/tools/replace-version-placeholder/Cargo.toml
@@ -0,0 +1,10 @@
+[package]
+name = "replace-version-placeholder"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+tidy = { path = "../tidy" }
+walkdir = "2"
diff --git a/src/tools/replace-version-placeholder/src/main.rs b/src/tools/replace-version-placeholder/src/main.rs
new file mode 100644
index 000000000..33b35d054
--- /dev/null
+++ b/src/tools/replace-version-placeholder/src/main.rs
@@ -0,0 +1,30 @@
+use std::path::PathBuf;
+use tidy::{t, walk};
+
+pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
+
+fn main() {
+ let root_path: PathBuf = std::env::args_os().nth(1).expect("need path to root of repo").into();
+ let version_path = root_path.join("src").join("version");
+ let version_str = t!(std::fs::read_to_string(&version_path), version_path);
+ let version_str = version_str.trim();
+ walk::walk(
+ &root_path,
+ &mut |path| {
+ walk::filter_dirs(path)
+ // We exempt these as they require the placeholder
+ // for their operation
+ || path.ends_with("compiler/rustc_attr/src/builtin.rs")
+ || path.ends_with("src/tools/tidy/src/features/version.rs")
+ || path.ends_with("src/tools/replace-version-placeholder")
+ },
+ &mut |entry, contents| {
+ if !contents.contains(VERSION_PLACEHOLDER) {
+ return;
+ }
+ let new_contents = contents.replace(VERSION_PLACEHOLDER, version_str);
+ let path = entry.path();
+ t!(std::fs::write(&path, new_contents), path);
+ },
+ );
+}