fn build(args: Args) -> Result<(), BuildError> {
    use self::BuildError::*;

    let mut args = cli::parse_build_args(args)?;

    eprintln!("{:>12} with cargo xbuild", "Building".green().bold());
    let artifact = cargo::run(&args)?;

    // Set default program name
    if args.name.is_empty() {
        args.name = artifact.target.name;
    }
    let args = args;

    eprintln!("{:>12} ELF to binary", "Dumping".green().bold());
    let filename = artifact.executable;
    let (entry_point, program) = elf::dump(&filename)?;

    // XXX: See https://github.com/parasyte/technek/issues/1
    if program.len() > 1024 * 1024 {
        return Err(ProgramTooBigError);
    }

    let path = get_output_filename(&filename)?;
    let fs = args
        .fs
        .as_ref()
        .map(|fs_path| {
            eprintln!(
                "{:>12} file system at `{}` to the ROM image",
                "Appending".green().bold(),
                fs_path,
            );

            fs::create_filesystem(fs_path)
        })
        .transpose()?;

    eprintln!("{:>12} final ROM image", "Building".green().bold());
    create_rom_image(path, &args, entry_point, program, fs)
}
/// The build subcommand. Parses cli args specific to build, executes
/// `cargo xbuild`, and transforms the ELF to a ROM file.
The build subcommand. Parses cli args specific to build, executes
`cargo xbuild`, and transforms the ELF to a ROM file.
The build subcommand . Parses cli args specific to build executes ` cargo xbuild ` and transforms the ELF to a ROM file .
fn build(args: Args) -> Result<(), BuildError> {
    use self::BuildError::*;
    let mut args = cli::parse_build_args(args)?;
    eprintln!("{:>12} with cargo xbuild", "Building".green().bold());
    let artifact = cargo::run(&args)?;
    // Set default program name
    if args.name.is_empty() {
        args.name = artifact.target.name;
    }
    let args = args;
    eprintln!("{:>12} ELF to binary", "Dumping".green().bold());
    let filename = artifact.executable;
    let (entry_point, program) = elf::dump(&filename)?;
    // XXX: See https://github.com/parasyte/technek/issues/1
    if program.len() > 1024 * 1024 {
        return Err(ProgramTooBigError);
    }
    let path = get_output_filename(&filename)?;
    let fs = args
        .fs
        .as_ref()
        .map(|fs_path| {
            eprintln!(
                "{:>12} file system at `{}` to the ROM image",
                "Appending".green().bold(),
                fs_path,
            );
            fs::create_filesystem(fs_path)
        })
        .transpose()?;
    eprintln!("{:>12} final ROM image", "Building".green().bold());
    create_rom_image(path, &args, entry_point, program, fs)
}
fn build ( args : Args ) -> Result < ( ) , BuildError > { use self :: BuildError :: * ; let mut args = cli :: parse_build_args ( args ) ? ; eprintln ! ( " " " " green ( ) bold ( ) ) ; let artifact = cargo :: run ( & args ) ? ; // Set default program name if args . name . is_empty ( ) { args . name = artifact . target . name ; } let args = args ; eprintln ! ( " " " " green ( ) bold ( ) ) ; let filename = artifact . executable ; let ( entry_point , program ) = elf :: dump ( & filename ) ? ; // XXX: See https://github.com/parasyte/technek/issues/1 if program . len ( ) > 1024 * 1024 { return Err ( ProgramTooBigError ) ; } let path = get_output_filename ( & filename ) ? ; let fs = args . fs . as_ref ( ) . map ( | fs_path | { eprintln ! ( " " " " green ( ) bold ( ) fs_path ) ; fs :: create_filesystem ( fs_path ) } ) . transpose ( ) ? ; eprintln ! ( " " " " green ( ) bold ( ) ) ; create_rom_image ( path , & args , entry_point , program , fs ) }
The build subcommand.
The build subcommand .
args
Args
args
Args