[Scons-users] AddPostAction memoization problem
Bill Deegan
bill at baddogconsulting.com
Tue May 28 23:10:42 EDT 2024
Mike,
Indeed it was not what I would have expected until I looked at the code.
That said, what's the solution, clear the memoization after each action?
Other?
As an aside, what does your actual post action do?
-Bill
On Tue, May 28, 2024 at 7:02 PM Mike Haboustak <haboustak at gmail.com> wrote:
> Bill,
>
> I think it's a fair clarification to say the Builder hasn't completed
> until the entire set of PreAction, Action, and PostAction lists have been
> executed. However, I'm still of the opinion that it's a problem when
> Actions that call a memoized function on a target or a side effect of the
> Builder get the wrong result.
>
> We could note in the documentation for memoized Node functions to indicate
> they can't be called during an Action, but that note would need to
> propagate to any function that has a memoized function in its call graph.
>
>
> Mike
>
>
>
> On Mon, May 27, 2024 at 7:03 PM Bill Deegan <bill at baddogconsulting.com>
> wrote:
>
>> Mike,
>>
>> AddPostAction() adds to the list of Actions for a builder, so when your
>> action is called the builder in question has not completed.
>>
>> AddPreAction() adds to a pre list
>> AddPostAction() adds to a post list
>> Then when the target is built, the executor will run the actions in this
>> order pre-list + normal-action-list + post list.
>> It looks like the memoization is cleared when the builder is called.
>> But certainly not called between each of the Action()'s in the list of
>> actions for a builder.
>>
>> -Bill
>>
>>
>>
>> On Thu, May 23, 2024 at 6:59 PM Mike Haboustak <haboustak at gmail.com>
>> wrote:
>>
>>> I encountered a problem recently with AddPostAction and the
>>> Node.get_size() function. The memoization features of the Node.exists()
>>> function does not appear to be reset after the Builder completes and before
>>> the PostAction runs. As a result, some of the cached values are not correct.
>>>
>>> Here's a simplified SConstruct that reproduces the issue when run with
>>> SCons 4.7.0 with GCC on Linux. The "PostAction" size of the test.o object
>>> file is based on the state of the file prior to the builder running.
>>>
>>> ---- SConstruct
>>> env = Environment()
>>> def print_size(target, source, env):
>>> print("PostAction:", target[0].getsize())
>>>
>>> test = env.Object("test.c")
>>> env.AddPostAction(test, Action(print_size))
>>> ----
>>>
>>> Test Output
>>> ----
>>> $ touch test.c
>>> $ scons
>>> scons: Reading SConscript files ...
>>> scons: done reading SConscript files.
>>> scons: Building targets ...
>>> gcc -o test.o -c test.c
>>> print_size(["test.o"], ["test.c"])
>>> PostAction: None
>>> scons: done building targets.
>>>
>>> $ echo -e "\n" >>test.c
>>> $ scons
>>> scons: Reading SConscript files ...
>>> scons: done reading SConscript files.
>>> scons: Building targets ...
>>> gcc -o test.o -c test.c
>>> print_size(["test.o"], ["test.c"])
>>> PostAction: 800
>>> scons: done building targets.
>>> ----
>>>
>>> Thanks,
>>> Mike
>>> _______________________________________________
>>> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20240528/7c171c09/attachment.htm>
More information about the Scons-users
mailing list