lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



Hamster is a Lua build system, which does dependency checking automatically.

However, it simply looks for any #include's and naively thinks they all affect the source. Are you sure this wouldn't be enough for you as well?

Maybe just run the files through cpp, then look for the #includes that remained?


James Dennett kirjoitti 14.3.2008 kello 23:57:

On Fri, Mar 14, 2008 at 2:48 PM, Eric Tetz <erictetz@gmail.com> wrote:
I'm writing a tool which needs (as one stage) to resolve the header
dependencies of C source modules. Currently we are using Opus Make
MKMF.EXE to parse the sources and generates dependency lists. I would
*like* to roll this part of the process into the main tool, which is
written in Lua.

Has anyone written something like this, or know of a module (in Lua,
usable by Lua, translatable into Lua) which does this? It doesn't need
to be a full blown preprocessor, but it needs to handle lines
continuation, comments, etc. and be able to resolve preprocessor
conditionals properly.

That covers most of the preprocessor: conditionals need macro
expansion and expression evaluation, and those require tokenization,
comment handling, etc.

Boost has a preprocessor implementation in library form if you don't
mind it being in C++ and having significant dependencies.  I have one
too, though it's not been tested except by me; it's also in C++.  Both
are fairly modular/flexible.

Writing such a thing in Lua would take, I'd expect, thousands rather
than hundreds of lines of code.  Performance may or may not be an
issue, but I'd think it easier to pick up an implementation off the
shelf and wrap it in Lua.

-- James