From 7d3c04843cc10d03e98adee3eef5a7aa5d2a1a7a Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Sun, 18 Oct 2020 13:55:10 -0500 Subject: [PATCH] Use $(BOARD)-$(HEADS_GIT_VERSION) as basis for output filename makes builds uniquely identifiable based on board and version. Signed-off-by: Matt DeVillier --- Makefile | 33 ++++++++++--------- .../qemu-coreboot-fbwhiptail.config | 2 +- boards/qemu-coreboot/qemu-coreboot.config | 2 +- boards/t430-flash/t430-flash.config | 2 +- boards/x230-flash/x230-flash.config | 2 +- modules/coreboot | 4 ++- modules/linuxboot | 6 ++-- 7 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 4deebe571..44023aed6 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,17 @@ +# Need to set CB_OUTPUT_FILE before board .config included so +# that target overrides in x230/x430-flash (eg) are properly handled +GIT_HASH := $(shell git rev-parse HEAD) +GIT_STATUS := $(shell \ + if git diff --exit-code >/dev/null ; then \ + echo clean ; \ + else \ + echo dirty ; \ + fi) +HEADS_GIT_VERSION := $(shell git describe --tags --dirty) + +CB_OUTPUT_FILE := heads-$(BOARD)-$(HEADS_GIT_VERSION).rom +LB_OUTPUT_FILE := linuxboot-$(BOARD)-$(HEADS_GIT_VERSION).rom + all: -include .config @@ -100,17 +114,6 @@ include $(CONFIG) # Unless otherwise specified, we are building for heads CONFIG_HEADS ?= y -# Some things want usernames, we use the current checkout -# so that they are reproducible -GIT_HASH := $(shell git rev-parse HEAD) -GIT_STATUS := $(shell \ - if git diff --exit-code >/dev/null ; then \ - echo clean ; \ - else \ - echo dirty ; \ - fi) -HEADS_GIT_VERSION := $(shell git describe --tags --dirty) - # record the build date / git hashes and other files here HASHES := $(build)/$(BOARD)/hashes.txt @@ -187,10 +190,10 @@ CROSS_TOOLS := \ -ifeq "$(CONFIG_COREBOOT)" "y" -all: $(build)/$(BOARD)/coreboot.rom -else ifeq "$(CONFIG_LINUXBOOT)" "y" -all: $(build)/$(BOARD)/linuxboot.rom +ifeq ($(CONFIG_COREBOOT), y) +all: $(build)/$(BOARD)/$(CB_OUTPUT_FILE) +else ifeq ($(CONFIG_LINUXBOOT), y) +all: $(build)/$(BOARD)/$(LB_OUTPUT_FILE) else $(error "$(BOARD): neither CONFIG_COREBOOT nor CONFIG_LINUXBOOT is set?") endif diff --git a/boards/qemu-coreboot-fbwhiptail/qemu-coreboot-fbwhiptail.config b/boards/qemu-coreboot-fbwhiptail/qemu-coreboot-fbwhiptail.config index b6210ca77..83ba5cd9e 100644 --- a/boards/qemu-coreboot-fbwhiptail/qemu-coreboot-fbwhiptail.config +++ b/boards/qemu-coreboot-fbwhiptail/qemu-coreboot-fbwhiptail.config @@ -48,7 +48,7 @@ export CONFIG_BOOT_DEV="/dev/sda1" run: qemu-system-x86_64 \ --machine q35 \ - --bios $(build)/$(BOARD)/coreboot.rom \ + --bios $(build)/$(BOARD)/$(CB_OUTPUT_FILE) \ -object rng-random,filename=/dev/urandom,id=rng0 \ -device virtio-rng-pci,rng=rng0 \ -netdev user,id=u1 -device e1000,netdev=u1 \ diff --git a/boards/qemu-coreboot/qemu-coreboot.config b/boards/qemu-coreboot/qemu-coreboot.config index dce3583ed..79643a5e1 100644 --- a/boards/qemu-coreboot/qemu-coreboot.config +++ b/boards/qemu-coreboot/qemu-coreboot.config @@ -58,7 +58,7 @@ run: qemu-system-x86_64 \ --machine q35 \ --serial /dev/tty \ - --bios $(build)/$(BOARD)/coreboot.rom \ + --bios $(build)/$(BOARD)/$(CB_OUTPUT_FILE) \ -object rng-random,filename=/dev/urandom,id=rng0 \ -device virtio-rng-pci,rng=rng0 \ -netdev user,id=u1 -device e1000,netdev=u1 \ diff --git a/boards/t430-flash/t430-flash.config b/boards/t430-flash/t430-flash.config index 43be7cb21..897eb6418 100644 --- a/boards/t430-flash/t430-flash.config +++ b/boards/t430-flash/t430-flash.config @@ -21,6 +21,6 @@ export CONFIG_FLASHROM_OPTIONS="--force --noverify-all -p internal --ifd --image # allow the board to boot into a minimal Heads and read the full # ROM from an external USB media. all: $(build)/$(BOARD)/$(BOARD).rom -$(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/coreboot.rom +$(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/$(CB_OUTPUT_FILE) dd of=$@ if=$< bs=65536 count=64 skip=128 sha256sum $@ diff --git a/boards/x230-flash/x230-flash.config b/boards/x230-flash/x230-flash.config index edb417ea7..283c8fbf8 100644 --- a/boards/x230-flash/x230-flash.config +++ b/boards/x230-flash/x230-flash.config @@ -26,6 +26,6 @@ export CONFIG_FLASHROM_OPTIONS="--force --noverify-all -p internal --ifd --image # allow the board to boot into a minimal Heads and read the full # ROM from an external USB media. all: $(build)/$(BOARD)/$(BOARD).rom -$(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/coreboot.rom +$(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/$(CB_OUTPUT_FILE) dd of=$@ if=$< bs=65536 count=64 skip=128 sha256sum $@ diff --git a/modules/coreboot b/modules/coreboot index f26888309..a4664e94e 100644 --- a/modules/coreboot +++ b/modules/coreboot @@ -78,10 +78,12 @@ $(build)/$(coreboot_dir)/.build: \ $(build)/$(BOARD)/initrd.cpio.xz \ # This produces a ROM image that is written with the flashrom program -$(build)/$(BOARD)/coreboot.rom: $(build)/$(coreboot_dir)/.build +ifneq ($(CONFIG_COREBOOT),) +$(build)/$(BOARD)/$(CB_OUTPUT_FILE): $(build)/$(coreboot_dir)/.build "$(build)/$(coreboot_dir)/cbfstool" "$(dir $<)coreboot.rom" print $(call do-copy,$(dir $<)coreboot.rom,$@) @touch $@ # update the time stamp +endif # # Helpful target for reconfiguring the coreboot target diff --git a/modules/linuxboot b/modules/linuxboot index 57ea31a23..19edcc4e6 100644 --- a/modules/linuxboot +++ b/modules/linuxboot @@ -59,9 +59,11 @@ endif linuxboot_output := build/$(linuxboot_board)/linuxboot.rom linuxboot_rom := $(build)/$(linuxboot_dir)/$(linuxboot_output) -$(build)/$(BOARD)/linuxboot.rom: $(build)/$(linuxboot_dir)/.build +ifneq ($(CONFIG_LINUXBOOT),) +$(build)/$(BOARD)/$(LB_OUTPUT_FILE): $(build)/$(linuxboot_dir)/.build $(call do-copy,$(dir $<)linuxboot.rom,$@) @touch $@ +endif # Also force a rebuild if any of the input files are updated $(build)/$(linuxboot_dir)/.build: \ @@ -70,7 +72,7 @@ $(build)/$(linuxboot_dir)/.build: \ $(build)/$(BOARD)/initrd.cpio.xz \ -linuxboot.run: $(build)/$(BOARD)/linuxboot.rom +linuxboot.run: $(build)/$(BOARD)/$(LB_OUTPUT_FILE) $(MAKE) -C $(build)/$(linuxboot_base_dir) \ BOARD:=$(linuxboot_board) \ KERNEL=$(build)/$(BOARD)/bzImage \