py/mkrules.mk: Add %.sz rule to print size of an object file.

It's frequently the case that a developer will want to compare the object
code size of various alternatives.  When this can be done at the single
object code level, the turnaround is faster.

Provide a rule `$(BUILD)/%.sz` to print the size of a given object.
Because it is a normal Makefile target that depends on an object file, it
rebuilds the object file if needed.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
This commit is contained in:
Jeff Epler
2025-09-21 08:47:09 -05:00
committed by Damien George
parent 70c4ffa770
commit 7e5c55dc2f

View File

@@ -108,6 +108,10 @@ $(BUILD)/%.pp: %.c FORCE
$(ECHO) "PreProcess $<"
$(Q)$(CPP) $(CFLAGS) -Wp,-C,-dD,-dI -o $@ $<
.PHONY: $(BUILD)/%.sz
$(BUILD)/%.sz: $(BUILD)/%.o
$(Q)$(SIZE) $<
# Special case for compiling auto-generated source files.
$(BUILD)/%.o: $(BUILD)/%.c
$(call compile_c)