August Karlstrom
August Karlstrom

Reputation: 11377

Can SCons keep track of linking dependencies?

I'm currently working on a C project with one main executable and one executable for each unit test. In the SConstruct file I specify the dependencies for each executable, something like

env.Program(['Main.c', 'Foo.c', 'Bar.c', 'Baz.c', ...])
env.Program(['FooTest.c', 'Foo.c', 'Baz.c', ...])
env.Program(['BarTest.c', 'Bar.c', 'Baz.c', ...])
...

This, however, is error prone and inelegant since the dependencies could just as well be tracked by the build tool, in this case SCons. How can I improve my build script?

Upvotes: 1

Views: 206

Answers (1)

Tom Tanner
Tom Tanner

Reputation: 9354

What you are asking for is some sort of tool that 1) Looks at the headers you include 2) Determines from the headers which source files need building 3) Rinse and repeat for all the source files you've just added

Once it's done that it'll have to look over the tree it has generated and try and squish some of that into sensible libraries, assuming you haven't done that already (and looking at the tone of both the questions, that exercise seems to have been viewed as academic, rather than a standard part of good software development).

There might be some mileage in a tool that says "You've included header A/B.h, so you'll need libA in your link line" but even that is going to have plenty of gotchas depending on how different people build and link their libraries.

But what you've asked is asking how to define a build script that writes a build script. It's something you should be doing for yourself.

Upvotes: 2

Related Questions