From 3f112856e5d3f71ee810eae0a1a2ef1158521f69 Mon Sep 17 00:00:00 2001 From: NinjaCheetah <58050615+NinjaCheetah@users.noreply.github.com> Date: Tue, 10 Mar 2026 16:38:31 -0400 Subject: [PATCH] cIOS building stub, continuing on desktop --- src/bin/rustwii/main.rs | 65 ++++++++---------- .../rustwii/title/{iospatcher.rs => ios.rs} | 66 ++++++++++++++++++- src/bin/rustwii/title/mod.rs | 2 +- 3 files changed, 93 insertions(+), 40 deletions(-) rename src/bin/rustwii/title/{iospatcher.rs => ios.rs} (73%) diff --git a/src/bin/rustwii/main.rs b/src/bin/rustwii/main.rs index 0177875..68476e8 100644 --- a/src/bin/rustwii/main.rs +++ b/src/bin/rustwii/main.rs @@ -45,24 +45,10 @@ enum Commands { /// The path to a TMD, Ticket, or WAD input: String, }, - /// Apply patches to an IOS - IosPatch { - /// The IOS WAD to apply patches to - input: String, - #[arg(short, long)] - /// An optional output path; default to overwriting input file if not provided - output: Option, - /// Set a new IOS version (0-65535) - #[arg(short, long)] - version: Option, - /// Set the slot that this IOS will install into - #[arg(short, long)] - slot: Option, - /// Set all patched content to be non-shared - #[arg(short, long, action)] - no_shared: bool, - #[command(flatten)] - enabled_patches: title::iospatcher::EnabledPatches, + /// Modify an IOS + Ios { + #[command(subcommand)] + command: title::ios::Commands }, /// Compress/decompress data using LZ77 compression Lz77 { @@ -137,24 +123,31 @@ fn main() -> Result<()> { Some(Commands::Info { input }) => { info::info(input)? }, - Some(Commands::IosPatch { - input, - output, - version, - slot, - no_shared, - enabled_patches - } - ) => { - title::iospatcher::patch_ios( - input, - output, - version, - slot, - no_shared, - enabled_patches, - )? - } + Some(Commands::Ios { command }) => { + match command { + title::ios::Commands::Cios { + base, + map, + output, + cios_version, + modules, + slot, + version + } => { + title::ios::build_cios(base, map, output, cios_version, modules, slot, version)? + }, + title::ios::Commands::Patch { + input, + output, + version, + slot, + no_shared, + enabled_patches + } => { + title::ios::patch_ios(input, output, version, slot, no_shared, enabled_patches)? + } + } + }, Some(Commands::Lz77 { command }) => { match command { archive::lz77::Commands::Compress { input, output } => { diff --git a/src/bin/rustwii/title/iospatcher.rs b/src/bin/rustwii/title/ios.rs similarity index 73% rename from src/bin/rustwii/title/iospatcher.rs rename to src/bin/rustwii/title/ios.rs index 9bc4008..8ef2d3f 100644 --- a/src/bin/rustwii/title/iospatcher.rs +++ b/src/bin/rustwii/title/ios.rs @@ -1,16 +1,62 @@ -// title/iospatcher.rs from ruswtii (c) 2025 NinjaCheetah & Contributors +// title/ios.rs from ruswtii (c) 2025 NinjaCheetah & Contributors // https://github.com/NinjaCheetah/rustwii // -// Code for the iospatcher command in the rustwii CLI. +// Code for the IOS patcher and cIOS build commands in the rustwii CLI. use std::fs; use std::path::{Path, PathBuf}; use anyhow::{bail, Context, Result}; -use clap::Args; +use clap::{Args, Subcommand}; use rustwii::title; use rustwii::title::iospatcher; use rustwii::title::tmd::ContentType; +#[derive(Subcommand)] +#[command(arg_required_else_help = true)] +pub enum Commands { + /// Build a cIOS from a provided base IOS and map + Cios { + /// The base IOS WAD + base: String, + /// The cIOS map file + map: String, + /// Path for the finished cIOS WAD + output: String, + /// The cIOS version from the map to build + #[arg(short, long)] + cios_version: Option, + /// Path to the directory containing the cIOS modules (optional, defaults to the current + /// directory) + #[arg(short, long)] + modules: Option, + /// Slot that the cIOS will install to (optional, defaults to 249) + #[arg(short, long)] + slot: Option, + /// IOS version the cIOS will have (optional, defaults to 65535) + #[arg(short, long)] + version: Option + }, + /// Apply patches to an IOS + Patch { + /// The IOS WAD to apply patches to + input: String, + /// An optional output path; default to overwriting input file if not provided + #[arg(short, long)] + output: Option, + /// Set a new IOS version (0-65535) + #[arg(short, long)] + version: Option, + /// Set the slot that this IOS will install into + #[arg(short, long)] + slot: Option, + /// Set all patched content to be non-shared + #[arg(short, long, action)] + no_shared: bool, + #[command(flatten)] + enabled_patches: EnabledPatches, + } +} + #[derive(Args)] #[clap(next_help_heading = "Patches")] #[group(multiple = true, required = true)] @@ -148,3 +194,17 @@ fn set_type_normal(ios: &mut title::Title, index: usize) -> Result<()> { Ok(()) } + +pub fn build_cios( + base: &str, + map: &str, + output: &str, + cios_version: &Option, + modules: &Option, + slot: &Option, + version: &Option +) -> Result<()> { + todo!(); + + Ok(()) +} diff --git a/src/bin/rustwii/title/mod.rs b/src/bin/rustwii/title/mod.rs index de18bd0..81aaaef 100644 --- a/src/bin/rustwii/title/mod.rs +++ b/src/bin/rustwii/title/mod.rs @@ -6,4 +6,4 @@ pub mod nus; pub mod wad; pub mod tmd; mod shared; -pub mod iospatcher; +pub mod ios;