[Scons-users] AddPostAction memoization problem
Mike Haboustak
haboustak at gmail.com
Wed May 29 17:27:58 EDT 2024
On Wed, May 29, 2024 at 9:49 AM Mats Wichmann <mats at wichmann.us> wrote:
>
> I'd personally agree as to correct behavior: if a step that makes
> changes has completed, information related to the node should be up to
> date and not old. I guess it's worth mentioning that the getsize()
> method isn't *officially* exposed as a public interface, it's possible
> there was an actual reason for that back in the mists of time.
>
Is it true that a function isn't officially exposed if it doesn't have
a docstring in the API docs? The documentation includes
SCons.Node.FS.File.get_size() right next to get_relpath().
https://scons.org/doc/latest/HTML/scons-api/SCons.Node/#SCons.Node.FS.File.get_size
> It should be sufficient to just remove the memoized 'stat', since it's
> the thing that holds information SCons itself doesn't update - it
> eventually comes from an os.stat() call - that could be considered
> "expensive" and thus worth memoizing.
I think exists() and rexists() need to be cleared as well. The
get_size() call returns -1 because the file didn't exist when the
Builder was executed. It never tries to get the current value
rfile().getsize()
> Stepping aside from the internal implementation questions, you could in
> this particular case do something that sidesteps the memoized stat
> structure, like:
>
> print("PostAction:", os.path.getsize(target[0].abspath))
This does work, and it's the same work-around we implemented. I was
just trying to use the SCons object model and API functions as much as
possible.
More information about the Scons-users
mailing list