Hacker News new | past | comments | ask | show | jobs | submit login

Auto-generate script that generates header0.h with #include to header1.h, and header1.h with #include to header2.h, up to N=10.

Of course, we don't know before generating the headers exactly what they'll need to #include. And N is determined solely by the existence of the #include, i.e: generation of header10.h does not #include header11.h and that should stop the build.




you can use most C compilers to autogenerate the dependencies in make format (see http://hastebin.com/kufajaqeso.sh for a sample makefile and script to generate the relevant code -- there's a commented line in header10.h that you should remove to prove to yourself that it indeed does the right thing)


Your solution isn't a solution, because it is not actually a Makefile.

Your shell script and Makefile both need to be run, in the correct order, by a meta build-system.

It won't re-generate just the right files when things change. Unless you always regenerate all the code, and that's gonna be very wasteful.

It won't parallelize things as possible. The code generation can be parallelized with parts of the build that don't depend on it.

It won't rescan just the right files (it will do more work than necessary).

Compare that with a real build system, such as tup or shake, that gets all of these properties right.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: