[Scons-users] Marking a node as "Never build" or "Unnecessary"
Jason Pettiss
jpettiss at broadwaytechnology.com
Thu Apr 4 15:41:22 EDT 2013
Is there some way to achieve the opposite of env.AlwaysBuild()? I have a case where I create a node simply to ask the question of "Can I build this thing?". If the answer is yes, I go on and provide the instructions for how to produce it, otherwise I do nothing. That works alright but prevents me for asking for the location of the thing (for example as a dependency), giving me an "Implicit dependency 'node' not found, needed by 'location'." message.
I.e.
node = Dir(env['CustomLibs']).File('Custom.dll')
dll = []
if ShouldBuild(node.abspath):
lib = env.SharedLibrary('Custom', custom_src)
dll = env.Install(Dir(env['CustomLibs']), lib)
env.Alias('build_custom_dll', dll)
env.Alias('build_all_custom_libs', Dir(env['CustomLibs']))
With something like that if I "scons build_custom_dll", either it gets built or it doesn't, according to what ShouldBuild returned. But, if I "scons build_all_custom_libs", I get what I want if ShouldBuild returns true, otherwise I get an error like this:
scons: *** [E:\out\CustomLibs] Implicit dependency `E:\out\CustomLibs\Custom.dll' not found, needed by target `E:\out\CustomLibs'.
scons: building terminated because of errors.
I'm wondering if there's a way to remove the node, or mark it as unnecessary, something like:
env.NeverBuild(node)
(Which I'd do as an else statement to the if above.)
Of course, I can avoid the issue entirely by string munging...
nodestr = Dir(env['CustomLibs']).abspath + 'Custom.dll'
if ShouldBuild(nodestr):
...
But I rather like the reasonable interface of Dir/File (especially with respect to path searching). Also in a large project it's nice just to nodify everything that might be built, just so you're not constantly messing around with strings.
I tried providing dummy instructions to just do nothing, like:
env.Command(node, '', [])
Which does avoid the error, but of course causes anything that depends on that node or its location to always run, even when there are no other changes. (And no, I'd rather not spit out a zero-byte placeholder of the right name.)
I hope that all makes sense, thanks,
--jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://four.pairlist.net/pipermail/scons-users/attachments/20130404/800b594b/attachment.htm>
More information about the Scons-users
mailing list