[][src]Struct gobuild::Build

pub struct Build { /* fields omitted */ }

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]

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]

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 lib
  • rustc-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

impl Clone for Build[src]

impl Debug for Build[src]

impl Default for Build[src]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.