1 # SPDX-License-Identifier: MIT
3 # Copyright The SCons Foundation
6 Phony compiler for testing SCons.
8 Copies its source file to the target file, dropping lines that match
9 a pattern, so we can recognize the tool has made a modification.
11 The first argument is the language (cc, c__, g77, etc.).
13 Recognizes a -x option to append the language to 'mygcc.out'
16 Intended for use as $CC, $CXX, etc.
24 # The gcc tool has this comment:
25 #> is executable, and is a GNU compiler (or accepts '--version' at least)
26 # So to pretend to be gcc, we need to recognize. Parrot what
27 # test/CC/CCVERSION-fixture/versioned.py does.
28 if '-dumpversion' in sys
.argv
:
31 if '--version' in sys
.argv
:
32 print('this is version 2.9.9 with extra text')
35 compiler
= sys
.argv
[1].encode('utf-8')
36 opts
, args
= getopt
.getopt(sys
.argv
[2:], 'co:xf:K:')
41 with
open('mygcc.out', 'ab') as logfile
:
42 logfile
.write(compiler
+ b
"\n")
44 with
open(out
, 'wb') as ofp
, open(args
[0], 'rb') as ifp
:
46 if not line
.startswith(b
'#' + compiler
):
49 if __name__
== '__main__':