Roman Stratiienko | cef5c77 | 2021-12-22 16:22:24 +0200 | [diff] [blame] | 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 | BUILD_FILES := \ |
| 15 | backend/BackendClient.cpp \ |
| 16 | backend/Backend.cpp \ |
| 17 | backend/BackendManager.cpp \ |
| 18 | backend/BackendRCarDu.cpp \ |
| 19 | bufferinfo/BufferInfoGetter.cpp \ |
| 20 | bufferinfo/legacy/BufferInfoImagination.cpp \ |
| 21 | bufferinfo/legacy/BufferInfoLibdrm.cpp \ |
| 22 | bufferinfo/legacy/BufferInfoMaliHisi.cpp \ |
| 23 | bufferinfo/legacy/BufferInfoMaliMediatek.cpp \ |
| 24 | bufferinfo/legacy/BufferInfoMaliMeson.cpp \ |
| 25 | bufferinfo/legacy/BufferInfoMinigbm.cpp \ |
| 26 | compositor/DrmDisplayComposition.cpp \ |
| 27 | compositor/DrmDisplayCompositor.cpp \ |
| 28 | compositor/Planner.cpp \ |
| 29 | drm/DrmConnector.cpp \ |
| 30 | drm/DrmCrtc.cpp \ |
| 31 | drm/DrmDevice.cpp \ |
| 32 | drm/DrmEncoder.cpp \ |
| 33 | drm/DrmFbImporter.cpp \ |
| 34 | drm/DrmMode.cpp \ |
| 35 | drm/DrmPlane.cpp \ |
| 36 | drm/DrmProperty.cpp \ |
| 37 | DrmHwcTwo.cpp \ |
| 38 | drm/ResourceManager.cpp \ |
| 39 | drm/UEventListener.cpp \ |
| 40 | drm/VSyncWorker.cpp \ |
| 41 | tests/worker_test.cpp \ |
| 42 | utils/autolock.cpp \ |
| 43 | utils/Worker.cpp \ |
| 44 | |
| 45 | #bufferinfo/BufferInfoMapperMetadata.cpp |
| 46 | #utils/hwcutils.cpp |
| 47 | |
| 48 | TIDY_FILES_H := \ |
| 49 | drm/DrmFbImporter.h \ |
| 50 | drm/DrmUnique.h \ |
| 51 | utils/UniqueFd.h \ |
| 52 | utils/log.h \ |
| 53 | utils/properties.h \ |
| 54 | |
| 55 | TIDY_FILES_CPP := \ |
| 56 | |
| 57 | TIDY_COARSE_CHECKS := * \ |
| 58 | -hicpp-* -llvmlibc-* -fuchsia-* -altera-* \ |
| 59 | -cppcoreguidelines-pro-bounds-array-to-pointer-decay \ |
| 60 | -cppcoreguidelines-pro-bounds-constant-array-index \ |
| 61 | -cppcoreguidelines-pro-bounds-pointer-arithmetic \ |
| 62 | -cppcoreguidelines-pro-type-cstyle-cast \ |
| 63 | -cppcoreguidelines-pro-type-union-access \ |
| 64 | -cppcoreguidelines-pro-type-vararg \ |
| 65 | -cppcoreguidelines-avoid-magic-numbers \ |
| 66 | -cppcoreguidelines-macro-usage \ |
| 67 | -cppcoreguidelines-avoid-c-arrays \ |
| 68 | -google-readability-braces-around-statements \ |
| 69 | -google-readability-casting \ |
| 70 | -misc-non-private-member-variables-in-classes \ |
| 71 | -modernize-avoid-c-arrays \ |
| 72 | -modernize-use-trailing-return-type \ |
| 73 | -readability-braces-around-statements \ |
| 74 | -readability-convert-member-functions-to-static \ |
| 75 | -readability-implicit-bool-conversion \ |
| 76 | -readability-identifier-naming \ |
| 77 | -readability-magic-numbers \ |
| 78 | -readability-use-anyofallof \ |
| 79 | |
| 80 | .PHONY: all build tidy tidy-fine clean |
| 81 | |
| 82 | all: build tidy tidy-fine |
| 83 | |
| 84 | clean: |
| 85 | rm -rf $(OUT_DIR)/ |
| 86 | |
| 87 | _OBJ := $(BUILD_FILES:.cpp=.o) |
| 88 | OBJ := $(patsubst %,$(OUT_DIR)/%,$(_OBJ)) |
| 89 | |
| 90 | _TIDY_TS := $(BUILD_FILES:.cpp=.cpp.t_ts) |
| 91 | TIDY_TS := $(patsubst %,$(OUT_DIR)/%,$(_TIDY_TS)) |
| 92 | |
| 93 | _FINE_TIDY_TS := $(TIDY_FILES_CPP:.cpp=.cpp,ft_ts) |
| 94 | _FINE_TIDY_TS += $(TIDY_FILES_H:.h=.h.ft_ts) |
| 95 | FINE_TIDY_TS := $(patsubst %,$(OUT_DIR)/%,$(_FINE_TIDY_TS)) |
| 96 | |
| 97 | DEPS := $(patsubst %.cpp,$(OUT_DIR)/%.d,$(BUILD_FILES)) |
| 98 | |
| 99 | build: $(OBJ) |
| 100 | |
Roman Stratiienko | 3511273 | 2021-12-23 13:41:13 +0200 | [diff] [blame^] | 101 | tidy: $(TIDY_TS) build |
Roman Stratiienko | cef5c77 | 2021-12-22 16:22:24 +0200 | [diff] [blame] | 102 | |
Roman Stratiienko | 3511273 | 2021-12-23 13:41:13 +0200 | [diff] [blame^] | 103 | tidy-fine: $(FINE_TIDY_TS) build |
Roman Stratiienko | cef5c77 | 2021-12-22 16:22:24 +0200 | [diff] [blame] | 104 | |
| 105 | CXXARGS := $(foreach dir,$(INCLUDE_DIRS),-I$(SRC_DIR)/$(dir)) $(foreach dir,$(SYSTEM_INCLUDE_DIRS),-I$(dir)) $(CXXFLAGS) |
| 106 | |
| 107 | $(OUT_DIR)/%.o: $(SRC_DIR)/%.cpp |
| 108 | mkdir -p $(dir $@) |
| 109 | $(CLANG) $< $(CXXARGS) -c -o $@ |
| 110 | |
| 111 | $(OUT_DIR)/%.d: $(SRC_DIR)/%.cpp |
| 112 | mkdir -p $(dir $@) |
Roman Stratiienko | 3511273 | 2021-12-23 13:41:13 +0200 | [diff] [blame^] | 113 | $(CLANG) $(CXXARGS) $< -MM -MT $(OUT_DIR)/$(patsubst %.cpp,%.o,$<) -o $@ |
Roman Stratiienko | cef5c77 | 2021-12-22 16:22:24 +0200 | [diff] [blame] | 114 | |
| 115 | space := $(subst ,, ) |
| 116 | comma := , |
| 117 | |
| 118 | # TIDY |
| 119 | define exec-tidy |
| 120 | mkdir -p $(dir $@) |
| 121 | $(CLANG_TIDY) $< --checks="$(subst $(space),$(comma),$(strip $(TIDY_COARSE_CHECKS)))" -- -x c++ $(CXXARGS) |
| 122 | touch $@ |
| 123 | endef |
| 124 | |
Roman Stratiienko | 3511273 | 2021-12-23 13:41:13 +0200 | [diff] [blame^] | 125 | $(OUT_DIR)/%.h.t_ts: $(SRC_DIR)/%.h |
Roman Stratiienko | cef5c77 | 2021-12-22 16:22:24 +0200 | [diff] [blame] | 126 | $(exec-tidy) |
| 127 | |
Roman Stratiienko | 3511273 | 2021-12-23 13:41:13 +0200 | [diff] [blame^] | 128 | $(OUT_DIR)/%.cpp.t_ts: $(SRC_DIR)/%.cpp $(OUT_DIR)/%.o |
Roman Stratiienko | cef5c77 | 2021-12-22 16:22:24 +0200 | [diff] [blame] | 129 | $(exec-tidy) |
| 130 | |
| 131 | # TIDY-FINE |
| 132 | define exec-tidy-fine |
| 133 | mkdir -p $(dir $@) |
| 134 | $(CLANG_TIDY) $< -- -x c++ $(CXXARGS) |
| 135 | touch $@ |
| 136 | endef |
| 137 | |
Roman Stratiienko | 3511273 | 2021-12-23 13:41:13 +0200 | [diff] [blame^] | 138 | $(OUT_DIR)/%.cpp.ft_ts: $(SRC_DIR)/%.cpp $(OUT_DIR)/%.o |
Roman Stratiienko | cef5c77 | 2021-12-22 16:22:24 +0200 | [diff] [blame] | 139 | $(exec-tidy-fine) |
| 140 | |
Roman Stratiienko | 3511273 | 2021-12-23 13:41:13 +0200 | [diff] [blame^] | 141 | $(OUT_DIR)/%.h.ft_ts: $(SRC_DIR)/%.h |
Roman Stratiienko | cef5c77 | 2021-12-22 16:22:24 +0200 | [diff] [blame] | 142 | $(exec-tidy-fine) |
| 143 | |
| 144 | ifneq ($(MAKECMDGOALS), clean) |
| 145 | -include $(DEPS) |
| 146 | endif |