File: build.the

package info (click to toggle)
the 3.1-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,452 kB
  • ctags: 5,268
  • sloc: ansic: 63,118; sh: 2,399; makefile: 444
file content (218 lines) | stat: -rw-r--r-- 7,501 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/*
$Id: build.the,v 1.1 2001/01/04 09:39:58 mark Exp $
*/
/***********************************************************************
 * Function:  REXX macro to simulate an Integrated Development
 *            Environment (IDE).
 * Syntax:    BUILD env
 * Notes:     This macro is an attempt at building an IDE using THE
 *            as the engine.
 *            Based on various settings, the macro executes the
 *            specified "make" process, captures the output in a
 *            file; make.log. The macro reads this file and parses 
 *            each line to determine the filename, line number (and 
 *            column if applicable) and error message. The macro
 *            edits each file with an error and each line in the file
 *            is given a name associated with the error message.       
 *            The screen is split into two screens with the error
 *            messages file in the top half, and other files in the
 *            bottom half. 
 *            The macro then goes into an infinite loop reading
 *            keystrokes from the user via READV KEY until the exit
 *            key is hit.  When the cursor is positioned in the
 *            error file and the "show error" key is hit, the macro
 *            parses the line to determine which file to edit and
 *            which line/column to position the cursor on.
 *            Normal editing is possible while in this macro,
 *            although the user will notice significant response
 *            delays.  Also note that while in this macro, the
 *            current directory is set to the value specified in
 *            SCM_MAKE_DIR.
 *            Before this macro can execute the following THE EDITV 
 *            variables must be set:
 *            SCM_KEY_EXIT       - the name of the key which will exit
 *                                 this macro.
 *            SCM_KEY_SHOW1      - the name of a key which will show
 *                                 the error line.
 *            SCM_KEY_SHOW2      - the name of a key which will show
 *                                 the error line.
 *            SCM_LOG_FILE       - the name of the file containing
 *                                 the output from SCM_MAKE_COMMAND
 *            SCM_MAKE_COMMAND   - the operating system command that
 *                                 will generate the appropriate error
 *                                 messages; usually "make" etc.
 *            SCM_MAKE_DIR       - the fully qualified directory from
 *                                 which this macro is to run.  Be
 *                                 careful to get this correct as most
 *                                 compilers display file names of files
 *                                 with compilation errors as relative
 *                                 path names.
 *            SCM_ERROR_FORMAT   - the parse template which defines
 *                                 the format of error messages.
 *            SCM_WARNING_FORMAT - the parse template which defines
 *                                 the format of warning messages.
 *            SCM_ERROR_LINES    - the number of lines to set the error
 *                                 window to..
 ***********************************************************************/
Trace o
Parse Arg make_flags
pos = Wordpos('-w',make_flags)
If pos \= 0 Then
   Do
      check_warnings = 'Y'
      make_flags = Delword(make_flags,pos)
   End
reqvars = "SCM_KEY_EXIT SCM_KEY_SHOW1 SCM_KEY_SHOW2 SCM_LOG_FILE SCM_MAKE_COMMAND SCM_MAKE_DIR SCM_ERROR_FORMAT SCM_WARNING_FORMAT SCM_ERROR_LINES"
'EDITV GET' reqvars
Do i = 1 To Words(reqvars)
   If Value(Word(reqvars,i)) = '' Then
      Do
         'emsg The EDITV variable;' Word(reqvars,i) 'has not been set'
         Return
      End
End

'width 32000'

here = Stream('.', 'C', 'QUERY EXISTS')

If Chdir(SCM_MAKE_DIR) \= 0 Then
   Do
      'emsg Unable to change directory to' SCM_MAKE_DIR
      Return
   End

