4 from SCons
.Script
import Builder
, Action
, Scanner
6 def soelim(target
, source
, env
):
8 Interpolate files included in [gnt]roff source files using the
11 This behaves somewhat like the soelim(1) wrapper around groff, but
12 makes us independent of whether the actual underlying implementation
13 includes an soelim() command or the corresponding command-line option
14 to groff(1). The key behavioral difference is that this doesn't
15 recursively include .so files from the include file. Not yet, anyway.
19 dir, f
= os
.path
.split(s
)
20 with
open(t
, 'w') as tfp
, open(s
, 'r') as sfp
:
21 for line
in sfp
.readlines():
22 if line
[:4] in ['.so ', "'so "]:
23 sofile
= os
.path
.join(dir, line
[4:-1])
24 with
open(sofile
, 'r') as f
:
29 def soscan(node
, env
, path
):
30 c
= node
.get_text_contents()
31 return re
.compile(r
"^[.']so\s+(\S+)", re
.M
).findall(c
)
33 soelimbuilder
= Builder(action
= Action(soelim
),
34 source_scanner
= Scanner(soscan
))