[−][src]Struct gobuild::Build
A builder for compilation of a native golang project.
A Build
is the main type of the gobuild
crate and is used to control all the
various configuration options and such of a compile. You'll find more
documentation on each method itself.
Methods
impl Build
[src]
pub fn new() -> Self
[src]
Construct a new instance of a blank set of configuration.
This builder is finished with the compile
function.
pub fn file<P: AsRef<Path>>(&mut self, p: P) -> &mut Build
[src]
Add a file which will be compiled
pub fn files<P>(&mut self, p: P) -> &mut Build where
P: IntoIterator,
P::Item: AsRef<Path>,
[src]
P: IntoIterator,
P::Item: AsRef<Path>,
Add files which will be compiled
pub fn env<K, V>(&mut self, key: K, val: V) -> &mut Build where
K: AsRef<OsStr>,
V: AsRef<OsStr>,
[src]
K: AsRef<OsStr>,
V: AsRef<OsStr>,
Inserts or updates an environment variable mapping.
pub fn out_dir<P: AsRef<Path>>(&mut self, out_dir: P) -> &mut Build
[src]
Configures the output directory where all object files and libraries will be located.
This option is automatically scraped from the OUT_DIR
environment
variable by build scripts, so it's not required to call this function.
pub fn buildmode(&mut self, buildmode: BuildMode) -> &mut Build
[src]
Configures the build mode. See `go help buildmode for more details.
Build mode c-archive
is used by default.
pub fn compiler<P: AsRef<Path>>(&mut self, compiler: P) -> &mut Build
[src]
Configures the compiler to be used to produce output.
This option is automatically determined from the target platform or a number of environment variables, so it's not required to call this function.
Default: go
pub fn goarch<T: AsRef<OsStr>>(&mut self, arch: T) -> &mut Build
[src]
Sets the GOARCH
.
This option is automatically scraped from the CARGO_CFG_*
environment
variables by build scripts, so it's not required to call this function.
pub fn goos<T: AsRef<OsStr>>(&mut self, os: T) -> &mut Build
[src]
Sets the GOOS
.
This option is automatically scraped from the CARGO_CFG_*
environment
variables by build scripts, so it's not required to call this function.
pub fn cargo_metadata(&mut self, cargo_metadata: bool) -> &mut Build
[src]
Define whether metadata should be emitted for cargo allowing it to
automatically link the binary. Defaults to true
.
The emitted metadata is:
rustc-link-lib=static=
compiled librustc-link-search=native=
target folder
pub fn try_compile(&self, lib_name: &str) -> Result<(), Error>
[src]
Run the compiler, generating the file output
This will return a result instead of panicing; see compile() for the complete description.
pub fn compile(&self, output: &str)
[src]
Run the compiler, generating the file output
The name output
should be the name of the library. The Rust compilier will create
the assembly with the lib prefix and .a extension.
Panics
Panics if output
is not formatted correctly or if one of the underlying
compiler commands fails. It can also panic if it fails reading file names
or creating directories.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Build
impl Send for Build
impl Sync for Build
impl Unpin for Build
impl UnwindSafe for Build
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,