Re: File only rebased to variant dir if Command action is a build function?
Damjan Jovanovic <[email protected]>
| Newsgroups | gmane.comp.programming.tools.scons.user |
|---|---|
| Message-ID | <CAJm2B-mj74oeMq4WGhboQJ3c2Lge_KYqkG340jLL0+-+wfdCeQ@mail.gmail.com> |
Great Thank you! On Sun, Jul 12, 2020 at 9:48 PM Hans-Christian Wild <[email protected]> wrote: > Hi Damjan, > > to me it looks like the problem is that the expression > `str(env['EXTRACT_DIR'])` in the print(...) statement will be processed by > python already when the SConscript file itself is processed and not later, > when scons actually executes the command. > > if I change the print statement e.g. to this > > "echo Extracting to (string action): $EXTRACT_DIR", > > the output is correct > > echo Extracting to (string action): build\External > Extracting to (string action): "build\External" > > On Sun, Jul 12, 2020 at 4:42 PM Damjan Jovanovic <[email protected]> > wrote: > >> Hi >> >> In a hierarchical build with a separate output directory, a Command()'s >> action will only see a File() in its env rebased to the variant dir if it's >> a function action, not a string action. >> >> The example below prints: >> Extracting to (string action) External [WRONG] >> Extracting to (function action) build/External [RIGHT] >> >> Why do string actions not see their env's File() entries rebased to >> variant dir? Is there some way to do the rebasing manually? >> >> If not, how can the function action run commands like the string action >> would? env.Execute()? >> >> Thank you >> Damjan >> >> SConstruct: >> SConscript('src/SConscript', variant_dir='build', duplicate=0) >> >> src/SConscript: >> import shutil >> env = DefaultEnvironment() >> tarball = env.File('52654eb3b2e60c35731ea8fc87f1bd29-jpeg-8d.tar.gz') >> env['EXTRACT_DIR'] = env.Dir('External') >> def unpack_tarball(target, source, env): >> print("Extracting to (function action) " + str(env['EXTRACT_DIR'])), >> shutil.unpack_archive(str(source[0]), str(env['EXTRACT_DIR'])) >> env.Command('${EXTRACT_DIR}/extracted.flg', tarball, [ >> print("Extracting to (string action) " + str(env['EXTRACT_DIR'])), >> unpack_tarball, >> Touch('${TARGET}') >> ]) >> >> _______________________________________________ >> 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