author | Daniel Jacobs <daniel.jacobs@nokia.com> |
Mon, 10 May 2010 10:18:26 +0100 | |
branch | fix |
changeset 526 | bf8ad270b306 |
parent 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 |
|
102 |
TALON_RECIPEATTRIBUTES:=\ |
|
103 |
name='$$RECIPE'\ |
|
104 |
target='$$TARGET'\ |
|
283
a5284ec02d61
fix: remove unnecessary changes. Reorganise gethostname stuff so it can be debugged.
timothy.murphy@nokia.com
parents:
282
diff
changeset
|
105 |
host='$$HOSTNAME'\ |
3 | 106 |
layer='$$COMPONENT_LAYER'\ |
107 |
component='$$COMPONENT_NAME'\ |
|
108 |
bldinf='$$COMPONENT_META' mmp='$$PROJECT_META'\ |
|
109 |
config='$$SBS_CONFIGURATION' platform='$$PLATFORM'\ |
|
110 |
phase='$$MAKEFILE_GROUP' source='$$SOURCE' |
|
111 |
||
112 |
export TALON_RECIPEATTRIBUTES |
|
113 |
export TALON_RETRIES |
|
114 |
export TALON_DESCRAMBLE |
|
115 |
||
116 |
define startrule |
|
117 |
@|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;| |
|
118 |
endef |
|
119 |
||
120 |
define endrule |
|
121 |
endef |
|
122 |
||
123 |
||
124 |
define startrawoutput |
|
125 |
@|TALON_FLAGS=forcesuccess rawoutput;| |
|
126 |
endef |
|
127 |
||
128 |
define endrawoutput |
|
129 |
endef |
|
130 |
||
131 |
||
132 |
||
133 |
endif |
|
134 |
||
135 |
||
136 |
||
137 |
||
138 |
endif |