Commits

Trammell Hudson committed fd5c0a5

More build rules for resource packing

  • Participants
  • Parent commits 5d7084a

Comments (0)

Files changed (3)

File Makefile.pebble

 LD := $(CC)
 OBJCOPY := $(GCC_PREFIX)objcopy
 
+# If no version is specified, use a default one
+VERSION ?= 0.1
+
+BUILD_TIME := $(shell date "+%s")
+
 
 CFLAGS += \
 	-std=c99 \
 	-Wl,--warn-common \
 	-fPIE \
 	-Wl,-Map,$(PEBBLE_HOME)/pebble-app.map,--emit-relocs \
-	-T/Users/hudson/build/pebble/th/hoelaat/pebble_app.ld \
+	-T$(PEBBLE_HOME)/pebble_app.ld \
 	-L$(PEBBLE_HOME)/lib \
-	-lpebble
+	-lpebble \
 
 %.bin: %.elf
 	$(OBJCOPY) -O binary $< $@
 %.pbw: %.bin
 	$(PYTHON) $(PEBBLE_HOME)/tools/mkbundle.py \
 		--watchapp $< \
-		--watchapp-timestamp "`date "+%s"`" \
+		--watchapp-timestamp $(BUILD_TIME) \
 		--req-fw 1 \
 		--resources resources.pbpack \
 		--resource-map resource_map.json \
-		--resources-timestamp "`date "+%s"`" \
+		--resources-timestamp $(BUILD_TIME) \
 		-o $@ \
 
 all: $(TARGET).pbw
-$(TARGET).pbw: resources.pbpack
 $(TARGET).elf: $(OBJS)
 	$(LD) -o $@ $^ $(LDFLAGS)
+$(TARGET).pbw: $(TARGET).bin resources.pbpack
+
+#
+# Every object requires that the resource_ids.auto.h be up to date
+#
+$(OBJS): resource_ids.auto.h
 
 clean:
-	$(RM) *.elf *.o *.a a.out core
+	$(RM) \
+		*.pbw \
+		*.pfo \
+		*.elf \
+		*.bin \
+		*.o \
+		*.a \
+		a.out \
+		core \
+		*.pbpack \
+		*.pbpack.* \
+		resource_ids.auto.h \
+
+#
+# Generate a font resource from a given ttf.
+#
+%.pfo:
+	$(PYTHON) $(PEBBLE_HOME)/tools/font/fontgen.py \
+		pfo \
+		$(subst .,,$(suffix $(basename $@))) \
+		$< \
+		$@ \
+
+#
+# Generate a resource binary from all of the fonts
+#
+resources.pbpack: \
+	resources.pbpack.manifest \
+	resources.pbpack.table \
+	resources.pbpack.data \
+
+	cat > $@ $^
+
+
+RESOURCES := $(FONTS) resource_map.json
+
+resources.pbpack.data: $(RESOURCES)
+	cat > $@ $^
+
+resources.pbpack.table: $(RESOURCES)
+	$(PYTHON) $(PEBBLE_HOME)/tools/pbpack_meta_data.py \
+		table \
+		$@ \
+		$^ \
+
+%.manifest: %.data
+	$(PYTHON) $(PEBBLE_HOME)/tools/pbpack_meta_data.py \
+		manifest \
+		$@ \
+		$(words $(RESOURCES)) \
+		$(BUILD_TIME) \
+		$(VERSION) \
+		$< \
+
+# This header file name is forced by <pebble_app.h>
+resource_ids.auto.h: resources.pbpack.data $(FONTS)
+	$(PYTHON) $(PEBBLE_HOME)/tools/generate_resource_code.py \
+		resource_header \
+		$@ \
+		RESOURCES \
+		$(VERSION) \
+		$(BUILD_TIME) \
+		pebble_os.h \
+		$< \
+		$(RESOURCE_LIST) \

File hoelaat/src/Makefile

 OBJS += nederlands.o
 
 TARGET := hoelaat
+FONTS := \
+	Arial.28.pfo \
+	Arial.30.pfo \
+	Arial-Black.30.pfo \
 
+RESOURCE_LIST := \
+	Arial.28.pfo FONT_ARIAL_28 \
+	Arial.30.pfo FONT_ARIAL_30 \
+	Arial-Black.30.pfo FONT_ARIAL_BLACK_30 \
 
 include ../../Makefile.pebble
+
+Arial.30.pfo: fonts/Arial.ttf
+Arial.28.pfo: fonts/Arial.ttf
+Arial-Black.30.pfo: fonts/Arial-Black.ttf
+

File hoelaat/src/nederlands.c

 
 
 PBL_APP_INFO(
-	"Hoe laat is het?",
+	"TEST",
 	"hudson",
 	1, // Version
 	INVALID_RESOURCE,
 	window_stack_push(&window, true);
 	window_set_background_color(&window, GColorBlack);
 
-	resource_init_current_app(&HOELAAT_RESOURCES);
+	resource_init_current_app(&RESOURCES);
 
 	int y = 15;
 	int h = 30;
 
 	// Stack top to bottom.  Note that the hour can take up
 	// two rows at midnight.
-	text_layer(&ampm_layer, GRect(4, y + 3*h, 144, h+8), RESOURCE_ID_FONT_ANDALE_28);
-	text_layer(&hour_layer, GRect(4, y + 2*h, 144, 2*h+8), RESOURCE_ID_FONT_ANDALE_30_BLACK);
-	text_layer(&rel_layer, GRect(4, y + 1*h, 144, h+8), RESOURCE_ID_FONT_ANDALE_30);
-	text_layer(&min_layer, GRect(4, y + 0*h, 144, h+8), RESOURCE_ID_FONT_ANDALE_30);
+	text_layer(&ampm_layer, GRect(4, y + 3*h, 144, h+8), RESOURCE_ID_FONT_ARIAL_28);
+	text_layer(&hour_layer, GRect(4, y + 2*h, 144, 2*h+8), RESOURCE_ID_FONT_ARIAL_BLACK_30);
+	text_layer(&rel_layer, GRect(4, y + 1*h, 144, h+8), RESOURCE_ID_FONT_ARIAL_30);
+	text_layer(&min_layer, GRect(4, y + 0*h, 144, h+8), RESOURCE_ID_FONT_ARIAL_30);
 }