[Scons-users] scons checking targets actually built?
Evan Driscoll
driscoll at cs.wisc.edu
Fri Apr 19 11:29:46 EDT 2013
On 04/19/2013 09:13 AM, robert zeigler wrote:
> Perhaps it could be something configured on a per-environment basis?
> I'm willing to do the work and submit the patch, but would appreciate
> some guidance. I'm still really just getting my feet wet with scons.
If you're actually thinking about doing this, I have a
brainstorming-type suggestion. It's brainstorming, so I'm not sure I
like it, but I thought I'd throw it out there.
When creating a rule that SHOULD not produce an output file, you really
ought to be doing something like
test_runner = env.Command('check', ['run_tests'], 'run_tests')
env.AlwaysBuild(test_runner)
(I don't want to quibble over how the name 'run_tests' is generated or
if it needs to be explicitly in the sources list (it may not, I dunno
without testing), etc. The point is that there's the AlwaysBuild line
present.)
In Make, you'd want something like
check: run_tests
./run_tests
.PHONY: check
where you really ought to have the .PHONY line to mark it as a pseudo
target. (Disclaimer: I'm not sure this is AS important in SCons as it is
in Make because of SCons's MD5 decider, but it still seems like a good
idea.)
One potential thing you could do instead of adding a configuration
option is, as a heuristic, use the presence of the AlwaysBuild() call.
In other words:
- If SCons is trying to build a target that's been marked AlwaysBuild
and no file is produced, do nothing
- If SCons is trying to build a target that has NOT been marked
AlwaysBuild and no file is produced, output a warning.
In other words, I'm using the AlwaysBuild function (which should be
there anyway IMO) as your configuration option.
By making the diagnostic in the second case into a warning, it won't
actually *break* existing builds. But you could also make it an error,
or switchable by the command line option.
Evan
More information about the Scons-users
mailing list