Re: AddPostAction memoization problem
Mike Haboustak <[email protected]> Tue, 28 May 2024 22:02:29 -0400
| Newsgroups | gmane.comp.programming.tools.scons.user |
|---|---|
| Message-ID | <CAMGCZSnnDW=Tjqk0b7_RqmsMaU-sCNk31Mexm2nL47ypDqgQYg@mail.gmail.com> |
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 <[email protected]> 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 <[email protected]> > 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 >> [email protected] >> https://pairlist4.pair.net/mailman/listinfo/scons-users >> > _______________________________________________ > Scons-users mailing list > [email protected] > https://pairlist4.pair.net/mailman/listinfo/scons-users > _______________________________________________ Scons-users mailing list [email protected] https://pairlist4.pair.net/mailman/listinfo/scons-users