author | timothy.murphy@nokia.com |
Mon, 01 Mar 2010 00:54:27 +0200 | |
branch | fix |
changeset 283 | a5284ec02d61 |
parent 282 | 99ac65572b14 |
child 284 | 2c24e0d7a5d4 |
permissions | -rw-r--r-- |
3 | 1 |
# |
2 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
# All rights reserved. |
|
4 |
# This component and the accompanying materials are made available |
|
5 |
# under the terms of the License "Eclipse Public License v1.0" |
|
6 |
# which accompanies this distribution, and is available |
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
# |
|
9 |
# Initial Contributors: |
|
10 |
# Nokia Corporation - initial contribution. |
|
11 |
# |
|
12 |
# Contributors: |
|
13 |
# |
|
14 |
# Description: |
|
15 |
# Tools for use in FLMs - enabling the output from |
|
16 |
# rules to be logged with start and end tags. |
|
17 |
# This is a place where one might to permit various information to |
|
18 |
# be logged, such as timestamps and host names or process ids |
|
19 |
# |
|
20 |
||
21 |
ifndef _TAGGEDRULES_FLM_ |
|
22 |
_TAGGEDRULES_FLM_:=1 |
|
23 |
||
24 |
# only run recipes once by default |
|
25 |
RECIPETRIES?=1 |
|
26 |
||
27 |
ifeq ($(USE_TALON),) |
|
28 |
||
29 |
## |
|
30 |
## Example usage: |
|
31 |
## |
|
32 |
# define func |
|
33 |
# auto_ok: |
|
34 |
# $(call startrule,auto) \ |
|
35 |
# true && \ |
|
36 |
# true && \ |
|
37 |
# true \ |
|
38 |
# $(call endrule,auto) |
|
39 |
# |
|
40 |
# auto_fail: |
|
41 |
# $(call startrule,auto) \ |
|
42 |
# find /usr >/dev/null 2>&1 && \ |
|
43 |
# false && \ |
|
44 |
# true \ |
|
45 |
# $(call endrule,auto) |
|
46 |
# endef |
|
47 |
# $(eval $(func)) |
|
48 |
||
49 |
# $(1) is the name of the FLM function |
|
50 |
# $(2) indicates whether the failure of this rule should be ignored (but still logged) |
|
51 |
# FORCESUCCESS indicates "on" |
|
52 |
define startrule |
|
53 |
@set -o pipefail; RV=0; ATTEMPT=1; \ |
|
54 |
{ while (( $$$$ATTEMPT <= $(RECIPETRIES) )); do \ |
|
55 |
echo -e "<recipe name='$(1)' \ |
|
56 |
target='$$@' host='$$$$HOSTNAME' \ |
|
57 |
layer='$(COMPONENT_LAYER)' component='$(COMPONENT_NAME)' \ |
|
58 |
bldinf='$(COMPONENT_META)' mmp='$(PROJECT_META)' \ |
|
59 |
config='$(SBS_CONFIGURATION)' platform='$(PLATFORM)' \ |
|
60 |
phase='$(MAKEFILE_GROUP)' \ |
|
61 |
source='$(3)'>\n<![CDATA["; \ |
|
62 |
FLM_RECIPE_FLAGS='$(2)'; \ |
|
63 |
export TIMEFORMAT="]]><time start='$$$$($(DATE) +%s.%N)' elapsed='%6R' />"; \ |
|
64 |
{ time { set -x; |
|
65 |
endef |
|
66 |
||
67 |
define endrule |
|
68 |
; } } 2>&1 ; RV=$$$$?; set +x; \ |
|
69 |
if (( $$$$RV==0 )); then \ |
|
70 |
echo "<status exit='ok' attempt='$$$$ATTEMPT' />"; \ |
|
71 |
echo "</recipe>"; \ |
|
72 |
break; \ |
|
73 |
else \ |
|
74 |
if (( $$$$ATTEMPT < $(RECIPETRIES) )); then \ |
|
75 |
echo "<status exit='retry' code='$$$$RV' attempt='$$$$ATTEMPT' />"; \ |
|
76 |
sleep 1; \ |
|
77 |
else \ |
|
78 |
if [ ! "$$$${FLM_RECIPE_FLAGS//FORCESUCCESS/}" == "$$$${FLM_RECIPE_FLAGS}" ]; then \ |
|
79 |
echo "<status exit='failed' code='$$$$RV' attempt='$$$$ATTEMPT' forcesuccess='FORCESUCCESS' />"; \ |
|
80 |
RV=0; \ |
|
81 |
else \ |
|
82 |
echo "<status exit='failed' code='$$$$RV' attempt='$$$$ATTEMPT' />"; \ |
|
83 |
fi; \ |
|
84 |
fi; \ |
|
85 |
fi; \ |
|
86 |
echo "</recipe>"; \ |
|
87 |
(( ATTEMPT=$$$$ATTEMPT + 1 )); \ |
|
88 |
done ; exit $$$${RV}; } $(if $(DESCRAMBLE),2>&1 | $(DESCRAMBLE) -k $$$$$$$$) |
|
89 |
endef |
|
90 |
||
91 |
||
92 |
define startrawoutput |
|
93 |
@ set -o pipefail; { |
|
94 |
endef |
|
95 |
||
96 |
define endrawoutput |
|
97 |
; exit 0; } $(if $(DESCRAMBLE),2>&1 | $(DESCRAMBLE) -k $$$$$$$$) |
|
98 |
endef |
|
99 |
||
100 |
||
101 |
else |
|
279
733464eaac50
fix: make sure host attribute is set rather than blank in logs on windows by using the env var 'COMPUTERNAME' instead of 'HOSTNAME'. Thus make it less difficult to order recipes in the log by time.
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
102 |
|
733464eaac50
fix: make sure host attribute is set rather than blank in logs on windows by using the env var 'COMPUTERNAME' instead of 'HOSTNAME'. Thus make it less difficult to order recipes in the log by time.
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
103 |
|
3 | 104 |
TALON_RECIPEATTRIBUTES:=\ |
105 |
name='$$RECIPE'\ |
|
106 |
target='$$TARGET'\ |
|
283
a5284ec02d61
fix: remove unnecessary changes. Reorganise gethostname stuff so it can be debugged.
timothy.murphy@nokia.com
parents:
282
diff
changeset
|
107 |
host='$$HOSTNAME'\ |
3 | 108 |
layer='$$COMPONENT_LAYER'\ |
109 |
component='$$COMPONENT_NAME'\ |
|
110 |
bldinf='$$COMPONENT_META' mmp='$$PROJECT_META'\ |
|
111 |
config='$$SBS_CONFIGURATION' platform='$$PLATFORM'\ |
|
112 |
phase='$$MAKEFILE_GROUP' source='$$SOURCE' |
|
113 |
||
114 |
export TALON_RECIPEATTRIBUTES |
|
115 |
export TALON_RETRIES |
|
116 |
export TALON_DESCRAMBLE |
|
117 |
||
118 |
define startrule |
|
119 |
@|RECIPE=$1;TARGET=$$@;COMPONENT_LAYER=$(COMPONENT_LAYER);COMPONENT_NAME=$(COMPONENT_NAME);COMPONENT_META=$(COMPONENT_META);PROJECT_META=$(PROJECT_META);SBS_CONFIGURATION=$(SBS_CONFIGURATION);PLATFORM=$(PLATFORM);MAKEFILE_GROUP=$(MAKEFILE_GROUP);SOURCE=$3;TALON_FLAGS=$2;| |
|
120 |
endef |
|
121 |
||
122 |
define endrule |
|
123 |
endef |
|
124 |
||
125 |
||
126 |
define startrawoutput |
|
127 |
@|TALON_FLAGS=forcesuccess rawoutput;| |
|
128 |
endef |
|
129 |
||
130 |
define endrawoutput |
|
131 |
endef |
|
132 |
||
133 |
||
134 |
||
135 |
endif |
|
136 |
||
137 |
||
138 |
||
139 |
||
140 |
endif |