explore paths ahead

cppinclude (cppi)

Labs

Source

license: MIT
README, browse source
snapshot: tar.gz, zip
git clone git://git.dvide.com/pub/cppinclude

Description

A small tool using the Ragel state machine compiler to scan C and C-like include files - anything with:


  #include "myfile"
  #include <mysysfile>

It is intentionally very stupid and ignore preprocessor flags. This is useful for dynamically generated content, and for copying in header files to a build directory, as some build tools do with source files and their dependencies.

Compiler tools like Ragel, flex, etc. tend to include .h files in the generated .c file. We can apply this to such files as well and thereby get the .h copied to a build directory by a build tool, even though the .c does not yet exits.

cppinclude is a general purpose tool but was created for ocamlbuild-ctools which apply it recursively to find both direct and indirect dependencies, and which filters the output against the source tree root so system files do not become dependencies.

To use it, you just need to run a C compiler like


$ gcc cppinclude.c -o cppi
./cppi myfile -o myfile.depends

Or the equivalent on non gcc platforms.

You only need Ragel if want to modify the code. Be aware the Ragel tend to change syntax between versions, so pay attention to the README to get the correct Ragel version.

You might want to modify the code slightly it to make Make depends compatible. The current output is made for ease of use with ocamlbuild-ctools.