pub struct Builder { /* private fields */ }Expand description
Generates one set of bindings from the IR files of one or more builds.
Create one with Builder::new, add each build’s IR file with
ir, optionally configure it, then call
generate from a build script or
generate_to anywhere else.
§Examples
// build.rs, for two builds of `target.exe`, the first also as a packed
// image that keeps its timestamp but grows the image.
fn main() -> Result<(), imping_build::Error> {
imping_build::Builder::new()
.ir("steam_2021", "ir/target-2021.json")
.ir("steam_2026", "ir/target-2026.json")
.accept_build("steam_2021", "target.exe", 0x64b8f2a1, 0xa3c000)
.generate()
}Implementations§
Source§impl Builder
impl Builder
Sourcepub fn ir(self, label: impl Into<String>, path: impl Into<PathBuf>) -> Self
pub fn ir(self, label: impl Into<String>, path: impl Into<PathBuf>) -> Self
Adds the IR file of the build labelled label, such as steam_2021.
The label names the build in the bindings: a Build::Steam2021 variant
and constants such as RVA_STEAM_2021. Labels are lowercase letters,
digits and single underscores, starting with a letter. In a build
script, a relative path is relative to the crate’s root.
Sourcepub fn module_name(
self,
ir_name: impl Into<String>,
rust_name: impl Into<String>,
) -> Self
pub fn module_name( self, ir_name: impl Into<String>, rust_name: impl Into<String>, ) -> Self
Names the Rust module generated for the IR module ir_name.
See imping_codegen::Generator::module_name for the default name.
Sourcepub fn accept_build(
self,
label: impl Into<String>,
ir_name: impl Into<String>,
timestamp: u32,
image_size: u32,
) -> Self
pub fn accept_build( self, label: impl Into<String>, ir_name: impl Into<String>, timestamp: u32, image_size: u32, ) -> Self
Makes the generated init() of the IR module ir_name also accept, as
the build labelled label, the image with this timestamp and image
size.
See imping_codegen::Generator::accept_build for when that’s sound.
Sourcepub fn out_file(self, name: impl Into<PathBuf>) -> Self
pub fn out_file(self, name: impl Into<PathBuf>) -> Self
Sets the file name generate writes in OUT_DIR,
imped.rs by default.
Use it to keep several sets of bindings apart.
Sourcepub fn generate(&self) -> Result<(), Error>
pub fn generate(&self) -> Result<(), Error>
Generates the bindings into $OUT_DIR/imped.rs, or the name set with
out_file.
For build scripts: also prints cargo:rerun-if-changed for each IR file
and one cargo:warning per Warning.
§Errors
Error::OutDirNotSet outside a build script, otherwise as for
generate_to.
Sourcepub fn generate_to(&self, path: impl AsRef<Path>) -> Result<Vec<Warning>, Error>
pub fn generate_to(&self, path: impl AsRef<Path>) -> Result<Vec<Warning>, Error>
Generates the bindings into the file at path and returns the
warnings, without printing anything.
§Errors
Error::Read, Error::Parse, Error::Generate or
Error::Write, each naming the file involved.