New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Event.pm in vendors/lib/FCM/Context – NEMO

source: vendors/lib/FCM/Context/Event.pm @ 10669

Last change on this file since 10669 was 10669, checked in by nicolasmartin, 5 years ago

Import latest FCM release from Github into the repository for testing

File size: 15.5 KB
Line 
1#-------------------------------------------------------------------------------
2# (C) British Crown Copyright 2006-17 Met Office.
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#-------------------------------------------------------------------------------
19use strict;
20use warnings;
21#-------------------------------------------------------------------------------
22
23package FCM::Context::Event;
24use base qw{FCM::Class::HASH};
25
26use 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#-------------------------------------------------------------------------------
771;
78__END__
79
80=head1 NAME
81
82FCM::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
91An instance of this class represents the context of an event. This class is a
92sub-class of L<FCM::Class::HASH|FCM::Class::HASH>.
93
94=head1 ATTRIBUTES
95
96=over 4
97
98=item args
99
100An ARRAY reference that represents the additional arguments/contexts of the
101event.
102
103=item code
104
105The event code. See below
106
107=back
108
109=head1 EVENTS
110
111The following is a list of event codes.
112
113=over 4
114
115=item FCM::Context::Event->CM_ABORT
116
117This event is raised when a code management command aborts. The 1st argument
118should be either "user" (user abort) or "null" (null command).
119
120=item FCM::Context::Event->CM_BRANCH_CREATE_SOURCE
121
122This event is raised to notify the source of a branch create. The 1st argument
123should be the expected source URL, and the 2nd argument is the specified peg
124revision.
125
126=item FCM::Context::Event->CM_BRANCH_LIST
127
128This event is raised when doing a branch listing. The 1st argument should be the
129project location and the rest of the arguments are the branches discovered.
130
131=item FCM::Context::Event->CM_COMMIT_MESSAGE
132
133This event is raised to notify the user the log message to be used for a commit.
134The 1st argument of the event should be an instance of
135FCM::System::CM::CommitMessage::State.
136
137=item FCM::Context::Event->CM_CONFLICT_TEXT
138
139This 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
143This event is raised to notify the path of a file with a text conflict that
144cannot be resolved using a merge tool. E.g. it may be a binary file.
145
146=item FCM::Context::Event->CM_CONFLICT_TREE
147
148This 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
152This event is raised to notify the path of a node with a tree conflict that
153cannot be resolved automatically under current functionality. For example, it
154may be a directory containing multiple conflicts.
155
156=item FCM::Context::Event->CM_CREATE_TARGET
157
158This event is raised to notify the target of a newly created URL. The 1st argument
159should be the target URL.
160
161=item FCM::Context::Event->CM_LOG_EDIT
162
163This event is raised before the system launches an editor to edit a commit log
164message. The 1st argument of the event should be the editor command.
165
166=item FCM::Context::Event->CONFIG_ENTRY
167
168This entry is raised to notify the reading of a configuration file entry. The
1691st argument should be a blessed reference of a
170L<FCM::Context::ConfigEntry|FCM::Context::ConfigEntry>. The second argument
171should be a boolean flag to indicate whether this entry is in FCM 1 format or
172not.
173
174=item FCM::Context::Event->CONFIG_OPEN
175
176This event is raised when a new configuration file is opened for reading. The
1771st argument of this event is an ARRAY that represents the include file stack,
178where the last element is the top of the stack. Each element of the stack is a
1792-element ARRAY reference, where the first element is a
180L<FCM::Context::Locator|FCM::Context::Locator> object and the second element is
181the line number. (At the top of the stack, the line number is set to 0.) The 2nd
182optional argument of this event is a number to adjust the verbosity level of the
183event.
184
185=item FCM::Context::Event->CONFIG_VAR_UNDEF
186
187This event is raised when a variable is undefined. The arguments of this event
188contain 2 elements. The 1st element is the configuration entry as a blessed
189reference of L<FCM::Context::ConfigEntry|FCM::Context::ConfigEntry>. The 2nd
190element is the name of the variable.
191
192=item FCM::Context::Event->E
193
194This event is raised when to notify an exception. The 1st argument of this event
195should be the exception.
196
197=item FCM::Context::Event->EXPORT_ITEM_CREATE
198
199This event is raised when the export-items system creates a link to an item.
200The 1st argument is the namespace of the item, the 2nd argument is the revision
201of the item and the 3rd argument is the name of the link.
202
203=item FCM::Context::Event->EXPORT_ITEM_DELETE
204
205This event is raised when the export-items system deletes a link to an item.
206The 1st argument is the namespace of the item, the 2nd argument is the revision
207of the item and the 3rd argument is the name of the link.
208
209=item FCM::Context::Event->FCM_VERSION
210
211This event is raised to notify the FCM version.
212
213=item FCM::Context::Event->KEYWORD_ENTRY
214
215This event is raised to notify a keyword entry. The 1st argument is the keyword
216entry as a blessed reference of FCM::Context::Keyword::Entry as described in
217L<FCM::Context::Keyword|FCM::Context::Keyword>.
218
219=item FCM::Context::Event->MAKE_BUILD_SHELL_OUT
220
221This event is raised to notify (shell command) output from make/build. The 1st
222argument should be the STDOUT, and the 2nd argument should be the STDERR.
223
224=item FCM::Context::Event->MAKE_BUILD_SOURCE_ANALYSE
225
226This event is raised when the make/build system has analysed a source file. The
2271st argument should be a blessed reference of FCM::Context::Make::Build::Source
228as described in L<FCM::Context::Make::Build|FCM::Context::Make::Build>. The 2nd
229argument should be the time it takes for the analysis.
230
231=item FCM::Context::Event->MAKE_BUILD_SOURCE_SUMMARY
232
233This event is raised when the make/build system has analysed all its source
234files. The 1st argument should be the total number of files. The 2nd argument
235should be the number analysed. The 3rd argument should be the elapsed time. The
2364th argument should be the total time, which may differ from the elapsed time if
237the analysis is run on more than 1 process.
238
239=item FCM::Context::Event->MAKE_BUILD_TARGET_DONE
240
241This event is raised when the make/build system has successfully updated a
242target or an update is unnecessary. The 1st argument is the target (as an
243instance of FCM::Context::Make::Build::Target), the 2nd argument is the elapsed
244time of the update, if relevant.
245
246=item FCM::Context::Event->MAKE_BUILD_TARGET_FAIL
247
248This event is raised when the make/build system failed to update a target or the
249target is failed by its dependencies. The 1st argument is the target (as an
250instance of FCM::Context::Make::Build::Target), the 2nd argument is the elapsed
251time, if the target is failed by its update.
252
253=item FCM::Context::Event->MAKE_BUILD_TARGET_FROM_NS
254
255This event is raised when the make/build system has generated a build target
256from a source or a source name-space. The arguments are: source/target
257namespace, target task, target category, and the target key.
258
259=item FCM::Context::Event->MAKE_BUILD_TARGET_MISSING_DEP
260
261This event is raised when the make/build system has discarded a missing
262dependency from a target. The 1st argument is the target ID, the 2nd argument is
263the dependency ID, and the 3rd argument is the dependency type.
264
265=item FCM::Context::Event->MAKE_BUILD_TARGET_SELECT
266
267This event is raised when the make/build system has selected a set of targets to
268build. The 1st argument is a HASH reference of the target set.
269
270=item FCM::Context::Event->MAKE_BUILD_TARGET_SELECT_TIMER
271
272This event is raised when the make/build system has completed the target select
273and dependency tree analysis. The only argument is the elapsed time.
274
275=item FCM::Context::Event->MAKE_BUILD_TARGET_STACK
276
277This event is raised when make/build system checks a target for cyclic
278dependency.  The 1st argument is the key of the task. The 2nd argument is rank
279of the task in the dependency hierarchy. The 3rd argument is the number of
280dependencies the task has if the task has already been checked, or undef if this
281is the first check for the task.
282
283=item FCM::Context::Event->MAKE_BUILD_TARGET_SUMMARY
284
285This event is raised when the make/build system has finished updating its
286targets, and is ready to give a total summary. The 1st argument is the number of
287modified targets, the 2nd argument is the number unchanged, the 3rd argument is
288the number failed, the 4th argument is the elapsed time.
289
290=item FCM::Context::Event->MAKE_BUILD_TARGET_TASK_SUMMARY
291
292This event is raised when the make/build system has finished updating its
293targets, and is ready to give a summary of each type of task. The 1st argument
294is the task type name, the 2nd argument is the number of modified targets, the
2953rd argument is the number unchanged, the 4th argument is the number failed, and
296the 5th argument is the total time spent on this task type.
297
298=item FCM::Context::Event->MAKE_BUILD_TARGETS_FAIL
299
300This event is raised when the make/build system has finished updating its
301targets, but some targets failed to update. The 1st argument is an ARRAY of
302FCM::Context::Make::Build::Target objects representing the failed targets.
303
304=item FCM::Context::Event->MAKE_DEST
305
306This event is raised when the make system sets up the destination. The 1st
307argument of this event is the make system context.
308
309=item FCM::Context::Event->MAKE_EXTRACT_PROJECT_TREE
310
311This event is raised after the make/extract system has finished gathering
312information for the source trees of each project. The 1st argument is a HASH of
313the (keys) project name-spaces and the (values) list (ARRAY) of source tree
314locators L<FCM::Context::Locator|FCM::Context::Locator> in the project.
315
316=item FCM::Context::Event->MAKE_EXTRACT_RUNNER_SUMMARY
317
318This event is raised after the make/extract system has finished using the task
319runner to perform some tasks. The 1st argument is an identifier for the tasks
320performed. The 2nd argument is the number of tasks. The 2nd argument is the
321elapsed time. The 3rd argument is the total time in all processes.
322
323=item FCM::Context::Event->MAKE_EXTRACT_SYMLINK
324
325This event is raised as the make/extract system ignores a source that is a
326symbolic link. The 1st argument of this event should be a blessed reference of
327FCM::Context::Make::Extract::Source as described in
328L<FCM::Context::Make::Extract|FCM::Context::Make::Extract>.
329
330=item FCM::Context::Event->MAKE_EXTRACT_TARGET
331
332This event is raised as the make/extract system updates a target destination. The
3331st argument of this event should be a blessed reference of
334FCM::Context::Make::Extract::Target as described in
335L<FCM::Context::Make::Extract|FCM::Context::Make::Extract>.
336
337=item FCM::Context::Event->MAKE_EXTRACT_TARGET_SUMMARY
338
339This event is raised after the make/extract system has updated all target
340destinations. The 1st argument of this event is a HASH reference, which contains
3412 keys: status and status_of_source, i.e. the destination status of the targets
342and the source status of the targets respectively. The values of both are HASH
343references. The keys are the names of the status, and the values are the number
344of targets with the corresponding status.
345
346=item FCM::Context::Event->MAKE_MIRROR
347
348This event is raised as the make/mirror system updates a target destination. The
3491st argument of this event should be the target URI. The remaining arguments
350should be the source paths.
351
352=item FCM::Context::Event->OUT
353
354This event is raised to notify (shell command) output. The 1st argument should
355be the STDOUT, and the 2nd argument should be the STDERR.
356
357=item FCM::Context::Event->SHELL
358
359This event is raised to notify the completion of a shell command. The 1st
360argument is an ARRAY reference of the shell command. The 2nd argument is an
361integer to override the verbosity level. The 3rd argument is the return code and
362the 4th argument is the elapsed time.
363
364=item FCM::Context::Event->TASK_WORKERS
365
366This event is raised on initialisation and destruction of worker processes for
367the utility task runner. The 1st argument should either be "init" or "destroy".
368The 2nd argument should be the number of workers initialised/destroyed.
369
370=item FCM::Context::Event->TIMER
371
372This event is raised at the start and end of the utility timer. The 1st
373argument is the name of the piece of code to time. The 2nd argument is the start
374the timer. The 3rd argument is the elapsed time at the end. If the 3rd argument
375is not specified, it is the start of the timer.
376
377=back
378
379=head1 COPYRIGHT
380
381(C) Crown copyright Met Office. All rights reserved.
382
383=cut
Note: See TracBrowser for help on using the repository browser.