scons icon indicating copy to clipboard operation
scons copied to clipboard

Unexpected behaviours when source or target omitted

Open bdbaddog opened this issue 7 years ago • 1 comments

This issue was originally created at: 2010-03-19 07:43:08. This issue was reported by: ydirson. ydirson said at 2010-03-19 07:43:08

When one defines a Builder, and then calls it without a target or source arg, then scons seems to have problems. In the most simple case, env.MyBuilder(target='foo') combined with `env.Command("bar", "foo", whatever)' fails with a funny "foo -> foo dependency cycle".

Rather than that, scons should warn (or even abort!) because the call is simply wrong.

Note that this simple testcase causes a not-so-obfuscated error, the real-life case which triggered my investigation simply said "Source `foo' not found" - which was easily fixed by adding "source=None", but took time to pinpoint.

garyo said at 2010-03-29 20:04:11

Hi Yann; can you provide a testcase that shows your error? Since emitters can also change the source/target list, it wouldn't always be correct to just give an error for builders with no source. But maybe we can be more helpful in a subset of cases.

gregnoel said at 2010-04-30 16:43:22

Bug party triage. The underlying cause is that when we intuit the source from the target (or vice versa) and the Builder doesn't do any suffix mangling, it's possible to end up with the same file name as both source and target, even after running through the emitters. We can and should detect this case and produce a better error message. Gary to collect a viable test case, then reschedule as 2.x p3 +Easy.

gregnoel said at 2010-07-21 16:58:12

Bug party triage. Bump this issue to P1 so it will be reviewed at next bug party.

garyo said at 2010-07-21 18:10:03

Here's a simple testcase that fails on Windows, SCons 2.0.

bld = Builder(action = 'cat < $SOURCE > $TARGET')
env = Environment(BUILDERS = {'MyBuilder' : bld})
env.MyBuilder(target='foo')
% scons -Q
scons: *** Found dependency cycle(s):
  foo -> foo

garyo said at 2012-09-01 10:01:49

Bumping all old issues targeted for past releases to 2.x.

bdbaddog avatar Jan 02 '18 14:01 bdbaddog

Is there something concrete we can do here? The analysis was if source/target guessing left us with source==target, then there's a problem. Other than "don't do that", can that scenario be detected and error out?

mwichmann avatar Dec 18 '23 21:12 mwichmann