Skip to content

Conversation

branc116
Copy link

@branc116 branc116 commented Sep 6, 2025

So I've implemented caching system that uses ptrace to automatically find out which are input/output files.

Example on how to use it.

#define NOB_IMPLEMENTATION
#include "nob.h"

int main(void)
{
    Nob_Cmd cmd = { 0 };
    Nob_Ptrace_Cache cache = { .file_path = "nob.cache" };

    nob_cmd_append(&cmd, "cc", "-o", "main", "main.c");
    nob_cmd_run(&cmd, .ptrace_cache = &cache);

    nob_ptrace_cache_finish(cache);
    nob_cmd_free(cmd);
}

First time you run it, it will generate nob.cache file.

When you run nob again it will read and parse nob.cache file and will only run the command if the main.c (or anything included by main.c) was modified (nob_needs_rebuild).

Motivation:
You have for example N png files.
You have a tool to generate atlas from png files.
You don't want to build the tool every time.
And you don't want to run the tool every time.
But you don't want to manually specify which .png will be used by the tool.

This is related to this PR Strace Cache only in this I'm using ptrace insted of strace and I've done some todos

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.

1 participant