[SERVER-27497] Scope SCons Environment modifications Created: 22/Dec/16  Updated: 05/Apr/17  Resolved: 03/Jan/17

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: None
Fix Version/s: 3.5.2

Type: Improvement Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: Andrew Morrow (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Platforms 2017-01-23
Participants:

 Description   

Right now, we make available the top level Environment by calling Export('env') in the top level SConstruct, and then subordinate SConscript files obtain it by calling Import('env'). This means that if a sloppy SConscript file directly modifies the global env, those changes are propagated to all later SConscript files that import the env, which was probably not the intention.

To fix this, we should:

  • Stop Export'ing the top level Environment
  • Open each subordinate SConscript by first Import'ing env, and then immediately cloning a new Environment into the env name, with env = env.Clone().
  • When invoking a subordinate SConscript, propagate the local env by adding exports=["env"] to the env.SConscript invocation.

By following this pattern everywhere, it becomes impossible for changes to escape the scope for which they were intended. In the worst case, a malformed subordinate SConscript could inject into its parent scope, but no further.



 Comments   
Comment by Githook User [ 03/Jan/17 ]

Author:

{u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@mongodb.com'}

Message: SERVER-27497 Scope SCons Environment changes narrowly
Branch: master
https://github.com/mongodb/mongo/commit/1346352ff66b163fb010a270d1826c18699f3b36

Comment by Githook User [ 03/Jan/17 ]

Author:

{u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@mongodb.com'}

Message: SERVER-27497 Scope Environment changes more narrowly
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/7cc51a454a406d9877e27502b1e88547e454d2cf

Generated at Thu Feb 08 04:15:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.