compiler: add -size flag to replace size utility

The size flag has two modes:
  -size=short: prints data basically equivalent to the `size` program.
  -size=full:  tries to determine sizes per package (not entirely
               accurate).
This commit is contained in:
Ayke van Laethem
2018-09-18 00:04:21 +02:00
parent 8b94fe9205
commit 87963d3d5b
3 changed files with 189 additions and 14 deletions
+2 -7
View File
@@ -9,16 +9,13 @@ TARGET ?= unix
ifeq ($(TARGET),unix)
# Regular *nix system.
SIZE = size
else ifeq ($(TARGET),pca10040)
# PCA10040: nRF52832 development board
SIZE = arm-none-eabi-size
OBJCOPY = arm-none-eabi-objcopy
TGOFLAGS += -target $(TARGET)
else ifeq ($(TARGET),arduino)
SIZE = avr-size
OBJCOPY = avr-objcopy
TGOFLAGS += -target $(TARGET)
@@ -68,13 +65,11 @@ build/tgo: *.go
# Binary that can run on the host.
build/%: src/examples/% src/examples/%/*.go build/tgo src/runtime/*.go
./build/tgo build $(TGOFLAGS) -o $@ $(subst src/,,$<)
@$(SIZE) $@
./build/tgo build $(TGOFLAGS) -size=short -o $@ $(subst src/,,$<)
# ELF file that can run on a microcontroller.
build/%.elf: src/examples/% src/examples/%/*.go build/tgo src/runtime/*.go
./build/tgo build $(TGOFLAGS) -o $@ $(subst src/,,$<)
@$(SIZE) $@
./build/tgo build $(TGOFLAGS) -size=short -o $@ $(subst src/,,$<)
# Convert executable to Intel hex file (for flashing).
build/%.hex: build/%.elf