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

Implement a facility for safer environment modifications

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • 6.0 Desired
    • Affects Version/s: None
    • Component/s: Build
    • None
    • Server Development Platform
    • Fully Compatible

      In SCons, it is very easy to make a mistake where when declaring a Program or Library, you inadvertently overwrite an existing environment customization.

      The problem is fairly obvious at a glance when you write something like:

      my_env = env.Clone()
      my_env.AppendUnique(LIBSDEPS=['a'])
      my_env.Library(
          target="some_lib",
          source=["some_lib.cpp"],
          LIBDEPS=['b'],
      )
      

      Because you can see by inspection that the LIBS kwarg to my_env.Library will overwrite the value of LIBS that was applied after cloning the Environment. Even though it is obvious, it can still be surprising to developers who are not familiar with the fact that kwargs-style arguments in a Builder call are overwriting.

      However, in cases where the Environment modification is programmatic, like with InjectThirdParty it can be very hard to spot the error:

      my_env = env.Clone()
      my_env.InjectThirdParty(libraries=["magic"])
      my_env.Library(
          target="some_lib",
          source=["some_lib.cpp"],
          LIBDEPS=['b'],
      )
      

      If the result of the InjectThirdParty call is to add to LIBDEPS, then this will actually not happen and the results can be very confusing.

      Some mechanism should be found to either prevent this error from being possible, or to introduce a syntax or feature that allows "inline" modifications to the Environment to be accumulative, rather than overwriting.

            Assignee:
            backlog-server-devplatform [DO NOT ASSIGN] Backlog - Server Development Platform Team (SDP) (Inactive)
            Reporter:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: