scons icon indicating copy to clipboard operation
scons copied to clipboard

It should be possible to access values in a Variables object before creating an environment

Open bdbaddog opened this issue 7 years ago • 1 comments

This issue was originally created at: 2010-04-06 10:14:20. This issue was reported by: evaned.

evaned said at 2010-04-06 10:14:20

I wanted to make a var=value option (the sort supported by the Variables module) and access one of the settings before I create an environment, so I could pick the tools based on the argument. Best suggestion was to create an empty environment with the variables object, access the appropriate values, and then make the "real" environment later. This is a fine workaround and not too convoluted, but accessing it directly would be a little cleaner.

See https://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2461266 and the reply from William Deegan (and sorry about the broken threading). [Tigris shut down, dead link]

gregnoel said at 2010-04-30 17:41:38

Bug party triage. Slated to be fixed as part of the toolchain rework. (It'll probably be fixed much earlier than 3.x p3; that's just an artifact of how the issue tracker groups issues.)

bdbaddog avatar Jan 02 '18 14:01 bdbaddog

[edited] Don't see how this is possible with the current design, as a Variables object doesn't hold any "data", just the descriptions of how the variables should work that it's been given (1). The Update method processes any associated files and arguments on the fly, builds them into a local dict, and uses that to update the passed-in environment. This is somewhat analogous to what optparse does (though not as cleanly separated): all the known options and how to handle them is stored in the parser object, which is then called to parse the actual passed args - the results never get stored in the parser object itself.

Unless we want to keep this around as a reminder for what to do in some future redesign (something which doesn't seem likely to happen), maybe we can close this one as a wontfix, and maybe I tweak the docs a bit?

(1) slight oversimplification, a Variables object's unknown attribute may be added to during Update() processing, and the args array is also stored in the object (in unprocessed form).

mwichmann avatar Apr 08 '24 16:04 mwichmann