[Scons-users] Getting build action details

Nacho Piqueras natxo.piq at gmail.com
Wed Apr 11 02:04:08 EDT 2018


Thanks Bill, I will try to explain the rationale.

My project contain several SConscripts in different directories
(components) beneath the SConstruct. Each SConscript tells SCons how to
build object files for that component.

The environment in each component is a clone of the original environment,
which loads the tools for that project and sets project-width compiler
settings (might be overridden in each SConscript!).

After loading all SConscripts I got a list with all objects to be built.
Then I call Program to generate the binary file in the SConstruct file.

The question is: I want to run a static analyzer on each source file. To be
run, the static analyzer needs to be passed some compiler-alike
information: defined symbols and include search path. I do not want to
modify any SConscript, but to do that in the SConstruct file. I though I
could do it getting the info from the Object nodes to be built, as
explained in my original message.

An example containing only one component called "foo":

 + SConstruct
 + inc
    - types.h
 + foo
    - foo.sconscript
    - foo.c
    + inc
       - foo.h

if `foo.sconscript` contains:

    Import('env')
    env.Object('foo.c', CPPPATH=["#inc", "inc"])

then foo.o is built correctly with CPPPATH (assuming default settings)
"-Iinc -Ifoo/inc"

but if in the SConstruct I use the overriden CPPPATH (as got from the File
node object) as construction variable in the command line generator for the
action that runs the static analyzer, then the resulting command line is:

"-Iinc -Iinc"

which obviously I do not want.

Best regards!

On Tue, Apr 10, 2018 at 10:36 PM, <scons-users-request at scons.org> wrote:

