Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for variables that must defined in ci.mk #37

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ci.mk
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# SPDX-License-Identifier: Apache-2.0
DavidMCerdeira marked this conversation as resolved.
Show resolved Hide resolved
# Copyright (c) Bao Project and Contributors. All rights reserved

$(call check_variable_defined, root_dir, \
"To include ci.mk the 'root_dir' must be defined")

ci_dir?=$(realpath $(root_dir)/ci)
cur_dir:=$(realpath .)

include $(ci_dir)/util.mk

CPPCHECK?=cppcheck
CLANG_VERSION?=14
CLANG-FORMAT?=clang-format-$(CLANG_VERSION)
Expand Down Expand Up @@ -138,6 +143,8 @@ endef
# Cppcheck static-analyzer
# Run it by:
# make cppcheck
# @pre the make variable 'cc' must be defined with the target's cross-compiler
# to run any cppcheck-based rules
# @param files a single space-separated list of C files (header or source)
# @param headers a list of preprocessor flags, including header files root path
# @example $(call ci, cppcheck, file1.c file2.c file3.h, -I/my/include/dir/inc)
Expand Down Expand Up @@ -165,6 +172,8 @@ clean: cppcheck-clean
non_build_targets+=cppcheck cppcheck-clean

define cppcheck
$(call check_variable_defined, cc, \
"For running cppcheck-based tests 'cc' must be defined")
_cppcheck_files+=$1
_cppcheck_flags+=$2
endef
Expand Down
10 changes: 10 additions & 0 deletions util.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) Bao Project and Contributors. All rights reserved

# Check if a given variable is defined.
# @param variable name
# @param error message (optional)
# @example $(call check_variable_defined, XPTO, "The XPTO must be defined!")
define check_variable_defined
$(if $($(strip $1)),,$(error $(strip $1) not defined: $(strip $2)))
endef