OSDN Git Service

drm_hwcomposer: CI: Find all source files instead of hardcoding them.
[android-x86/external-drm_hwcomposer.git] / .ci / Makefile
1
2 INCLUDE_DIRS := . ../libdrm/include/drm include ./.ci/android_headers ./tests/test_include
3 SYSTEM_INCLUDE_DIRS := /usr/include/libdrm
4
5 CLANG := clang++-12
6 CLANG_TIDY := clang-tidy-12
7 OUT_DIR := /tmp/drm_hwcomposer/build
8 SRC_DIR := .
9
10 CXXFLAGS := -fPIC -Wall -Wextra -Werror -DPLATFORM_SDK_VERSION=31 -D__ANDROID_API__=31
11 CXXFLAGS += -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
12 CXXFLAGS += -fvisibility-inlines-hidden -std=gnu++17 -DHWC2_USE_CPP11 -DHWC2_INCLUDE_STRINGIFICATION -fno-rtti
13
14 SKIP_FILES := \
15     bufferinfo/BufferInfoMapperMetadata.cpp
16
17 TIDY_FILES_OVERRIDE := \
18     backend/BackendManager.h:COARSE                     \
19     bufferinfo/legacy/BufferInfoImagination.cpp:COARSE  \
20     bufferinfo/legacy/BufferInfoLibdrm.cpp:COARSE       \
21     bufferinfo/legacy/BufferInfoMaliHisi.cpp:COARSE     \
22     bufferinfo/legacy/BufferInfoMaliMediatek.cpp:COARSE \
23     bufferinfo/legacy/BufferInfoMaliMeson.cpp:COARSE    \
24     bufferinfo/legacy/BufferInfoMinigbm.cpp:COARSE      \
25     compositor/DrmDisplayComposition.cpp:COARSE         \
26     compositor/DrmDisplayComposition.h:COARSE           \
27     compositor/DrmDisplayCompositor.cpp:COARSE          \
28     compositor/DrmDisplayCompositor.h:COARSE            \
29     drm/DrmFbImporter.h:FINE                            \
30     drm/DrmMode.h:COARSE                                \
31     drm/DrmDevice.h:COARSE                              \
32     drm/DrmProperty.h:COARSE                            \
33     drm/DrmConnector.h:COARSE                           \
34     drm/DrmCrtc.h:COARSE                                \
35     drm/DrmUnique.h:FINE                                \
36     drm/DrmEncoder.h:COARSE                             \
37     drm/DrmConnector.cpp:COARSE                         \
38     drm/DrmDevice.cpp:COARSE                            \
39     drm/DrmPlane.cpp:COARSE                             \
40     drm/DrmProperty.cpp:COARSE                          \
41     drm/UEventListener.cpp:COARSE                       \
42     drm/VSyncWorker.cpp:COARSE                          \
43     tests/worker_test.cpp:COARSE                        \
44     utils/Worker.h:COARSE                               \
45     utils/UniqueFd.h:FINE                               \
46     utils/log.h:FINE                                    \
47     utils/properties.h:FINE                             \
48     DrmHwcTwo.cpp:COARSE                                \
49     DrmHwcTwo.h:COARSE                                  \
50
51 TIDY_CHECKS_NORMAL := * \
52     -hicpp-* -llvmlibc-* -fuchsia-* -altera-* \
53     -cppcoreguidelines-special-member-functions \
54     -llvm-header-guard \
55     -cppcoreguidelines-avoid-c-arrays \
56     -cppcoreguidelines-pro-type-vararg \
57     -cppcoreguidelines-pro-bounds-array-to-pointer-decay \
58     -cppcoreguidelines-pro-bounds-constant-array-index \
59     -cppcoreguidelines-avoid-magic-numbers \
60     -google-readability-braces-around-statements \
61     -google-readability-casting \
62     -misc-non-private-member-variables-in-classes \
63     -modernize-avoid-c-arrays \
64     -modernize-use-nodiscard \
65     -modernize-use-trailing-return-type \
66     -readability-braces-around-statements \
67
68 TIDY_CHECKS_COARSE := \
69     $(TIDY_CHECKS_NORMAL) \
70     -cppcoreguidelines-non-private-member-variables-in-classes \
71     -cppcoreguidelines-pro-bounds-array-to-pointer-decay \
72     -cppcoreguidelines-pro-bounds-constant-array-index \
73     -cppcoreguidelines-pro-bounds-pointer-arithmetic \
74     -cppcoreguidelines-pro-type-cstyle-cast \
75     -cppcoreguidelines-pro-type-reinterpret-cast \
76     -cppcoreguidelines-pro-type-static-cast-downcast \
77     -cppcoreguidelines-pro-type-union-access \
78     -cppcoreguidelines-pro-type-vararg \
79     -cppcoreguidelines-avoid-magic-numbers \
80     -cppcoreguidelines-macro-usage \
81     -cppcoreguidelines-avoid-c-arrays \
82     -google-readability-braces-around-statements \
83     -google-readability-casting \
84     -misc-non-private-member-variables-in-classes \
85     -modernize-avoid-c-arrays \
86     -modernize-use-trailing-return-type \
87     -modernize-use-nodiscard \
88     -readability-braces-around-statements \
89     -readability-convert-member-functions-to-static \
90     -readability-implicit-bool-conversion \
91     -readability-identifier-naming \
92     -readability-magic-numbers \
93     -readability-use-anyofallof \
94
95 .PHONY: all build tidy clean
96
97 all: build tidy
98
99 clean:
100         rm -rf $(OUT_DIR)/
101
102 # Build
103
104 BUILD_FILES_AUTO := $(shell find -L $(SRC_DIR) -not -path '*/\.*' -not -path '*/tests/*' -path '*.cpp')
105 SKIP_FILES_path := $(foreach file,$(SKIP_FILES),$(SRC_DIR)/$(file))
106
107 BUILD_FILES := $(subst ./,,$(filter-out $(SKIP_FILES_path),$(BUILD_FILES_AUTO)))
108
109 _OBJ := $(BUILD_FILES:.cpp=.o)
110 OBJ  := $(patsubst %,$(OUT_DIR)/%,$(_OBJ))
111
112 DEPS := $(patsubst %.cpp,$(OUT_DIR)/%.d,$(BUILD_FILES))
113
114 build: $(OBJ)
115
116 CXXARGS := $(foreach dir,$(INCLUDE_DIRS),-I$(SRC_DIR)/$(dir)) $(foreach dir,$(SYSTEM_INCLUDE_DIRS),-I$(dir)) $(CXXFLAGS)
117
118 $(OUT_DIR)/%.o: $(SRC_DIR)/%.cpp
119         mkdir -p $(dir $@)
120         $(CLANG) $< $(CXXARGS) -c -o $@
121
122 $(OUT_DIR)/%.d: $(SRC_DIR)/%.cpp
123         mkdir -p $(dir $@)
124         $(CLANG) $(CXXARGS) $< -MM -MT $(OUT_DIR)/$(patsubst %.cpp,%.o,$<) -o $@
125
126 # TIDY
127 TIDY_FILES_AUTO := $(shell find -L $(SRC_DIR) -not -path '*/\.*' -not -path '*/tests/*' \( -path '*.cpp' -o -path '*.h' \))
128
129 TIDY_FILES_AUTO_filtered := $(filter-out $(SKIP_FILES_path),$(TIDY_FILES_AUTO))
130
131 TIDY_FILES_OVERRIDE_path := $(foreach pair,$(TIDY_FILES_OVERRIDE),$(SRC_DIR)/$(pair))
132
133 TIDY_FILES_OVERRIDE_name_only := $(foreach pair,$(TIDY_FILES_OVERRIDE_path),$(word 1, $(subst :, ,$(pair))))
134
135 TIDY_FILES := $(sort $(TIDY_FILES_AUTO_filtered) $(TIDY_FILES_OVERRIDE_name_only))
136
137 space := $(subst ,, )
138 comma := ,
139
140 TIDY_ARGS_FINE :=
141 TIDY_ARGS_NONE := --checks="-*,llvm-include-order"
142 TIDY_ARGS_     := --checks="-*,llvm-include-order"
143 TIDY_ARGS_NORMAL := --checks="$(subst $(space),$(comma),$(strip $(TIDY_CHECKS_NORMAL)))"
144 TIDY_ARGS_COARSE := --checks="$(subst $(space),$(comma),$(strip $(TIDY_CHECKS_COARSE)))"
145
146 define process-tidy
147
148 _TARG := $(OUT_DIR)/$1.tidy.ts
149 _DEP := $(SRC_DIR)/$1
150
151 TIDY_DEPS += $(_TARG)
152
153 TIDY_LEVEL_1 := $$(strip $$(foreach pair,$$(TIDY_FILES_OVERRIDE_path),$$(if $$(filter $$(word 1, $$(subst :, ,$$(pair))),$1),$$(word 2, $$(subst :, ,$$(pair))),)))
154
155 TIDY_LEVEL_2 := $$(if $$(TIDY_LEVEL_1),$$(TIDY_LEVEL_1),NORMAL)
156
157 TIDY_ARGS := $$(TIDY_ARGS_$$(TIDY_LEVEL_2))
158
159 $$(_TARG): _DEP := $$(_DEP)
160 $$(_TARG): _TARG := $$(_TARG)
161 $$(_TARG): TIDY_ARGS := $$(TIDY_ARGS)
162 $$(_TARG): $$(_DEP)
163         mkdir -p $$(dir $$(_TARG))
164         $$(CLANG_TIDY) $$(_DEP) $$(TIDY_ARGS) -- -x c++ $$(CXXARGS)
165         touch $$(_TARG)
166
167 endef
168
169 $(foreach file,$(TIDY_FILES),$(eval $(call process-tidy,$(file))))
170
171 tidy: $(TIDY_DEPS)
172
173 ifneq ($(MAKECMDGOALS), clean)
174 -include $(DEPS)
175 endif