Skip to content

Commit

Permalink
change size to family size
Browse files Browse the repository at this point in the history
  • Loading branch information
bradjc committed Sep 2, 2022
1 parent ab6bf79 commit 556b003
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 28 additions & 1 deletion AppMakefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,31 @@ $$(BUILDDIR)/$(1)/$(2).userland_debug.lst: $$(BUILDDIR)/$(1)/$(2).userland_debug
############################################################################################
endef


# Rules that apply to an entire architecture family (e.g. cortex-m).
#
# - Argument $(1) is the architecture family (e.g. cortex-m).
# - Argument $(2) is the list of architectures in that family.
# - Argument $(3) is the list of output names for the .elf of each arch.
#
# Note: all variables, other than $(1), used within this block must be double
# dollar-signed so that their values will be evaluated when run, not when
# generated.
define ARCH_FAMILY_RULES

$(1)_DIRECTORY_NAMES := $$(addsuffix /,$(2))
$(1)_DIRECTORY_FILES := $$(join $$($(1)_DIRECTORY_NAMES),$(3))
$(1)_DIRECTORY_FILES_EXT := $$(addsuffix .elf,$$($(1)_DIRECTORY_FILES))
$(1)_ELF_FILES := $$(addprefix $$(BUILDDIR)/,$$($(1)_DIRECTORY_FILES_EXT))

# Rule to print the size of the built binaries from an architecture family.
.PHONY: size-$(1)
size-$(1): $$($(1)_ELF_FILES)
@echo Application size report for arch family $(1):
$$(Q)$$(TOOLCHAIN_$(1))$$(SIZE) -t $$^

endef

# Functions to parse the `TOCK_TARGETS` array. Entries 3 and 4 default to the
# PIC addresses if they are not specified.
ARCH_FN = $(firstword $(subst |, ,$1))
Expand All @@ -279,6 +304,7 @@ RAM_ADDRESS_FN = $(if $(word 4,$(subst |, ,$1)),$(word 4,$(subst |, ,$1)),0x0000
# Actually generate the rules for each architecture
$(foreach platform, $(TOCK_ARCHS), $(eval $(call BUILD_RULES_PER_ARCH,$(platform))))
$(foreach platform, $(TOCK_TARGETS), $(eval $(call BUILD_RULES,$(call ARCH_FN,$(platform)),$(call OUTPUT_NAME_FN,$(platform)),$(call FLASH_ADDRESS_FN,$(platform)),$(call RAM_ADDRESS_FN,$(platform)))))
$(foreach family, $(TOCK_ARCH_FAMILIES), $(eval $(call ARCH_FAMILY_RULES,$(family),$(foreach target, $(filter $(family)%,$(TOCK_TARGETS)), $(call ARCH_FN, $(target))),$(foreach target, $(filter $(family)%,$(TOCK_TARGETS)), $(call OUTPUT_NAME_FN, $(target))))))



Expand All @@ -290,8 +316,9 @@ $(BUILDDIR)/$(PACKAGE_NAME).tab: $(foreach platform, $(TOCK_TARGETS), $(BUILDDIR


# Rules for building apps
SIZE_RULES = $(addprefix size-,$(TOCK_ARCH_FAMILIES))
.PHONY: all
all: $(BUILDDIR)/$(PACKAGE_NAME).tab size
all: $(BUILDDIR)/$(PACKAGE_NAME).tab $(SIZE_RULES)

# The size target accumulates dependencies in the platform build rule creation
.PHONY: size
Expand Down
2 changes: 2 additions & 0 deletions Configuration.mk
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ PACKAGE_NAME ?= $(shell basename "$(shell pwd)")
# targets build by default as well.
ifeq ($(RISCV),)
TOCK_TARGETS ?= cortex-m0 cortex-m3 cortex-m4 cortex-m7
TOCK_ARCH_FAMILIES ?= cortex-m
else
# Specific addresses useful for the OpenTitan hardware memory map.
OPENTITAN_TOCK_TARGETS := rv32imc|rv32imc.0x20030080.0x10005000|0x20030080|0x10005000\
Expand All @@ -92,6 +93,7 @@ TOCK_TARGETS ?= cortex-m0\
rv32imc|rv32imc.0x00080060.0x40008000|0x00080060|0x40008000\
$(OPENTITAN_TOCK_TARGETS) \
$(ARTY_E21_TOCK_TARGETS)
TOCK_ARCH_FAMILIES ?= cortex-m rv32i
endif

# Generate `TOCK_ARCHS`, the set of architectures listed in `TOCK_TARGETS`.
Expand Down

0 comments on commit 556b003

Please sign in to comment.