Function libcnb_package::build::build_binary
source · pub fn build_binary(
project_path: impl AsRef<Path>,
cargo_metadata: &Metadata,
cargo_profile: CargoProfile,
cargo_env: Vec<(OsString, OsString)>,
target_triple: impl AsRef<str>,
target_name: impl AsRef<str>
) -> Result<PathBuf, BuildError>Expand description
Builds a binary using Cargo.
It is designed to handle cross-compilation without requiring custom configuration in the Cargo manifest of the user’s buildpack. The triple for the target platform is a mandatory argument of this function.
Depending on the host platform, this function will try to set the required cross compilation settings automatically. Please note that only selected host platforms and targets are supported. For other combinations, compilation might fail, surfacing cross-compile related errors to the user.
In many cases, cross-compilation requires external tools such as compilers and linkers to be
installed on the user’s machine. When a tool is missing, a BuildError::CrossCompileError is
returned which provides additional information. Use the cross_compile::cross_compile_help
function to obtain human-readable instructions on how to setup the required tools.
This function will write Cargo’s output to stdout and stderr.
Errors
Will return Err if the build did not finish successfully.