Skip to content

Commit

Permalink
Merge rust-bitcoin#3176: Io improvements
Browse files Browse the repository at this point in the history
56b19d0 Add missing IO impls for `std` types (Martin Habovstiak)
5e30c9f Use macro to implement our traits for `std` types (Martin Habovstiak)
505ecd8 Move `std` impl from `lib.rs` to `bridge.rs` (Martin Habovstiak)
94768d3 Add `set_position` method to `Cursor` (Martin Habovstiak)
fc7e213 Add `bitcoin-io` -> `std` bridge (Martin Habovstiak)
54fdcb7 Add `std` -> `bitcoin-io` bridge (Martin Habovstiak)

Pull request description:

  This addresses significant API holes. Originally I wanted to add a commit that bumps the IO version but then I remembered we have rust-bitcoin#3162 which we most likely also want to merge and release.

  Closes rust-bitcoin#3174
  Closes rust-bitcoin#3175

ACKs for top commit:
  apoelstra:
    ACK 56b19d0 successfully ran local tests
  tcharding:
    ACK 56b19d0

Tree-SHA512: 9b0934da8dfd962c916c74032d734583175c6016f514861e24a29179c15925389a506ccf1b784a1bf99bc22909b5e7dcaece5fb689bd32f21ca0112ee798eca5
  • Loading branch information
apoelstra committed Aug 17, 2024
2 parents bcbb0ae + 56b19d0 commit c00faa0
Show file tree
Hide file tree
Showing 4 changed files with 618 additions and 36 deletions.
2 changes: 1 addition & 1 deletion io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints.rust]
unexpected_cfgs = { level = "deny" }
unexpected_cfgs = { level = "deny", check-cfg = ['cfg(rust_v_1_72)', 'cfg(rust_v_1_73)', 'cfg(rust_v_1_75)', 'cfg(rust_v_1_78)'] }
37 changes: 37 additions & 0 deletions io/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
fn main() {
let rustc = std::env::var_os("RUSTC");
let rustc = rustc.as_ref().map(std::path::Path::new).unwrap_or_else(|| "rustc".as_ref());
let output = std::process::Command::new(rustc)
.arg("--version")
.output()
.unwrap_or_else(|error| panic!("failed to run `{:?} --version`: {:?}", rustc, error));
assert!(output.status.success(), "{:?} -- version returned non-zero exit code", rustc);
let stdout = String::from_utf8(output.stdout).expect("rustc produced non-UTF-8 output");
let version_prefix = "rustc ";
if !stdout.starts_with(version_prefix) {
panic!("unexpected rustc output: {}", stdout);
}

let version = &stdout[version_prefix.len()..];
let end = version.find(&[' ', '-'] as &[_]).unwrap_or(version.len());
let version = &version[..end];
let mut version_components = version.split('.');
let major = version_components.next().unwrap();
assert_eq!(major, "1", "unexpected Rust major version");
let minor = version_components
.next()
.unwrap_or("0")
.parse::<u64>()
.expect("invalid Rust minor version");

let msrv = std::env::var("CARGO_PKG_RUST_VERSION").unwrap();
let mut msrv = msrv.split(".");
let msrv_major = msrv.next().unwrap();
assert_eq!(msrv_major, "1", "unexpected Rust major version");
let msrv_minor = msrv.next().unwrap().parse::<u64>().unwrap();

// print cfg for all interesting versions less than or equal to minor
for version in msrv_minor..=minor {
println!("cargo:rustc-cfg=rust_v_1_{}", version);
}
}
Loading

0 comments on commit c00faa0

Please sign in to comment.