[Scons-users] Custom builder with conditional actions
Dirk Bächle
tshortik at gmx.de
Tue May 19 13:58:34 EDT 2015
Hi Jeremy,
On 19.05.2015 17:03, jeremy combs wrote:
> I am trying to create a builder that performs actions similar to how the Linux kernel does symbol versioning.
> See ( https://github.com/torvalds/linux/blob/c0a80c0c27e5e65b180a25e6c4c2f7ef9e386cd3/scripts/Makefile.build#L200 )
>
> As a first step I am trying to duplicate the linux kernel's steps as close as I can:
>
> 1. Build .o file from .c file
> 2. if .o file contains special section
> 2.true.1. Run: gcc -E [.c file] | [analaysis program] > [.o.ver file]
> 2.true.1 Run: ld -T [.o.ver file] -o [other.o file]
> 2.true.1 Run: mv [other.o file] [.o file]
> 2.false.1 Copy [.o file] [other.o file]
>
> [...]
>
> So after all that I guess my question is: What is the recommended way to do something like this where actions are dependent on
> source file contents?
>
the way I see it, it's not your source files that drive the further processing but the .o files as your targets. That's why the
classical approaches like an "action generator" won't work for you, you'd have to know the name of the resulting .o file beforehand.
Since SCons relies on proper dependency information (as derived in the Emitter/Scanner) you're basically stuck: you can't get at the
required information without actually building the .o file. This is the same problem as with Java files, you have to compile them
first, to know which .class files get created additionally by anonymous/inner classes. But then it's too late to add this info to
the dependency graph...files that would otherwise implicitly depend on these "new" nodes might already be marked as "up-to-date" and
won't get rebuilt.
Finally, overwriting your .o file "in place" ("mv [other.o file] [.o file]") is a bad idea in general.
Just my 2 cents.
Best regards,
Dirk
More information about the Scons-users
mailing list