Browse Source

Merge pull request #202 from opilar/feature/include-define-flag-docs

Include/define/flag docs
cmd
Alex Crichton 8 years ago
committed by GitHub
parent
commit
a95d61a790
  1. 33
      src/lib.rs

33
src/lib.rs

@ -208,12 +208,36 @@ impl Config {
} }
/// Add a directory to the `-I` or include path for headers /// Add a directory to the `-I` or include path for headers
///
/// # Example
///
/// ```no_run
/// use std::path::Path;
///
/// let library_path = Path::new("/path/to/library");
///
/// gcc::Config::new()
/// .file("src/foo.c")
/// .include(library_path)
/// .include("src")
/// .compile("libfoo.a");
/// ```
pub fn include<P: AsRef<Path>>(&mut self, dir: P) -> &mut Config { pub fn include<P: AsRef<Path>>(&mut self, dir: P) -> &mut Config {
self.include_directories.push(dir.as_ref().to_path_buf()); self.include_directories.push(dir.as_ref().to_path_buf());
self self
} }
/// Specify a `-D` variable with an optional value. /// Specify a `-D` variable with an optional value.
///
/// # Example
///
/// ```no_run
/// gcc::Config::new()
/// .file("src/foo.c")
/// .define("FOO", Some("BAR"))
/// .define("BAZ", None)
/// .compile("libfoo.a");
/// ```
pub fn define(&mut self, var: &str, val: Option<&str>) -> &mut Config { pub fn define(&mut self, var: &str, val: Option<&str>) -> &mut Config {
self.definitions.push((var.to_string(), val.map(|s| s.to_string()))); self.definitions.push((var.to_string(), val.map(|s| s.to_string())));
self self
@ -226,6 +250,15 @@ impl Config {
} }
/// Add an arbitrary flag to the invocation of the compiler /// Add an arbitrary flag to the invocation of the compiler
///
/// # Example
///
/// ```no_run
/// gcc::Config::new()
/// .file("src/foo.c")
/// .flag("-ffunction-sections")
/// .compile("libfoo.a");
/// ```
pub fn flag(&mut self, flag: &str) -> &mut Config { pub fn flag(&mut self, flag: &str) -> &mut Config {
self.flags.push(flag.to_string()); self.flags.push(flag.to_string());
self self

Loading…
Cancel
Save