[ci skip] update generated files
[scons.git] / test / fixture / mycompile.py
blob0e28e5ba54215f9daed7d5889e09ea46f744b6ee
1 # SPDX-License-Identifier: MIT
3 # Copyright The SCons Foundation
5 """
6 Phony compiler for testing SCons.
8 Copies its source files to the target file, dropping lines that match
9 a pattern, so we can recognize the tool has made a modification.
10 Intended for use as a *COM construction variable.
12 Calling convention is:
13 argv[1] the function of the script (cc, c++, as, link etc.)
14 argv[2] the output file to write
15 argv[3:] one or more input files to "compile"
17 Invocation often looks like:
18 Environment(CCCOM = r'%(_python_)s mycompile.py cc $TARGET $SOURCE', ...
19 """
21 import fileinput
22 import sys
24 def fake_compile():
25 skipline = f"/*{sys.argv[1]}*/\n".encode()
26 with open(sys.argv[2], 'wb') as ofp, fileinput.input(files=sys.argv[3:], mode='rb') as ifp:
27 for line in ifp:
28 if line != skipline:
29 ofp.write(line)
32 if __name__ == '__main__':
33 fake_compile()
34 sys.exit(0)