[Scons-users] Environment clones linked?
Jonathon Reinhart
jonathon.reinhart at gmail.com
Fri May 25 14:28:25 EDT 2018
Yes a friendly warning might be helpful, pointing out that Clone() is
not a totally deep-clone, and that specifically Action objects remain
linked.
You might also consider going on to say that the correct way to
manipulate the way Actions work on a per-environment basis is to
manipulate the *COM variables which the Actions reference.
On Fri, May 25, 2018 at 11:01 AM, Bill Deegan <bill at baddogconsulting.com> wrote:
> Any thoughts on how better to document this?
> More verbiage under Clone()
>
> You're already in the deep end of the pool when you're doing this kind of
> SCons code though..
>
> On Fri, May 25, 2018 at 9:25 AM, Jonathon Reinhart
> <jonathon.reinhart at gmail.com> wrote:
>>
>> We've fought this exact issue before as well: Modifications to Actions
>> or ActionLists affect all environments.
>>
>> The key, as Bill explained, is to leverage the indirection that the
>> environments provide via the *COM variables. In our case, we actually
>> append to the action lists in the environments.
>>
>>
>> Jonathon
>>
>> On Fri, May 25, 2018 at 12:23 AM, Daniel Moody <dmoody256 at gmail.com>
>> wrote:
>> > Thanks that worked!
>> >
>> > I didn't understand how deep Clone went. Originally I tried to modify
>> > the
>> > Action command directly because I didn't want to mess with the other
>> > actions
>> > for the SHLINKCOM.
>> >
>> > On Thu, May 24, 2018 at 11:54 PM, Bill Deegan
>> > <bill at baddogconsulting.com>
>> > wrote:
>> >>
>> >> So you're reaching into an Action defined in a builder.
>> >> That's pretty far inside the Environment to a level that there's not a
>> >> deep copy of it.
>> >>
>> >> This when using mslink right?
>> >>
>> >> shlibLinkAction = SCons.Action.Action('${TEMPFILE("$SHLINK $SHLINKFLAGS
>> >> $_SHLINK_TARGETS $_LIBDIRFLAGS $_LIBFLAGS $_PDB $_SHLINK_SOURCES",
>> >> "$SHLINKCOMSTR")}', '$SHLINKCOMSTR')
>> >>
>> >> regServerAction = SCons.Action.Action("$REGSVRCOM", "$REGSVRCOMSTR")
>> >>
>> >> embedManifestDllCheckAction =
>> >> SCons.Action.Action(embedManifestDllCheck,
>> >> None)
>> >>
>> >> compositeShLinkAction = shlibLinkAction + regServerCheck +
>> >> embedManifestDllCheckAction
>> >>
>> >> env['SHLINKCOM'] = compositeShLinkAction
>> >>
>> >>
>> >> In this case I'd expect the Clone copy/deep copying logic would yield
>> >> what
>> >> you are seeing.
>> >> If you did this:
>> >>
>> >> env2['SHLINKCOM'] = SCons.Action.Action("echo link command env2",None)
>> >> +
>> >> env2['SHLINKCOM'].list[1] + env2['SHLINKCOM'].list[2]
>> >>
>> >> Then it shouldn't modify env1..
>> >> -Bill
>> >>
>> >>
>> >> On Thu, May 24, 2018 at 8:33 PM, Daniel Moody <dmoody256 at gmail.com>
>> >> wrote:
>> >>>
>> >>> I am trying to clone an environment and then make changes to the clone
>> >>> so
>> >>> that it is different than the original.
>> >>>
>> >>> But somehow changing the clone also changes my original env? Is that
>> >>> expected behavior?
>> >>>
>> >>> Below is an example SConstruct which reproduces the issue (SCons 3.01
>> >>> installed from pip on windows 10):
>> >>>
>> >>> env1 = Environment()
>> >>> env2 = env1.Clone()
>> >>>
>> >>> print("env2 before = " + env1['SHLINKCOM'].list[0].cmd_list)
>> >>> env2['SHLINKCOM'].list[0].cmd_list = "echo link command env2"
>> >>> print("env2 after = " + env1['SHLINKCOM'].list[0].cmd_list)
>> >>>
>> >>> print("env1 = " + env2['SHLINKCOM'].list[0].cmd_list)
>> >>>
>> >>> Which produces this output:
>> >>>
>> >>> C:\Users\Daniel\workspace>scons -f SConstruct.py
>> >>> scons: Reading SConscript files ...
>> >>> env2 before = ${TEMPFILE("$SHLINK $SHLINKFLAGS $_SHLINK_TARGETS
>> >>> $_LIBDIRFLAGS $_LIBFLAGS $_PDB $_SHLINK_SOURCES", "$SHLINKCOMSTR")}
>> >>> env2 after = echo link command env2
>> >>> env1 = echo link command env2
>> >>> scons: done reading SConscript files.
>> >>> scons: Building targets ...
>> >>> scons: `.' is up to date.
>> >>> scons: done building targets.
>> >>>
>> >>> Can someone shed some light on if this is a bug or how do I uniquely
>> >>> modify the SHLINKCOM?
>> >>>
>> >>> _______________________________________________
>> >>> Scons-users mailing list
>> >>> Scons-users at scons.org
>> >>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>> >>>
>> >>
>> >>
>> >> _______________________________________________
>> >> Scons-users mailing list
>> >> Scons-users at scons.org
>> >> https://pairlist4.pair.net/mailman/listinfo/scons-users
>> >>
>> >
>> >
>> > _______________________________________________
>> > Scons-users mailing list
>> > Scons-users at scons.org
>> > https://pairlist4.pair.net/mailman/listinfo/scons-users
>> >
>> _______________________________________________
>> Scons-users mailing list
>> Scons-users at scons.org
>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
More information about the Scons-users
mailing list