From 2dc5dfe8f033de4917c30edad629d456c2ec6a0d Mon Sep 17 00:00:00 2001 From: "ma.rybakov" Date: Thu, 13 Jul 2017 19:18:28 +0300 Subject: [PATCH 1/2] Include/define/flag docs --- src/lib.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 02ee1da..5f8b1fc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -207,12 +207,34 @@ impl Config { } /// Add a directory to the `-I` or include path for headers + /// + /// # Example + /// + /// ```no_run + /// 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>(&mut self, dir: P) -> &mut Config { self.include_directories.push(dir.as_ref().to_path_buf()); self } /// 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 { self.definitions.push((var.to_string(), val.map(|s| s.to_string()))); self @@ -225,6 +247,15 @@ impl Config { } /// 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 { self.flags.push(flag.to_string()); self From 320a033e18bee4b979e11556f502067d77a890a5 Mon Sep 17 00:00:00 2001 From: opilarium Date: Thu, 13 Jul 2017 23:10:19 +0300 Subject: [PATCH 2/2] Tests compilation --- src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 5f8b1fc..140aa64 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -211,6 +211,8 @@ impl Config { /// # Example /// /// ```no_run + /// use std::path::Path; + /// /// let library_path = Path::new("/path/to/library"); /// /// gcc::Config::new() @@ -249,8 +251,8 @@ impl Config { /// Add an arbitrary flag to the invocation of the compiler /// /// # Example - /// ```no_run /// + /// ```no_run /// gcc::Config::new() /// .file("src/foo.c") /// .flag("-ffunction-sections")