]> git.lizzy.rs Git - rust.git/blob - src/bootstrap/config.rs
87c35e0502ce6d853ce5ad0ff95e1668b9bacead
[rust.git] / src / bootstrap / config.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! Serialized configuration of a build.
12 //!
13 //! This module implements parsing `config.mk` and `config.toml` configuration
14 //! files to tweak how the build runs.
15
16 use std::collections::HashMap;
17 use std::env;
18 use std::fs::File;
19 use std::io::prelude::*;
20 use std::path::PathBuf;
21 use std::process;
22
23 use num_cpus;
24 use rustc_serialize::Decodable;
25 use toml::{Parser, Decoder, Value};
26 use util::push_exe_path;
27
28 /// Global configuration for the entire build and/or bootstrap.
29 ///
30 /// This structure is derived from a combination of both `config.toml` and
31 /// `config.mk`. As of the time of this writing it's unlikely that `config.toml`
32 /// is used all that much, so this is primarily filled out by `config.mk` which
33 /// is generated from `./configure`.
34 ///
35 /// Note that this structure is not decoded directly into, but rather it is
36 /// filled out from the decoded forms of the structs below. For documentation
37 /// each field, see the corresponding fields in
38 /// `src/bootstrap/config.toml.example`.
39 #[derive(Default)]
40 pub struct Config {
41     pub ccache: Option<String>,
42     pub ninja: bool,
43     pub verbose: usize,
44     pub submodules: bool,
45     pub compiler_docs: bool,
46     pub docs: bool,
47     pub locked_deps: bool,
48     pub vendor: bool,
49     pub target_config: HashMap<String, Target>,
50     pub full_bootstrap: bool,
51     pub extended: bool,
52     pub sanitizers: bool,
53
54     // llvm codegen options
55     pub llvm_assertions: bool,
56     pub llvm_optimize: bool,
57     pub llvm_release_debuginfo: bool,
58     pub llvm_version_check: bool,
59     pub llvm_static_stdcpp: bool,
60     pub llvm_link_shared: bool,
61     pub llvm_targets: Option<String>,
62     pub llvm_link_jobs: Option<u32>,
63
64     // rust codegen options
65     pub rust_optimize: bool,
66     pub rust_codegen_units: u32,
67     pub rust_debug_assertions: bool,
68     pub rust_debuginfo: bool,
69     pub rust_debuginfo_lines: bool,
70     pub rust_debuginfo_only_std: bool,
71     pub rust_rpath: bool,
72     pub rustc_default_linker: Option<String>,
73     pub rustc_default_ar: Option<String>,
74     pub rust_optimize_tests: bool,
75     pub rust_debuginfo_tests: bool,
76     pub rust_dist_src: bool,
77
78     pub build: String,
79     pub host: Vec<String>,
80     pub target: Vec<String>,
81     pub rustc: Option<PathBuf>,
82     pub cargo: Option<PathBuf>,
83     pub local_rebuild: bool,
84
85     // dist misc
86     pub dist_sign_folder: Option<PathBuf>,
87     pub dist_upload_addr: Option<String>,
88     pub dist_gpg_password_file: Option<PathBuf>,
89
90     // libstd features
91     pub debug_jemalloc: bool,
92     pub use_jemalloc: bool,
93     pub backtrace: bool, // support for RUST_BACKTRACE
94
95     // misc
96     pub channel: String,
97     pub quiet_tests: bool,
98     // Fallback musl-root for all targets
99     pub musl_root: Option<PathBuf>,
100     pub prefix: Option<PathBuf>,
101     pub docdir: Option<PathBuf>,
102     pub libdir: Option<PathBuf>,
103     pub libdir_relative: Option<PathBuf>,
104     pub mandir: Option<PathBuf>,
105     pub codegen_tests: bool,
106     pub nodejs: Option<PathBuf>,
107     pub gdb: Option<PathBuf>,
108     pub python: Option<PathBuf>,
109     pub configure_args: Vec<String>,
110     pub openssl_static: bool,
111 }
112
113 /// Per-target configuration stored in the global configuration structure.
114 #[derive(Default)]
115 pub struct Target {
116     pub llvm_config: Option<PathBuf>,
117     pub jemalloc: Option<PathBuf>,
118     pub cc: Option<PathBuf>,
119     pub cxx: Option<PathBuf>,
120     pub ndk: Option<PathBuf>,
121     pub musl_root: Option<PathBuf>,
122     pub qemu_rootfs: Option<PathBuf>,
123 }
124
125 /// Structure of the `config.toml` file that configuration is read from.
126 ///
127 /// This structure uses `Decodable` to automatically decode a TOML configuration
128 /// file into this format, and then this is traversed and written into the above
129 /// `Config` structure.
130 #[derive(RustcDecodable, Default)]
131 struct TomlConfig {
132     build: Option<Build>,
133     install: Option<Install>,
134     llvm: Option<Llvm>,
135     rust: Option<Rust>,
136     target: Option<HashMap<String, TomlTarget>>,
137     dist: Option<Dist>,
138 }
139
140 /// TOML representation of various global build decisions.
141 #[derive(RustcDecodable, Default, Clone)]
142 struct Build {
143     build: Option<String>,
144     host: Vec<String>,
145     target: Vec<String>,
146     cargo: Option<String>,
147     rustc: Option<String>,
148     compiler_docs: Option<bool>,
149     docs: Option<bool>,
150     submodules: Option<bool>,
151     gdb: Option<String>,
152     locked_deps: Option<bool>,
153     vendor: Option<bool>,
154     nodejs: Option<String>,
155     python: Option<String>,
156     full_bootstrap: Option<bool>,
157     extended: Option<bool>,
158     verbose: Option<usize>,
159     sanitizers: Option<bool>,
160     openssl_static: Option<bool>,
161 }
162
163 /// TOML representation of various global install decisions.
164 #[derive(RustcDecodable, Default, Clone)]
165 struct Install {
166     prefix: Option<String>,
167     mandir: Option<String>,
168     docdir: Option<String>,
169     libdir: Option<String>,
170 }
171
172 /// TOML representation of how the LLVM build is configured.
173 #[derive(RustcDecodable, Default)]
174 struct Llvm {
175     ccache: Option<StringOrBool>,
176     ninja: Option<bool>,
177     assertions: Option<bool>,
178     optimize: Option<bool>,
179     release_debuginfo: Option<bool>,
180     version_check: Option<bool>,
181     static_libstdcpp: Option<bool>,
182     targets: Option<String>,
183     link_jobs: Option<u32>,
184 }
185
186 #[derive(RustcDecodable, Default, Clone)]
187 struct Dist {
188     sign_folder: Option<String>,
189     gpg_password_file: Option<String>,
190     upload_addr: Option<String>,
191     src_tarball: Option<bool>,
192 }
193
194 #[derive(RustcDecodable)]
195 enum StringOrBool {
196     String(String),
197     Bool(bool),
198 }
199
200 impl Default for StringOrBool {
201     fn default() -> StringOrBool {
202         StringOrBool::Bool(false)
203     }
204 }
205
206 /// TOML representation of how the Rust build is configured.
207 #[derive(RustcDecodable, Default)]
208 struct Rust {
209     optimize: Option<bool>,
210     codegen_units: Option<u32>,
211     debug_assertions: Option<bool>,
212     debuginfo: Option<bool>,
213     debuginfo_lines: Option<bool>,
214     debuginfo_only_std: Option<bool>,
215     debug_jemalloc: Option<bool>,
216     use_jemalloc: Option<bool>,
217     backtrace: Option<bool>,
218     default_linker: Option<String>,
219     default_ar: Option<String>,
220     channel: Option<String>,
221     musl_root: Option<String>,
222     rpath: Option<bool>,
223     optimize_tests: Option<bool>,
224     debuginfo_tests: Option<bool>,
225     codegen_tests: Option<bool>,
226 }
227
228 /// TOML representation of how each build target is configured.
229 #[derive(RustcDecodable, Default)]
230 struct TomlTarget {
231     llvm_config: Option<String>,
232     jemalloc: Option<String>,
233     cc: Option<String>,
234     cxx: Option<String>,
235     android_ndk: Option<String>,
236     musl_root: Option<String>,
237     qemu_rootfs: Option<String>,
238 }
239
240 impl Config {
241     pub fn parse(build: &str, file: Option<PathBuf>) -> Config {
242         let mut config = Config::default();
243         config.llvm_optimize = true;
244         config.use_jemalloc = true;
245         config.backtrace = true;
246         config.rust_optimize = true;
247         config.rust_optimize_tests = true;
248         config.submodules = true;
249         config.docs = true;
250         config.rust_rpath = true;
251         config.rust_codegen_units = 1;
252         config.build = build.to_string();
253         config.channel = "dev".to_string();
254         config.codegen_tests = true;
255         config.rust_dist_src = true;
256
257         let toml = file.map(|file| {
258             let mut f = t!(File::open(&file));
259             let mut toml = String::new();
260             t!(f.read_to_string(&mut toml));
261             let mut p = Parser::new(&toml);
262             let table = match p.parse() {
263                 Some(table) => table,
264                 None => {
265                     println!("failed to parse TOML configuration:");
266                     for err in p.errors.iter() {
267                         let (loline, locol) = p.to_linecol(err.lo);
268                         let (hiline, hicol) = p.to_linecol(err.hi);
269                         println!("{}:{}-{}:{}: {}", loline, locol, hiline,
270                                  hicol, err.desc);
271                     }
272                     process::exit(2);
273                 }
274             };
275             let mut d = Decoder::new(Value::Table(table));
276             match Decodable::decode(&mut d) {
277                 Ok(cfg) => cfg,
278                 Err(e) => {
279                     println!("failed to decode TOML: {}", e);
280                     process::exit(2);
281                 }
282             }
283         }).unwrap_or_else(|| TomlConfig::default());
284
285         let build = toml.build.clone().unwrap_or(Build::default());
286         set(&mut config.build, build.build.clone());
287         config.host.push(config.build.clone());
288         for host in build.host.iter() {
289             if !config.host.contains(host) {
290                 config.host.push(host.clone());
291             }
292         }
293         for target in config.host.iter().chain(&build.target) {
294             if !config.target.contains(target) {
295                 config.target.push(target.clone());
296             }
297         }
298         config.rustc = build.rustc.map(PathBuf::from);
299         config.cargo = build.cargo.map(PathBuf::from);
300         config.nodejs = build.nodejs.map(PathBuf::from);
301         config.gdb = build.gdb.map(PathBuf::from);
302         config.python = build.python.map(PathBuf::from);
303         set(&mut config.compiler_docs, build.compiler_docs);
304         set(&mut config.docs, build.docs);
305         set(&mut config.submodules, build.submodules);
306         set(&mut config.locked_deps, build.locked_deps);
307         set(&mut config.vendor, build.vendor);
308         set(&mut config.full_bootstrap, build.full_bootstrap);
309         set(&mut config.extended, build.extended);
310         set(&mut config.verbose, build.verbose);
311         set(&mut config.sanitizers, build.sanitizers);
312         set(&mut config.openssl_static, build.openssl_static);
313
314         if let Some(ref install) = toml.install {
315             config.prefix = install.prefix.clone().map(PathBuf::from);
316             config.mandir = install.mandir.clone().map(PathBuf::from);
317             config.docdir = install.docdir.clone().map(PathBuf::from);
318             config.libdir = install.libdir.clone().map(PathBuf::from);
319         }
320
321         if let Some(ref llvm) = toml.llvm {
322             match llvm.ccache {
323                 Some(StringOrBool::String(ref s)) => {
324                     config.ccache = Some(s.to_string())
325                 }
326                 Some(StringOrBool::Bool(true)) => {
327                     config.ccache = Some("ccache".to_string());
328                 }
329                 Some(StringOrBool::Bool(false)) | None => {}
330             }
331             set(&mut config.ninja, llvm.ninja);
332             set(&mut config.llvm_assertions, llvm.assertions);
333             set(&mut config.llvm_optimize, llvm.optimize);
334             set(&mut config.llvm_release_debuginfo, llvm.release_debuginfo);
335             set(&mut config.llvm_version_check, llvm.version_check);
336             set(&mut config.llvm_static_stdcpp, llvm.static_libstdcpp);
337             config.llvm_targets = llvm.targets.clone();
338             config.llvm_link_jobs = llvm.link_jobs;
339         }
340
341         if let Some(ref rust) = toml.rust {
342             set(&mut config.rust_debug_assertions, rust.debug_assertions);
343             set(&mut config.rust_debuginfo, rust.debuginfo);
344             set(&mut config.rust_debuginfo_lines, rust.debuginfo_lines);
345             set(&mut config.rust_debuginfo_only_std, rust.debuginfo_only_std);
346             set(&mut config.rust_optimize, rust.optimize);
347             set(&mut config.rust_optimize_tests, rust.optimize_tests);
348             set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests);
349             set(&mut config.codegen_tests, rust.codegen_tests);
350             set(&mut config.rust_rpath, rust.rpath);
351             set(&mut config.debug_jemalloc, rust.debug_jemalloc);
352             set(&mut config.use_jemalloc, rust.use_jemalloc);
353             set(&mut config.backtrace, rust.backtrace);
354             set(&mut config.channel, rust.channel.clone());
355             config.rustc_default_linker = rust.default_linker.clone();
356             config.rustc_default_ar = rust.default_ar.clone();
357             config.musl_root = rust.musl_root.clone().map(PathBuf::from);
358
359             match rust.codegen_units {
360                 Some(0) => config.rust_codegen_units = num_cpus::get() as u32,
361                 Some(n) => config.rust_codegen_units = n,
362                 None => {}
363             }
364         }
365
366         if let Some(ref t) = toml.target {
367             for (triple, cfg) in t {
368                 let mut target = Target::default();
369
370                 if let Some(ref s) = cfg.llvm_config {
371                     target.llvm_config = Some(env::current_dir().unwrap().join(s));
372                 }
373                 if let Some(ref s) = cfg.jemalloc {
374                     target.jemalloc = Some(env::current_dir().unwrap().join(s));
375                 }
376                 if let Some(ref s) = cfg.android_ndk {
377                     target.ndk = Some(env::current_dir().unwrap().join(s));
378                 }
379                 target.cxx = cfg.cxx.clone().map(PathBuf::from);
380                 target.cc = cfg.cc.clone().map(PathBuf::from);
381                 target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
382                 target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
383
384                 config.target_config.insert(triple.clone(), target);
385             }
386         }
387
388         if let Some(ref t) = toml.dist {
389             config.dist_sign_folder = t.sign_folder.clone().map(PathBuf::from);
390             config.dist_gpg_password_file = t.gpg_password_file.clone().map(PathBuf::from);
391             config.dist_upload_addr = t.upload_addr.clone();
392             set(&mut config.rust_dist_src, t.src_tarball);
393         }
394
395         return config
396     }
397
398     /// "Temporary" routine to parse `config.mk` into this configuration.
399     ///
400     /// While we still have `./configure` this implements the ability to decode
401     /// that configuration into this. This isn't exactly a full-blown makefile
402     /// parser, but hey it gets the job done!
403     pub fn update_with_config_mk(&mut self) {
404         let mut config = String::new();
405         File::open("config.mk").unwrap().read_to_string(&mut config).unwrap();
406         for line in config.lines() {
407             let mut parts = line.splitn(2, ":=").map(|s| s.trim());
408             let key = parts.next().unwrap();
409             let value = match parts.next() {
410                 Some(n) if n.starts_with('\"') => &n[1..n.len() - 1],
411                 Some(n) => n,
412                 None => continue
413             };
414
415             macro_rules! check {
416                 ($(($name:expr, $val:expr),)*) => {
417                     if value == "1" {
418                         $(
419                             if key == concat!("CFG_ENABLE_", $name) {
420                                 $val = true;
421                                 continue
422                             }
423                             if key == concat!("CFG_DISABLE_", $name) {
424                                 $val = false;
425                                 continue
426                             }
427                         )*
428                     }
429                 }
430             }
431
432             check! {
433                 ("MANAGE_SUBMODULES", self.submodules),
434                 ("COMPILER_DOCS", self.compiler_docs),
435                 ("DOCS", self.docs),
436                 ("LLVM_ASSERTIONS", self.llvm_assertions),
437                 ("LLVM_RELEASE_DEBUGINFO", self.llvm_release_debuginfo),
438                 ("OPTIMIZE_LLVM", self.llvm_optimize),
439                 ("LLVM_VERSION_CHECK", self.llvm_version_check),
440                 ("LLVM_STATIC_STDCPP", self.llvm_static_stdcpp),
441                 ("LLVM_LINK_SHARED", self.llvm_link_shared),
442                 ("OPTIMIZE", self.rust_optimize),
443                 ("DEBUG_ASSERTIONS", self.rust_debug_assertions),
444                 ("DEBUGINFO", self.rust_debuginfo),
445                 ("DEBUGINFO_LINES", self.rust_debuginfo_lines),
446                 ("DEBUGINFO_ONLY_STD", self.rust_debuginfo_only_std),
447                 ("JEMALLOC", self.use_jemalloc),
448                 ("DEBUG_JEMALLOC", self.debug_jemalloc),
449                 ("RPATH", self.rust_rpath),
450                 ("OPTIMIZE_TESTS", self.rust_optimize_tests),
451                 ("DEBUGINFO_TESTS", self.rust_debuginfo_tests),
452                 ("QUIET_TESTS", self.quiet_tests),
453                 ("LOCAL_REBUILD", self.local_rebuild),
454                 ("NINJA", self.ninja),
455                 ("CODEGEN_TESTS", self.codegen_tests),
456                 ("LOCKED_DEPS", self.locked_deps),
457                 ("VENDOR", self.vendor),
458                 ("FULL_BOOTSTRAP", self.full_bootstrap),
459                 ("EXTENDED", self.extended),
460                 ("SANITIZERS", self.sanitizers),
461                 ("DIST_SRC", self.rust_dist_src),
462                 ("CARGO_OPENSSL_STATIC", self.openssl_static),
463             }
464
465             match key {
466                 "CFG_BUILD" => self.build = value.to_string(),
467                 "CFG_HOST" => {
468                     self.host = value.split(" ").map(|s| s.to_string())
469                                      .collect();
470                 }
471                 "CFG_TARGET" => {
472                     self.target = value.split(" ").map(|s| s.to_string())
473                                        .collect();
474                 }
475                 "CFG_MUSL_ROOT" if value.len() > 0 => {
476                     self.musl_root = Some(parse_configure_path(value));
477                 }
478                 "CFG_MUSL_ROOT_X86_64" if value.len() > 0 => {
479                     let target = "x86_64-unknown-linux-musl".to_string();
480                     let target = self.target_config.entry(target)
481                                      .or_insert(Target::default());
482                     target.musl_root = Some(parse_configure_path(value));
483                 }
484                 "CFG_MUSL_ROOT_I686" if value.len() > 0 => {
485                     let target = "i686-unknown-linux-musl".to_string();
486                     let target = self.target_config.entry(target)
487                                      .or_insert(Target::default());
488                     target.musl_root = Some(parse_configure_path(value));
489                 }
490                 "CFG_MUSL_ROOT_ARM" if value.len() > 0 => {
491                     let target = "arm-unknown-linux-musleabi".to_string();
492                     let target = self.target_config.entry(target)
493                                      .or_insert(Target::default());
494                     target.musl_root = Some(parse_configure_path(value));
495                 }
496                 "CFG_MUSL_ROOT_ARMHF" if value.len() > 0 => {
497                     let target = "arm-unknown-linux-musleabihf".to_string();
498                     let target = self.target_config.entry(target)
499                                      .or_insert(Target::default());
500                     target.musl_root = Some(parse_configure_path(value));
501                 }
502                 "CFG_MUSL_ROOT_ARMV7" if value.len() > 0 => {
503                     let target = "armv7-unknown-linux-musleabihf".to_string();
504                     let target = self.target_config.entry(target)
505                                      .or_insert(Target::default());
506                     target.musl_root = Some(parse_configure_path(value));
507                 }
508                 "CFG_DEFAULT_AR" if value.len() > 0 => {
509                     self.rustc_default_ar = Some(value.to_string());
510                 }
511                 "CFG_DEFAULT_LINKER" if value.len() > 0 => {
512                     self.rustc_default_linker = Some(value.to_string());
513                 }
514                 "CFG_GDB" if value.len() > 0 => {
515                     self.gdb = Some(parse_configure_path(value));
516                 }
517                 "CFG_RELEASE_CHANNEL" => {
518                     self.channel = value.to_string();
519                 }
520                 "CFG_PREFIX" => {
521                     self.prefix = Some(PathBuf::from(value));
522                 }
523                 "CFG_DOCDIR" => {
524                     self.docdir = Some(PathBuf::from(value));
525                 }
526                 "CFG_LIBDIR" => {
527                     self.libdir = Some(PathBuf::from(value));
528                 }
529                 "CFG_LIBDIR_RELATIVE" => {
530                     self.libdir_relative = Some(PathBuf::from(value));
531                 }
532                 "CFG_MANDIR" => {
533                     self.mandir = Some(PathBuf::from(value));
534                 }
535                 "CFG_LLVM_ROOT" if value.len() > 0 => {
536                     let target = self.target_config.entry(self.build.clone())
537                                      .or_insert(Target::default());
538                     let root = parse_configure_path(value);
539                     target.llvm_config = Some(push_exe_path(root, &["bin", "llvm-config"]));
540                 }
541                 "CFG_JEMALLOC_ROOT" if value.len() > 0 => {
542                     let target = self.target_config.entry(self.build.clone())
543                                      .or_insert(Target::default());
544                     target.jemalloc = Some(parse_configure_path(value).join("libjemalloc_pic.a"));
545                 }
546                 "CFG_ARM_LINUX_ANDROIDEABI_NDK" if value.len() > 0 => {
547                     let target = "arm-linux-androideabi".to_string();
548                     let target = self.target_config.entry(target)
549                                      .or_insert(Target::default());
550                     target.ndk = Some(parse_configure_path(value));
551                 }
552                 "CFG_ARMV7_LINUX_ANDROIDEABI_NDK" if value.len() > 0 => {
553                     let target = "armv7-linux-androideabi".to_string();
554                     let target = self.target_config.entry(target)
555                                      .or_insert(Target::default());
556                     target.ndk = Some(parse_configure_path(value));
557                 }
558                 "CFG_I686_LINUX_ANDROID_NDK" if value.len() > 0 => {
559                     let target = "i686-linux-android".to_string();
560                     let target = self.target_config.entry(target)
561                                      .or_insert(Target::default());
562                     target.ndk = Some(parse_configure_path(value));
563                 }
564                 "CFG_AARCH64_LINUX_ANDROID_NDK" if value.len() > 0 => {
565                     let target = "aarch64-linux-android".to_string();
566                     let target = self.target_config.entry(target)
567                                      .or_insert(Target::default());
568                     target.ndk = Some(parse_configure_path(value));
569                 }
570                 "CFG_LOCAL_RUST_ROOT" if value.len() > 0 => {
571                     let path = parse_configure_path(value);
572                     self.rustc = Some(push_exe_path(path.clone(), &["bin", "rustc"]));
573                     self.cargo = Some(push_exe_path(path, &["bin", "cargo"]));
574                 }
575                 "CFG_PYTHON" if value.len() > 0 => {
576                     let path = parse_configure_path(value);
577                     self.python = Some(path);
578                 }
579                 "CFG_ENABLE_CCACHE" if value == "1" => {
580                     self.ccache = Some("ccache".to_string());
581                 }
582                 "CFG_ENABLE_SCCACHE" if value == "1" => {
583                     self.ccache = Some("sccache".to_string());
584                 }
585                 "CFG_CONFIGURE_ARGS" if value.len() > 0 => {
586                     self.configure_args = value.split_whitespace()
587                                                .map(|s| s.to_string())
588                                                .collect();
589                 }
590                 "CFG_QEMU_ARMHF_ROOTFS" if value.len() > 0 => {
591                     let target = "arm-unknown-linux-gnueabihf".to_string();
592                     let target = self.target_config.entry(target)
593                                      .or_insert(Target::default());
594                     target.qemu_rootfs = Some(parse_configure_path(value));
595                 }
596                 _ => {}
597             }
598         }
599     }
600
601     pub fn verbose(&self) -> bool {
602         self.verbose > 0
603     }
604
605     pub fn very_verbose(&self) -> bool {
606         self.verbose > 1
607     }
608 }
609
610 #[cfg(not(windows))]
611 fn parse_configure_path(path: &str) -> PathBuf {
612     path.into()
613 }
614
615 #[cfg(windows)]
616 fn parse_configure_path(path: &str) -> PathBuf {
617     // on windows, configure produces unix style paths e.g. /c/some/path but we
618     // only want real windows paths
619
620     use std::process::Command;
621     use build_helper;
622
623     // '/' is invalid in windows paths, so we can detect unix paths by the presence of it
624     if !path.contains('/') {
625         return path.into();
626     }
627
628     let win_path = build_helper::output(Command::new("cygpath").arg("-w").arg(path));
629     let win_path = win_path.trim();
630
631     win_path.into()
632 }
633
634 fn set<T>(field: &mut T, val: Option<T>) {
635     if let Some(v) = val {
636         *field = v;
637     }
638 }