aboutsummaryrefslogtreecommitdiff
path: root/src/rust/build.rs
diff options
context:
space:
mode:
authorcypherpunks <cypherpunks@torproject.org>2018-08-03 19:48:10 +0000
committerNick Mathewson <nickm@torproject.org>2018-08-16 08:42:57 -0400
commit6b609ce4356423a28e7b421a9f09849d831a0c6f (patch)
tree0feff6aae6ea11f4933d47e96949539c32368e3d /src/rust/build.rs
parent32ad8e991999277948e896196731f2919c390f00 (diff)
downloadtor-6b609ce4356423a28e7b421a9f09849d831a0c6f.tar.gz
tor-6b609ce4356423a28e7b421a9f09849d831a0c6f.zip
rust: run rustfmt
Diffstat (limited to 'src/rust/build.rs')
-rw-r--r--src/rust/build.rs35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/rust/build.rs b/src/rust/build.rs
index 2ac24b334b..bf389cf7df 100644
--- a/src/rust/build.rs
+++ b/src/rust/build.rs
@@ -10,14 +10,12 @@
use std::collections::HashMap;
use std::env;
use std::fs::File;
-use std::io::prelude::*;
use std::io;
+use std::io::prelude::*;
use std::path::PathBuf;
/// Wrapper around a key-value map.
-struct Config(
- HashMap<String,String>
-);
+struct Config(HashMap<String, String>);
/// Locate a config.rust file generated by autoconf, starting in the OUT_DIR
/// location provided by cargo and recursing up the directory tree. Note that
@@ -31,9 +29,9 @@ fn find_cfg() -> io::Result<String> {
return Ok(path.to_str().unwrap().to_owned());
}
path.pop(); // remove config.rust
- if ! path.pop() { // can't remove last part of directory
- return Err(io::Error::new(io::ErrorKind::NotFound,
- "No config.rust"));
+ if !path.pop() {
+ // can't remove last part of directory
+ return Err(io::Error::new(io::ErrorKind::NotFound, "No config.rust"));
}
}
}
@@ -55,12 +53,11 @@ impl Config {
}
let idx = match s.find("=") {
None => {
- return Err(io::Error::new(io::ErrorKind::InvalidData,
- "missing ="));
- },
- Some(x) => x
+ return Err(io::Error::new(io::ErrorKind::InvalidData, "missing ="));
+ }
+ Some(x) => x,
};
- let (var,eq_val) = s.split_at(idx);
+ let (var, eq_val) = s.split_at(idx);
let val = &eq_val[1..];
map.insert(var.to_owned(), val.to_owned());
}
@@ -70,34 +67,34 @@ impl Config {
/// Return a reference to the value whose key is 'key'.
///
/// Panics if 'key' is not found in the configuration.
- fn get(&self, key : &str) -> &str {
+ fn get(&self, key: &str) -> &str {
self.0.get(key).unwrap()
}
/// Add a dependency on a static C library that is part of Tor, by name.
- fn component(&self, s : &str) {
+ fn component(&self, s: &str) {
println!("cargo:rustc-link-lib=static={}", s);
}
/// Add a dependency on a native library that is not part of Tor, by name.
- fn dependency(&self, s : &str) {
+ fn dependency(&self, s: &str) {
println!("cargo:rustc-link-lib={}", s);
}
/// Add a link path, relative to Tor's build directory.
- fn link_relpath(&self, s : &str) {
+ fn link_relpath(&self, s: &str) {
let builddir = self.get("BUILDDIR");
println!("cargo:rustc-link-search=native={}/{}", builddir, s);
}
/// Add an absolute link path.
- fn link_path(&self, s : &str) {
+ fn link_path(&self, s: &str) {
println!("cargo:rustc-link-search=native={}", s);
}
/// Parse the CFLAGS in s, looking for -l and -L items, and adding
/// rust configuration as appropriate.
- fn from_cflags(&self, s : &str) {
+ fn from_cflags(&self, s: &str) {
let mut next_is_lib = false;
let mut next_is_path = false;
for ent in self.get(s).split_whitespace() {
@@ -184,7 +181,7 @@ pub fn main() {
cfg.from_cflags("TOR_LZMA_LIBS");
cfg.from_cflags("TOR_ZSTD_LIBS");
cfg.from_cflags("LIBS");
- },
+ }
_ => {
panic!("No configuration in build.rs for package {}", package);
}