Question

My C-gcc project structure is:

\Project\wscript (only one in project)
\Project\build\
\Project\Source\Module_1\foo.c
\Project\Source\Module_1\foo.h
\Project\Source\Module_1\dummy\foo2.h
\Project\Source\Module_n\bar.c
\Project\Source\Module_n\any dept...\bar.h

How can I recursively find all *.C files in 'Source' and add to

bld.program(source=HERE)?

instead of manually listing it:

bld.program(source="foo.c bar.c...", includes='..\\Source ..\\Source\Module_1')

Also how can I find every subfolders (preferably which has *.h) and append to include path?

Should I write my own finder functions in python and just pass it?

bld.program(source=SRCs_FOUND, includes=Paths_FOUND)

Will this cause any dependency problems in building?

In any modern IDE this thinking is common, drag one file to the Source tree, and it's automatically added to the build list. Thanks!

Was it helpful?

Solution

You can use globbing to scan the directories.

bld.program(
    name = ...
    ....
    source = bld.path.ant_glob('**/Source/*.C')
)

Just search for ant_glob in the waf book.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top