Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor PathList out! #497

Closed
bdbaddog opened this issue Jan 2, 2018 · 0 comments
Closed

Refactor PathList out! #497

bdbaddog opened this issue Jan 2, 2018 · 0 comments
Labels

Comments

@bdbaddog
Copy link
Contributor

bdbaddog commented Jan 2, 2018

This issue was originally created at: 2003-04-30 12:38:04.
This issue was reported by: issues@scons.
issues@scons said at 2003-04-30 12:38:04

The main thrust of this change is to get rid of
SCons.Util.PathList, so that the $TARGETS and $SOURCES
variables are actual lists of Node objects. This
allows some powerful new tricks, and it moves the
"special attributes" like .abspath, .suffix, .posix,
etc. to the Node subclasses where they belong.

This change lays the groundwork for stuff like URI
nodes, Java only rebuilding changed source files, etc.

Other than the obvious change above, I had to make a
couple other changes to get everything to work right:

  1. Big change: we now use real, live target and source
    Nodes when computing the signature of a command like
    (i.e., in Action.get_contents()). We have to do this
    now, because we want users to be able to start doing
    neat tricks with the fact that $TARGETS and $SOURCES
    are real Nodes, and we don't want to worry about having
    a work-alike class for every possible Node type!

  2. To get #1 to work (recall that the main barrier was
    that it would break Repository), I changed the behavior
    of the $( $) delimiters in Environment variable
    substitution slightly. These delimiters used to remove
    anything between them from the command line for
    purposes of signature calculation. Now, the don't
    remove it, they simply keep it from being substituted.
    In other words, if you were to say "$( $FOO $)" on a
    command line, changing the contents of the FOO variable
    would not cause a rebuild, but changing the command
    line to "$( $BAR $)" will! I think this is a better
    overall implementation anyway, since before, we might
    have missed some cases when we really did want to rebuild.

  3. I went through all the Tool specifications, and made
    sure $TARGETS, $SOURCES, $_LIBDIRFLAGS, $_CPPINCFLAGS,
    and $_F77INCFLAGS were enclosed in $( $), so we won't
    break Repository, and so we won't needlessly rebuild.

  4. Since Environment.sig_dict() went away (obviously),
    I had to change the way new-style command generators
    are called. I added a "for_signature" argument that
    works just like for_signature on old-style command
    generators (i.e., it is nonzero when the command
    generator is being called for signature generation).
    This makes them more flexible, if a little more
    cumbersome (since you need that argument in your
    parameter list even if you are going to ignore it). I
    also changed all new-style command generators in the
    Tools to have this new argument.

  5. Mingw was still using an old-style command generator
    for shared libraries. Since we are planning on
    deprecating this soon, I changed it to new-style.

  6. A couple test fixes.

  7. New Node method: get_abspath(). I added this
    because many modules outside SCons.Node.FS were looking
    directly at the .abspath member of a Node without first
    checking to see if it was a File Node. This will break
    when we start adding new Node types, so I added the
    method to the Node base class. It returns str(Node) by
    default. I also had to do this because
    SCons.Node.FS.Entry has the .abspath special attribute,
    which returns a SCons.Util.Literal instance instead of
    a string.

  8. Nodes that were targets of ListBuilders were not
    passing all the targets of the build into
    Builder.get_contents(). This is now fixed.

issues@scons said at 2003-05-05 14:51:23

Okay here is my second crack at this. I changed the $( $)
back to their old behavior, and I changed the Tools back to
their old form (except for changes I had to make pursuant to
#4 (for_signature argument).

Also, I removed #5 entirely, and just left the old-style
command generator in mingw. I figured we had enough changes
for one diff, plus I don't have mingw to test my change.

Finally, I changed the way we calculate signatures from
$TARGET, $SOURCE, and indeed any Node, according to a
conversation I had on scons-devel with Steve K and Anthony.
Nodes now has a for_signature() method that is expected to
return a string that is suitable for describing a Node in
signature calculation.

There is also a new Node method get_string(), that takes a
single argument for_signature, and will return
self.for_signature() if it is nonzero, or str(self) if it is
zero. This is provided for convenience when implementing
command generators -- command generators are passed a
for_signature argument as well, and an implementor can
simply say Node.get_string(for_signature) from withing the
command generator to get the proper string represenation of
a Node for both signature calculation and the "real thing."

I also changed the interface for the
SCons.Util.scons_subst() and scons_subst_dict() methods. We
do not pass a regex into them anymore, but rather a "mode"
parameter, which can be one of SCons.Util.SUBST_CMD (for
"normal" mode to generate a command line), SUBST_SIG (for
signature generation), or SUBST_RAW (for
Action.get_raw_contents()). This was to handle the fact
that we not onlt change the stuff we remove from substituted
strings, but we change the way we convert Nodes to strings
as well.

issues@scons said at 2003-05-05 15:39:19

Okay here is a very slight change to RefactorPathList2.diff
that adds an important ability. Before, I added a class
NodeList that allows us to do the same magic we could do
with the old PathList, like:

$TARGETS.abspath

...which will return a list of the absolut paths of all
targets. The new and improved NodeList in this path allows
you to do stuff like:

$TARGETS.srcpath.rdir().filebase

(i.e., multiple attribute references on lists, whereas that
would blow up before)

issues@scons said at 2003-05-05 15:39:19

Converted from SourceForge tracker item 730393

@bdbaddog bdbaddog closed this as completed Jan 2, 2018
@bdbaddog bdbaddog added the P3 label Jan 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant