scons icon indicating copy to clipboard operation
scons copied to clipboard

Configure() called from a builder or scanner

Open bdbaddog opened this issue 7 years ago • 2 comments

This issue was originally created at: 2008-09-17 23:35:10. This issue was reported by: gregnoel.

gregnoel said at 2008-09-17 23:35:10

This code appears twice in Script/SConscript.py:

    if not SCons.Script.sconscript_reading:
        raise SCons.Errors.UserError, "Calling Configure from Builders is not supported."

What this code says is, if we're not reading a SConscript, complain that you can't use Configure() inside a Builder.

Er, on the one hand, if you're not reading a SConscript, you're not running a Builder, so the message is clearly wrong. My guess is that this message is intended be triggered inside a Scanner.

On the other hand, it clearly is a bad idea to invoke Configure from a Builder, so there should be some way of detecting that and generating an error.

My suggestion would be that the wrappers for Builders and Scanners should each increment a variable before they call the actual builder/scanner and decrement it when the builder/scanner returns. This error message should be keyed off of those variables.

Oh, and all that logic should be moved out of Script/* and into some core file (maybe SConf.py?). Calling Configure() from a builder or scanner is a bad idea in general, not just when the builder or scanner is in a SConscript file.

gregnoel said at 2008-09-25 01:20:51

Bug party triage.

bdbaddog avatar Jan 02 '18 12:01 bdbaddog

@bdbaddog any thoughts on this "mature" report?

mwichmann avatar Aug 31 '25 18:08 mwichmann

Interesting. The comment is correct. There's no guarantee that you are calling it from a builder, only that you are calling it outside of processing the SConscript/SConstruct/associated logic.

So maybe Calling Configure from invalid context. You can only call Configure from SConstruct/SConscript/Associated logic processing ?

bdbaddog avatar Aug 31 '25 23:08 bdbaddog