Commits

Trammell Hudson committed 6551267

Simplified font generation

Comments (0)

Files changed (3)

 
 #
 # Generate a font resource from a given ttf.
-# The fonts are specified in the leaf makefiles in $(FONT) as
+# The fonts are specified in the leaf makefiles in $(FONT) as a list of:
 #
-#	path-to-font:size:resource-name
+#	path-to-font:size
+#
+# For example:
+#
+#	FONTS := fonts/Arial.ttf:28 fonts/Arial-Black.ttf:30
+#
+# This will produce resources named FONT_ARIAL_28 and FONT_ARIAL_BLACK_30.
 #
 # A somewhat complex make rule translates this list into the
 # targets for each font to be generated and as well as the
 mkfont_rules = \
 	$(eval F = $(word 1,$1)) \
 	$(eval S = $(word 2,$1)) \
-	$(eval R = $(word 3,$1)) \
-	$(eval $(info rules '$F' '$S' '$R')) \
+	$(eval R = FONT_$(shell echo $(basename $(notdir $F)) | tr '[a-z]-.' '[A-Z]__')_$S) \
 	$(eval $O/$R.$S.pfo: $F) \
-	$(eval FONT_LIST += $O/$R.$S.pfo) \
+	$(eval RESOURCES += $O/$R.$S.pfo) \
 	$(eval RESOURCE_LIST += $O/$R.$S.pfo $R) \
 
 mkfont = \
-	$(info mkfont '$(1)') \
 	$(call mkfont_rules,$(subst :, ,$1)) \
 
 $(eval $(call map,mkfont,$(FONTS)))
 
 
 #
+# Generate the list of all resources from the fonts, images and
+# the resource map file.
+# \todo Images.
+#
+RESOURCES += $O/resource_map.json
+RESOURCE_LIST += $O/resource_map.json DUMMY
+
+#
 # Generate a resource binary from all of the fonts
 #
 $O/app_resources.pbpack: \
 
 	cat > $@ $^
 
-
-RESOURCES := $(FONT_LIST) $O/resource_map.json
-
 $O/app_resources.pbpack.data: $(RESOURCES)
 	cat > $@ $^
 
 		$(VERSION) \
 		$< \
 
-# This header file name is forced by <pebble_app.h>
+#
+# This header file name is forced by <pebble_app.h>.
+# Put it into the output build directory so that it does not
+# clutter the input source tree.
+#
 $O/src/resource_ids.auto.h: \
 	$O/app_resources.pbpack.data \
-	$(FONT_LIST) \
+	$(RESOURCES) \
 
 	$(PYTHON) $(PEBBLE_HOME)/tools/generate_resource_code.py \
 		resource_header \
 		pebble_os.h \
 		$< \
 		$(RESOURCE_LIST) \
-		$O/resource_map.json DUMMY \
 
-# Bring in all of the generated dependency files
+#
+# Bring in all of the generated dependency files if any exist.
+# These are produced by the -MMD flag to gcc in $(CFLAGS).
+#
 -include $O/.*.o.d

auth/src/Makefile

 
 TARGET := auth
 
-# No resources
-RESOURCE_LIST :=
-
 include ../../Makefile.pebble

hoelaat/src/Makefile

 TARGET := hoelaat
 
 FONTS := \
-	fonts/Arial.ttf:28:FONT_ARIAL_28 \
-	fonts/Arial-Black.ttf:30:FONT_ARIAL_BLACK_30 \
+	fonts/Arial.ttf:28 \
+	fonts/Arial-Black.ttf:30 \
 
 include ../../Makefile.pebble