Skip to content

Commit

Permalink
fix(ci.mk): check if 'root_dir' and 'cc' variables are defined
Browse files Browse the repository at this point in the history
Certain variables must be defined before including 'ci.mk' or
instantiating some of its rules. This commits adds checks for two of
them 'root_dir' that should contain the repositories root directory
where the ci repo is located, and 'cc' which defines the compiler to be
used.

Signed-off-by: Jose Martins <josemartins90@gmail.com>
  • Loading branch information
josecm committed Feb 13, 2023
1 parent 4d8980b commit 4636d53
Showing 1 changed file with 9 additions and 0 deletions.
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
# 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

0 comments on commit 4636d53

Please sign in to comment.