Commits

Trammell Hudson committed cf965f2

Image bundling works

Comments (0)

Files changed (1)

 # 	SRCS with a list of source files.
 #	APP := project to build
 #	FONTS := list of fonts to bundle
+#	IMAGES := list of images to bundle
 #
 # Change PEBBLE_HOME to point to the sdk directory
 # and GCC_PREFIX to point to your arm-none-eabi gcc tree.
 VERSION ?= 0.1
 APP ?= pebble-app
 
+
+# Helper macros
+map = $(foreach f,$2,$(call $1,$f))
+uppercase = $(shell echo $(basename $(notdir $1)) | tr '[a-z]-.' '[A-Z]__')
+
+
 #
 # If no output directory is specified, put things into ../build/
 #
 
 clean:
 	$(RM) \
-		$O/*.{o,a,pbw,pfo,elf,bin,map} \
+		$O/*.{o,a,pbw,pfo,pbi,elf,bin,map} \
 		a.out \
 		core \
 		$O/*.pbpack \
 # targets for each font to be generated and as well as the
 # resource list to pass into the make bundle tool.
 #
-map = $(foreach f,$2,$(call $1,$f))
 
 $O/%.pfo:
 	$(PYTHON) $(PEBBLE_HOME)/tools/font/fontgen.py \
 		$@ \
 
 mkfont_rules = \
-	$(eval F = $(word 1,$1)) \
-	$(eval S = $(word 2,$1)) \
-	$(eval R = FONT_$(shell echo $(basename $(notdir $F)) | tr '[a-z]-.' '[A-Z]__')_$S) \
-	$(eval $O/$R.$S.pfo: $F) \
-	$(eval RESOURCES += $O/$R.$S.pfo) \
-	$(eval RESOURCE_LIST += $O/$R.$S.pfo $R) \
+	$(eval F := $(word 1,$1)) \
+	$(eval S := $(word 2,$1)) \
+	$(eval N := FONT_$(call uppercase,$F)_$S) \
+	$(eval R := $O/$N.$S.pfo) \
+	$(eval $R: $F) \
+	$(eval RESOURCES += $R) \
+	$(eval RESOURCE_LIST += $R $N) \
 
 mkfont = \
 	$(call mkfont_rules,$(subst :, ,$1)) \
 
 $(eval $(call map,mkfont,$(FONTS)))
 
+#
+# Images are converted to pbi format
+#
+$O/%.pbi:
+	$(PYTHON) $(PEBBLE_HOME)/tools/bitmapgen.py \
+		pbi \
+		$< \
+		$@ \
+
+mkimage = \
+	$(eval N := IMAGE_$(call uppercase,$1)) \
+	$(eval R := $O/$N.pbi) \
+	$(eval $R: $1) \
+	$(eval RESOURCES += $R) \
+	$(eval RESOURCE_LIST += $R $N) \
+
+$(eval $(call map,mkimage,$(IMAGES)))
+
 
 #
 # Generate the list of all resources from the fonts, images and
 # Start a web server in the .. directory
 #
 httpd:
-	cd .. ; $(PYTHON) -mSimpleHTTPServer
+	cd ../.. ; $(PYTHON) -mSimpleHTTPServer