Nim icon indicating copy to clipboard operation
Nim copied to clipboard

Allow specifying dependencies in `.compile.` to make rebuild logic correct

Open arnetheduck opened this issue 7 months ago • 2 comments

Summary

When compiling a c file, it might have dependencies (its #include files) which nim doesn't know about - when such dependencies are changed, the C file needs recompilation which currently does not happen.

Description

This could be resolved by adding a parameter to .compile("myfile.c", flags = "...", dependencies = [myfile1.h, ...]). - alternatively, a smarter version would discover such dependencies automatically (using gcc -MD and similar flags, parsing the output)

Alternatives

No response

Examples

No response

Backwards Compatibility

No response

Links

No response

arnetheduck avatar May 15 '25 06:05 arnetheduck

Fwiw, it was always supposed to be used as "if .c file deps changed, invoke with the -f switch".

Araq avatar May 15 '25 06:05 Araq

-f is a blunt tool - ie projects might have hundreds of c files to compile (like ours do) so recompiling all of them is messy - it's also inconvenient when using any sort of tooling (like a code editor) where adding a flag to a one-off compilation requires extra manual steps.

The aim is to have nim c "just work" without having to teach magic flags like -f which are only used in exceptional cases.

arnetheduck avatar May 15 '25 06:05 arnetheduck