Files
oemcrypto/oemcrypto/opk/ports/trusty/ta/reference/clang-tidy-inc.mk
Googler 98f0721662 OEMCrypto and OPK 18.10.0
GitOrigin-RevId: 987123747bd0be50fc5e4e89ec26eaa6d215bc36
2025-06-09 23:55:51 -07:00

64 lines
2.0 KiB
Makefile

# Copyright (C) 2023 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
OPK_TRUSTY_CLANG_TIDY ?= false
ifeq ($(call TOBOOL,$(OPK_TRUSTY_CLANG_TIDY)),true)
clang-tidy-srcs := $(MODULE_SRCS)
clang-tidy-incs := $(MODULE_INCLUDES)
clang-tidy-flags := \
--header-filter '$(subst $(SPACE),|,$(strip $(clang-tidy-incs)))' \
--quiet
clang-tidy-cflags := \
$(MODULE_CFLAGS) \
$(if $(filter .c,$(suffix $(1))),-std=c11 -D_POSIX_C_SOURCE=200809L) \
$(if $(filter .cpp,$(suffix $(1))),-std=c++14) \
$(addprefix -D,$(MODULE_DEFINES) TRUSTY_USERSPACE) \
$(addprefix -I,\
$(MODULE_INCLUDES) \
$(addsuffix /include,$(MODULE_LIBRARY_DEPS)) \
external/open-dice/include/dice/config/boringssl_ed25519 \
$(BUILDDIR)/sdk/sysroot/usr/include)
# Define a rule template to run clang-tidy with a single source file.
define clang-tidy-rule
.PHONY: clang-tidy-$(1)
clang-tidy-$(1): clang-tidy-flags := $(clang-tidy-flags)
clang-tidy-$(1): clang-tidy-cflags := $(call clang-tidy-cflags,$(1))
clang-tidy-$(1):
@echo running clang-tidy: $(1)
$(NOECHO)clang-tidy $(clang-tidy-flags) $(1) -- $(clang-tidy-cflags)
endef
# Generate rules to run clang-tidy with each source file.
$(foreach src,$(clang-tidy-srcs),$(eval $(call clang-tidy-rule,$(src))))
# Run clang-tidy with all source files.
.PHONY: clang-tidy
clang-tidy: $(addprefix clang-tidy-,$(clang-tidy-srcs))
EXTRA_BUILDDEPS += clang-tidy
clang-tidy-srcs :=
clang-tidy-incs :=
clang-tidy-flags :=
clang-tidy-cflags :=
clang-tidy-rule :=
endif