#[non_exhaustive]pub struct EmbedOptions {
pub out_dir: Option<PathBuf>,
pub emit_cargo_link_arg: bool,
}Expand description
Options controlling how embed_package_metadata writes artifacts and
whether it emits cargo link-arg directives.
EmbedOptions::default() preserves the original zero-config behavior:
write to $OUT_DIR and emit cargo:rustc-link-arg=-T<linker_script.ld>.
Override when the crate is a static library whose final link happens later
in the outer build system.
§Non-exhaustive
This struct is #[non_exhaustive] so new options can land without a
SemVer break. Use ..Default::default() when constructing.
§Example
// Static-library flow: write the linker script to a directory the outer
// build system knows about, so it can pass the script to the final linker.
// In practice `out_dir` comes from an env var the outer build sets, or a
// subdirectory of `OUT_DIR`; here we use `env::temp_dir()` as a portable
// placeholder. `EmbedOptions` is `#[non_exhaustive]`, so construct via
// `Default` and assign fields rather than using struct-literal syntax.
let mut opts = EmbedOptions::default();
opts.out_dir = Some(std::env::temp_dir().join("module_info_linker"));
opts.emit_cargo_link_arg = false;Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.out_dir: Option<PathBuf>Directory where linker_script.ld, note.package.bin, and
module_info.json are written. When None, the OUT_DIR environment
variable is used (the normal cargo build-script case).
emit_cargo_link_arg: boolWhen true, emit cargo:rustc-link-arg=-T<path-to-linker_script.ld>
on stdout so cargo passes the script to the final link step.
Set to false when the current crate is a static library whose final
link happens later in the outer build system. Have that system pass
the linker script to its own linker.
Trait Implementations§
Source§impl Clone for EmbedOptions
impl Clone for EmbedOptions
Source§fn clone(&self) -> EmbedOptions
fn clone(&self) -> EmbedOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more