sbsv2/raptor/lib/flm/resource.flm
branchfix
changeset 468 27d111560672
parent 466 b9e5cf94aac3
child 470 f45853a5ce36
equal deleted inserted replaced
456:f9d258cee458 468:27d111560672
    57 
    57 
    58         # If there are multiple LANGUAGES then it is the last one in the list
    58         # If there are multiple LANGUAGES then it is the last one in the list
    59         # which produces the header.
    59         # which produces the header.
    60         HEADLANG:=$(lastword $(LANGUAGES:SC=sc))
    60         HEADLANG:=$(lastword $(LANGUAGES:SC=sc))
    61 else
    61 else
    62 	HEADLANG:=
    62         HEADLANG:=
    63     RESOURCEHEADER:=
    63     RESOURCEHEADER:=
    64 endif
    64 endif
    65 
    65 
    66 # we create intermediate .rpp and .d files
    66 # we create intermediate .rpp and .d files
    67 INTERBASE:=$(OUTPUTPATH)/$(TARGET_lower)$(if $(TARGETPATH),_$(subst /,_,$(TARGETPATH)),)
    67 INTERBASE:=$(OUTPUTPATH)/$(TARGET_lower)
    68 
    68 
    69 ################################## localisation ###########################$(GNUMKDIR)#############
    69 ################################## localisation ###########################$(GNUMKDIR)#############
    70 # Only make copies for full resource builds
    70 # Only make copies for full resource builds
    71 
    71 
    72 # Initialise to prevent RELEASABLES spill-over between calls
    72 # Initialise to prevent RELEASABLES spill-over between calls
   111 # make the output directories while reading makefile - some build engines prefer this
   111 # make the output directories while reading makefile - some build engines prefer this
   112 $(call makepath,$(INTERBASE))
   112 $(call makepath,$(INTERBASE))
   113 
   113 
   114 # common pre-processor options
   114 # common pre-processor options
   115 CPPOPT:=-nostdinc -undef -Wno-trigraphs -D_UNICODE -include $(PRODUCT_INCLUDE)\
   115 CPPOPT:=-nostdinc -undef -Wno-trigraphs -D_UNICODE -include $(PRODUCT_INCLUDE)\
   116  -I$(dir $(SOURCE)) $(foreach I, $(USERINCLUDE),-I$(I) ) -I- $(foreach J,$(SYSTEMINCLUDE),-I$(J) )
   116  -I$(dir $(SOURCE)) $(foreach I, $(USERINCLUDE),-iquote $(I) ) $(foreach J,$(SYSTEMINCLUDE),-I $(J) )
   117 
   117 
   118 CREATABLEPATHS:=$(RSCDIR) $(RSGDIR) $(OUTPUTPATH)
   118 CREATABLEPATHS:=$(RSCDIR) $(RSGDIR) $(OUTPUTPATH)
   119 
   119 
       
   120 # We intend to generate the resource in an intermediate locationand copy to the final destination to
       
   121 # ensure that when the "same" resource is built into separare locations it is 
       
   122 RSCCOPYDIRS:=$(RSCDIR)
   120 # additional binary resource copies performed based on BINCOPYDIRS
   123 # additional binary resource copies performed based on BINCOPYDIRS
   121 RSCCOPYDIRS:=
       
   122 ifneq ($(BINCOPYDIRS),)
   124 ifneq ($(BINCOPYDIRS),)
   123         RSCCOPYDIRS:=$(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS)))
   125         RSCCOPYDIRS:=$(RSCCOPYDIRS) $(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS)))
   124         CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCCOPYDIRS)
   126 endif
   125 endif
   127 CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCCOPYDIRS)
   126 
   128 
   127 ###############################################################################
   129 ###############################################################################
       
   130 
       
   131 
   128 define preprocessresource
   132 define preprocessresource
   129 # $(1) is the RPPFILE		(eg. /epoc32/build/xxx/b_sc.rpp)
   133 # $(1) is the RPPFILE		(eg. /epoc32/build/xxx/b_sc.rpp)
   130 # $(2) is the related RESOURCEFILE if any (eg. /a/b.rsc)
   134 # $(2) is the related RESOURCEFILE if any (eg. /a/b.rsc)
   131 # $(3) is the LANGUAGE		(eg. sc or 01 or 02 ...)
   135 # $(3) is the LANGUAGE		(eg. sc or 01 or 02 ...)
   132 
   136 
   133   ifeq ($(TARGET_$(call sanitise,$1)),)
   137   ifeq ($(TARGET_$(call sanitise,$1)),)
   134     TARGET_$(call sanitise,$1):=1
   138     TARGET_$(call sanitise,$1):=1
   135     $(if $(FLMDEBUG),$(info preprocessresource: $(1) for $(2) LANG:$(3)))
   139     $(if $(FLMDEBUG),$(info <debug>preprocessresource: $(1) for $(2) LANG:$(3)</debug>))
       
   140 
       
   141 
       
   142     # Correct dependency information when a header file can't be found.
       
   143     # If the c preprocessor can't find a dependency it appears as it did in the #include statement
       
   144     # e.g. "filename.mbg" or "filename.rsg" in the dependency file.
       
   145     # we can correct the dependencies by assuming that the file will be in epoc32\include as this is the default
       
   146     ifneq ($(NO_DEPEND_GENERATE),)
       
   147       # This version minimises the size of dependency files, to contain only .mbg and .rsg deps.
       
   148       # It allows resources to be built in the right order but doesn't impose the weight of
       
   149       # of full dependency information which can overwhelm make in large builds.
       
   150       DEPENDENCY_CORRECTOR:={ $(GNUSED) -n -r '1 p;\% [^ \/]+\.((rsg)|(mbg))%I {s% ([^ \/]+\.((rsg)|(mbg)))% $(EPOCROOT)\/epoc32\/include\/\1%ig; p}' && echo "" ; }
       
   151     else
       
   152       # Generate full dependency information
       
   153       DEPENDENCY_CORRECTOR:=$(GNUSED)  -r 's% ([^ \/]+\.((rsg)|(mbg)))% $(EPOCROOT)\/epoc32\/include\/\1%ig'
       
   154     endif
       
   155 
   136 
   156 
   137     RESOURCE_DEPS:: $(1).d
   157     RESOURCE_DEPS:: $(1).d
   138     $(1).d: $(SOURCE)
   158     $(1).d: $(SOURCE)
   139 	  $(call startrule,resourcedependencies,FORCESUCCESS) \
   159 	  $(call startrule,resourcedependencies,FORCESUCCESS) \
   140 	  $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\
   160 	  $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\
   141 	  $(CPPOPT) $(SOURCE) -M -MG -MT"$(1)" | \
   161 	  $(CPPOPT) $(SOURCE) -M -MG -MT"$(1)" | \
   142 	  $(GNUSED)  -r 's# ([^ \/]+\.((rsg)|(mbg)))# $(EPOCROOT)\/epoc32\/include\/\1#ig' > $(1).d \
   162 	  $(DEPENDENCY_CORRECTOR) >$$@ \
   143 	  $(call endrule,resourcedependencies)
   163 	  $(call endrule,resourcedependencies)
   144 
   164 
   145     $(1): $(1).d
   165     $(1): $(1).d
   146 	  $(call startrule,resourcepreprocess,FORCESUCCESS) \
   166 	  $(call startrule,resourcepreprocess,FORCESUCCESS) \
   147 	  $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\
   167 	  $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\
   154     $(eval DEPENDFILE:=$(wildcard $(DEPENDFILENAME)))
   174     $(eval DEPENDFILE:=$(wildcard $(DEPENDFILENAME)))
   155 
   175 
   156     CLEANTARGETS:=$$(CLEANTARGETS) $(DEPENDFILENAME)
   176     CLEANTARGETS:=$$(CLEANTARGETS) $(DEPENDFILENAME)
   157     ifneq "$(DEPENDFILE)" ""
   177     ifneq "$(DEPENDFILE)" ""
   158       ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" ""
   178       ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" ""
   159         -include $(DEPENDFILE)
   179         ifeq "$(filter RESOURCE_DEPS,$(call uppercase,$(MAKECMDGOALS)))" ""
       
   180           -include $(DEPENDFILE)
       
   181         endif
   160       endif
   182       endif
   161     endif
   183     endif
   162 
   184 
   163   endif
   185   endif
   164 endef # preprocessresource #
   186 endef # preprocessresource #
   212         endif
   234         endif
   213 #	Whether or not we have generated this resource for some other variant, check if there
   235 #	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
   236 #       are any new copies to be made for this variant. e.g. winscw requires that we make
   215 #       some extra copies.
   237 #       some extra copies.
   216 
   238 
       
   239         $(if $(FLMDEBUG),$(info <debug>resource copies of $(notdir $1) in: $(RSCCOPYDIRS)</debug>))
       
   240         $(foreach F,$(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS))),$(call copyresource,$(1),$(F)))
   217         $(foreach F,$(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS))),$(call copyresource,$(1),$(F)))
   241         $(foreach F,$(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS))),$(call copyresource,$(1),$(F)))
   218 
   242 
   219         # individual source file compilation
   243         # individual source file compilation
   220         SOURCETARGET_$(call sanitise,$(SOURCE)): $(1)
   244         SOURCETARGET_$(call sanitise,$(SOURCE)): $(1)
   221 
   245 
   230 
   254 
   231 		RELEASABLES:= $$(RELEASABLES) $(1)
   255 		RELEASABLES:= $$(RELEASABLES) $(1)
   232 
   256 
   233         ifeq ($(TARGET_$(call sanitise,$1)),)
   257         ifeq ($(TARGET_$(call sanitise,$1)),)
   234                 TARGET_$(call sanitise,$1):=1
   258                 TARGET_$(call sanitise,$1):=1
   235                 $(if $(FLMDEBUG),$(info resourceheader: $(1) from $(2) LANG:$(3)))
   259                 $(if $(FLMDEBUG),$(info <debug>resourceheader: $(1) from $(2) LANG:$(3)</debug>))
   236 
   260 
   237                 RESOURCE:: $(1)
   261                 RESOURCE:: $(1)
   238 
   262 
   239                 $(1): $(2) $(RCOMP)
   263                 $(1): $(2) $(RCOMP)
   240 			$(call startrule,resourceheader,FORCESUCCESS) \
   264 			$(call startrule,resourceheader,FORCESUCCESS) \
   259 endif
   283 endif
   260 
   284 
   261 ifeq ($(HEADERONLY),)
   285 ifeq ($(HEADERONLY),)
   262         # generate a resource file for each language
   286         # generate a resource file for each language
   263         # For sc we generate $(RESBASE).rsc and define LANGUAGE_SC and LANGUAGE_sc.
   287         # 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))))
   288         $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call preprocessresource,$(INTERBASE)_$(L).rpp,$(INTERBASE).r$(L),$(L))))
   265         $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call generateresource,$(RESBASE).r$(L),$(INTERBASE)_$(L).rpp,$(L))))
   289         $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call generateresource,$(INTERBASE).r$(L),$(INTERBASE)_$(L).rpp,$(L))))
   266 else
   290 else
   267         # No resources are going to be made so unless we specifically ask for it, there will be no
   291         # 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:
   292         # preprocessed file from which to create the header:
   269 
   293 
   270         $(eval $(call preprocessresource,$(INTERBASE)_$(HEADLANG).rpp,,$(HEADLANG)))
   294         $(eval $(call preprocessresource,$(INTERBASE)_$(HEADLANG).rpp,,$(HEADLANG)))