diff options
author | Anton Staaf <robotboy@chromium.org> | 2014-11-03 15:31:24 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-11-04 21:34:39 +0000 |
commit | 8513e23df17be689c42b6d904d57694fbe2ffd88 (patch) | |
tree | 2ca7b8c54d8a4ec0c809eaacfae93dec26d6104d /Makefile.rules | |
parent | bde06f7697fcbe09d061e1c77515f962ef09452b (diff) | |
download | chrome-ec-8513e23df17be689c42b6d904d57694fbe2ffd88.tar.gz |
USB: Remove special case for iVersion string descriptor
Previously the version string was special cased in the USB stack
because the build system prevented the inclusion of ec_version.h in
any file other than common/version.c. This lead to common/version.c
being the only place that the USB version string could be computed
and thus the special case of filling in the version string descriptor
at run time. This made the USB stack more complex, and lead to the
common/version.c file including usb.h, which is actually STM32
specific.
Now, the portion of ec_version.h that is deterministic is only
updated when something in the tree actually changes (by way of a
conditional in the makefile), and ec_version.h no longer has to
depend on all object files (other than the special version.o).
This allows anyone to include ec_version.h as needed. In particular,
each board that wants to define a USB version string can directly
include ec_version.h and do so.
Signed-off-by: Anton Staaf <robotboy@chromium.org>
BRANCH=None
BUG=None
TEST=make buildall -j
touch files and verify rebuilds happen correctly
Change-Id: Ic84d0b9da90f82ebb4630fb550ec841071e25a49
Reviewed-on: https://chromium-review.googlesource.com/227211
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'Makefile.rules')
-rw-r--r-- | Makefile.rules | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/Makefile.rules b/Makefile.rules index 205c89a983..3a1b415ad3 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -52,6 +52,7 @@ cmd_c_to_build = $(BUILDCC) $(BUILD_CFLAGS) \ cmd_c_to_host = $(HOSTCC) $(HOST_CFLAGS) -MMD -MF $@.d -o $@ \ $(sort $(foreach c,$($(*F)-objs),util/$(c:%.o=%.c)) $*.c) cmd_host_test = ./util/run_host_test $* $(silent) +cmd_date = ./util/getdate.sh > $@ cmd_version = ./util/getversion.sh > $@ cmd_mv_from_tmp = mv $(out)/$*.bin.tmp $(out)/$*.bin cmd_extractrw-y = dd if=$(out)/$(PROJECT).bin.tmp of=$(out)/$(PROJECT).RW.bin \ @@ -179,10 +180,33 @@ $(out)/vboot/%.o:$(VBOOT_SOURCE)/%.c $(out)/%.o:%.S $(call quiet,c_to_o,AS ) -$(out)/common/version.o: $(out)/ec_version.h -$(out)/ec_version.h: $(filter-out $(out)/common/version.o,$(objs)) +# Conditionally force the rebuilding of ec_version.h only if it would be +# changed. +old_version_hash := $(shell cat $(out)/ec_version.h 2> /dev/null | md5sum -) +new_version_hash := $(shell BOARD=$(BOARD) ./util/getversion.sh | md5sum -) + +ifneq ($(old_version_hash),$(new_version_hash)) +.PHONY: $(out)/ec_version.h +endif + +# All of the objects have an order only dependency on the ec_version header. +# This ensures that if ec_version.h needs to be build (because it was marked +# PHONY above) then it will be rebuilt before any objects. This is important +# because some source files will include ev_version.h and fail to compile if +# it doesn't already exist. This dependency shouldn't be a normal dependency +# because that would cause every object to be rebuilt when ec_version.h +# changes, instead of just the ones that actually depend on it. The objects +# that truly depend on ec_version.h will have that information encoded in their +# .d file. +$(objs): | $(out)/ec_version.h + +$(out)/ec_version.h: $(call quiet,version,VERSION) +$(out)/common/version.o: $(out)/ec_date.h +$(out)/ec_date.h: $(filter-out $(out)/common/version.o,$(objs)) + $(call quiet,date,DATE ) + $(out)/gen_pub_key.h: $(PEM) $(call quiet,pubkey,PUBKEY ) |