> Send Scons-users mailing list submissions to
>         scons-users at scons.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://pairlist4.pair.net/mailman/listinfo/scons-users
> or, via email, send a message with subject or body 'help' to
>         scons-users-request at scons.org
>
> You can reach the person managing the list at
>         scons-users-owner at scons.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Scons-users digest..."
>
>
> Today's Topics:
>
>    1. Getting build action details (Nacho Piqueras)
>    2. Re: Getting build action details (Bill Deegan)
>    3. Re: Getting build action details (Bill Deegan)
>    4. Re: Fortran dependency in a higher directory (GUEZ Lionel)
>    5. Re: Getting build action details (Mats Wichmann)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 10 Apr 2018 08:05:20 +0200
> From: Nacho Piqueras <natxo.piq at gmail.com>
> To: scons-users at scons.org
> Subject: [Scons-users] Getting build action details
> Message-ID:
>         <CADak=V_hSDfF_qd70mMK+NCv_X546iPgkmGY2bwiDmX24VHoDA@
> mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hello,
>
> Given a list a nodes representing object files built by SCons, I would like
> to get the resolved $CPPPATH list for each one.
>
> Inspecting each file object I can see they contain a reference to the
> executor object, and I tried using the overriden environment with the
> executor to subst the variable, but without luck.
>
> Given that some entries in CPPPATH list contain '#', others are absolute
> paths and others are relative to the directory of the sconscript that told
> SCons to generate that Object, I cannot find a way to easily get that
> information.
>
> Is there something in the Subst module that I can use?
>
> Best regards!
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <https://pairlist4.pair.net/pipermail/scons-users/
> attachments/20180410/c6e72ff9/attachment-0001.html>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 10 Apr 2018 09:58:02 -0400
> From: Bill Deegan <bill at baddogconsulting.com>
> To: SCons users mailing list <scons-users at scons.org>
> Subject: Re: [Scons-users] Getting build action details
> Message-ID:
>         <CAEyG4CEegB+axS2ih_JxUWuguBiZ-KpM9xOvSEv_+
> RLuiFjXWQ at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Can you explain what you are trying to do?
> (Why do you want to do this?)
>
> That may point out other ways to accomplish what you need than the way you
> have tried already.
>
> On Tue, Apr 10, 2018 at 2:05 AM, Nacho Piqueras <natxo.piq at gmail.com>
> wrote:
>
> > Hello,
> >
> > Given a list a nodes representing object files built by SCons, I would
> > like to get the resolved $CPPPATH list for each one.
> >
> > Inspecting each file object I can see they contain a reference to the
> > executor object, and I tried using the overriden environment with the
> > executor to subst the variable, but without luck.
> >
> > Given that some entries in CPPPATH list contain '#', others are absolute
> > paths and others are relative to the directory of the sconscript that
> told
> > SCons to generate that Object, I cannot find a way to easily get that
> > information.
> >
> > Is there something in the Subst module that I can use?
> >
> > Best regards!
> >
> > _______________________________________________
> > 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/20180410/b9d58c96/attachment-0001.html>
>
> ------------------------------
>
> Message: 3
> Date: Tue, 10 Apr 2018 09:58:17 -0400
> From: Bill Deegan <bill at baddogconsulting.com>
> To: SCons users mailing list <scons-users at scons.org>
> Subject: Re: [Scons-users] Getting build action details
> Message-ID:
>         <CAEyG4CEd7E0i8jw27D0CLBi1m9Y7RaCfTRFiC74tEszD_58ZmQ at mail.
> gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Also, can you paste an small example.
>
> On Tue, Apr 10, 2018 at 9:58 AM, Bill Deegan <bill at baddogconsulting.com>
> wrote:
>
> > Can you explain what you are trying to do?
> > (Why do you want to do this?)
> >
> > That may point out other ways to accomplish what you need than the way
> you
> > have tried already.
> >
> > On Tue, Apr 10, 2018 at 2:05 AM, Nacho Piqueras <natxo.piq at gmail.com>
> > wrote:
> >
> >> Hello,
> >>
> >> Given a list a nodes representing object files built by SCons, I would
> >> like to get the resolved $CPPPATH list for each one.
> >>
> >> Inspecting each file object I can see they contain a reference to the
> >> executor object, and I tried using the overriden environment with the
> >> executor to subst the variable, but without luck.
> >>
> >> Given that some entries in CPPPATH list contain '#', others are absolute
> >> paths and others are relative to the directory of the sconscript that
> told
> >> SCons to generate that Object, I cannot find a way to easily get that
> >> information.
> >>
> >> Is there something in the Subst module that I can use?
> >>
> >> Best regards!
> >>
> >> _______________________________________________
> >> 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/20180410/c0aea79f/attachment-0001.html>
>
> ------------------------------
>
> Message: 4
> Date: Tue, 10 Apr 2018 17:53:48 +0200
> From: GUEZ Lionel <guez at lmd.ens.fr>
> To: scons-users at scons.org
> Subject: Re: [Scons-users] Fortran dependency in a higher directory
> Message-ID: <20180410175348.263c2ab7 at vierne>
> Content-Type: text/plain; charset=UTF-8
>
> On Mon, 9 Apr 2018 10:48:40 -0400
> Bill Deegan <bill at baddogconsulting.com> wrote:
>
> > It's been a LONG time since I've worked with fortran.
> > I'm pointing you at the variables listed in the docs for you to
> > figure it out yourself.
> > I'm not in anyway contradicting what's in the docs..
> >
>
> I am not ignoring what you say: I read the description of all
> Fortran variables in the doc (and I read the SCons 3.0.1 user guide
> completely down to chapter 15).
>
> I will try to be more precise. It is ambiguous to refer to "module
> files". "Module file" could mean a compiled module interface (with
> usually a .mod suffix) or it could mean a source Fortran file
> containing one or more modules. The compilation system must be able to
> search for compiled module interfaces (.mod files) in a set of
> directories, without corresponding source files: this happens when a
> program uses a Fortran library. And the compilation system must be able
> to search for source module files, to be compiled, in another set of
> directories, in order to figure out the order of compilation.
>
> Now the documentation on FORTRANPATH says:
>
> "The list of directories that the Fortran compiler will search for
> include files and (for some compilers) module files."
>
> I guess that, here, "module files" means compiled module interfaces. So
> I would propose that you amend this sentence to:
>
> "The list of directories that the Fortran compiler will search for
> include files and (for some compilers) compiled module interfaces
> (files with suffix $FORTRANMODSUFFIX)."
>
> Then the documentation on FORTRANPATH says:
>
> "The Fortran implicit dependency scanner will search these directories
> for include files (but not module files since they are autogenerated
> and, as such, may not actually exist at the time the scan takes place)."
>
> Here I guess that "module files" also means compiled module interfaces.
> But there misses the information that the dependency scanner
> WILL search these directories for source module files.
>
> Thus, I would propose that you amend this sentence to:
>
> "The Fortran implicit dependency scanner will search these directories
> for include files and source module files (but not compiled module
> interfaces (files with suffix $FORTRANMODSUFFIX) since they are
> autogenerated and, as such, may not actually exist at the time the scan
> takes place)."
>
> --
> Lionel GUEZ
> Laboratoire de m?t?orologie dynamique
> ?cole normale sup?rieure
> 24 rue Lhomond
> 75005 Paris
>
>
> ------------------------------
>
> Message: 5
> Date: Tue, 10 Apr 2018 14:36:51 -0600
> From: Mats Wichmann <mats at wichmann.us>
> To: scons-users at scons.org
> Subject: Re: [Scons-users] Getting build action details
> Message-ID: <a22f6f4c-c29e-fa90-f6a6-5125471282e2 at wichmann.us>
> Content-Type: text/plain; charset=utf-8
>
> On 04/10/2018 07:58 AM, Bill Deegan wrote:
> > Also, can you paste an small example.
> >
> > On Tue, Apr 10, 2018 at 9:58 AM, Bill Deegan <bill at baddogconsulting.com>
> > wrote:
> >
> >> Can you explain what you are trying to do?
> >> (Why do you want to do this?)
> >>
> >> That may point out other ways to accomplish what you need than the way
> you
> >> have tried already.
> >>
> >> On Tue, Apr 10, 2018 at 2:05 AM, Nacho Piqueras <natxo.piq at gmail.com>
> >> wrote:
> >>
> >>> Hello,
> >>>
> >>> Given a list a nodes representing object files built by SCons, I would
> >>> like to get the resolved $CPPPATH list for each one.
> >>>
> >>> Inspecting each file object I can see they contain a reference to the
> >>> executor object, and I tried using the overriden environment with the
> >>> executor to subst the variable, but without luck.
> >>>
> >>> Given that some entries in CPPPATH list contain '#', others are
> absolute
> >>> paths and others are relative to the directory of the sconscript that
> told
> >>> SCons to generate that Object, I cannot find a way to easily get that
> >>> information.
> >>>
> >>> Is there something in the Subst module that I can use?
>
> I have at times sought something slightly similar so I'll point out: I
> may be misunderstanding but the settings you care about are not
> per-node, but per-construction-environment.
>
> If there's just one construction environment, Dump() it. Since all the
> scripts are executed first, that is the environment are built up before
> the targets are acted on, put this at the end of your SConstruct and you
> know what each of the targets will be encountering as they build. You
> certainly don't have to dump the whole environment if you are just
> interested in one variable from it, just extract that one instead.
>
> However, if there are many environments you would need to Dump at
> suitable places for each one you care about. I know of no great answer
> in this case.  [[this has driven me nuts in our project - just counted
> again and there are 179 Clone() calls in this beast. sadly I can't wave
> a magic wand and simplify this, I have to improve things piecemeal]]
> This kind of edit-something-in-to-debug becomes painful if you have to
> fiddle with a bunch of sconscripts, and doing it at the top, in the
> SConstruct, is also problematic because it's not going to have the
> context - it has no idea what environments have been created in the
> things it has called (that may then have then called other things etc.)
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
> ------------------------------
>
> End of Scons-users Digest, Vol 77, Issue 4
> ******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20180411/fa178756/attachment-0001.html>


More information about the Scons-users mailing list