Skip to content

Temp/generate npdm#69

Open
Rothschilds12 wants to merge 51 commits intomainfrom
temp/generate_npdm
Open

Temp/generate npdm#69
Rothschilds12 wants to merge 51 commits intomainfrom
temp/generate_npdm

Conversation

@Rothschilds12
Copy link
Collaborator

No description provided.

lwbuchanan and others added 30 commits October 7, 2025 22:38
* Temporary build script for library

* Syscalls now can be done in rust with the script too, requires exporting from lib though (I think).

* Futex ops in progress

* Use std::atomic and libnx SVCs

* Move typedefs and structs to .h

* Import SVCs from libnx

* Respond to PR comments

* Re-add .vscode to .gitignore

* Add license and respond to remaining PR comments

* Move include to .cpp from .h

---------

Co-authored-by: Michael Chalupiak <mikec@mchalupiak.com>
* Added code for malloc
* Added code for abort
@lwbuchanan lwbuchanan changed the base branch from main to temp/min_build_tool January 21, 2026 17:06
Base automatically changed from temp/min_build_tool to main January 27, 2026 02:02
Copy link
Collaborator

@lwbuchanan lwbuchanan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure you also reenable the compialation stuff and test it with everything working together. We have the example mod getting built now so try it with that. Check with Andrew if have trouble building the example mod. You will probobly need to use the latest version of the build tool from main.

// }
my_compdb.save();

let template_str = include_str!("npdm_template.json");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probobly be stored in the library, not in the sources. I'd put it with link.ld and grab the path through the btartifacts struct (maybe merge/rebase from main so you have the latest changes).

my_compdb.save();

let template_str = include_str!("npdm_template.json");
let npdm: Value = serde_json::from_str(template_str)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to use the cu json implementation, see the compdb.cache implementation in compile.rs for an example

cu::fs::make_dir(module_dir)
.expect("failed to create module output directory");

let npdm_path = module_dir.join("npdm.json");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also get this path from the BTArtifacts struct.


let npdm_path = module_dir.join("npdm.json");

cu::fs::write(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't actually populate the json file with the data you need. You will need to set the titleid and run the npdmtool command.

Heres a snippet from the old build tool. Maybe give that a look

fn create_npdm(
    target: PathBuf,
    npdmtool: PathBuf,
    title_id: String,
    m_time: FileTime,
) -> ResultIn<(), NpdmContext> {
    verboseln!("creating main.npdm");

    let mut npdm_data: Value = serde_json::from_str(include_str!("template/main.npdm.json"))?;
    npdm_data["title_id"] = json!(format!("0x{}", title_id));
    let npdm_data = serde_json::to_string_pretty(&npdm_data)?;
    let npdm_json = target.join("main.npdm.json");
    system::write_file(&npdm_json, &npdm_data)?;
    system::set_mtime(&npdm_json, m_time)?;
    let main_npdm = target.join("main.npdm");
    // not piping output because it always displays some warning/error
    Command::new(npdmtool)
        .args(args![&npdm_json, &main_npdm])
        .silent()
        .spawn()?
        .wait()?
        .check()?;

    infoln!("Created", "main.npdm");
    Ok(())
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

Comments