Merged revisions 2136-2200,2202-2290,2292-2301 via svnmerge from
[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 os
32 import string
33 import sys
34
35 import TestSCons
36
37 _python_ = TestSCons._python_
38 _exe   = TestSCons._exe
39
40 test = TestSCons.TestSCons()
41
42 if sys.platform != 'win32':
43     test.skip_test("Skipping ml test on non-win32 platform '%s'\n" % sys.platform)
44
45 ml = test.where_is('ml')
46
47 if not ml:
48     test.skip_test("ml not found; skipping test\n")
49
50 test.write("wrapper.py",
51 """import os
52 import string
53 import sys
54 open('%s', 'wb').write("wrapper.py\\n")
55 os.system(string.join(sys.argv[1:], " "))
56 """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
57
58 test.write('SConstruct', """
59 import os
60 ccc = Environment(tools = ['msvc', 'mslink', 'masm'],
61                   ASFLAGS = '/nologo /coff')
62 ccc['ENV']['PATH'] = ccc['ENV']['PATH'] + os.pathsep + os.environ['PATH']
63 ddd = ccc.Clone(AS = r'%(_python_)s wrapper.py ' + ccc['AS'])
64 ccc.Program(target = 'ccc', source = ['ccc.asm', 'ccc_main.c'])
65 ddd.Program(target = 'ddd', source = ['ddd.asm', 'ddd_main.c'])
66 """ % locals())
67
68 test.write('ccc.asm', 
69 """
70 DSEG    segment
71         PUBLIC _name
72 _name   byte "ccc.asm",0
73 DSEG    ends
74         end
75 """)
76
77 test.write('ddd.asm', 
78 """        
79 DSEG    segment
80         PUBLIC _name
81 _name   byte "ddd.asm",0
82 DSEG    ends
83         end
84 """)
85
86 test.write('ccc_main.c', r"""
87 extern char name[];
88
89 int
90 main(int argc, char *argv[])
91 {
92         argv[argc++] = "--";
93         printf("ccc_main.c %s\n", name);
94         exit (0);
95 }
96 """)
97
98 test.write('ddd_main.c', r"""
99 extern char name[];
100
101 int
102 main(int argc, char *argv[])
103 {
104         argv[argc++] = "--";
105         printf("ddd_main.c %s\n", name);
106         exit (0);
107 }
108 """)
109
110 test.run(arguments = 'ccc' + _exe, stderr = None)
111
112 test.run(program = test.workpath('ccc'), stdout =  "ccc_main.c ccc.asm\n")
113
114 test.must_not_exist('wrapper.out')
115
116 test.run(arguments = 'ddd' + _exe)
117
118 test.run(program = test.workpath('ddd'), stdout =  "ddd_main.c ddd.asm\n")
119
120 test.must_match('wrapper.out', "wrapper.py\n")
121
122
123
124 test.pass_test()