[Scons-users] Dependency between generated source files and their VariantDir counterpart

ZEISSLOFF Thibaut thibaut.zeissloff at hagergroup.com
Thu Mar 12 12:33:39 EDT 2020


I am struggling to find the proper way to make SCons aware of my dependency tree.

I would like (and already did) users to be able to write something like :

cots_sources = env.UseCots(‘math_library at 1.1.0’, install_path=’cots/’)

and then build their program using the regular Object, Library, Program builders.

Behind this « CotsBuilder » hides the logic of retrieving package metadata from a package manager (in emitter) so that SCons knows about sources and headers that will be gathered. This Builder action being to actually download the package and extract it in given install path.

This works like a charm until I use VariantDir :

Basically, retrieved sources lie in : cots/math_library/*.c
While regular sources lie in : src/*.c

When using VariantDir(‘build/’, ‘.’, duplicate=1’), only regular sources are duplicated and I end up with a
scons: *** [build/cots/math_library/math.o] Source `build/cots/math_library/math.c ' not found, needed by target `build/cots/math_library/math.o’

After some research, I understood that the problem is that these cots/ are “targets” for SCons and therefore expected to be produced in variant dir.

If I manually fill the dependency gap by setting :
env.Depends(‘build/cots/math_library/math.c’, ‘cots/math_library/math.c’)
it works as expected.

Now, my point, how can I inform SCons during the emission stage of my Builder that its targets shall be considered as sources, or that they should not be expected in variant dir ? I cannot do this Depends call in emitter because VariantDir method may not have been called yet and I can not make assumptions about variant dir.

I found a very dirty way to do that, “hooking” the VariantDir call but I would prefer a SCons-way of doing so.

Can somebody help ?

Thanks, Thibaut

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20200312/5a619f81/attachment.html>

More information about the Scons-users mailing list