author | Richard Taylor <richard.i.taylor@nokia.com> |
Tue, 04 May 2010 12:08:55 +0100 | |
branch | wip |
changeset 507 | 54a88b895bcd |
parent 394 | b6f8d38305f2 |
child 462 | 7f12c652f36d |
child 464 | a6aa62a0998d |
permissions | -rw-r--r-- |
394 | 1 |
# Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 | 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 |
# Function Like Makefile (FLM) to create a resource header (.rsg) |
|
15 |
# and resource files (.rsc, .r01, .r02 etc.) |
|
16 |
# |
|
17 |
# |
|
18 |
||
19 |
## Parameters that are expected: |
|
20 |
# TARGET |
|
21 |
# TARGETPATH |
|
22 |
# LANGUAGES |
|
23 |
# HEADER |
|
24 |
# HEADERONLY |
|
25 |
# EPOCROOT |
|
26 |
# MMPDEFS |
|
27 |
# PRODUCT_INCLUDE |
|
28 |
# SYSTEMINCLUDE |
|
29 |
# USERINCLUDE |
|
30 |
# GNUCPP |
|
31 |
# GNUSED |
|
32 |
# RCOMP |
|
33 |
# OUTPUTPATH |
|
34 |
# SOURCE |
|
35 |
# BINCOPYDIRS |
|
36 |
||
37 |
||
38 |
# The rss is pre-processed once for each language and results |
|
39 |
# in a file with extension r$(LANGUAGE) where $(LANGUAGE) is |
|
40 |
# either "sc" or a 2 (or more) digit number. |
|
41 |
ifneq ($(TARGETPATH),) |
|
42 |
RSCDIR:=$(subst //,/,$(EPOCROOT)/epoc32/data/z/$(TARGETPATH)) |
|
43 |
else |
|
44 |
RSCDIR:=$(subst //,/,$(EPOCROOT)/epoc32/data) |
|
45 |
endif |
|
46 |
RESBASE:=$(RSCDIR)/$(TARGET_lower) |
|
47 |
||
48 |
# Ensure that RELEASABLES and CLEANTARGETS cannot expand indefinitely in successive calls to this flm: |
|
49 |
CLEANTARGETS:= |
|
50 |
RELEASABLES:= |
|
51 |
||
52 |
# There is only one resource header (.rsg) file and we only |
|
53 |
# make that if we are asked. |
|
54 |
RSGDIR:=$(EPOCROOT)/epoc32/include |
|
55 |
ifneq ($(or $(HEADER),$(HEADERONLY)),) |
|
56 |
RESOURCEHEADER:=$(RSGDIR)/$(HEADER) |
|
57 |
||
58 |
# If there are multiple LANGUAGES then it is the last one in the list |
|
59 |
# which produces the header. |
|
60 |
HEADLANG:=$(lastword $(LANGUAGES:SC=sc)) |
|
61 |
else |
|
62 |
HEADLANG:= |
|
63 |
RESOURCEHEADER:= |
|
64 |
endif |
|
65 |
||
66 |
# we create intermediate .rpp and .d files |
|
67 |
INTERBASE:=$(OUTPUTPATH)/$(TARGET_lower)$(if $(TARGETPATH),_$(subst /,_,$(TARGETPATH)),) |
|
68 |
||
69 |
################################## localisation ###########################$(GNUMKDIR)############# |
|
70 |
# Only make copies for full resource builds |
|
71 |
||
72 |
# Initialise to prevent RELEASABLES spill-over between calls |
|
73 |
DESTRPP:= |
|
74 |
INFOFILE:= |
|
75 |
||
76 |
ifeq ($(HEADERONLY),) |
|
77 |
||
78 |
RSSBASENAME:=$(call lowercase,$(basename $(notdir $(SOURCE)))) |
|
79 |
DESTRPP:=$(EPOCROOT)/epoc32/localisation/$(RSSBASENAME)/rsc/$(RSSBASENAME).rpp |
|
80 |
$(call makepath,$(EPOCROOT)/epoc32/localisation/$(RSSBASENAME)/rsc) |
|
81 |
||
82 |
INFOFILE:=$(EPOCROOT)/epoc32/localisation/group/$(RSSBASENAME).info |
|
83 |
# If there are MULTIPLE languages then copy the .rpp for the last one |
|
84 |
RPPLANG:=$(lastword $(LANGUAGES:SC=sc)) |
|
85 |
||
86 |
# Copy .rpp files from epoc32/build/ to epoc32/localisation/x/rsc/x.rpp and create .info files in localisation |
|
87 |
define CreateRppAndInfo |
|
88 |
||
89 |
ifeq ($(RESOURCE_$(call sanitise,$(SOURCE))),) |
|
90 |
RESOURCE_$(call sanitise,$(SOURCE)):=1 |
|
91 |
||
92 |
RESOURCE:: $(DESTRPP) $(INFOFILE) |
|
93 |
||
94 |
$(DESTRPP): $(INTERBASE)_$(RPPLANG).rpp |
|
95 |
$(call startrule,rppfilecopy,FORCESUCCESS) \ |
|
96 |
$(GNUCP) $$< $$@ \ |
|
97 |
$(call endrule,rppfilecopy) |
|
98 |
||
99 |
$(INFOFILE):: |
|
100 |
@if [ ! -d $(EPOCROOT)/epoc32/localisation/group ]; then $(GNUMKDIR) -p $(EPOCROOT)/epoc32/localisation/group; fi |
|
101 |
@if [ ! -f $$@ ]; then echo "DATADIR: /$(RSSBASENAME)" > $$@ ; fi |
|
102 |
@echo -e "\n/z$(TARGETPATH)/$(TARGET_lower).rsc : $(RSSBASENAME).rpp" >> $$@ |
|
103 |
||
104 |
endif |
|
105 |
endef |
|
106 |
||
107 |
$(eval $(call CreateRppAndInfo)) |
|
108 |
endif |
|
109 |
################################# end of localisation ################################### |
|
110 |
||
111 |
# make the output directories while reading makefile - some build engines prefer this |
|
112 |
$(call makepath,$(INTERBASE)) |
|
113 |
||
114 |
# common pre-processor options |
|
393
629079c72ee4
Suppress trigraph warnings in resource file preprocessing.
Jon Chatten
parents:
5
diff
changeset
|
115 |
CPPOPT:=-nostdinc -undef -Wno-trigraphs -D_UNICODE -include $(PRODUCT_INCLUDE)\ |
3 | 116 |
-I$(dir $(SOURCE)) $(foreach I, $(USERINCLUDE),-I$(I) ) -I- $(foreach J,$(SYSTEMINCLUDE),-I$(J) ) |
117 |
||
118 |
CREATABLEPATHS:=$(RSCDIR) $(RSGDIR) $(OUTPUTPATH) |
|
119 |
||
120 |
# additional binary resource copies performed based on BINCOPYDIRS |
|
121 |
RSCCOPYDIRS:= |
|
122 |
ifneq ($(BINCOPYDIRS),) |
|
123 |
RSCCOPYDIRS:=$(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS))) |
|
124 |
CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCCOPYDIRS) |
|
125 |
endif |
|
126 |
||
127 |
############################################################################### |
|
128 |
define preprocessresource |
|
129 |
# $(1) is the RPPFILE (eg. /epoc32/build/xxx/b_sc.rpp) |
|
130 |
# $(2) is the related RESOURCEFILE if any (eg. /a/b.rsc) |
|
131 |
# $(3) is the LANGUAGE (eg. sc or 01 or 02 ...) |
|
132 |
||
133 |
ifeq ($(TARGET_$(call sanitise,$1)),) |
|
134 |
TARGET_$(call sanitise,$1):=1 |
|
135 |
$(if $(FLMDEBUG),$(info preprocessresource: $(1) for $(2) LANG:$(3))) |
|
136 |
||
137 |
RESOURCE_DEPS:: $(1).d |
|
138 |
$(1).d: $(SOURCE) |
|
139 |
$(call startrule,resourcedependencies,FORCESUCCESS) \ |
|
140 |
$(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\ |
|
141 |
$(CPPOPT) $(SOURCE) -M -MG -MT"$(1)" | \ |
|
142 |
$(GNUSED) -r 's# ([^ \/]+\.((rsg)|(mbg)))# $(EPOCROOT)\/epoc32\/include\/\1#ig' > $(1).d \ |
|
143 |
$(call endrule,resourcedependencies) |
|
144 |
||
145 |
$(1): $(1).d |
|
146 |
$(call startrule,resourcepreprocess,FORCESUCCESS) \ |
|
147 |
$(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\ |
|
148 |
$(CPPOPT) $(SOURCE) -o $$@ \ |
|
149 |
$(call endrule,resourcepreprocess) |
|
150 |
||
151 |
CLEANTARGETS:= $$(CLEANTARGETS) $(1) |
|
152 |
||
153 |
$(eval DEPENDFILENAME:=$(1).d) |
|
154 |
$(eval DEPENDFILE:=$(wildcard $(DEPENDFILENAME))) |
|
155 |
||
156 |
CLEANTARGETS:=$$(CLEANTARGETS) $(DEPENDFILENAME) |
|
157 |
ifneq "$(DEPENDFILE)" "" |
|
158 |
ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" "" |
|
159 |
-include $(DEPENDFILE) |
|
160 |
endif |
|
161 |
endif |
|
162 |
||
163 |
endif |
|
164 |
endef # preprocessresource # |
|
165 |
||
166 |
############################################################################### |
|
167 |
define copyresource |
|
168 |
# $(1) is the source |
|
169 |
# $(2) is the destination |
|
170 |
||
171 |
RELEASABLES:=$$(RELEASABLES) $(2) |
|
172 |
||
173 |
ifeq ($(TARGET_$(call sanitise,$2)),) |
|
174 |
TARGET_$(call sanitise,$2):=1 |
|
175 |
||
176 |
RESOURCE:: $2 |
|
177 |
## perform additional copies of binaries |
|
178 |
# |
|
179 |
# Only certain builds require further copies of the generated resource binaries |
|
180 |
# |
|
181 |
$(2): $(1) |
|
182 |
$(call startrule,resourcecopy,FORCESUCCESS) \ |
|
183 |
$(GNUCP) $$< $$@ \ |
|
184 |
$(call endrule,resourcecopy) |
|
185 |
||
186 |
endif |
|
187 |
||
188 |
endef # copyresource # |
|
189 |
||
190 |
############################################################################### |
|
191 |
define generateresource |
|
192 |
||
193 |
# $(1) is the resource filename e.g. /a/b/resource.rsc |
|
194 |
# $(2) is the preprocessed resource to make it from |
|
195 |
# $(3) is the language e.g. sc or 01 or 02 |
|
196 |
||
197 |
RELEASABLES:=$$(RELEASABLES) $(1) |
|
198 |
||
199 |
ifeq ($(TARGET_$(call sanitise,$1)),) |
|
200 |
TARGET_$(call sanitise,$1):=1 |
|
201 |
||
202 |
$(if $(FLMDEBUG),$(info generateresource: $(1) from $(2) LANG:$(3)),) |
|
203 |
||
204 |
||
205 |
RESOURCE:: $(1) |
|
206 |
||
207 |
$(1): $(2) $(RCOMP) |
|
208 |
$(call startrule,resourcecompile,FORCESUCCESS) \ |
|
209 |
$(RCOMP) -m045,046,047 -u -o$(1) -s$(2) \ |
|
210 |
$(call endrule,resourcecompile) |
|
211 |
||
212 |
endif |
|
213 |
# Whether or not we have generated this resource for some other variant, check if there |
|
214 |
# are any new copies to be made for this variant. e.g. winscw requires that we make |
|
215 |
# some extra copies. |
|
216 |
||
217 |
$(foreach F,$(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS))),$(call copyresource,$(1),$(F))) |
|
218 |
||
219 |
# individual source file compilation |
|
220 |
SOURCETARGET_$(call sanitise,$(SOURCE)): $(1) |
|
221 |
||
222 |
endef # generateresource |
|
223 |
||
224 |
||
225 |
############################################################################### |
|
226 |
define generateresourceheader |
|
227 |
# $(1) is the resource header (eg. /epoc32/include/a.rsg) |
|
228 |
# $(2) is the preprocessed resource to make it from |
|
229 |
# $(3) is the language to use (eg. sc) |
|
230 |
||
231 |
RELEASABLES:= $$(RELEASABLES) $(1) |
|
232 |
||
233 |
ifeq ($(TARGET_$(call sanitise,$1)),) |
|
234 |
TARGET_$(call sanitise,$1):=1 |
|
235 |
$(if $(FLMDEBUG),$(info resourceheader: $(1) from $(2) LANG:$(3))) |
|
236 |
||
237 |
RESOURCE:: $(1) |
|
238 |
||
239 |
$(1): $(2) $(RCOMP) |
|
240 |
$(call startrule,resourceheader,FORCESUCCESS) \ |
|
241 |
$(RCOMP) -m045,046,047 -u -h$(1) -s$(2) \ |
|
242 |
$(call endrule,resourceheader) |
|
243 |
||
244 |
endif |
|
245 |
||
246 |
||
247 |
# individual source file compilation |
|
248 |
SOURCETARGET_$(call sanitise,$(SOURCE)): $(1) |
|
249 |
||
250 |
endef |
|
251 |
||
252 |
############################################################################### |
|
253 |
## call the generator |
|
254 |
||
255 |
# We always create at least the header |
|
256 |
# even if we sometimes don't create the resources |
|
257 |
ifneq ($(RESOURCEHEADER),) |
|
258 |
$(eval $(call generateresourceheader,$(RESOURCEHEADER),$(INTERBASE)_$(HEADLANG).rpp,$(HEADLANG))) |
|
259 |
endif |
|
260 |
||
261 |
ifeq ($(HEADERONLY),) |
|
262 |
# generate a resource file for each language |
|
263 |
# For sc we generate $(RESBASE).rsc and define LANGUAGE_SC and LANGUAGE_sc. |
|
264 |
$(foreach L,$(LANGUAGES:SC=sc),$(eval $(call preprocessresource,$(INTERBASE)_$(L).rpp,$(RESBASE).r$(L),$(L)))) |
|
265 |
$(foreach L,$(LANGUAGES:SC=sc),$(eval $(call generateresource,$(RESBASE).r$(L),$(INTERBASE)_$(L).rpp,$(L)))) |
|
266 |
else |
|
267 |
# No resources are going to be made so unless we specifically ask for it, there will be no |
|
268 |
# preprocessed file from which to create the header: |
|
269 |
||
270 |
$(eval $(call preprocessresource,$(INTERBASE)_$(HEADLANG).rpp,,$(HEADLANG))) |
|
271 |
||
272 |
endif |
|
273 |
||
274 |
############################################################################### |
|
275 |
## .rfi generation in support of the gccxml build |
|
276 |
## Note that .rfi files are created from the dependency files generated from preprocessing resources to create .rpp files |
|
277 |
ifneq ($(RFIFILE),) |
|
278 |
RESOURCE:: $(RFIFILE) |
|
279 |
RELEASABLES:=$(RELEASABLES) $(RFIFILE) |
|
280 |
CREATABLEPATHS:=$(CREATABLEPATHS) $(dir $(RFIFILE)) |
|
281 |
||
282 |
RPPFILES:=$(foreach L,$(LANGUAGES:SC=sc),$(INTERBASE)_$(L).rpp) |
|
283 |
$(eval $(call generaterfifile,$(RFIFILE),$(RPPFILES),$(addsuffix .d,$(RPPFILES)))) |
|
284 |
endif |
|
285 |
||
286 |
||
287 |
## Clean up |
|
5 | 288 |
$(call raptor_clean,$(CLEANTARGETS)) |
3 | 289 |
# make the output directories while reading makefile - some build engines prefer this |
290 |
$(call makepath,$(CREATABLEPATHS)) |
|
291 |
||
5 | 292 |
# for the --what option and the log file |
3 | 293 |
RELEASABLES:=$(RELEASABLES) $(DESTRPP) $(INFOFILE) |
5 | 294 |
$(call raptor_release,$(RELEASABLES),RESOURCE) |
3 | 295 |