1 # SPDX-License-Identifier: MIT
3 # Copyright The SCons Foundation
8 from SCons
.Script
import Builder
, Action
, Scanner
11 def soelim(target
, source
, env
):
13 Interpolate files included in [gnt]roff source files using the
16 This behaves somewhat like the soelim(1) wrapper around groff, but
17 makes us independent of whether the actual underlying implementation
18 includes an soelim() command or the corresponding command-line option
19 to groff(1). The key behavioral difference is that this doesn't
20 recursively include .so files from the include file. Not yet, anyway.
24 dir, f
= os
.path
.split(s
)
25 with
open(t
, 'w') as tfp
, open(s
) as sfp
:
26 for line
in sfp
.readlines():
27 if line
[:4] in ['.so ', "'so "]:
28 sofile
= os
.path
.join(dir, line
[4:-1])
29 with
open(sofile
) as f
:
35 def soscan(node
, env
, path
):
36 c
= node
.get_text_contents()
37 return re
.compile(r
"^[.']so\s+(\S+)", re
.M
).findall(c
)
40 soelimbuilder
= Builder(action
=Action(soelim
), source_scanner
=Scanner(soscan
))