Merge rust-bitcoin/rust-bitcoin#3202: Document the new build script magic

39f10339ad Document the new build script magic (Tobin C. Harding)

Pull request description:

  This is a follow up to #3182 which introduced a new way of conditionally including code based on the compiler version.

  When originally reviewing I missed the fact that the two loops were controlled by the current compiler version (`minor`) so the created macro is different dependent on the compiler used to build the code.

  To help the next guy notice, add a comment.

ACKs for top commit:
  Kixunil:
    ACK 39f10339ad
  apoelstra:
    ACK 39f10339ad successfully ran local tests

Tree-SHA512: 9a223718e2691a0f3b6a72c6d666ef4c238764b3ed967e15779311625f6535aea41c2e10795c5a98e69d0d50f23fc928edd72c01ed4a0074cf320f7c1a032b6a
This commit is contained in:
merge-script 2024-08-22 14:18:36 +00:00
commit 6a2f9e0182
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 3 additions and 0 deletions

View File

@ -59,6 +59,9 @@ fn write_macro(mut macro_file: impl io::Write, msrv_minor: u64, minor: u64) -> i
writeln!(macro_file, "/// Currently only the `>=` operator is supported.")?; writeln!(macro_file, "/// Currently only the `>=` operator is supported.")?;
writeln!(macro_file, "#[macro_export]")?; writeln!(macro_file, "#[macro_export]")?;
writeln!(macro_file, "macro_rules! rust_version {{")?; writeln!(macro_file, "macro_rules! rust_version {{")?;
// These two loops are the magic; we output the clause if_yes/if_no
// dependent on the current compiler version (`minor`).
for version in msrv_minor..=minor { for version in msrv_minor..=minor {
writeln!(macro_file, " (if >= 1.{} {{ $($if_yes:tt)* }} $(else {{ $($if_no:tt)* }})?) => {{", version)?; writeln!(macro_file, " (if >= 1.{} {{ $($if_yes:tt)* }} $(else {{ $($if_no:tt)* }})?) => {{", version)?;
writeln!(macro_file, " $($if_yes)*")?; writeln!(macro_file, " $($if_yes)*")?;