[Scons-users] using variant_dir but strip out the variant_dir from source files

Hua Yanghao huayanghao at gmail.com
Wed Oct 24 11:04:16 EDT 2018


Any thoughts? This seems really like when you move around some header
files scons is using some cached knowledge from last built which
caused the incremental built to fail.
Not sure if the trace file is useful enough already, I could try to
create a minimal suite of files that actually reproduce this issue too
if needed.
On Thu, Oct 18, 2018 at 6:06 PM Hua Yanghao <huayanghao at gmail.com> wrote:
>
> Hi Bill, I am chdir only to the top level folder "build", and want to
> build CC a/b/c.c instead of CC build/a/b/c.c
>
> I got this working but wonder if there is a way that I do not need to
> change the Defaults.py file.
> On Thu, Oct 18, 2018 at 6:04 PM Bill Deegan <bill at baddogconsulting.com> wrote:
> >
> > So you have a file:
> > a/b/c.c
> > variant dir to
> > build/a/b/c.c
> >
> > you're chdir'ing into
> > build/a/b ?
> >
> > And you want the command line to be
> > compiler c.c
> >
> > ?
> >
> > On Thu, Oct 18, 2018 at 6:30 AM Hua Yanghao <huayanghao at gmail.com> wrote:
> >>
> >> Update: it looks like the _concat()-like stuff can only be put in the
> >> SCons/Defaults.py otherwise not all environment will get it.
> >> Not sure if there is a way that I do not need to modify the
> >> Defaults.py but still able to add one function to the default
> >> environment construction.
> >>
> >> Thanks,
> >> Yanghao
> >> On Thu, Oct 18, 2018 at 12:07 AM Hua Yanghao <huayanghao at gmail.com> wrote:
> >> >
> >> > Looked into the Action.py a little bit, doesn't seem to really have a
> >> > controllable print for chdir messages.
> >> > I tested below patch which works for me:
> >> >
> >> > diff --git i/tools/scons-3.0.1/scons-local-3.0.1/SCons/Action.py
> >> > w/tools/scons-3.0.1/scons-local-3.0.1/SCons/Action.py
> >> > index ce5471d..ee2a5c1 100644
> >> > --- i/tools/scons-3.0.1/scons-local-3.0.1/SCons/Action.py
> >> > +++ w/tools/scons-3.0.1/scons-local-3.0.1/SCons/Action.py
> >> > @@ -647,7 +647,8 @@ class _ActionAction(ActionBase):
> >> >                                 show=_null,
> >> >                                 execute=_null,
> >> >                                 chdir=_null,
> >> > -                               executor=None):
> >> > +                               executor=None,
> >> > +                               chdir_verbose=False):
> >> >          if not is_List(target):
> >> >              target = [target]
> >> >          if not is_List(source):
> >> > @@ -691,7 +692,8 @@ class _ActionAction(ActionBase):
> >> >                  cmd = self.strfunction(target, source, env)
> >> >              if cmd:
> >> >                  if chdir:
> >> > -                    cmd = ('os.chdir(%s)\n' % repr(chdir)) + cmd
> >> > +                    if chdir_verbose:
> >> > +                        cmd = ('os.chdir(%s)\n' % repr(chdir)) + cmd
> >> >                  try:
> >> >                      get = env.get
> >> >                  except AttributeError:
> >> > @@ -718,7 +720,7 @@ class _ActionAction(ActionBase):
> >> >              finally:
> >> >                  if save_cwd:
> >> >                      os.chdir(save_cwd)
> >> > -        if cmd and save_cwd:
> >> > +        if cmd and save_cwd and chdir_verbose:
> >> >              print_func('os.chdir(%s)' % repr(save_cwd), target, source, env)
> >> >
> >> >          return stat
> >> > On Wed, Oct 17, 2018 at 11:54 PM Hua Yanghao <huayanghao at gmail.com> wrote:
> >> > >
> >> > > I finally implemented something like _concat() so I can use it
> >> > > directly in the COMSTR definition to strip out the additional path.
> >> > > However now scons trying to be very verbose and every single
> >> > > os.chdir() is being printed (chdir="..." used for all builders). Is
> >> > > there a way to disable this os.chdir() print message without modifying
> >> > > the scons source code? Thanks.
> >> > > On Wed, Oct 17, 2018 at 9:55 PM Hua Yanghao <huayanghao at gmail.com> wrote:
> >> > > >
> >> > > > Dear Scons User,
> >> > > > I am having maybe an odd request. The background is there are some
> >> > > > compilers out there produces all kinds of output in your current
> >> > > > directory which you do not have control. I wanted to combine the
> >> > > > variant_dir feature plus the chdir kw arguments to builders, to be
> >> > > > able to invoke those compilers directly inside the variant_dir. And I
> >> > > > still want to keep the source duplication in the variant_dir as it
> >> > > > will be a snapshot of only the used files for a particular built out
> >> > > > of thousands of irrelevant files. As a side effect now the source
> >> > > > files are all prefixed with the variant_dir which becomes "invalid"
> >> > > > because the compiler is already invoked in the variant_dir instead of
> >> > > > the top level directory.
> >> > > >
> >> > > > Is there a way (e.g. a special env variable) already that when I write
> >> > > > my builders instead of "$COMPILER $SOURCE", I can use something like
> >> > > > "$COMPILER $ORIGINAL_SOURCE"? Or do I have to wrap around the
> >> > > > $COMPILER with another command such that I can do things like
> >> > > > "$COMPILER_WRAPPED $VARIANT_DIR $SOURCE"? I know the second one
> >> > > > definitely can work but wondering if there are better ways already in
> >> > > > scons.
> >> > > >
> >> > > > Best Regards,
> >> > > > Yanghao
> >> _______________________________________________
> >> 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


More information about the Scons-users mailing list