Move 2.0 changes collected in branches/pending back to trunk for further
[scons.git] / test / AS / ml.py
1 #!/usr/bin/env python
2 #
3 # __COPYRIGHT__
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #
24
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26
27 """
28 Verify correct use of the live 'ml' assembler.
29 """
30
31 import sys
32
33 import TestSCons
34
35 _python_ = TestSCons._python_
36 _exe   = TestSCons._exe
37
38 test = TestSCons.TestSCons()
39
40 if sys.platform != 'win32':
41     test.skip_test("Skipping ml test on non-win32 platform '%s'\n" % sys.platform)
42
43 ml = test.where_is('ml')
44
45 if not ml:
46     test.skip_test("ml not found; skipping test\n")
47
48 test.write("wrapper.py",
49 """import os
50 import sys
51 open('%s', 'wb').write("wrapper.py\\n")
52 os.system(" ".join(sys.argv[1:]))
53 """ % test.workpath('wrapper.out').replace('\\', '\\\\'))
54
55 test.write('SConstruct', """
56 import os
57 ccc = Environment(tools = ['msvc', 'mslink', 'masm'],
58                   ASFLAGS = '/nologo /coff')
59 ccc['ENV']['PATH'] = ccc['ENV']['PATH'] + os.pathsep + os.environ['PATH']
60 ddd = ccc.Clone(AS = r'%(_python_)s wrapper.py ' + ccc['AS'])
61 ccc.Program(target = 'ccc', source = ['ccc.asm', 'ccc_main.c'])
62 ddd.Program(target = 'ddd', source = ['ddd.asm', 'ddd_main.c'])
63 """ % locals())
64
65 test.write('ccc.asm', 
66 """
67 DSEG    segment
68         PUBLIC _name
69 _name   byte "ccc.asm",0
70 DSEG    ends
71         end
72 """)
73
74 test.write('ddd.asm', 
75 """        
76 DSEG    segment
77         PUBLIC _name
78 _name   byte "ddd.asm",0
79 DSEG    ends
80         end
81 """)
82
83 test.write('ccc_main.c', r"""
84 extern char name[];
85
86 int
87 main(int argc, char *argv[])
88 {
89         argv[argc++] = "--";
90         printf("ccc_main.c %s\n", name);
91         exit (0);
92 }
93 """)
94
95 test.write('ddd_main.c', r"""
96 extern char name[];
97
98 int
99 main(int argc, char *argv[])
100 {
101         argv[argc++] = "--";
102         printf("ddd_main.c %s\n", name);
103         exit (0);
104 }
105 """)
106
107 test.run(arguments = 'ccc' + _exe, stderr = None)
108
109 test.run(program = test.workpath('ccc'), stdout =  "ccc_main.c ccc.asm\n")
110
111 test.must_not_exist('wrapper.out')
112
113 test.run(arguments = 'ddd' + _exe)
114
115 test.run(program = test.workpath('ddd'), stdout =  "ddd_main.c ddd.asm\n")
116
117 test.must_match('wrapper.out', "wrapper.py\n")
118
119
120
121 test.pass_test()
122
123 # Local Variables:
124 # tab-width:4
125 # indent-tabs-mode:nil
126 # End:
127 # vim: set expandtab tabstop=4 shiftwidth=4: