Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-27497

Scope SCons Environment modifications

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.2
    • Affects Version/s: None
    • Component/s: Build
    • None
    • Fully Compatible
    • Platforms 2017-01-23

      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.

            Assignee:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Reporter:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: