sbsv2/raptor/lib/flm/bitmap.flm
changeset 0 044383f39525
child 3 e1eecf4d390d
child 590 360bd6b35136
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 # Copyright (c) 2007-2009 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 # Header file exporting Function Like Makefile (FLM)
       
    15 # The file destinations  relative to EPOCROOT
       
    16 # 
       
    17 #
       
    18 
       
    19 ## Parameters that are expected:
       
    20 # BMCONV
       
    21 # EPOCROOT
       
    22 # HEADER
       
    23 # OUTPUTPATH
       
    24 # SOURCE
       
    25 # BMTARGET
       
    26 # TARGETPATH
       
    27 # BINCOPYDIRS
       
    28 
       
    29 ifneq ($(TARGETPATH),)
       
    30 DATAPATH:=$(subst //,/,$(EPOCROOT)/epoc32/data/z/$(TARGETPATH))
       
    31 else
       
    32 DATAPATH:=$(subst //,/,$(EPOCROOT)/epoc32/data)
       
    33 endif
       
    34 CREATABLEPATHS:=$(DATAPATH) $(OUTPUTPATH)
       
    35 
       
    36 BITMAPFILE:=$(subst //,/,$(DATAPATH)/$(BMTARGET))
       
    37 
       
    38 # additional binary resource copies performed based on BINCOPYDIRS
       
    39 MBMCOPYDIRS:=
       
    40 MBMCOPYFILES:=
       
    41 ifneq ($(BINCOPYDIRS),)
       
    42   MBMCOPYDIRS:=$(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS)))
       
    43   CREATABLEPATHS:=$(CREATABLEPATHS) $(MBMCOPYDIRS)
       
    44   MBMCOPYFILES:=$(subst //,/,$(patsubst %, %/$(notdir $(BITMAPFILE)),$(MBMCOPYDIRS)))
       
    45 endif
       
    46 
       
    47 
       
    48 ifneq ($(HEADER),)
       
    49 BITMAPHEADER:=$(subst //,/,$(EPOCROOT)/epoc32/include/$(basename $(BMTARGET)).mbg)
       
    50 else
       
    51 BITMAPHEADER:=
       
    52 endif
       
    53 
       
    54 
       
    55 # SOURCE is something like "DEPTH=2 FILE=/var/local/fred.bmp"
       
    56 # Extract the file parts for the dependencies.
       
    57 # Generate -2/var/local/fred.bmp for the command-line argument.
       
    58 SOURCEDEPS:=$(subst //,/,$(subst FILE=,,$(filter FILE=%,$(SOURCE))))
       
    59 SOURCEARGS:=$(subst //,/,$(subst DEPTH=,-,$(subst $(CHAR_SPACE)FILE=,,$(SOURCE))))
       
    60 
       
    61 BMCONVCMDFILE:=$(OUTPUTPATH)/$(BMTARGET)_bmconvcommands
       
    62 RELEASEABLES:=$(BITMAPHEADER) $(BITMAPFILE)
       
    63 CLEANTARGETS:=$(BITMAPHEADER) $(BITMAPFILE) $(BMCONVCMDFILE)
       
    64 
       
    65 # The groupbmpin10 macro allows us to construct a command file, 10 
       
    66 # bitmap objects at a time to avoid limits on argument lengths and 
       
    67 # sizes on Windows.
       
    68 define groupbmpin10
       
    69 	$(if $1,$(shell echo -e $(foreach L,$(wordlist 1,10,$1),"$(L)\\n") >>$(BMCONVCMDFILE)),)
       
    70 	$(if $1,$(call groupbmpin10,$(wordlist 11,$(words $1),$1)))
       
    71 endef
       
    72 
       
    73 GUARD:=$(call sanitise,TARGET_$(BITMAPFILE))
       
    74 define generatebitmap
       
    75 $(GUARD):=1
       
    76 
       
    77 BITMAP:: $(RELEASEABLES)
       
    78 
       
    79 ifneq ($(BITMAPHEADER),)
       
    80 $(BITMAPHEADER): $(BITMAPFILE)
       
    81 endif
       
    82 
       
    83 # Create commandfile during parse so that the log is not littered with 
       
    84 # these commands in parallel builds.
       
    85 $(info <bmconvcmdfile>)
       
    86 $(info $(BMCONVCMDFILE))
       
    87 $(shell $(GNUMKDIR) -p "$(dir $(BMCONVCMDFILE))")
       
    88 $(if $(BITMAPHEADER),$(shell echo -e "-h$(BITMAPHEADER)\n$(BITMAPFILE)" >$(BMCONVCMDFILE)),$(shell echo "$(BITMAPFILE)" >$(BMCONVCMDFILE)) )
       
    89 $(call groupbmpin10, $(SOURCEARGS))
       
    90 $(info </bmconvcmdfile>)
       
    91 
       
    92 $(BITMAPFILE): $(SOURCEDEPS) $(BMCONV) 
       
    93 	$(call startrule,bitmapcompile,FORCESUCCESS) \
       
    94 	$(BMCONV) $(BMCONVCMDFILE) \
       
    95 	$(call endrule,bitmapcompile)
       
    96 
       
    97 endef
       
    98 
       
    99 
       
   100 # Some builds require further copies of the generated mbm binaries
       
   101 define copybitmap
       
   102 
       
   103 BITMAP:: $(MBMCOPYFILES)
       
   104 
       
   105 $(MBMCOPYFILES): $(BITMAPFILE) 
       
   106 	$(call startrule,bitmapcopy,FORCESUCCESS) \
       
   107 	$(GNUCP) $$< $$@ \
       
   108 	$(call endrule,bitmapcopy)
       
   109 
       
   110 CLEANTARGETS:=$(CLEANTARGETS) $(MBMCOPYFILES)
       
   111 endef
       
   112 
       
   113 
       
   114 ifeq ($($(GUARD)),)
       
   115 $(eval $(call generatebitmap))
       
   116 endif
       
   117 
       
   118 ifneq ($(MBMCOPYFILES),)
       
   119 $(eval $(call copybitmap))
       
   120 endif
       
   121 
       
   122 ################################### localisation #########################################
       
   123 ## copy .bmp files to localisation
       
   124 
       
   125 # $(BMPFILES) is a list of bmp files in src
       
   126 BMPFILES:=$(subst FILE=,,$(filter FILE=%,$(SOURCE)))
       
   127 BMBASENAME:=$(call lowercase,$(basename $(BMTARGET)))
       
   128 BMPCOPYFILES:=
       
   129 BMPCOPYDIR:=$(EPOCROOT)/epoc32/localisation/$(BMBASENAME)/mbm
       
   130 $(call makepath,$(BMPCOPYDIR))
       
   131 
       
   132 define copyBMP
       
   133 # $(1) is the source .bmp file
       
   134 # $(2) is the (lower cased) copy in localisation 
       
   135 
       
   136 ifneq ($(BINCOPYDIRS),)
       
   137 BITMAP:: $(2)
       
   138 
       
   139 $(2): $(1)
       
   140 	$(call startrule,bmpfilecopy,FORCESUCCESS) \
       
   141 	$(GNUCP) $(1) $(2) && $(GNUCHMOD) +rw $(2) \
       
   142 	$(call endrule,bmpfilecopy)
       
   143 
       
   144 CLEANTARGETS:=$$(CLEANTARGETS) $(2)
       
   145 endif
       
   146 
       
   147 BMPCOPYFILES:=$$(BMPCOPYFILES) $(2)
       
   148 endef
       
   149 
       
   150 $(foreach BMP,$(BMPFILES),$(eval $(call copyBMP,$(BMP),$(BMPCOPYDIR)/$(call lowercase,$(notdir $(BMP))))))
       
   151 
       
   152 ## create and edit info files for bitmap files in localisation/group
       
   153 INFOFILE:=$(EPOCROOT)/epoc32/localisation/group/$(BMBASENAME).info
       
   154 DEPTH:=$(subst DEPTH=,,$(filter DEPTH=%,$(SOURCE)))
       
   155 BMP:=$(notdir $(BMPFILES))
       
   156 DEPTHBMP:=$(subst _,\,$(join $(patsubst %,/%,$(DEPTH)),$(patsubst %,_%,$(BMP))))
       
   157 
       
   158 define bmpInfo
       
   159 
       
   160 BITMAP::$(INFOFILE)
       
   161 
       
   162 $(INFOFILE)::
       
   163 	@if [ ! -d $(EPOCROOT)/epoc32/localisation/group ]; then $(GNUMKDIR) -p $(EPOCROOT)/epoc32/localisation/group; fi
       
   164 	@if [ ! -f $$@ ]; then echo "DATADIR: /$(BMBASENAME)" > $$@ ; fi
       
   165 	@echo -e "\n/z$(TARGETPATH)/$(BMTARGET) : $(DEPTHBMP)" >> $$@
       
   166 
       
   167 CLEANTARGETS:=$$(CLEANTARGETS) $(INFOFILE)
       
   168 endef
       
   169 
       
   170 $(eval $(call bmpInfo))
       
   171 
       
   172 # end of localisation #########################################################
       
   173 
       
   174 ## Clean up
       
   175 $(eval $(call GenerateStandardCleanTarget,$(CLEANTARGETS) ,$(CREATABLEPATHS)))
       
   176 $(call makepath,$(CREATABLEPATHS))
       
   177 $(call makepathfor,$(BITMAPHEADER))
       
   178 
       
   179 # for the abld -what target
       
   180 BMPRELEASEABLES:=$(RELEASEABLES) $(MBMCOPYFILES) $(BMPCOPYFILES) $(INFOFILE)
       
   181 $(eval $(call whatmacro,$(BMPRELEASEABLES),WHATBITMAP))
       
   182