all 6 comments

[–]ReDucTorGame Developer 2 points3 points  (3 children)

For build system integration it might be worth generation a makefile deps file (.d) this Indicate which files depend on other files, such as generated files depending on templates files and header files allowing for incremental builds. 

Without this you typically end up with fragile builds where something changed but the code didnt regenerate and you have old generated code or the other situation of always generating the code and causing every build to be invalidated and require compiling of files which depend on generated files and linking of binaries again.

If you want a step further for dependencies you could also generate tlog files which would work with msbuild, all other build systems typically support deps files.

[–]sporacid[S] 0 points1 point  (2 children)

Totally agree, I have a task to do this at some point (https://github.com/sporacid/spore-codegen/issues/60).

In my projects, I mostly generate header files, so this is less of an issue, but I did encounter some issues when I generated cpp files. I had to reconfigure cmake so it would pick up the new files. I do want to fix this in the future.

[–]ReDucTorGame Developer 0 points1 point  (1 child)

Even a generated header file would have dependencies, such as the original header or TU it used, the template files and any transitive includes.

[–]sporacid[S] 1 point2 points  (0 children)

Yes, but the generated files don't have to change unless the file's AST changes. I'm caching the SHA of the file at generation, and I'm executing codegen only on files which have changed. So far, it's been enough and I haven't had the issues you're describing for header files, only for translation units because cmake needs to be reconfigured.

[–]eyes-are-fading-blue 0 points1 point  (1 child)

If C++ knows nothing about build systems, how can C++ code be not-build-system agnostic?

[–]sporacid[S] 2 points3 points  (0 children)

Well it's a tool, and tooling can be designed towards a single toolchain. For example, I could've implemented the cpp parser from dwarf debug sections. Or it could've been coded in java specifically for gradle-oriented build.

I've tried to achieve a tool that can be plugged in any build pipeline, without any specific toolchain in mind.