ec_commands: Make importing ec_commands.h easier for foreign projects
There are many projects (e.g., kernel, coreboot, flashrom, mosys) having their own copy of the ec_commands.h header file. To reduce the effort of synchronization, this file should be maintained so that it can be copied and included without modification whenever possible. Currently ec_commands.h includes compile_time_macros.h only if __KERNEL__ is not defined. However, there are many macros defined in the latter file (e.g., ARRAY_SIZE) that are already defined in other projects, leading to a redefinition error. To resolve this issue, ec_commands.h is modified in this CL so that compile_time_macros.h is only included when inside the Chromium EC repository, which is controlled by the macro CHROMIUM_EC. Option '-DCHROMIUM_EC' is also added to CPPFLAGS to avoid redefinition error of macro 'BUILD_ASSERT'. BUG=b:109900671,b:118654976,chromium:984623 BRANCH=none TEST=make buildall -j Cq-Depend:chromium:1760656 Change-Id: I38c77f0233ff5962b6f90f25ba96802d05e706d7 Signed-off-by: Yu-Ping Wu <yupingso@chromium.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1535086 Tested-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
This commit is contained in:
parent
fb08e0bf9d
commit
0393557c98
|
@ -100,6 +100,7 @@ CPPFLAGS+=-Ibuiltin/
|
|||
else
|
||||
CPPFLAGS+=-Og
|
||||
endif
|
||||
CPPFLAGS+= -DCHROMIUM_EC=$(EMPTY)
|
||||
CFLAGS=$(CPPFLAGS) $(CFLAGS_CPU) $(CFLAGS_DEBUG) $(COMMON_WARN) $(CFLAGS_y)
|
||||
CFLAGS+= -ffunction-sections -fshort-wchar
|
||||
CFLAGS+= -fno-delete-null-pointer-checks
|
||||
|
@ -107,7 +108,6 @@ ifneq ($(cc-name),clang)
|
|||
CFLAGS+= -ffat-lto-objects
|
||||
CFLAGS+= -fconserve-stack
|
||||
endif
|
||||
CFLAGS+= -DCHROMIUM_EC=$(EMPTY)
|
||||
CXXFLAGS+=-DPROTOBUF_INLINE_NOT_IN_HEADERS=0
|
||||
|
||||
FTDIVERSION:=$(shell $(PKG_CONFIG) --modversion libftdi1 2>/dev/null)
|
||||
|
@ -130,11 +130,13 @@ LIBPROTOBUF_MUTATOR_LDLIBS:=$(shell $(PKG_CONFIG) --libs libprotobuf-mutator) \
|
|||
${LIBPROTOBUF_LDLIBS}
|
||||
endif
|
||||
|
||||
BUILD_CFLAGS = $(LIBFTDIUSB_CFLAGS) $(BUILD_CPPFLAGS) -O3 $(CFLAGS_DEBUG)
|
||||
BUILD_CFLAGS += $(CFLAGS_WARN)
|
||||
BUILD_CFLAGS=$(LIBFTDIUSB_CFLAGS) $(BUILD_CPPFLAGS) -O3 $(CFLAGS_DEBUG)
|
||||
BUILD_CFLAGS+=$(CFLAGS_WARN)
|
||||
BUILD_CFLAGS+=-DCHROMIUM_EC=$(EMPTY)
|
||||
HOST_CFLAGS=$(HOST_CPPFLAGS) -O3 $(CFLAGS_DEBUG) $(CFLAGS_WARN) \
|
||||
-DHOST_TOOLS_BUILD=$(EMPTY)
|
||||
HOST_CFLAGS+=$(LIBFTDIUSB_CFLAGS)
|
||||
HOST_CFLAGS+=-DCHROMIUM_EC=$(EMPTY)
|
||||
ifneq (${SYSROOT},)
|
||||
LDFLAGS_EXTRA+=--sysroot=${SYSROOT}
|
||||
endif
|
||||
|
|
|
@ -16,6 +16,11 @@
|
|||
extern "C"{
|
||||
#endif
|
||||
|
||||
/*
|
||||
* CHROMIUM_EC is defined by the Makefile system of Chromium EC repository.
|
||||
* It is used to not include macros that may cause conflicts in foreign
|
||||
* projects (refer to crbug.com/984623).
|
||||
*/
|
||||
#ifdef CHROMIUM_EC
|
||||
/*
|
||||
* Include common.h for CONFIG_HOSTCMD_ALIGNED, if it's defined. This
|
||||
|
@ -23,14 +28,22 @@ extern "C"{
|
|||
* ARM Cortex-M if the structures are guaranteed 32-bit aligned.
|
||||
*/
|
||||
#include "common.h"
|
||||
#include "compile_time_macros.h"
|
||||
|
||||
#else
|
||||
|
||||
#define BUILD_ASSERT(_cond)
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(nr) (1UL << (nr))
|
||||
#endif
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#define BUILD_ASSERT(_cond)
|
||||
#else
|
||||
#include "compile_time_macros.h"
|
||||
#ifndef BIT_ULL
|
||||
#define BIT_ULL(nr) (1ULL << (nr))
|
||||
#endif
|
||||
|
||||
#endif /* CHROMIUM_EC */
|
||||
|
||||
/*
|
||||
* Current version of this protocol
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue