Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Ptrace cache#131

Open
branc116 wants to merge 21 commits intotsoding:main from
branc116:ptrace-cache
Open

Ptrace cache #131
branc116 wants to merge 21 commits intotsoding:main from
branc116:ptrace-cache

Conversation

@branc116
Copy link

@branc116 branc116 commented Sep 6, 2025
edited
Loading

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

mister-choo reacted with thumbs up emoji
branc116 added 21 commits August 28, 2025 19:45
Added more todos.
Add executing program to the list of input files.
Resume inferior faster.
Don't include input files that don't exist.
Include cwd into command cache entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /