forked from DPDK/dpdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buildtools: externally check exported headers
At the moment, the headers check is run "internally", iow with compilation flags and include path coming from the meson components. One issue is that both internal and public headers are usually stored in a single directory in the DPDK components. If a lib/foo library exports a header rte_foo.h (iow rte_foo.h is part of the headers list in lib/foo/meson.build) and this rte_foo.h includes an internal header foo_internal.h, then the headers check won't detect such an issue as rte_foo.h is compiled with -Ilib/foo. Add an additional check which relies on a DPDK installed in a staging directory. This check then compiles every header against the staging directory. Signed-off-by: David Marchand <[email protected]>
- Loading branch information
1 parent
0b5f5a8
commit 4a28a7e
Showing
3 changed files
with
109 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright (c) 2024 Red Hat, Inc. | ||
|
||
ifeq ($(V),) | ||
Q ?= @ | ||
else | ||
Q = | ||
endif | ||
|
||
O ?= build | ||
|
||
PKGCONF ?= pkg-config | ||
|
||
ifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0) | ||
$(error "no installation of DPDK found") | ||
endif | ||
|
||
ifeq ($(I),) | ||
|
||
.PHONY: headers_list | ||
.ONESHELL: | ||
headers_list: | ||
$(Q)for dir in $$($(PKGCONF) --cflags-only-I libdpdk); do | ||
dir=$${dir##-I} | ||
[ -e $$dir/rte_build_config.h ] || continue | ||
$(MAKE) I="$$dir" O="$(O)" | ||
break | ||
done | ||
else | ||
|
||
HEADERS := $(shell find $(I) -name "*.h" | grep -vE $(I)'/(generic|internal)/') | ||
SRCS := $(patsubst $(I)/%.h, $(O)/%.c, $(HEADERS)) | ||
.PRECIOUS: $(SRCS) | ||
|
||
PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) | ||
CFLAGS = $(shell $(PKGCONF) --cflags libdpdk) | ||
LDFLAGS = $(shell $(PKGCONF) --libs libdpdk) | ||
|
||
all: $(O)/chkincs $(O)/chkincs-exp $(O)/chkincs-all | ||
|
||
OBJS := $(O)/main.o $(patsubst %.c, %.o, $(SRCS)) | ||
OBJS_EXP := $(O)/main.o $(patsubst %.c, %_exp.o, $(SRCS)) | ||
OBJS_ALL := $(O)/main.o $(patsubst %.c, %_all.o, $(SRCS)) | ||
|
||
$(O): | ||
$(Q)mkdir -p $(O) | ||
|
||
$(O)/%.c: $(I)/%.h $(O) gen_c_file_for_header.py Makefile | ||
$(Q)python3 gen_c_file_for_header.py $< $@ | ||
|
||
$(O)/chkincs: $(OBJS) | ||
$(Q)$(CC) $(LDFLAGS) -o $@ $^ | ||
|
||
$(O)/chkincs-exp: $(OBJS_EXP) | ||
$(Q)$(CC) $(LDFLAGS) -o $@ $^ | ||
|
||
$(O)/chkincs-all: $(OBJS_ALL) | ||
$(Q)$(CC) $(LDFLAGS) -o $@ $^ | ||
|
||
$(O)/main.o: main.c $(O) Makefile $(PC_FILE) | ||
$(Q)$(CC) $(CFLAGS) -o $@ -c $< | ||
|
||
$(O)/%.o: $(O)/%.c Makefile $(PC_FILE) | ||
$(Q)$(CC) $(CFLAGS) -o $@ -c $< | ||
|
||
$(O)/%_exp.o: $(O)/%.c Makefile $(PC_FILE) | ||
$(Q)$(CC) $(CFLAGS) -DALLOW_EXPERIMENTAL_API -o $@ -c $< | ||
|
||
$(O)/%_all.o: $(O)/%.c Makefile $(PC_FILE) | ||
$(Q)$(CC) $(CFLAGS) -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -o $@ -c $< | ||
|
||
CXXFLAGS = $(shell $(PKGCONF) --cflags libdpdk) | ||
|
||
all: $(O)/chkincs-cpp $(O)/chkincs-cpp-exp $(O)/chkincs-cpp-all | ||
|
||
OBJS_CPP := $(O)/main_cpp.o $(patsubst %.c, %.cpp.o, $(SRCS)) | ||
OBJS_CPP_EXP := $(O)/main_cpp.o $(patsubst %.c, %_exp.cpp.o, $(SRCS)) | ||
OBJS_CPP_ALL := $(O)/main_cpp.o $(patsubst %.c, %_all.cpp.o, $(SRCS)) | ||
|
||
$(O)/chkincs-cpp: $(OBJS_CPP) | ||
$(Q)$(CXX) $(LDFLAGS) -o $@ $^ | ||
|
||
$(O)/chkincs-cpp-exp: $(OBJS_CPP_EXP) | ||
$(Q)$(CXX) $(LDFLAGS) -o $@ $^ | ||
|
||
$(O)/chkincs-cpp-all: $(OBJS_CPP_ALL) | ||
$(Q)$(CXX) $(LDFLAGS) -o $@ $^ | ||
|
||
$(O)/main_cpp.o: main.c $(O) Makefile $(PC_FILE) | ||
$(Q)$(CXX) $(CXXFLAGS) -o $@ -c $< | ||
|
||
$(O)/%.cpp.o: $(O)/%.c Makefile $(PC_FILE) | ||
$(Q)$(CXX) $(CXXFLAGS) -o $@ -c $< | ||
|
||
$(O)/%_exp.cpp.o: $(O)/%.c Makefile $(PC_FILE) | ||
$(Q)$(CXX) $(CXXFLAGS) -DALLOW_EXPERIMENTAL_API -o $@ -c $< | ||
|
||
$(O)/%_all.cpp.o: $(O)/%.c Makefile $(PC_FILE) | ||
$(Q)$(CXX) $(CXXFLAGS) -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -o $@ -c $< | ||
|
||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters