11 # Contributors: |
11 # Contributors: |
12 # |
12 # |
13 # Description: |
13 # Description: |
14 # Run Trace Compiler on source files to generate trace headers and decode files |
14 # Run Trace Compiler on source files to generate trace headers and decode files |
15 |
15 |
|
16 # Expected inputs: |
|
17 # TARGETEXT |
|
18 |
16 # Set project name as <mmp_name> |
19 # Set project name as <mmp_name> |
17 TRACE_PRJNAME:=$(basename $(notdir $(PROJECT_META))) |
20 TRACE_PRJNAME:=$(basename $(notdir $(PROJECT_META))) |
18 |
21 OLDTC_TRACE_PRJNAME:=$(TRACE_PRJNAME) |
19 TARGETEXT:=$(if $(REQUESTEDTARGETEXT),$(REQUESTEDTARGETEXT),$(POSTLINKFILETYPE)) |
22 TRACE_RELEASABLE_ID:=$(TARGET)_$(TARGETEXT) |
20 |
23 |
21 # Find out TRACE_PATH |
24 define get_trace_path |
22 # first look for .*/traces/traces_<target_name>_<target_extension> |
25 $(firstword $(filter %$1, $(USERINCLUDE) $(SYSTEMINCLUDE))) |
23 TRACE_PATH:=$(strip $(foreach DIR,$(USERINCLUDE),$(filter %/traces/traces_$(TARGET)_$(TARGETEXT),$(DIR)))) |
26 endef |
24 |
27 |
|
28 $(if $(FLMDEBUG),$(info <debug>INCLUDES=$(USERINCLUDE) $(SYSTEMINCLUDE)</debug>)) |
|
29 $(if $(FLMDEBUG),$(info <debug>TARGET=$(TARGET) TARGETEXT=$(TARGETEXT)</debug>)) |
|
30 |
|
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)) |
25 ifneq ($(TRACE_PATH),) |
34 ifneq ($(TRACE_PATH),) |
26 # set project name as <target_name>_<target_extension> instead of <mmp_name> |
35 TRACE_PRJNAME:=$(TRACE_RELEASABLE_ID) |
27 TRACE_PRJNAME:=$(TARGET)_$(TARGETEXT) |
36 else # obsolete forms for compatibility |
28 endif |
37 # traces_<target_name>_<target_ext> |
29 |
38 TRACE_PATH:=$(call get_trace_path,/traces_$(TARGET)_$(TARGETEXT)) |
30 # if not found look for .*/traces_<mmp_name> |
39 ifneq ($(TRACE_PATH),) |
31 ifeq ($(TRACE_PATH),) |
40 # set project name as <target_name>_<target_ext> instead of <mmp_name> |
32 TRACE_PATH:=$(strip $(foreach DIR,$(USERINCLUDE),$(filter %/traces_$(TRACE_PRJNAME),$(DIR)))) |
41 # to trick old TCom into finding the path. |
33 endif |
42 OLDTC_TRACE_PRJNAME:=$(TARGET)_$(TARGETEXT) |
34 |
43 else |
35 # if not found look for .*/traces |
44 # traces_<target_name>_<target_type> |
36 ifeq ($(TRACE_PATH),) |
45 TRACE_PATH:=$(call get_trace_path,/traces_$(TARGET)_$(TARGETTYPE)) |
37 TRACE_PATH:=$(strip $(foreach DIR,$(USERINCLUDE),$(filter %/traces,$(DIR)))) |
46 ifneq ($(TRACE_PATH),) |
38 endif |
47 # set project name as <target_name>_<target_type> instead of <mmp_name> |
39 |
48 # to trick old TCom into finding the path. |
40 # if not found look for .*/traces_<target_name>_<target_type> |
49 OLDTC_TRACE_PRJNAME:=$(TARGET)_$(TARGETTYPE) |
41 ifeq ($(TRACE_PATH),) |
50 else |
42 TRACE_PATH:=$(strip $(foreach DIR,$(USERINCLUDE),$(filter %/traces_$(TARGET)_$(TARGETTYPE),$(DIR)))) |
51 # traces_<mmp_name> |
43 # set project name as <target_name>_<target_type> instead of <mmp_name> |
52 TRACE_PATH:=$(call get_trace_path,/traces_$(TRACE_PRJNAME)) |
44 TRACE_PRJNAME:=$(TARGET)_$(TARGETTYPE) |
53 |
45 endif |
54 # traces |
|
55 ifeq ($(TRACE_PATH),) |
|
56 TRACE_PATH:=$(call get_trace_path,/traces) |
|
57 endif |
|
58 endif |
|
59 endif |
|
60 endif |
|
61 |
46 |
62 |
47 # initialise (so what output will be correct if we don't actually run the TC) |
63 # initialise (so what output will be correct if we don't actually run the TC) |
48 TRACE_DICTIONARY:= |
64 TRACE_DICTIONARY:= |
49 AUTOGEN_HEADER:= |
65 AUTOGEN_HEADER:= |
50 |
66 $(if $(FLMDEBUG),$(info <debug>TRACE_PATH='$(TRACE_PATH)' TRACE_RELEASABLE_ID='$(TRACE_RELEASABLE_ID)'</debug>)) |
51 $(if $(FLMDEBUG),$(info <debug>TRACE_PATH = $(TRACE_PATH)</debug>)) |
|
52 |
67 |
53 # Run trace compiler only if TRACE_PATH exists |
68 # Run trace compiler only if TRACE_PATH exists |
54 ifneq ($(TRACE_PATH),) |
69 ifneq ($(TRACE_PATH),) |
55 TRACE_MARKER:=$(TRACE_MARKER_PATH)/tracecompile_$(TRACE_PRJNAME)_$(UID_TC).done |
70 TRACE_MARKER:=$(TRACE_MARKER_PATH)/tracecompile_$(TRACE_RELEASABLE_ID)_$(UID_TC).done |
56 TRACE_HEADERS:= |
71 TRACE_HEADERS:= |
57 |
72 |
58 TRACE_SOURCE_LIST:=$(TRACE_MARKER_PATH)/tracecompile_$(TRACE_PRJNAME)_$(UID_TC).sourcelist |
73 TRACE_SOURCE_LIST:=$(TRACE_MARKER_PATH)/tracecompile_$(TRACE_RELEASABLE_ID)_$(UID_TC).sourcelist |
59 |
74 TRACE_VARIANT_SOURCE_LIST:=$(OUTPUTPATH)/$(VARIANTPLATFORM)/$(VARIANTTYPE)/tracecompile_$(TRACE_RELEASABLE_ID)_$(UID_TC).sourcelist |
60 # 1. Append to or create the list of source files for trace compiler to process |
75 |
61 # 2. Check if the hash in trace marker remain unchanged. If not, remove marker so trace compiler will run again. |
76 # The sourcelist_grouped_write macro allows us to construct a source list file, 10 objects at a time |
62 X:=$(shell set -x ; $(GNUMKDIR) -p $(TRACE_MARKER_PATH) ; $(GNUTOUCH) $(TRACE_SOURCE_LIST) ; echo -e "$(subst $(CHAR_SPACE),\\n,$(SOURCE))" | $(GNUSORT) -u $(TRACE_SOURCE_LIST) - > $(TRACE_SOURCE_LIST).tmp && $(GNUMV) $(TRACE_SOURCE_LIST).tmp $(TRACE_SOURCE_LIST) ; $(GNUMD5SUM) -c $(TRACE_MARKER) || $(GNURM) $(TRACE_MARKER)) |
77 # to avoid limits on argument lengths and sizes on Windows. |
63 |
78 # $1 = list of source files |
64 $(if $(FLMDEBUG),$(info <debug>Trace Compiler sourcelist generation output: $(X)</debug>)) |
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 |
|
86 |
|
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) |
|
97 |
|
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>)) |
65 |
110 |
66 $(TRACE_MARKER) : $(SOURCE) |
111 $(TRACE_MARKER) : $(SOURCE) |
67 |
112 |
68 TRACE_HEADERS:=$(foreach SRC,$(SOURCE),$(TRACE_PATH)/$(basename $(notdir $(SRC)))Traces.h) |
113 TRACE_HEADERS:=$(foreach SRC,$(SOURCE),$(TRACE_PATH)/$(basename $(notdir $(SRC)))Traces.h) |
69 |
114 |
70 $(TRACE_HEADERS): $(TRACE_MARKER) |
115 $(TRACE_HEADERS): $(TRACE_MARKER) |
71 |
116 |
72 ifeq ($(GUARD_$(call sanitise,$(TRACE_MARKER))),) |
117 ifeq ($(GUARD_$(call sanitise,$(TRACE_MARKER))),) |
73 GUARD_$(call sanitise,$(TRACE_MARKER)):=1 |
118 GUARD_$(call sanitise,$(TRACE_MARKER)):=1 |
74 |
119 |
|
120 $(if $(FLMDEBUG),$(info <debug>PAST MARKER='$(TRACE_RELEASABLE_ID)'</debug>)) |
75 # The trace compiler likes to change . into _ so we must do the same in the case of mmps with a name like |
121 # The trace compiler likes to change . into _ so we must do the same in the case of mmps with a name like |
76 # fred.prd.mmp we want fred_prd |
122 # fred.prd.mmp we want fred_prd |
77 TRACE_PRJNAME_SANITISED:=$(subst .,_,$(TRACE_PRJNAME)) |
123 TRACE_PRJNAME_SANITISED:=$(subst .,_,$(TRACE_PRJNAME)) |
78 |
124 OLDTC_TRACE_PRJNAME_SANITISED:=$(subst .,_,$(OLDTC_TRACE_PRJNAME)) |
79 TRACE_DICTIONARY:=$(EPOCROOT)/epoc32/ost_dictionaries/$(TRACE_PRJNAME_SANITISED)_0x$(UID_TC)_Dictionary.xml |
125 |
80 AUTOGEN_HEADER:=$(EPOCROOT)/epoc32/include/internal/SymbianTraces/autogen/$(TRACE_PRJNAME_SANITISED)_0x$(UID_TC)_TraceDefinitions.h |
|
81 |
126 |
82 JAVA_COMMAND:=$(SBS_JAVATC) |
127 JAVA_COMMAND:=$(SBS_JAVATC) |
83 TRACE_COMPILER_PATH:=$(EPOCROOT)/epoc32/tools |
128 TRACE_COMPILER_PATH:=$(EPOCROOT)/epoc32/tools |
84 TRACE_COMPILER_START:=-classpath $(TRACE_COMPILER_PATH)/tracecompiler com.nokia.tracecompiler.TraceCompiler |
129 |
85 |
130 # declare the trace_compile macro but only do it once in the build |
86 |
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>)) |
|
148 |
|
149 |
|
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 |
87 # 1. Use pipe to send inputs to trace compiler to process |
156 # 1. Use pipe to send inputs to trace compiler to process |
88 # 2. Create a hash regarding to source names and put it in marker. |
157 # 2. Create a hash regarding to source names and put it in marker. |
89 # 3. Show source names that are processed by trace compiler |
158 # 3. Show source names that are processed by trace compiler |
|
159 |
|
160 ifeq ($(TRACE_VER),new) |
90 define trace_compile |
161 define trace_compile |
91 $(TRACE_MARKER) : $(PROJECT_META) |
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) |
92 $(call startrule,tracecompile) \ |
171 $(call startrule,tracecompile) \ |
93 ( echo -en "$(TRACE_PRJNAME)\n$(PROJECT_META)\n"; \ |
172 ( $(GNUCAT) $(TRACE_SOURCE_LIST); \ |
|
173 echo -en "*ENDOFSOURCEFILES*\n" ) | \ |
|
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 && \ |
|
176 { $(GNUTOUCH) $(TRACE_DICTIONARY) $(AUTOGEN_HEADER); \ |
|
177 $(GNUCAT) $(TRACE_SOURCE_LIST) ; true ; } \ |
|
178 $(call endrule,tracecompile) |
|
179 endef |
|
180 |
|
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"; \ |
94 $(GNUCAT) $(TRACE_SOURCE_LIST); \ |
196 $(GNUCAT) $(TRACE_SOURCE_LIST); \ |
95 echo -en "*ENDOFSOURCEFILES*\n" ) | \ |
197 echo -en "*ENDOFSOURCEFILES*\n" ) | \ |
96 $(JAVA_COMMAND) $(TRACE_COMPILER_START) $(UID_TC) && \ |
198 $(JAVA_COMMAND) $(TRACE_COMPILER_START) $(UID_TC) && \ |
97 $(GNUMD5SUM) $(TRACE_SOURCE_LIST) > $(TRACE_MARKER) && \ |
199 $(GNUMD5SUM) $(TRACE_SOURCE_LIST).new > $$@ 2>/dev/null && \ |
98 { $(GNUTOUCH) $(TRACE_DICTIONARY) $(AUTOGEN_HEADER); \ |
200 { $(GNUTOUCH) $(TRACE_DICTIONARY) $(AUTOGEN_HEADER); \ |
99 $(GNUCAT) $(TRACE_SOURCE_LIST) ; true ; } \ |
201 $(GNUCAT) $(TRACE_SOURCE_LIST) ; true ; } \ |
100 $(call endrule,tracecompile) |
202 $(call endrule,tracecompile) |
101 endef |
203 endef |
102 |
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 |
103 $(eval $(trace_compile)) |
219 $(eval $(trace_compile)) |
104 |
220 |
105 $(eval $(call GenerateStandardCleanTarget, $(TRACE_PATH)/tracebuilder.cache $(TRACE_MARKER) $(TRACE_SOURCE_LIST),,)) |
221 $(eval $(call GenerateStandardCleanTarget, $(TRACE_PATH)/tracebuilder.cache $(TRACE_MARKER) $(TRACE_SOURCE_LIST),,)) |
106 |
222 |
107 # End sanity guard |
223 $(call makepath,$(TRACE_PATH) $(dir $(TRACE_DICTIONARY) $(AUTOGEN_HEADER))) |
|
224 # End - guard that prevents repeated calls to TCom |
108 endif |
225 endif |
109 |
226 |
110 $(eval $(call GenerateStandardCleanTarget,$(TRACE_HEADERS),,)) |
227 $(eval $(call GenerateStandardCleanTarget,$(TRACE_HEADERS),,)) |
111 |
228 |
|
229 # End - Nothing to trace (not trace path in include) |
112 else |
230 else |
113 # Indicate to following parts of the FLM that we actually won't run |
231 # Indicate to following parts of the FLM that we actually won't run |
114 # trace compiler so they can set dependencies accordingly. |
232 # trace compiler so they can set dependencies accordingly. |
115 USE_TRACE_COMPILER:= |
233 USE_TRACE_COMPILER:= |
116 endif |
234 endif |