mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
flock leaves the lock file and git complains about it. Let's move the lock file to /tmp/ec-lcov-lock. BUG=chrome-os-partner:19235 TEST=make coverage and check .lcov_lock is in /tmp BRANCH=None Change-Id: Id6d68af327b53aa1c0c7ae9186149126d8a5cc37 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/62858 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
186 lines
5.6 KiB
Makefile
186 lines
5.6 KiB
Makefile
# -*- makefile -*-
|
|
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
#
|
|
# Embedded Controller firmware build system - common targets
|
|
#
|
|
|
|
objs := $(all-y)
|
|
deps := $(objs:%.o=%.o.d)
|
|
build-utils := $(foreach u,$(build-util-bin),$(out)/util/$(u))
|
|
host-utils := $(foreach u,$(host-util-bin),$(out)/util/$(u))
|
|
|
|
# Create output directories if necessary
|
|
_dir_create := $(foreach d,$(dirs),$(shell [ -d $(out)/$(d) ] || \
|
|
mkdir -p $(out)/$(d)))
|
|
_dir_y_create := $(foreach d,$(dirs-y),$(shell [ -d $(out)/$(d) ] || \
|
|
mkdir -p $(out)/$(d)))
|
|
|
|
section = $(subst .,,$(suffix $(1)))
|
|
section_is = $(subst .,,SECTION_IS_$(suffix $(1)))
|
|
|
|
# Decrease verbosity unless you pass V=1
|
|
quiet = $(if $(V),,@echo ' $(2)' $(subst $(out)/,,$@) ; )$(cmd_$(1))
|
|
silent = $(if $(V),,1>/dev/null)
|
|
|
|
# commands to build all targets
|
|
cmd_lds = $(CPP) -P -C -MMD -MF $@.d -MT $@ $(CPPFLAGS) \
|
|
-D$(call section_is,$*) \
|
|
-DSECTION=$(call section,$*) $< -o $@
|
|
cmd_obj_to_bin = $(OBJCOPY) --gap-fill=0xff -O binary $^ $(out)/$*.bin.tmp
|
|
cmd_flat_to_obj = $(CC) -T $(out)/firmware_image.lds -nostdlib $(CPPFLAGS) \
|
|
-Wl,--build-id=none -o $@ $<
|
|
cmd_elf_to_flat = $(OBJCOPY) -O binary $^ $@
|
|
cmd_elf_to_dis = $(OBJDUMP) -D $< > $@
|
|
cmd_elf = $(LD) $(LDFLAGS) $(objs) -o $@ -T $< -Map $(out)/$*.map
|
|
cmd_exe = $(CC) $(HOST_TEST_LDFLAGS) $(objs) -o $@
|
|
cmd_c_to_o = $(CC) $(CFLAGS) -MMD -MF $@.d -c $< -o $@
|
|
cmd_c_to_build = $(BUILDCC) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) \
|
|
-MMD -MF $@.d $< -o $@
|
|
cmd_c_to_host = $(HOSTCC) $(HOST_CFLAGS) -MMD -MF $@.d $(filter %.c, $^) -o $@
|
|
cmd_qemu = ./util/run_qemu_test --image=build/$(BOARD)/$*/$*.bin test/$*.py \
|
|
$(silent)
|
|
cmd_host_test = ./util/run_host_test $* $(silent)
|
|
cmd_version = ./util/getversion.sh > $@
|
|
cmd_mv_from_tmp = mv $(out)/$*.bin.tmp $(out)/$*.bin
|
|
cmd_extractrw-y = cd $(out) && \
|
|
dump_fmap -x $(PROJECT).bin.tmp RW_SECTION_A $(silent) && \
|
|
mv RW_SECTION_A $(PROJECT).RW.bin
|
|
cmd_copyrw-y = cd $(out) && cp $(PROJECT).RW.flat $(PROJECT).RW.bin
|
|
|
|
.PHONY: all tests utils hosttests
|
|
all: $(out)/$(PROJECT).bin utils
|
|
|
|
dis-y = $(out)/$(PROJECT).RO.dis $(out)/$(PROJECT).RW.dis
|
|
dis: $(dis-y)
|
|
|
|
utils: $(build-utils) $(host-utils)
|
|
|
|
# On board test binaries
|
|
test-targets=$(foreach t,$(test-list-y),test-$(t))
|
|
qemu-test-targets=$(foreach t,$(test-list-y),qemu-$(t))
|
|
.PHONY: $(qemu-test-targets) $(test-targets)
|
|
|
|
$(test-targets): test-%:
|
|
@set -e ; \
|
|
echo " BUILD $(out)/$*" ; \
|
|
$(MAKE) --no-print-directory BOARD=$(BOARD) PROJECT=$* \
|
|
V=$(V) out=$(out)/$* TEST_BUILD=y; \
|
|
cp $(out)/$*/$*.bin $(out)/test-$*.bin
|
|
|
|
$(qemu-test-targets): qemu-%: test-%
|
|
$(call quiet,qemu,TEST )
|
|
|
|
tests: $(test-targets)
|
|
qemu-tests: $(qemu-test-targets)
|
|
|
|
# Emulator test executables
|
|
host-test-targets=$(foreach t,$(test-list-host),host-$(t))
|
|
run-test-targets=$(foreach t,$(test-list-host),run-$(t))
|
|
.PHONY: $(host-test-targets) $(run-test-targets)
|
|
|
|
$(host-test-targets): host-%:
|
|
@set -e ; \
|
|
echo " BUILD host - build/host/$*" ; \
|
|
$(MAKE) --no-print-directory BOARD=host PROJECT=$* \
|
|
V=$(V) out=build/host/$* TEST_BUILD=y EMU_BUILD=y $(TEST_FLAG) \
|
|
CROSS_COMPILE= build/host/$*/$*.exe
|
|
|
|
$(run-test-targets): run-%: host-%
|
|
$(call quiet,host_test,TEST )
|
|
|
|
hosttests: $(host-test-targets)
|
|
runtests: $(run-test-targets)
|
|
|
|
cov-test-targets=$(foreach t,$(test-list-host),build/host/$(t).info)
|
|
bldversion=$(shell (./util/getversion.sh ; echo VERSION) | $(CPP) -P)
|
|
|
|
# lcov fails when multiple instances run at the same time.
|
|
# We need to run them sequentially by using flock
|
|
cmd_lcov=flock /tmp/ec-lcov-lock -c "lcov -q -o $@ -c -d build/host/$*"
|
|
cmd_report_cov=genhtml -q -o build/host/coverage_rpt -t \
|
|
"EC Unittest "$(bldversion) $^
|
|
|
|
build/host/%.info: run-%
|
|
$(call quiet,lcov,COV )
|
|
|
|
coverage: TEST_FLAG=TEST_COVERAGE=y
|
|
coverage: $(cov-test-targets)
|
|
$(call quiet,report_cov,REPORT )
|
|
|
|
.PHONY: coverage
|
|
|
|
$(out)/firmware_image.lds: common/firmware_image.lds.S
|
|
$(call quiet,lds,LDS )
|
|
$(out)/%.lds: core/$(CORE)/ec.lds.S
|
|
$(call quiet,lds,LDS )
|
|
|
|
$(out)/%.bin: $(out)/%.obj
|
|
$(call quiet,obj_to_bin,OBJCOPY)
|
|
$(if $(sign-y),$(call quiet,sign,SIGN ),)
|
|
$(if $(sign-y),$(call quiet,extractrw-y,EXTR_RW), \
|
|
$(call quiet,copyrw-y,COPY_RW))
|
|
$(call quiet,mv_from_tmp,MV )
|
|
|
|
flat-y = $(out)/$(PROJECT).RO.flat $(out)/$(PROJECT).RW.flat
|
|
|
|
$(out)/%.obj: common/firmware_image.S $(out)/firmware_image.lds $(flat-y)
|
|
$(call quiet,flat_to_obj,CAT )
|
|
|
|
$(out)/%.dis: $(out)/%.elf
|
|
$(call quiet,elf_to_dis,OBJDUMP)
|
|
|
|
$(out)/%.flat: $(out)/%.elf
|
|
$(call quiet,elf_to_flat,OBJCOPY)
|
|
|
|
$(out)/%.elf: $(out)/%.lds $(objs)
|
|
$(call quiet,elf,LD )
|
|
|
|
$(out)/$(PROJECT).exe: $(objs)
|
|
$(call quiet,exe,EXE )
|
|
|
|
$(out)/%.o:%.c
|
|
$(call quiet,c_to_o,CC )
|
|
|
|
$(out)/vboot/%.o:$(VBOOT_SOURCE)/%.c
|
|
$(call quiet,c_to_o,CC )
|
|
|
|
$(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))
|
|
$(call quiet,version,VERSION)
|
|
|
|
$(build-utils): $(out)/%:%.c
|
|
$(call quiet,c_to_build,BUILDCC)
|
|
|
|
$(host-utils): $(out)/%:%.c $(foreach u,$(host-util-common),util/$(u).c) \
|
|
$(foreach u,$(util-lock-objs),util/lock/$(u).c)
|
|
$(call quiet,c_to_host,HOSTCC )
|
|
|
|
$(out)/util/burn_my_ec: $(out)/$(PROJECT).bin
|
|
|
|
.PHONY: FORCE
|
|
cscope.files: FORCE
|
|
@-rm -f cscope.out
|
|
@find chip/${CHIP} board/${BOARD} common core include -name '*.[chS]' \
|
|
-not -name '*test*' -not -name '*mock*' -not -name '*~*' \
|
|
> cscope.files
|
|
|
|
TAGS tags: cscope.files
|
|
@etags $(shell cat cscope.files)
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
-rm -rf $(out)
|
|
|
|
.PHONY: clobber
|
|
clobber:
|
|
-rm -rf build TAGS cscope.files cscope.out
|
|
|
|
.SECONDARY:
|
|
|
|
-include $(deps)
|