'msg Running' '"'SCM_MAKE_COMMAND'"' 'in' SCM_MAKE_DIR
'osredir' SCM_LOG_FILE SCM_MAKE_COMMAND make_flags
rrc = rc
num_errors = 0
num_warnings = 0
'XEDIT' SCM_LOG_FILE
'EDITV SETFL SCM_THE_LOG_FILE Y'
':1'
first_error_line = 0
Do Forever
   'EXTRACT /CURLINE/LINE'
   line = curline.3
   If FormatMatch(line,SCM_WARNING_FORMAT) = 'N' Then
       Do
          If FormatMatch(line,SCM_ERROR_FORMAT) = 'Y' Then
             Do
                If first_error_line = 0 Then first_error_line = line.1
                Call setline !line, !fn
                num_errors = num_errors + 1
             End
       End
   If check_warnings = 'Y' Then
      Do
         If FormatMatch(line,SCM_WARNING_FORMAT) = 'Y' Then
            Do
               If first_error_line = 0 Then first_error_line = line.1
               Call setline !line, !fn
               num_warnings = num_warnings + 1
            End
      End
   'n'
   If rc \= 0 Then Leave
End
num_errs = num_errors + num_warnings
If num_errs = 0 & rrc = 0 Then
   Do
      'msg No errors'
      Call cleanup
      Return
   End

'XEDIT' SCM_LOG_FILE
'EXTRACT /LSCREEN/STATUSLINE'
If statusline.1 = 'BOTTOM' | statusline.1 = 'TOP' Then lines2 = lscreen.5 - SCM_ERROR_LINES - 1
Else lines2 = lscreen.5 - SCM_ERROR_LINES
'SCREEN SIZE' SCM_ERROR_LINES lines2
'SET PREFIX OFF'
'SET COLOR IDLINE red on white'
'RESERVED 1' Centre('Press' SCM_KEY_EXIT 'to leave macro', lscreen.6())

msg = num_errors 'errors'
If check_warnings = 'Y' Then msg = msg num_warnings 'warnings'
If num_errs = 0 Then 'msg "'SCM_MAKE_COMMAND'" failed'
Else 'msg' msg 'identified'

'cursor home'
':'||first_error_line

Do Forever
   'readv key'
   Select
      When readv.1 = SCM_KEY_EXIT Then Leave
      When readv.1 = SCM_KEY_SHOW1 | readv.1 = SCM_KEY_SHOW2 Then
         Do
/*          If fpath.1()||filename.1() = SCM_LOG_FILE & \incommand() & \inprefix() Then */
            'EDITV GETF SCM_THE_LOG_FILE'
            If SCM_THE_LOG_FILE = 'Y' & \incommand() & \inprefix() Then
               Do
                  'EXTRACT /CURLINE'
                  line = curline.3
                  If FormatMatch(line,SCM_WARNING_FORMAT) = 'N' Then
                     Do
                        If FormatMatch(line,SCM_ERROR_FORMAT) = 'Y' Then Call show_err !line, !column, !fn
                     End
                  If check_warnings = 'Y' Then
                     Do
                        If FormatMatch(line,SCM_WARNING_FORMAT) = 'Y' Then Call show_err !line, !column, !fn
                     End
               End
            Else
               Do
                  'hit' readv.1
                  If rc \= 0 Then Leave
               End
         End
      Otherwise 
         Do
            'hit' readv.1
            If rc \= 0 Then Leave
         End
   End
End
Call cleanup
Return

FormatMatch:
Parse Arg myline, fmt
pc = 'Parse Var myline' fmt
Interpret pc
If Datatype(!line) = 'NUM' & !fn \= '' & !msg \= '' Then Return 'Y'
Else Return 'N'
Return

cleanup:
'scr 1'
'x' SCM_LOG_FILE
'nomsg reserved 1 off'
'qq'
Call Chdir(here)
Return

show_err: Procedure
Parse Arg lineno, col, fn
'nextw'
'x' Strip(fn)
If incommand() Then 'cursor home'
'nomsg locate .l' || Strip(lineno)
If rc > 1 Then
  Do
    'nextw'
    'msg Original line:' lineno 'no longer exists'
  End
If Datatype(col) = 'NUM' Then 'cl :' || Strip(col)
Return

setline: Procedure Expose SCM_LOG_FILE
Parse Arg lineno, fn
'x' fn
'EXTRACT /LINE'
':'||lineno
'set point .l'||lineno
':'||line.1
'x' SCM_LOG_FILE
Return