13
|
1 |
# Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
# All rights reserved.
|
|
3 |
# This component and the accompanying materials are made available
|
|
4 |
# under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
# which accompanies this distribution, and is available
|
|
6 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
#
|
|
8 |
# Initial Contributors:
|
|
9 |
# Nokia Corporation - initial contribution.
|
|
10 |
#
|
|
11 |
# Contributors:
|
|
12 |
#
|
|
13 |
# Description:
|
|
14 |
# Run Trace Compiler on source files to generate trace headers and decode files
|
|
15 |
|
18
|
16 |
# Expected inputs:
|
|
17 |
# TARGETEXT
|
|
18 |
|
13
|
19 |
# Set project name as <mmp_name>
|
|
20 |
TRACE_PRJNAME:=$(basename $(notdir $(PROJECT_META)))
|
18
|
21 |
OLDTC_TRACE_PRJNAME:=$(TRACE_PRJNAME)
|
|
22 |
TRACE_RELEASABLE_ID:=$(TARGET)_$(TARGETEXT)
|
13
|
23 |
|
18
|
24 |
define get_trace_path
|
|
25 |
$(firstword $(filter %$1, $(USERINCLUDE) $(SYSTEMINCLUDE)))
|
|
26 |
endef
|
|
27 |
|
|
28 |
$(if $(FLMDEBUG),$(info <debug>INCLUDES=$(USERINCLUDE) $(SYSTEMINCLUDE)</debug>))
|
|
29 |
$(if $(FLMDEBUG),$(info <debug>TARGET=$(TARGET) TARGETEXT=$(TARGETEXT)</debug>))
|
13
|
30 |
|
18
|
31 |
# Find out TRACE_PATH by looking for the trace folder in SYSTEMINCLUDE and USERINCLUDES
|
|
32 |
# traces/traces_<target_name>_<target_extension>
|
|
33 |
TRACE_PATH:=$(call get_trace_path,/traces/traces_$(TRACE_RELEASABLE_ID))
|
13
|
34 |
ifneq ($(TRACE_PATH),)
|
18
|
35 |
TRACE_PRJNAME:=$(TRACE_RELEASABLE_ID)
|
|
36 |
else # obsolete forms for compatibility
|
|
37 |
# traces_<target_name>_<target_ext>
|
|
38 |
TRACE_PATH:=$(call get_trace_path,/traces_$(TARGET)_$(TARGETEXT))
|
|
39 |
ifneq ($(TRACE_PATH),)
|
|
40 |
# set project name as <target_name>_<target_ext> instead of <mmp_name>
|
|
41 |
# to trick old TCom into finding the path.
|
|
42 |
OLDTC_TRACE_PRJNAME:=$(TARGET)_$(TARGETEXT)
|
|
43 |
else
|
|
44 |
# traces_<target_name>_<target_type>
|
|
45 |
TRACE_PATH:=$(call get_trace_path,/traces_$(TARGET)_$(TARGETTYPE))
|
|
46 |
ifneq ($(TRACE_PATH),)
|
|
47 |
# set project name as <target_name>_<target_type> instead of <mmp_name>
|
|
48 |
# to trick old TCom into finding the path.
|
|
49 |
OLDTC_TRACE_PRJNAME:=$(TARGET)_$(TARGETTYPE)
|
|
50 |
else
|
|
51 |
# traces_<mmp_name>
|
|
52 |
TRACE_PATH:=$(call get_trace_path,/traces_$(TRACE_PRJNAME))
|
|
53 |
|
|
54 |
# traces
|
|
55 |
ifeq ($(TRACE_PATH),)
|
|
56 |
TRACE_PATH:=$(call get_trace_path,/traces)
|
|
57 |
endif
|
|
58 |
endif
|
|
59 |
endif
|
13
|
60 |
endif
|
|
61 |
|
|
62 |
|
|
63 |
# initialise (so what output will be correct if we don't actually run the TC)
|
|
64 |
TRACE_DICTIONARY:=
|
|
65 |
AUTOGEN_HEADER:=
|
18
|
66 |
$(if $(FLMDEBUG),$(info <debug>TRACE_PATH='$(TRACE_PATH)' TRACE_RELEASABLE_ID='$(TRACE_RELEASABLE_ID)'</debug>))
|
13
|
67 |
|
|
68 |
# Run trace compiler only if TRACE_PATH exists
|
|
69 |
ifneq ($(TRACE_PATH),)
|
18
|
70 |
TRACE_MARKER:=$(TRACE_MARKER_PATH)/tracecompile_$(TRACE_RELEASABLE_ID)_$(UID_TC).done
|
13
|
71 |
TRACE_HEADERS:=
|
|
72 |
|
18
|
73 |
TRACE_SOURCE_LIST:=$(TRACE_MARKER_PATH)/tracecompile_$(TRACE_RELEASABLE_ID)_$(UID_TC).sourcelist
|
|
74 |
TRACE_VARIANT_SOURCE_LIST:=$(OUTPUTPATH)/$(VARIANTPLATFORM)/$(VARIANTTYPE)/tracecompile_$(TRACE_RELEASABLE_ID)_$(UID_TC).sourcelist
|
|
75 |
|
|
76 |
# The sourcelist_grouped_write macro allows us to construct a source list file, 10 objects at a time
|
|
77 |
# to avoid limits on argument lengths and sizes on Windows.
|
|
78 |
# $1 = list of source files
|
|
79 |
# $2 = ">" or ">>" i.e. for creating the file.
|
|
80 |
define sourcelist_grouped_write
|
|
81 |
$(call startrule,sourcelist_write) \
|
|
82 |
$(if $1,echo -en '$(subst $(CHAR_SPACE),\n,$(strip $(wordlist 1,10,$1)))\n' $2 $$@,true) \
|
|
83 |
$(call endrule,sourcelist_write)
|
|
84 |
$(if $1,$(call sourcelist_grouped_write,$(wordlist 11,$(words $1),$1),>>),)
|
|
85 |
endef
|
13
|
86 |
|
18
|
87 |
# Write the list of sources for this variant to a file
|
|
88 |
# Make the combined sourcelist for this target depend on it
|
|
89 |
# It's all to do with how make treats this file when it
|
|
90 |
# does exist. We are forcing it evaluate the target rule here
|
|
91 |
# even if the file is in place by making it PHONY. In other
|
|
92 |
# words, this is forcing the variant source list to always
|
|
93 |
# be written but later on we might not write to the combined
|
|
94 |
# source list if it isn't going to change.
|
|
95 |
define sourcelist_write
|
|
96 |
$(TRACE_SOURCE_LIST): $(TRACE_VARIANT_SOURCE_LIST)
|
13
|
97 |
|
18
|
98 |
.PHONY:: $(TRACE_VARIANT_SOURCE_LIST)
|
|
99 |
|
|
100 |
$(TRACE_VARIANT_SOURCE_LIST): $(SOURCE)
|
|
101 |
$(call sourcelist_grouped_write,$(SOURCE),>)
|
|
102 |
|
|
103 |
endef
|
|
104 |
|
|
105 |
$(eval $(sourcelist_write))
|
|
106 |
$(eval $(call GenerateStandardCleanTarget,$(TRACE_VARIANT_SOURCE_LIST),,))
|
|
107 |
|
|
108 |
|
|
109 |
$(if $(FLMDEBUG),$(info <debug>Trace Compiler SOURCES: $(SOURCE)</debug>))
|
13
|
110 |
|
|
111 |
$(TRACE_MARKER) : $(SOURCE)
|
|
112 |
|
|
113 |
TRACE_HEADERS:=$(foreach SRC,$(SOURCE),$(TRACE_PATH)/$(basename $(notdir $(SRC)))Traces.h)
|
|
114 |
|
|
115 |
$(TRACE_HEADERS): $(TRACE_MARKER)
|
|
116 |
|
|
117 |
ifeq ($(GUARD_$(call sanitise,$(TRACE_MARKER))),)
|
|
118 |
GUARD_$(call sanitise,$(TRACE_MARKER)):=1
|
|
119 |
|
18
|
120 |
$(if $(FLMDEBUG),$(info <debug>PAST MARKER='$(TRACE_RELEASABLE_ID)'</debug>))
|
13
|
121 |
# The trace compiler likes to change . into _ so we must do the same in the case of mmps with a name like
|
|
122 |
# fred.prd.mmp we want fred_prd
|
|
123 |
TRACE_PRJNAME_SANITISED:=$(subst .,_,$(TRACE_PRJNAME))
|
18
|
124 |
OLDTC_TRACE_PRJNAME_SANITISED:=$(subst .,_,$(OLDTC_TRACE_PRJNAME))
|
13
|
125 |
|
|
126 |
|
|
127 |
JAVA_COMMAND:=$(SBS_JAVATC)
|
|
128 |
TRACE_COMPILER_PATH:=$(EPOCROOT)/epoc32/tools
|
18
|
129 |
|
|
130 |
# declare the trace_compile macro but only do it once in the build
|
|
131 |
ifeq ($(trace_compile),)
|
|
132 |
|
|
133 |
# Find out which macro to declare - the one supporting the new CLI
|
|
134 |
# or the old one. First try to find TraceCompilerMain.class
|
|
135 |
# If it is there then it might be the new posix-like interface
|
|
136 |
TRACE_VER:=
|
|
137 |
TRACE_VSTR:=
|
|
138 |
|
|
139 |
TCClass:=$(wildcard $(TRACE_COMPILER_PATH)/tracecompiler/com/nokia/tracecompiler/TraceCompilerMain.class)
|
|
140 |
ifneq ($(TCClass),)
|
|
141 |
# Get the version string from the TC (assume it's the new one)
|
|
142 |
TRACE_COMPILER_START:=-classpath $(TRACE_COMPILER_PATH)/tracecompiler com.nokia.tracecompiler.TraceCompilerMain
|
|
143 |
TRACE_VSTR:=$(firstword $(subst TraceCompiler version ,,$(shell $(JAVA_COMMAND) $(TRACE_COMPILER_START) --version)))
|
|
144 |
# check if it looks like a version that supports the new cli interface: supporting up to verion 9 in the future.
|
|
145 |
TRACE_VER:=$(findstring new,$(foreach version,2 3 4 5 6 7 8 9,$(patsubst $(version).%,new,$(TRACE_VSTR))))
|
|
146 |
endif
|
|
147 |
$(if $(FLMDEBUG),$(info <debug>TRACE_VSTR=$(TRACE_VSTR) TRACE_VER=$(TRACE_VER)</debug>))
|
13
|
148 |
|
|
149 |
|
18
|
150 |
# 0. Generate a combined sourcelist from all variants.
|
|
151 |
# 0.1 Write the combined list to a temporary file
|
|
152 |
# 0.2 Check if there are new files since the last build
|
|
153 |
# md5 stored in the trace marker.
|
|
154 |
# 0.3 Rewrite the combined sourcelist if new sourcefiles have appeared
|
|
155 |
# since the last build
|
13
|
156 |
# 1. Use pipe to send inputs to trace compiler to process
|
|
157 |
# 2. Create a hash regarding to source names and put it in marker.
|
|
158 |
# 3. Show source names that are processed by trace compiler
|
18
|
159 |
|
|
160 |
ifeq ($(TRACE_VER),new)
|
13
|
161 |
define trace_compile
|
18
|
162 |
|
|
163 |
$(TRACE_SOURCE_LIST):
|
|
164 |
$(call startrule,sourcelist_combine) \
|
|
165 |
$(GNUCAT) $(TRACE_SOURCE_LIST) $$^ 2>/dev/null | $(GNUSORT) -u > $$@.new && \
|
|
166 |
$(GNUMD5SUM) -c $(TRACE_MARKER) 2>/dev/null || \
|
|
167 |
$(GNUCP) $$@.new $$@ \
|
|
168 |
$(call endrule,sourcelist_combine)
|
|
169 |
|
|
170 |
$(TRACE_MARKER) : $(PROJECT_META) $(TRACE_SOURCE_LIST)
|
13
|
171 |
$(call startrule,tracecompile) \
|
18
|
172 |
( $(GNUCAT) $(TRACE_SOURCE_LIST); \
|
13
|
173 |
echo -en "*ENDOFSOURCEFILES*\n" ) | \
|
18
|
174 |
$(JAVA_COMMAND) $(TRACE_COMPILER_START) $(if $(FLMDEBUG),-d,) --uid=$(UID_TC) --project=$(TRACE_PRJNAME) --mmp=$(PROJECT_META) --traces=$(TRACE_PATH) && \
|
|
175 |
$(GNUMD5SUM) $(TRACE_SOURCE_LIST).new > $$@ 2>/dev/null && \
|
13
|
176 |
{ $(GNUTOUCH) $(TRACE_DICTIONARY) $(AUTOGEN_HEADER); \
|
|
177 |
$(GNUCAT) $(TRACE_SOURCE_LIST) ; true ; } \
|
|
178 |
$(call endrule,tracecompile)
|
|
179 |
endef
|
|
180 |
|
18
|
181 |
else # Old inteface
|
|
182 |
TRACE_COMPILER_START:=-classpath $(TRACE_COMPILER_PATH)/tracecompiler com.nokia.tracecompiler.TraceCompiler
|
|
183 |
|
|
184 |
define trace_compile
|
|
185 |
|
|
186 |
$(TRACE_SOURCE_LIST):
|
|
187 |
$(call startrule,sourcelist_combine) \
|
|
188 |
$(GNUCAT) $(TRACE_SOURCE_LIST) $$^ 2>/dev/null | $(GNUSORT) -u > $$@.new && \
|
|
189 |
$(GNUMD5SUM) -c $(TRACE_MARKER) 2>/dev/null || \
|
|
190 |
$(GNUCP) $$@.new $$@ \
|
|
191 |
$(call endrule,sourcelist_combine)
|
|
192 |
|
|
193 |
$(TRACE_MARKER) : $(PROJECT_META) $(TRACE_SOURCE_LIST)
|
|
194 |
$(call startrule,tracecompile) \
|
|
195 |
( echo -en "$(OLDTC_TRACE_PRJNAME)\n$(PROJECT_META)\n"; \
|
|
196 |
$(GNUCAT) $(TRACE_SOURCE_LIST); \
|
|
197 |
echo -en "*ENDOFSOURCEFILES*\n" ) | \
|
|
198 |
$(JAVA_COMMAND) $(TRACE_COMPILER_START) $(UID_TC) && \
|
|
199 |
$(GNUMD5SUM) $(TRACE_SOURCE_LIST).new > $$@ 2>/dev/null && \
|
|
200 |
{ $(GNUTOUCH) $(TRACE_DICTIONARY) $(AUTOGEN_HEADER); \
|
|
201 |
$(GNUCAT) $(TRACE_SOURCE_LIST) ; true ; } \
|
|
202 |
$(call endrule,tracecompile)
|
|
203 |
endef
|
|
204 |
|
|
205 |
# End - new/old trace compiler
|
|
206 |
endif
|
|
207 |
|
|
208 |
# End - tracecompile is defined
|
|
209 |
endif
|
|
210 |
|
|
211 |
ifeq ($(TRACE_VER),new)
|
|
212 |
TRACE_DICTIONARY:=$(EPOCROOT)/epoc32/ost_dictionaries/$(TRACE_PRJNAME_SANITISED)_0x$(UID_TC)_Dictionary.xml
|
|
213 |
AUTOGEN_HEADER:=$(EPOCROOT)/epoc32/include/platform/symbiantraces/autogen/$(TRACE_PRJNAME_SANITISED)_0x$(UID_TC)_TraceDefinitions.h
|
|
214 |
else
|
|
215 |
TRACE_DICTIONARY:=$(EPOCROOT)/epoc32/ost_dictionaries/$(OLDTC_TRACE_PRJNAME_SANITISED)_0x$(UID_TC)_Dictionary.xml
|
|
216 |
AUTOGEN_HEADER:=$(EPOCROOT)/epoc32/include/internal/symbiantraces/autogen/$(OLDTC_TRACE_PRJNAME_SANITISED)_0x$(UID_TC)_TraceDefinitions.h
|
|
217 |
endif
|
|
218 |
|
13
|
219 |
$(eval $(trace_compile))
|
|
220 |
|
|
221 |
$(eval $(call GenerateStandardCleanTarget, $(TRACE_PATH)/tracebuilder.cache $(TRACE_MARKER) $(TRACE_SOURCE_LIST),,))
|
|
222 |
|
18
|
223 |
$(call makepath,$(TRACE_PATH) $(dir $(TRACE_DICTIONARY) $(AUTOGEN_HEADER)))
|
|
224 |
# End - guard that prevents repeated calls to TCom
|
13
|
225 |
endif
|
|
226 |
|
|
227 |
$(eval $(call GenerateStandardCleanTarget,$(TRACE_HEADERS),,))
|
|
228 |
|
18
|
229 |
# End - Nothing to trace (not trace path in include)
|
13
|
230 |
else
|
|
231 |
# Indicate to following parts of the FLM that we actually won't run
|
|
232 |
# trace compiler so they can set dependencies accordingly.
|
|
233 |
USE_TRACE_COMPILER:=
|
|
234 |
endif
|
|
235 |
|