Commit | Line | Data |
---|---|---|
82704155 | 1 | # Copyright (C) 2001-2019 Free Software Foundation, Inc. |
64e08727 DD |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
32866df7 | 5 | # the Free Software Foundation; either version 3 of the License, or |
64e08727 DD |
6 | # (at your option) any later version. |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program; if not, write to the Free Software | |
b43b5d5f | 15 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
64e08727 DD |
16 | |
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-dejagnu@prep.ai.mit.edu | |
19 | ||
20 | # Written by DJ Delorie <dj@redhat.com> | |
21 | ||
11a6da56 NC |
22 | if {![istarget "i*86-*-*"] && ![istarget "x86_64-*-mingw*"] && ![istarget "x86_64-*-cygwin"] } { |
23 | verbose "Not a Cygwin/Mingw target" 1 | |
64e08727 DD |
24 | return |
25 | } | |
26 | ||
27 | if {![info exists WINDRES]} then { | |
11a6da56 | 28 | verbose "WINDRES not defined" 1 |
64e08727 DD |
29 | return |
30 | } | |
31 | ||
32 | if {[which $WINDRES] == 0} then { | |
11a6da56 | 33 | verbose "$WINDRES not found" 1 |
64e08727 DD |
34 | return |
35 | } | |
36 | ||
37 | set wr "$WINDRES --include-dir $srcdir/$subdir" | |
38 | ||
39 | if [file exists "$srcdir/../../winsup/w32api/include"] { | |
40 | set wr "$wr --include-dir $srcdir/../../winsup/w32api/include" | |
41 | } else { | |
42 | send_log "\nWarning: Assuming windres can find the win32 headers\n\n" | |
43 | } | |
44 | ||
45 | set res_list [lsort [glob -nocomplain $srcdir/$subdir/*.rc]] | |
46 | ||
47 | proc oneline { file } { | |
48 | while { 1 } { | |
49 | if { [gets $file line] == -1 } { | |
50 | return "" | |
51 | } | |
52 | if [regexp "^ \[0-9a-z\]\[0-9a-z\]* " $line] { | |
53 | return $line | |
54 | } | |
55 | } | |
56 | } | |
57 | ||
58 | foreach res $res_list { | |
59 | set sroot [file rootname $res] | |
60 | set broot [file tail $sroot] | |
61 | set done 0 | |
ec25acb3 | 62 | set cpp_opts "" |
64e08727 DD |
63 | |
64 | set rc [open $res] | |
65 | while { [gets $rc line] != -1 } { | |
66 | if ![regexp "^(//|/\*|#)" $line] { | |
67 | break | |
68 | } | |
69 | if [regexp "\[xp\]fail *(\[^ \]*)" $line junk sys] { | |
70 | setup_xfail $sys | |
8d263650 | 71 | continue |
64e08727 | 72 | } |
ec25acb3 NC |
73 | if [regexp "cpparg *(\[^ \]*)" $line junk cppopt] { |
74 | set cpp_opts "--preprocessor-arg \"$cppopt\"" | |
75 | continue | |
76 | } | |
64e08727 DD |
77 | } |
78 | ||
85eb5110 | 79 | verbose "$wr -J rc -O res $res tmpdir/$broot.res" 1 |
ec25acb3 | 80 | catch "exec $wr $cpp_opts -J rc -O res $res tmpdir/$broot.res" err |
64e08727 DD |
81 | |
82 | if ![string match "" $err] then { | |
83 | send_log "$err\n" | |
84 | verbose "$err" 1 | |
1e1c6a43 AM |
85 | if [string match "*windows.h: No such file*" $err] then { |
86 | unsupported "windres/$broot (parse)" | |
87 | } else { | |
88 | fail "windres/$broot (parse)" | |
89 | } | |
8d263650 | 90 | continue |
64e08727 DD |
91 | } |
92 | pass "windres/$broot (parse)" | |
93 | ||
94 | set rc [open $res] | |
95 | while { [gets $rc line] != -1 } { | |
96 | if ![regexp "^(//|/\*|#)" $line] { | |
97 | break | |
98 | } | |
99 | if [regexp "parse-only" $line] { | |
100 | file delete "tmpdir/$broot.res" | |
101 | set done 1 | |
8d263650 | 102 | break |
64e08727 DD |
103 | } |
104 | if [regexp "\[xc\]fail *(\[^ \]*)" $line junk sys] { | |
105 | setup_xfail $sys | |
8d263650 | 106 | continue |
64e08727 DD |
107 | } |
108 | } | |
109 | if { $done != 0 } { | |
8d263650 | 110 | continue |
64e08727 DD |
111 | } |
112 | ||
113 | verbose "$OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" 1 | |
114 | catch "exec $OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" err | |
115 | ||
116 | if ![string match "" $err] then { | |
117 | send_log "$err\n" | |
118 | verbose "$err" 1 | |
119 | fail "windres/$broot (compare)" | |
8d263650 | 120 | continue |
64e08727 DD |
121 | } |
122 | ||
123 | set pat [open "$sroot.rsd"] | |
124 | set out [open "tmpdir/$broot.dump"] | |
125 | set patline "foo" | |
126 | ||
127 | while { ![string match $patline ""] } { | |
128 | set patline [oneline $pat] | |
129 | set outline [oneline $out] | |
130 | ||
131 | if ![string match $patline $outline] { | |
8d263650 BE |
132 | send_log "< $patline\n" |
133 | send_log "> $outline\n" | |
134 | fail "windres/$broot (compare)" | |
64e08727 | 135 | set done 1 |
8d263650 | 136 | break |
64e08727 DD |
137 | } |
138 | } | |
139 | if { $done == 0 } { | |
140 | pass "windres/$broot (compare)" | |
141 | file delete "tmpdir/$broot.res" | |
142 | file delete "tmpdir/$broot.dump" | |
143 | } | |
144 | } | |
11a6da56 NC |
145 | |
146 | # Test objdump -p | |
147 | ||
148 | if {[which $OBJDUMP] == 0} then { | |
149 | unsupported "objdump -p" | |
150 | return | |
151 | } | |
152 | ||
153 | verbose "$wr $cpp_opts -J rc $srcdir/$subdir/version.rc tmpdir/version.o" 1 | |
154 | catch "exec $wr $cpp_opts -J rc $srcdir/$subdir/version.rc tmpdir/version.o" err | |
155 | ||
156 | if ![string match "" $err] then { | |
157 | send_log "$err\n" | |
158 | verbose "$err" 1 | |
159 | if [string match "*windows.h: No such file*" $err] then { | |
160 | unsupported "objdump -p (no header files found)" | |
161 | } else { | |
162 | fail "objdump -p (build)" | |
163 | } | |
164 | continue | |
165 | } | |
166 | ||
167 | set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -p tmpdir/version.o"] | |
168 | ||
169 | # FIXME: We should extend this regexp to check for more information. | |
170 | set want ".*The .rsrc Resource Directory section.*Type Table:.*Entry: ID:.*Name Table:.*Entry: ID:.*Language Table:.*Entry: ID:.*" | |
171 | ||
172 | if ![regexp $want $got] then { | |
173 | fail "objdump -p" | |
174 | } else { | |
175 | pass "objdump -p" | |
176 | } | |
177 | ||
178 | # file delete "tmpdir/version.o" |