diff -r 1f5ab557c1d0 -r 4d8a8d0b17c0 sbsv2/raptor/lib/flm/resource.flm --- a/sbsv2/raptor/lib/flm/resource.flm Wed Apr 14 14:36:58 2010 +0100 +++ b/sbsv2/raptor/lib/flm/resource.flm Tue Apr 20 12:08:50 2010 +0100 @@ -59,12 +59,12 @@ # which produces the header. HEADLANG:=$(lastword $(LANGUAGES:SC=sc)) else - HEADLANG:= + HEADLANG:= RESOURCEHEADER:= endif # we create intermediate .rpp and .d files -INTERBASE:=$(OUTPUTPATH)/$(TARGET_lower)$(if $(TARGETPATH),_$(subst /,_,$(TARGETPATH)),) +INTERBASE:=$(OUTPUTPATH)/$(TARGET_lower) ################################## localisation ###########################$(GNUMKDIR)############# # Only make copies for full resource builds @@ -112,19 +112,30 @@ $(call makepath,$(INTERBASE)) # common pre-processor options + +# We really should be using -iquote with a recent cpp. This is a note for when we do update: +#CPPOPT:=-nostdinc -undef -Wno-trigraphs -D_UNICODE -include $(PRODUCT_INCLUDE)\ +# -I$(dir $(SOURCE)) $(foreach I, $(USERINCLUDE),-iquote $(I) ) $(foreach J,$(SYSTEMINCLUDE),-I $(J) ) + CPPOPT:=-nostdinc -undef -Wno-trigraphs -D_UNICODE -include $(PRODUCT_INCLUDE)\ -I$(dir $(SOURCE)) $(foreach I, $(USERINCLUDE),-I$(I) ) -I- $(foreach J,$(SYSTEMINCLUDE),-I$(J) ) CREATABLEPATHS:=$(RSCDIR) $(RSGDIR) $(OUTPUTPATH) +# We intend to generate the resource in an intermediate location and copy to the targetpath to +# ensure that when the "same" resource is built into separare target paths, it doesn't have to be +# completely recreated each time - just copied. +RSCCOPYDIRS:=$(RSCDIR) + # additional binary resource copies performed based on BINCOPYDIRS -RSCCOPYDIRS:= ifneq ($(BINCOPYDIRS),) - RSCCOPYDIRS:=$(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS))) - CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCCOPYDIRS) + RSCCOPYDIRS:=$(RSCCOPYDIRS) $(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS))) endif +CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCCOPYDIRS) ############################################################################### + + define preprocessresource # $(1) is the RPPFILE (eg. /epoc32/build/xxx/b_sc.rpp) # $(2) is the related RESOURCEFILE if any (eg. /a/b.rsc) @@ -132,21 +143,42 @@ ifeq ($(TARGET_$(call sanitise,$1)),) TARGET_$(call sanitise,$1):=1 - $(if $(FLMDEBUG),$(info preprocessresource: $(1) for $(2) LANG:$(3))) + $(if $(FLMDEBUG),$(info preprocessresource: $(1) for $(2) LANG:$(3))) + + + # Correct dependency information when a header file can't be found. + # If the c preprocessor can't find a dependency it appears as it did in the #include statement + # e.g. "filename.mbg" or "filename.rsg" in the dependency file. + # we can correct the dependencies by assuming that the file will be in epoc32\include as this is the default + ifneq ($(NO_DEPEND_GENERATE),) + # This version minimises the size of dependency files, to contain only .mbg and .rsg deps. + # It allows resources to be built in the right order but doesn't impose the weight of + # of full dependency information which can overwhelm make in large builds. + # The strategy is to filter out lines (apart from the target line which is the first) which don't have .rsg or + # .mbg dependencies in them. The first line can sometimes not contain the target but + # have a lonely "\" so we use a pattern to recognise the target line in order not to get confused. + DEPENDENCY_CORRECTOR:={ $(GNUSED) -n -r '/.*: +.$$$$/ p;\%\.((rsg)|(mbg))%I {s% ([^ \/]+\.((rsg)|(mbg)))% __EPOCROOT\/epoc32\/include\/\1%ig;s% [^_][^_][^E][^ ]+%%g;s%__EPOCROOT%$(EPOCROOT)%g; p}' && echo "" ; } + else + # Generate full dependency information + DEPENDENCY_CORRECTOR:=$(GNUSED) -r 's% ([^ \/]+\.((rsg)|(mbg)))% $(EPOCROOT)\/epoc32\/include\/\1%ig' + endif + RESOURCE_DEPS:: $(1).d $(1).d: $(SOURCE) $(call startrule,resourcedependencies,FORCESUCCESS) \ $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\ $(CPPOPT) $(SOURCE) -M -MG -MT"$(1)" | \ - $(GNUSED) -r 's# ([^ \/]+\.((rsg)|(mbg)))# $(EPOCROOT)\/epoc32\/include\/\1#ig' > $(1).d \ + $$(DEPENDENCY_CORRECTOR) >$$@ \ $(call endrule,resourcedependencies) + ifeq "$(MAKEFILE_GROUP)" "RESOURCE" $(1): $(1).d $(call startrule,resourcepreprocess,FORCESUCCESS) \ $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\ $(CPPOPT) $(SOURCE) -o $$@ \ $(call endrule,resourcepreprocess) + endif CLEANTARGETS:= $$(CLEANTARGETS) $(1) @@ -156,7 +188,9 @@ CLEANTARGETS:=$$(CLEANTARGETS) $(DEPENDFILENAME) ifneq "$(DEPENDFILE)" "" ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" "" - -include $(DEPENDFILE) + ifeq "$(MAKEFILE_GROUP)" "RESOURCE" + -include $(DEPENDFILE) + endif endif endif @@ -176,8 +210,6 @@ RESOURCE:: $2 ## perform additional copies of binaries # - # Only certain builds require further copies of the generated resource binaries - # $(2): $(1) $(call startrule,resourcecopy,FORCESUCCESS) \ $(GNUCP) $$< $$@ \ @@ -194,26 +226,32 @@ # $(2) is the preprocessed resource to make it from # $(3) is the language e.g. sc or 01 or 02 - RELEASABLES:=$$(RELEASABLES) $(1) ifeq ($(TARGET_$(call sanitise,$1)),) TARGET_$(call sanitise,$1):=1 - $(if $(FLMDEBUG),$(info generateresource: $(1) from $(2) LANG:$(3)),) + $(if $(FLMDEBUG),$(info generateresource: $(1) from $(2) LANG:$(3)),) + $(if $(FLMDEBUG),$(info generateresource: copies: $(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS))))) + CLEANTARGETS:=$$(CLEANTARGETS) $(1) RESOURCE:: $(1) $(1): $(2) $(RCOMP) $(call startrule,resourcecompile,FORCESUCCESS) \ - $(RCOMP) -m045,046,047 -u -o$(1) -s$(2) \ + $(RCOMP) -m045,046,047 -u -o$(1) -s$(2) && \ + { $(foreach F,$(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS))),$(GNUCP) $(1) $(F) ; ) } \ $(call endrule,resourcecompile) endif + # Whether or not we have generated this resource for some other variant, check if there # are any new copies to be made for this variant. e.g. winscw requires that we make -# some extra copies. +# some extra copies. We tried to copy after running rcomp itself but we still need these +# targets for the sake of dependencies or, for example if someone merely adds a new copy +# when the resource is up-to-date + $(if $(FLMDEBUG),$(info resource copies of $(notdir $1) in: $(RSCCOPYDIRS))) $(foreach F,$(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS))),$(call copyresource,$(1),$(F))) # individual source file compilation @@ -232,7 +270,7 @@ ifeq ($(TARGET_$(call sanitise,$1)),) TARGET_$(call sanitise,$1):=1 - $(if $(FLMDEBUG),$(info resourceheader: $(1) from $(2) LANG:$(3))) + $(if $(FLMDEBUG),$(info resourceheader: $(1) from $(2) LANG:$(3))) RESOURCE:: $(1) @@ -261,8 +299,11 @@ ifeq ($(HEADERONLY),) # generate a resource file for each language # For sc we generate $(RESBASE).rsc and define LANGUAGE_SC and LANGUAGE_sc. - $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call preprocessresource,$(INTERBASE)_$(L).rpp,$(RESBASE).r$(L),$(L)))) - $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call generateresource,$(RESBASE).r$(L),$(INTERBASE)_$(L).rpp,$(L)))) + $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call preprocessresource,$(INTERBASE)_$(L).rpp,$(INTERBASE).r$(L),$(L)))) + + ifeq "$(MAKEFILE_GROUP)" "RESOURCE" + $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call generateresource,$(INTERBASE).r$(L),$(INTERBASE)_$(L).rpp,$(L)))) + endif else # No resources are going to be made so unless we specifically ask for it, there will be no # preprocessed file from which to create the header: