summaryrefslogtreecommitdiffstats
path: root/test/fixture/mycompile.py
blob: 27bf840e92597d56c608534162904bb8aa5c4857 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
r"""
Phony "compiler" for testing SCons.

Copies its source files to the target file, dropping lines
that match a pattern, so we can recognize the tool
has made a modification.
"""

import sys

if __name__ == '__main__':
    line = ('/*' + sys.argv[1] + '*/\n').encode()
    with open(sys.argv[2], 'wb') as ofp:
        for f in sys.argv[3:]:
            with open(f, 'rb') as ifp:
                lines = [ln for ln in ifp.readlines() if ln != line]
                for ln in lines:
                    ofp.write(ln)
    sys.exit(0)