summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2012-06-09 12:52:43 +0800
committerGerrit <chrome-bot@google.com>2012-06-14 07:06:07 -0700
commitcca78cfcfdda7700dc3e5659ef68cadedaef136b (patch)
tree5fc4467424c761d662aebf62a337a2dd24ccfb8d
parentb9ee0fe4f5cf561115b3544b0faf3dac86b884b9 (diff)
downloadchrome-ec-cca78cfcfdda7700dc3e5659ef68cadedaef136b.tar.gz
Modify Makefile to allow insertion of mock modules
When we need to mock modules in a unit test, we need a way to mock the actual modules. This CL enables mock of given source files. For example, if we need to mock watchdog for test 'foo', we can add to test/build.mk: "core-mock-foo-watchdog.o=fake_watchdog.o", and then implement its own watchdog in fake_watchdog.c. Signed-off-by: Vic Yang <victoryang@chromium.org> BUG=chrome-os-partner:10356 TEST=Set a mock fake_watchdog.c and check the test is compiled with fake_watchdog.c instead of watchdog.c. Change-Id: I4a0afb589a49dad7c4d6faf8926438085cdc46cf Reviewed-on: https://gerrit.chromium.org/gerrit/24942 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Ready: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org>
-rw-r--r--Makefile17
1 files changed, 9 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index ee86da1881..80566276e2 100644
--- a/Makefile
+++ b/Makefile
@@ -40,16 +40,17 @@ include util/build.mk
includes+=$(includes-y)
-objs_from_dir=$(foreach obj,$(2), $(out)/$(1)/$(obj))
+objs_from_dir=$(foreach obj, $($(2)-y), \
+ $(out)/$(1)/$(firstword $($(2)-mock-$(PROJECT)-$(obj)) $(obj)))
# Get all sources to build
-all-y=$(call objs_from_dir,core/$(CORE),$(core-y))
-all-y+=$(call objs_from_dir,chip/$(CHIP),$(chip-y))
-all-y+=$(call objs_from_dir,board/$(BOARD),$(board-y))
-all-y+=$(call objs_from_dir,private,$(private-y))
-all-y+=$(call objs_from_dir,common,$(common-y))
-all-y+=$(call objs_from_dir,test,$($(PROJECT)-y))
-all-y+=$(call objs_from_dir,vboot,$(vboot-y))
+all-y=$(call objs_from_dir,core/$(CORE),core)
+all-y+=$(call objs_from_dir,chip/$(CHIP),chip)
+all-y+=$(call objs_from_dir,board/$(BOARD),board)
+all-y+=$(call objs_from_dir,private,private)
+all-y+=$(call objs_from_dir,common,common)
+all-y+=$(call objs_from_dir,test,$(PROJECT))
+all-y+=$(call objs_from_dir,vboot,vboot)
dirs=core/$(CORE) chip/$(CHIP) board/$(BOARD) private common test util
include Makefile.rules