[Scons-users] find new targets from other targets?
Bill Deegan
bill at baddogconsulting.com
Thu Feb 20 21:46:10 EST 2020
Yes. set it as src_scanner.
You're scanner doesn't return any nodes...
On Thu, Feb 20, 2020 at 8:50 PM Scott Johnson <scott.johnson at arilinc.com>
wrote:
>
> > On Feb 20, 2020, at 4:18 AM, Paweł Tomulik <ptomulik at meil.pw.edu.pl>
> wrote:
> > Looks like a perfect job for a scanner.
> >
>
> I was hopeful when I saw the target_scanner= option to Builder, but when I
> tried this, it seems that SCons is running my scanner before the target
> gets built. Which isn’t very helpful, since I can’t parse the file to find
> the additional targets until this target gets built.
>
> Is there a way to get the scanner to run only after the target is built?
> I’m not sure I understand the expected use model of target_scanner
> otherwise.
>
> Here’s my SConstruct:
> ```
> import re
>
> ffile_include = re.compile(r'-F\s+(.*)')
>
> def scan_f_file(node, env, path):
> """Scan the specified node for new targets."""
> print(f"HACK scan_f_file scanning {node}")
> contents = node.get_text_contents()
> for line in contents.splitlines():
> ffile_match = ffile_include.fullmatch(line)
> if ffile_match:
> print(f"HACK found -F {ffile_match.group(1)}")
> return []
>
> verilog_f_scanner = Scanner(function=scan_f_file)
>
> verilog_f_builder = Builder(action = 'cp $SOURCE $TARGET',
> target_scanner=verilog_f_scanner)
> env = Environment(tools=[], BUILDERS={
> 'VerilogF': verilog_f_builder,
> })
>
> env.VerilogF('outputs/tb1.F', 'inputs/tb1.F’)
> ```
>
> And when I run it twice (clean, then incremental):
> ```
> $ scons
> scons: Reading SConscript files ...
> scons: done reading SConscript files.
> scons: Building targets ...
> HACK scan_f_file scanning outputs/tb1.F
> cp inputs/tb1.F outputs/tb1.F
> scons: done building targets.
> $ scons
> scons: Reading SConscript files ...
> scons: done reading SConscript files.
> scons: Building targets ...
> HACK scan_f_file scanning outputs/tb1.F
> HACK found -F sub1/sub1.F
> HACK found -F sub2/sub2.F
> scons: `.' is up to date.
> scons: done building targets.
> ```
>
> I need it to find sub1.F and sub2.F in the clean build, so that I can tell
> it to build those files too.
>
>
> _______________________________________________
> 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/20200220/df3b9520/attachment-0001.html>
More information about the Scons-users
mailing list