aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrevor Spiteri <tspiteri@ieee.org>2019-01-21 23:46:25 +0100
committerAndrew Gallant <jamslam@gmail.com>2019-01-22 12:13:53 -0500
commit802bc11cd2a0a7a8bfdad5749baf58683ea0bcf3 (patch)
treef904892b0af7c728516b73d1e447ca21a5f06014
parentfe8c8ed12c9fe1e467109c9dc3d33d2da36168d6 (diff)
downloadbyteorder-802bc11cd2a0a7a8bfdad5749baf58683ea0bcf3.tar.gz
build: add back support for Rust 1.12
In older versions of Rust, the build.rs file is not auto-detected, so we add it to the Cargo.toml. Moreover, the existing build.rs was not compatible with older Rust versions because of the use of eprintln! and short-hand struct initialization. We fix that. Closes #140, Closes #141
-rw-r--r--Cargo.toml1
-rw-r--r--build.rs15
2 files changed, 11 insertions, 5 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 8d612f6..5a1f1d8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,6 +11,7 @@ categories = ["encoding", "parsing"]
keywords = ["byte", "endian", "big-endian", "little-endian", "binary"]
license = "Unlicense OR MIT"
exclude = ["/ci/*"]
+build = "build.rs"
[lib]
name = "byteorder"
diff --git a/build.rs b/build.rs
index a2c8d18..002135b 100644
--- a/build.rs
+++ b/build.rs
@@ -1,12 +1,17 @@
use std::env;
use std::ffi::OsString;
+use std::io::{self, Write};
use std::process::Command;
fn main() {
let version = match Version::read() {
Ok(version) => version,
Err(err) => {
- eprintln!("failed to parse `rustc --version`: {}", err);
+ writeln!(
+ &mut io::stderr(),
+ "failed to parse `rustc --version`: {}",
+ err
+ ).unwrap();
return;
}
};
@@ -57,7 +62,7 @@ impl Version {
}
num.push(c);
}
- let major = num.parse::<u32>().map_err(|e| e.to_string())?;
+ let major = try!(num.parse::<u32>().map_err(|e| e.to_string()));
num.clear();
for c in parts[1].chars() {
@@ -66,7 +71,7 @@ impl Version {
}
num.push(c);
}
- let minor = num.parse::<u32>().map_err(|e| e.to_string())?;
+ let minor = try!(num.parse::<u32>().map_err(|e| e.to_string()));
num.clear();
for c in parts[2].chars() {
@@ -75,8 +80,8 @@ impl Version {
}
num.push(c);
}
- let patch = num.parse::<u32>().map_err(|e| e.to_string())?;
+ let patch = try!(num.parse::<u32>().map_err(|e| e.to_string()));
- Ok(Version { major, minor, patch })
+ Ok(Version { major: major, minor: minor, patch: patch })
}
}