1 | #------------------------------------------------------------------------------- |
---|
2 | # Copyright (C) 2006-2021 British Crown (Met Office) & Contributors. |
---|
3 | # |
---|
4 | # This file is part of FCM, tools for managing and building source code. |
---|
5 | # |
---|
6 | # FCM is free software: you can redistribute it and/or modify |
---|
7 | # it under the terms of the GNU General Public License as published by |
---|
8 | # the Free Software Foundation, either version 3 of the License, or |
---|
9 | # (at your option) any later version. |
---|
10 | # |
---|
11 | # FCM is distributed in the hope that it will be useful, |
---|
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | # GNU General Public License for more details. |
---|
15 | # |
---|
16 | # You should have received a copy of the GNU General Public License |
---|
17 | # along with FCM. If not, see <http://www.gnu.org/licenses/>. |
---|
18 | #------------------------------------------------------------------------------- |
---|
19 | use strict; |
---|
20 | use warnings; |
---|
21 | #------------------------------------------------------------------------------- |
---|
22 | |
---|
23 | package FCM::Context::Event; |
---|
24 | use base qw{FCM::Class::HASH}; |
---|
25 | |
---|
26 | use constant { |
---|
27 | CM_ABORT => 'CM_ABORT', |
---|
28 | CM_BRANCH_CREATE_SOURCE => 'CM_BRANCH_CREATE_SOURCE', |
---|
29 | CM_BRANCH_LIST => 'CM_BRANCH_LIST', |
---|
30 | CM_COMMIT_MESSAGE => 'CM_COMMIT_MESSAGE', |
---|
31 | CM_CONFLICT_TEXT => 'CM_CONFLICT_TEXT', |
---|
32 | CM_CONFLICT_TEXT_SKIP => 'CM_CONFLICT_TEXT_SKIP', |
---|
33 | CM_CONFLICT_TREE => 'CM_CONFLICT_TREE', |
---|
34 | CM_CONFLICT_TREE_SKIP => 'CM_CONFLICT_TREE_SKIP', |
---|
35 | CM_CONFLICT_TREE_TIME_WARN => 'CM_CONFLICT_TREE_TIME_WARN', |
---|
36 | CM_CREATE_TARGET => 'CM_CREATE_TARGET', |
---|
37 | CM_LOG_EDIT => 'CM_LOG_EDIT', |
---|
38 | #CM_WC_STATUS => 'CM_WC_STATUS', |
---|
39 | #CM_WC_STATUS_PATH => 'CM_WC_STATUS_PATH', |
---|
40 | CONFIG_OPEN => 'CONFIG_OPEN', |
---|
41 | CONFIG_ENTRY => 'CONFIG_ENTRY', |
---|
42 | CONFIG_VAR_UNDEF => 'CONFIG_VAR_UNDEF', |
---|
43 | E => 'E', |
---|
44 | EXPORT_ITEM_CREATE => 'EXPORT_ITEM_CREATE', |
---|
45 | EXPORT_ITEM_DELETE => 'EXPORT_ITEM_DELETE', |
---|
46 | FCM_VERSION => 'FCM_VERSION', |
---|
47 | KEYWORD_ENTRY => 'KEYWORD_ENTRY', |
---|
48 | OUT => 'OUT', |
---|
49 | MAKE_BUILD_SHELL_OUT => 'MAKE_BUILD_SHELL_OUT', |
---|
50 | MAKE_BUILD_SOURCE_ANALYSE => 'MAKE_BUILD_SOURCE_ANALYSE', |
---|
51 | MAKE_BUILD_SOURCE_SUMMARY => 'MAKE_BUILD_SOURCE_SUMMARY', |
---|
52 | MAKE_BUILD_TARGET_DONE => 'MAKE_BUILD_TARGET_DONE', |
---|
53 | MAKE_BUILD_TARGET_FAIL => 'MAKE_BUILD_TARGET_FAIL', |
---|
54 | MAKE_BUILD_TARGET_FROM_NS => 'MAKE_BUILD_TARGET_FROM_NS', |
---|
55 | MAKE_BUILD_TARGET_MISSING_DEP => 'MAKE_BUILD_TARGET_MISSING_DEP', |
---|
56 | MAKE_BUILD_TARGET_SELECT => 'MAKE_BUILD_TARGET_SELECT', |
---|
57 | MAKE_BUILD_TARGET_SELECT_TIMER=> 'MAKE_BUILD_TARGET_SELECT_TIMER', |
---|
58 | MAKE_BUILD_TARGET_STACK => 'MAKE_BUILD_TARGET_STACK', |
---|
59 | MAKE_BUILD_TARGET_SUMMARY => 'MAKE_BUILD_TARGET_SUMMARY', |
---|
60 | MAKE_BUILD_TARGET_TASK_SUMMARY=> 'MAKE_BUILD_TARGET_TASK_SUMMARY', |
---|
61 | MAKE_BUILD_TARGETS_FAIL => 'MAKE_BUILD_TARGETS_FAIL', |
---|
62 | MAKE_DEST => 'MAKE_DEST', |
---|
63 | MAKE_EXTRACT_PROJECT_TREE => 'MAKE_EXTRACT_PROJECT_TREE', |
---|
64 | MAKE_EXTRACT_RUNNER_SUMMARY => 'MAKE_EXTRACT_RUNNER_SUMMARY', |
---|
65 | MAKE_EXTRACT_SYMLINK => 'MAKE_EXTRACT_SYMLINK', |
---|
66 | MAKE_EXTRACT_TARGET => 'MAKE_EXTRACT_TARGET', |
---|
67 | MAKE_EXTRACT_TARGET_SUMMARY => 'MAKE_EXTRACT_TARGET_SUMMARY', |
---|
68 | MAKE_MIRROR => 'MAKE_MIRROR', |
---|
69 | SHELL => 'SHELL', |
---|
70 | TASK_WORKERS => 'TASK_WORKERS', |
---|
71 | TIMER => 'TIMER', |
---|
72 | }; |
---|
73 | |
---|
74 | __PACKAGE__->class({args => '@', code => '$'}); |
---|
75 | |
---|
76 | #------------------------------------------------------------------------------- |
---|
77 | 1; |
---|
78 | __END__ |
---|
79 | |
---|
80 | =head1 NAME |
---|
81 | |
---|
82 | FCM::Context::Event |
---|
83 | |
---|
84 | =head1 SYNOPSIS |
---|
85 | |
---|
86 | use FCM::Context::Event; |
---|
87 | my $event_ctx = FCM::Context::Event->new($code, @args); |
---|
88 | |
---|
89 | =head1 DESCRIPTION |
---|
90 | |
---|
91 | An instance of this class represents the context of an event. This class is a |
---|
92 | sub-class of L<FCM::Class::HASH|FCM::Class::HASH>. |
---|
93 | |
---|
94 | =head1 ATTRIBUTES |
---|
95 | |
---|
96 | =over 4 |
---|
97 | |
---|
98 | =item args |
---|
99 | |
---|
100 | An ARRAY reference that represents the additional arguments/contexts of the |
---|
101 | event. |
---|
102 | |
---|
103 | =item code |
---|
104 | |
---|
105 | The event code. See below |
---|
106 | |
---|
107 | =back |
---|
108 | |
---|
109 | =head1 EVENTS |
---|
110 | |
---|
111 | The following is a list of event codes. |
---|
112 | |
---|
113 | =over 4 |
---|
114 | |
---|
115 | =item FCM::Context::Event->CM_ABORT |
---|
116 | |
---|
117 | This event is raised when a code management command aborts. The 1st argument |
---|
118 | should be either "user" (user abort) or "null" (null command). |
---|
119 | |
---|
120 | =item FCM::Context::Event->CM_BRANCH_CREATE_SOURCE |
---|
121 | |
---|
122 | This event is raised to notify the source of a branch create. The 1st argument |
---|
123 | should be the expected source URL, and the 2nd argument is the specified peg |
---|
124 | revision. |
---|
125 | |
---|
126 | =item FCM::Context::Event->CM_BRANCH_LIST |
---|
127 | |
---|
128 | This event is raised when doing a branch listing. The 1st argument should be the |
---|
129 | project location and the rest of the arguments are the branches discovered. |
---|
130 | |
---|
131 | =item FCM::Context::Event->CM_COMMIT_MESSAGE |
---|
132 | |
---|
133 | This event is raised to notify the user the log message to be used for a commit. |
---|
134 | The 1st argument of the event should be an instance of |
---|
135 | FCM::System::CM::CommitMessage::State. |
---|
136 | |
---|
137 | =item FCM::Context::Event->CM_CONFLICT_TEXT |
---|
138 | |
---|
139 | This event is raised to notify the path of a file with a text conflict. |
---|
140 | |
---|
141 | =item FCM::Context::Event->CM_CONFLICT_TEXT_SKIP |
---|
142 | |
---|
143 | This event is raised to notify the path of a file with a text conflict that |
---|
144 | cannot be resolved using a merge tool. E.g. it may be a binary file. |
---|
145 | |
---|
146 | =item FCM::Context::Event->CM_CONFLICT_TREE |
---|
147 | |
---|
148 | This event is raised to notify the path of a node with a tree conflict. |
---|
149 | |
---|
150 | =item FCM::Context::Event->CM_CONFLICT_TREE_SKIP |
---|
151 | |
---|
152 | This event is raised to notify the path of a node with a tree conflict that |
---|
153 | cannot be resolved automatically under current functionality. For example, it |
---|
154 | may be a directory containing multiple conflicts. |
---|
155 | |
---|
156 | =item FCM::Context::Event->CM_CREATE_TARGET |
---|
157 | |
---|
158 | This event is raised to notify the target of a newly created URL. The 1st argument |
---|
159 | should be the target URL. |
---|
160 | |
---|
161 | =item FCM::Context::Event->CM_LOG_EDIT |
---|
162 | |
---|
163 | This event is raised before the system launches an editor to edit a commit log |
---|
164 | message. The 1st argument of the event should be the editor command. |
---|
165 | |
---|
166 | =item FCM::Context::Event->CONFIG_ENTRY |
---|
167 | |
---|
168 | This entry is raised to notify the reading of a configuration file entry. The |
---|
169 | 1st argument should be a blessed reference of a |
---|
170 | L<FCM::Context::ConfigEntry|FCM::Context::ConfigEntry>. The second argument |
---|
171 | should be a boolean flag to indicate whether this entry is in FCM 1 format or |
---|
172 | not. |
---|
173 | |
---|
174 | =item FCM::Context::Event->CONFIG_OPEN |
---|
175 | |
---|
176 | This event is raised when a new configuration file is opened for reading. The |
---|
177 | 1st argument of this event is an ARRAY that represents the include file stack, |
---|
178 | where the last element is the top of the stack. Each element of the stack is a |
---|
179 | 2-element ARRAY reference, where the first element is a |
---|
180 | L<FCM::Context::Locator|FCM::Context::Locator> object and the second element is |
---|
181 | the line number. (At the top of the stack, the line number is set to 0.) The 2nd |
---|
182 | optional argument of this event is a number to adjust the verbosity level of the |
---|
183 | event. |
---|
184 | |
---|
185 | =item FCM::Context::Event->CONFIG_VAR_UNDEF |
---|
186 | |
---|
187 | This event is raised when a variable is undefined. The arguments of this event |
---|
188 | contain 2 elements. The 1st element is the configuration entry as a blessed |
---|
189 | reference of L<FCM::Context::ConfigEntry|FCM::Context::ConfigEntry>. The 2nd |
---|
190 | element is the name of the variable. |
---|
191 | |
---|
192 | =item FCM::Context::Event->E |
---|
193 | |
---|
194 | This event is raised when to notify an exception. The 1st argument of this event |
---|
195 | should be the exception. |
---|
196 | |
---|
197 | =item FCM::Context::Event->EXPORT_ITEM_CREATE |
---|
198 | |
---|
199 | This event is raised when the export-items system creates a link to an item. |
---|
200 | The 1st argument is the namespace of the item, the 2nd argument is the revision |
---|
201 | of the item and the 3rd argument is the name of the link. |
---|
202 | |
---|
203 | =item FCM::Context::Event->EXPORT_ITEM_DELETE |
---|
204 | |
---|
205 | This event is raised when the export-items system deletes a link to an item. |
---|
206 | The 1st argument is the namespace of the item, the 2nd argument is the revision |
---|
207 | of the item and the 3rd argument is the name of the link. |
---|
208 | |
---|
209 | =item FCM::Context::Event->FCM_VERSION |
---|
210 | |
---|
211 | This event is raised to notify the FCM version. |
---|
212 | |
---|
213 | =item FCM::Context::Event->KEYWORD_ENTRY |
---|
214 | |
---|
215 | This event is raised to notify a keyword entry. The 1st argument is the keyword |
---|
216 | entry as a blessed reference of FCM::Context::Keyword::Entry as described in |
---|
217 | L<FCM::Context::Keyword|FCM::Context::Keyword>. |
---|
218 | |
---|
219 | =item FCM::Context::Event->MAKE_BUILD_SHELL_OUT |
---|
220 | |
---|
221 | This event is raised to notify (shell command) output from make/build. The 1st |
---|
222 | argument should be the STDOUT, and the 2nd argument should be the STDERR. |
---|
223 | |
---|
224 | =item FCM::Context::Event->MAKE_BUILD_SOURCE_ANALYSE |
---|
225 | |
---|
226 | This event is raised when the make/build system has analysed a source file. The |
---|
227 | 1st argument should be a blessed reference of FCM::Context::Make::Build::Source |
---|
228 | as described in L<FCM::Context::Make::Build|FCM::Context::Make::Build>. The 2nd |
---|
229 | argument should be the time it takes for the analysis. |
---|
230 | |
---|
231 | =item FCM::Context::Event->MAKE_BUILD_SOURCE_SUMMARY |
---|
232 | |
---|
233 | This event is raised when the make/build system has analysed all its source |
---|
234 | files. The 1st argument should be the total number of files. The 2nd argument |
---|
235 | should be the number analysed. The 3rd argument should be the elapsed time. The |
---|
236 | 4th argument should be the total time, which may differ from the elapsed time if |
---|
237 | the analysis is run on more than 1 process. |
---|
238 | |
---|
239 | =item FCM::Context::Event->MAKE_BUILD_TARGET_DONE |
---|
240 | |
---|
241 | This event is raised when the make/build system has successfully updated a |
---|
242 | target or an update is unnecessary. The 1st argument is the target (as an |
---|
243 | instance of FCM::Context::Make::Build::Target), the 2nd argument is the elapsed |
---|
244 | time of the update, if relevant. |
---|
245 | |
---|
246 | =item FCM::Context::Event->MAKE_BUILD_TARGET_FAIL |
---|
247 | |
---|
248 | This event is raised when the make/build system failed to update a target or the |
---|
249 | target is failed by its dependencies. The 1st argument is the target (as an |
---|
250 | instance of FCM::Context::Make::Build::Target), the 2nd argument is the elapsed |
---|
251 | time, if the target is failed by its update. |
---|
252 | |
---|
253 | =item FCM::Context::Event->MAKE_BUILD_TARGET_FROM_NS |
---|
254 | |
---|
255 | This event is raised when the make/build system has generated a build target |
---|
256 | from a source or a source name-space. The arguments are: source/target |
---|
257 | namespace, target task, target category, and the target key. |
---|
258 | |
---|
259 | =item FCM::Context::Event->MAKE_BUILD_TARGET_MISSING_DEP |
---|
260 | |
---|
261 | This event is raised when the make/build system has discarded a missing |
---|
262 | dependency from a target. The 1st argument is the target ID, the 2nd argument is |
---|
263 | the dependency ID, and the 3rd argument is the dependency type. |
---|
264 | |
---|
265 | =item FCM::Context::Event->MAKE_BUILD_TARGET_SELECT |
---|
266 | |
---|
267 | This event is raised when the make/build system has selected a set of targets to |
---|
268 | build. The 1st argument is a HASH reference of the target set. |
---|
269 | |
---|
270 | =item FCM::Context::Event->MAKE_BUILD_TARGET_SELECT_TIMER |
---|
271 | |
---|
272 | This event is raised when the make/build system has completed the target select |
---|
273 | and dependency tree analysis. The only argument is the elapsed time. |
---|
274 | |
---|
275 | =item FCM::Context::Event->MAKE_BUILD_TARGET_STACK |
---|
276 | |
---|
277 | This event is raised when make/build system checks a target for cyclic |
---|
278 | dependency. The 1st argument is the key of the task. The 2nd argument is rank |
---|
279 | of the task in the dependency hierarchy. The 3rd argument is the number of |
---|
280 | dependencies the task has if the task has already been checked, or undef if this |
---|
281 | is the first check for the task. |
---|
282 | |
---|
283 | =item FCM::Context::Event->MAKE_BUILD_TARGET_SUMMARY |
---|
284 | |
---|
285 | This event is raised when the make/build system has finished updating its |
---|
286 | targets, and is ready to give a total summary. The 1st argument is the number of |
---|
287 | modified targets, the 2nd argument is the number unchanged, the 3rd argument is |
---|
288 | the number failed, the 4th argument is the elapsed time. |
---|
289 | |
---|
290 | =item FCM::Context::Event->MAKE_BUILD_TARGET_TASK_SUMMARY |
---|
291 | |
---|
292 | This event is raised when the make/build system has finished updating its |
---|
293 | targets, and is ready to give a summary of each type of task. The 1st argument |
---|
294 | is the task type name, the 2nd argument is the number of modified targets, the |
---|
295 | 3rd argument is the number unchanged, the 4th argument is the number failed, and |
---|
296 | the 5th argument is the total time spent on this task type. |
---|
297 | |
---|
298 | =item FCM::Context::Event->MAKE_BUILD_TARGETS_FAIL |
---|
299 | |
---|
300 | This event is raised when the make/build system has finished updating its |
---|
301 | targets, but some targets failed to update. The 1st argument is an ARRAY of |
---|
302 | FCM::Context::Make::Build::Target objects representing the failed targets. |
---|
303 | |
---|
304 | =item FCM::Context::Event->MAKE_DEST |
---|
305 | |
---|
306 | This event is raised when the make system sets up the destination. The 1st |
---|
307 | argument of this event is the make system context. |
---|
308 | |
---|
309 | =item FCM::Context::Event->MAKE_EXTRACT_PROJECT_TREE |
---|
310 | |
---|
311 | This event is raised after the make/extract system has finished gathering |
---|
312 | information for the source trees of each project. The 1st argument is a HASH of |
---|
313 | the (keys) project name-spaces and the (values) list (ARRAY) of source tree |
---|
314 | locators L<FCM::Context::Locator|FCM::Context::Locator> in the project. |
---|
315 | |
---|
316 | =item FCM::Context::Event->MAKE_EXTRACT_RUNNER_SUMMARY |
---|
317 | |
---|
318 | This event is raised after the make/extract system has finished using the task |
---|
319 | runner to perform some tasks. The 1st argument is an identifier for the tasks |
---|
320 | performed. The 2nd argument is the number of tasks. The 2nd argument is the |
---|
321 | elapsed time. The 3rd argument is the total time in all processes. |
---|
322 | |
---|
323 | =item FCM::Context::Event->MAKE_EXTRACT_SYMLINK |
---|
324 | |
---|
325 | This event is raised as the make/extract system ignores a source that is a |
---|
326 | symbolic link. The 1st argument of this event should be a blessed reference of |
---|
327 | FCM::Context::Make::Extract::Source as described in |
---|
328 | L<FCM::Context::Make::Extract|FCM::Context::Make::Extract>. |
---|
329 | |
---|
330 | =item FCM::Context::Event->MAKE_EXTRACT_TARGET |
---|
331 | |
---|
332 | This event is raised as the make/extract system updates a target destination. The |
---|
333 | 1st argument of this event should be a blessed reference of |
---|
334 | FCM::Context::Make::Extract::Target as described in |
---|
335 | L<FCM::Context::Make::Extract|FCM::Context::Make::Extract>. |
---|
336 | |
---|
337 | =item FCM::Context::Event->MAKE_EXTRACT_TARGET_SUMMARY |
---|
338 | |
---|
339 | This event is raised after the make/extract system has updated all target |
---|
340 | destinations. The 1st argument of this event is a HASH reference, which contains |
---|
341 | 2 keys: status and status_of_source, i.e. the destination status of the targets |
---|
342 | and the source status of the targets respectively. The values of both are HASH |
---|
343 | references. The keys are the names of the status, and the values are the number |
---|
344 | of targets with the corresponding status. |
---|
345 | |
---|
346 | =item FCM::Context::Event->MAKE_MIRROR |
---|
347 | |
---|
348 | This event is raised as the make/mirror system updates a target destination. The |
---|
349 | 1st argument of this event should be the target URI. The remaining arguments |
---|
350 | should be the source paths. |
---|
351 | |
---|
352 | =item FCM::Context::Event->OUT |
---|
353 | |
---|
354 | This event is raised to notify (shell command) output. The 1st argument should |
---|
355 | be the STDOUT, and the 2nd argument should be the STDERR. |
---|
356 | |
---|
357 | =item FCM::Context::Event->SHELL |
---|
358 | |
---|
359 | This event is raised to notify the completion of a shell command. The 1st |
---|
360 | argument is an ARRAY reference of the shell command. The 2nd argument is an |
---|
361 | integer to override the verbosity level. The 3rd argument is the return code and |
---|
362 | the 4th argument is the elapsed time. |
---|
363 | |
---|
364 | =item FCM::Context::Event->TASK_WORKERS |
---|
365 | |
---|
366 | This event is raised on initialisation and destruction of worker processes for |
---|
367 | the utility task runner. The 1st argument should either be "init" or "destroy". |
---|
368 | The 2nd argument should be the number of workers initialised/destroyed. |
---|
369 | |
---|
370 | =item FCM::Context::Event->TIMER |
---|
371 | |
---|
372 | This event is raised at the start and end of the utility timer. The 1st |
---|
373 | argument is the name of the piece of code to time. The 2nd argument is the start |
---|
374 | the timer. The 3rd argument is the elapsed time at the end. If the 3rd argument |
---|
375 | is not specified, it is the start of the timer. |
---|
376 | |
---|
377 | =back |
---|
378 | |
---|
379 | =head1 COPYRIGHT |
---|
380 | |
---|
381 | Copyright (C) 2006-2021 British Crown (Met Office) & Contributors. |
---|
382 | |
---|
383 | =cut |
---|