forked from GloDroid/aospext
-
Notifications
You must be signed in to change notification settings - Fork 2
/
meson_mesa3d.mk
218 lines (179 loc) · 8.8 KB
/
meson_mesa3d.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# SPDX-License-Identifier: Apache-2.0
#
# AOSPEXT project (https://github.com/GloDroid/aospext)
#
# Copyright (C) 2021 GlobalLogic Ukraine
# Copyright (C) 2021-2022 Roman Stratiienko ([email protected])
ifneq ($(filter true, $(BOARD_BUILD_AOSPEXT_MESA3D)),)
LOCAL_PATH := $(call my-dir)
include $(LOCAL_PATH)/aospext_cleanup.mk
AOSPEXT_PROJECT_NAME := MESA3D
AOSPEXT_BUILD_SYSTEM := meson
LIBDRM_VERSION = $(shell cat external/libdrm/meson.build | grep -o "\<version\>\s*:\s*'\w*\.\w*\.\w*'" | grep -o "\w*\.\w*\.\w*" | head -1)
MESA_VK_LIB_SUFFIX_amd := radeon
MESA_VK_LIB_SUFFIX_intel := intel
MESA_VK_LIB_SUFFIX_intel_hasvk := intel_hasvk
MESA_VK_LIB_SUFFIX_freedreno := freedreno
MESA_VK_LIB_SUFFIX_broadcom := broadcom
MESA_VK_LIB_SUFFIX_panfrost := panfrost
MESA_VK_LIB_SUFFIX_virtio := virtio
MESA_VK_LIB_SUFFIX_swrast := lvp
MESON_BUILD_ARGUMENTS := \
-Dplatforms=android \
-Dplatform-sdk-version=$(PLATFORM_SDK_VERSION) \
-Dgallium-drivers=$(subst $(space),$(comma),$(BOARD_MESA3D_GALLIUM_DRIVERS)) \
-Dvulkan-drivers=$(subst $(space),$(comma),$(subst radeon,amd,$(BOARD_MESA3D_VULKAN_DRIVERS))) \
-Dgbm=enabled \
-Degl=$(if $(BOARD_MESA3D_GALLIUM_DRIVERS),enabled,disabled) \
-Dllvm=$(if $(MESON_GEN_LLVM_STUB),enabled,disabled) \
-Dcpp_rtti=false \
-Dlmsensors=disabled \
-Dandroid-libbacktrace=disabled \
-Dgallium-va=$(BOARD_MESA3D_GALLIUM_VA) \
-Dvideo-codecs=$(subst $(space),$(comma),$(BOARD_MESA3D_VIDEO_CODECS)) \
-Dallow-kcmp=enabled \
-Dxmlconfig=enabled \
$(BOARD_MESA3D_EXTRA_MESON_ARGS)
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 30; echo $$?), 0)
MESA_LIBGBM_NAME := libgbm_mesa
else
MESA_LIBGBM_NAME := libgbm
endif
# Format: TYPE:REL_PATH_TO_INSTALL_ARTIFACT:VENDOR_SUBDIR:MODULE_NAME:SYMLINK_SUFFIX
# TYPE one of: lib, bin, etc
AOSPEXT_GEN_TARGETS := $(BOARD_MESA3D_EXTRA_TARGETS)
ifneq ($(strip $(BOARD_MESA3D_GALLIUM_DRIVERS)),)
AOSPEXT_GEN_TARGETS += \
lib:libgallium_dri.so:dri:libgallium_dri: \
lib:libglapi.so::libglapi: \
lib:libEGL.so:egl:libEGL_mesa: \
lib:libGLESv1_CM.so:egl:libGLESv1_CM_mesa: \
lib:libGLESv2.so:egl:libGLESv2_mesa: \
endif
ifneq ($(filter true, $(BOARD_MESA3D_BUILD_LIBGBM)),)
AOSPEXT_GEN_TARGETS += lib:$(MESA_LIBGBM_NAME).so::$(MESA_LIBGBM_NAME):
endif
ifneq ($(BOARD_MESA3D_GALLIUM_VA),)
AOSPEXT_GEN_TARGETS += lib:libgallium_drv_video.so:dri:libgallium_drv_video:
endif
AOSPEXT_GEN_TARGETS += \
$(foreach driver,$(BOARD_MESA3D_VULKAN_DRIVERS), lib:libvulkan_$(MESA_VK_LIB_SUFFIX_$(driver)).so:hw:vulkan.$(driver):)
include $(CLEAR_VARS)
LOCAL_SHARED_LIBRARIES := libc libdl libdrm libm liblog libcutils libz libc++ libnativewindow libsync libhardware libxml2
LOCAL_STATIC_LIBRARIES := libexpat libarect libelf
LOCAL_HEADER_LIBRARIES := libnativebase_headers hwvulkan_headers
AOSPEXT_GEN_PKGCONFIGS := cutils expat hardware libdrm:$(LIBDRM_VERSION) nativewindow sync zlib:1.2.11 libelf libxml2
LOCAL_CFLAGS += $(BOARD_MESA3D_CFLAGS)
ifneq ($(filter swrast,$(BOARD_MESA3D_GALLIUM_DRIVERS) $(BOARD_MESA3D_VULKAN_DRIVERS)),)
ifeq ($(BOARD_MESA3D_FORCE_SOFTPIPE),)
MESON_GEN_LLVM_STUB := true
endif
endif
ifneq ($(filter zink,$(BOARD_MESA3D_GALLIUM_DRIVERS)),)
LOCAL_SHARED_LIBRARIES += libvulkan
AOSPEXT_GEN_PKGCONFIGS += vulkan
endif
ifneq ($(filter iris,$(BOARD_MESA3D_GALLIUM_DRIVERS)),)
LOCAL_SHARED_LIBRARIES += libdrm_intel
AOSPEXT_GEN_PKGCONFIGS += libdrm_intel:$(LIBDRM_VERSION)
endif
ifneq ($(filter radeonsi,$(BOARD_MESA3D_GALLIUM_DRIVERS)),)
MESON_GEN_LLVM_STUB := true
LOCAL_CFLAGS += -DFORCE_BUILD_AMDGPU # instructs LLVM to declare LLVMInitializeAMDGPU* functions
endif
ifneq ($(filter radeonsi amd,$(BOARD_MESA3D_GALLIUM_DRIVERS) $(BOARD_MESA3D_VULKAN_DRIVERS)),)
LOCAL_SHARED_LIBRARIES += libdrm_amdgpu
AOSPEXT_GEN_PKGCONFIGS += libdrm_amdgpu:$(LIBDRM_VERSION)
endif
ifneq ($(filter radeonsi r300 r600,$(BOARD_MESA3D_GALLIUM_DRIVERS)),)
LOCAL_SHARED_LIBRARIES += libdrm_radeon
AOSPEXT_GEN_PKGCONFIGS += libdrm_radeon:$(LIBDRM_VERSION)
endif
ifneq ($(filter nouveau,$(BOARD_MESA3D_GALLIUM_DRIVERS)),)
LOCAL_SHARED_LIBRARIES += libdrm_nouveau
AOSPEXT_GEN_PKGCONFIGS += libdrm_nouveau:$(LIBDRM_VERSION)
endif
ifneq ($(filter d3d12,$(BOARD_MESA3D_GALLIUM_DRIVERS)),)
LOCAL_HEADER_LIBRARIES += DirectX-Headers
LOCAL_STATIC_LIBRARIES += DirectX-Guids
AOSPEXT_GEN_PKGCONFIGS += DirectX-Headers
endif
ifneq ($(MESON_GEN_LLVM_STUB),)
MESON_LLVM_VERSION := 16.0.6
LOCAL_SHARED_LIBRARIES += libLLVM16
endif
ifneq ($(BOARD_MESA3D_GALLIUM_VA),)
LOCAL_SHARED_LIBRARIES += libva libva-android
AOSPEXT_GEN_PKGCONFIGS += libva:1.20.0
endif
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 30; echo $$?), 0)
LOCAL_SHARED_LIBRARIES += \
libgralloctypes \
libhidlbase \
libutils
AOSPEXT_GEN_PKGCONFIGS += android.hardware.graphics.mapper:4.0
endif
LOCAL_EXPORT_C_INCLUDE_DIRS := $(BOARD_MESA3D_SRC_DIR)/src/gbm/main
AOSPEXT_EXPORT_INSTALLED_INCLUDE_DIRS := vendor/include
define populate_dri_symlinks
# -------------------------------------------------------------------------------
# Mesa3d installs every dri target as a separate shared library, but for gallium drivers all
# dri targets are identical and can be replaced with symlinks to save some disk space.
# To do that we take first driver, copy it as libgallium_dri.so and populate vendor/lib{64}/dri/
# directory with a symlinks to libgallium_dri.so
$(SYMLINKS_TARGET): MESA3D_LIB_INSTALL_DIR:=$(dir $(AOSPEXT_INTERNAL_BUILD_TARGET))/install/vendor/lib$(if $(TARGET_IS_64_BIT),$(if $(filter 64 first,$(LOCAL_MULTILIB)),64))
$(SYMLINKS_TARGET): $(AOSPEXT_INTERNAL_BUILD_TARGET)
# Create Symlinks
mkdir -p $$(dir $$@)
ifneq ($(strip $(BOARD_MESA3D_GALLIUM_DRIVERS)),)
find $$(MESA3D_LIB_INSTALL_DIR)/dri -name \*_dri.so -printf '%f\n' | PATH=/usr/bin:$$PATH xargs -I{} ln -s -f libgallium_dri.so $$(dir $$@)/{}
cp `find $$(MESA3D_LIB_INSTALL_DIR)/dri -name \*_dri.so | head -1` $$(MESA3D_LIB_INSTALL_DIR)/libgallium_dri.so
endif
touch $$@
endef
define populate_drv_video_symlinks
# -------------------------------------------------------------------------------
# This function is the same as populate_dri_symlinks, but made for Mesa's VA-API
# drivers instead of Gallium dri drivers
$(SYMLINKS_TARGET_VIDEO): MESA3D_LIB_INSTALL_DIR:=$(dir $(AOSPEXT_INTERNAL_BUILD_TARGET))/install/vendor/lib$(if $(TARGET_IS_64_BIT),$(if $(filter 64 first,$(LOCAL_MULTILIB)),64))
$(SYMLINKS_TARGET_VIDEO): $(AOSPEXT_INTERNAL_BUILD_TARGET)
# Create Symlinks
mkdir -p $$(dir $$@)
ifneq ($(strip $(BOARD_MESA3D_GALLIUM_VA)),)
find $$(MESA3D_LIB_INSTALL_DIR)/dri -name \*_drv_video.so -printf '%f\n' | PATH=/usr/bin:$$PATH xargs -I{} ln -s -f libgallium_drv_video.so $$(dir $$@)/{}
cp `find $$(MESA3D_LIB_INSTALL_DIR)/dri -name \*_drv_video.so | head -1` $$(MESA3D_LIB_INSTALL_DIR)/libgallium_drv_video.so
endif
touch $$@
endef
#-------------------------------------------------------------------------------
LOCAL_MULTILIB := first
include $(LOCAL_PATH)/aospext_cross_compile.mk
SYMLINKS_TARGET := $($(AOSPEXT_ARCH_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES)/dri/.symlinks.timestamp
$(eval $(call populate_dri_symlinks))
SYMLINKS_TARGET_VIDEO := $($(AOSPEXT_ARCH_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES)/dri/.symlinks.drv_video.timestamp
$(eval $(call populate_drv_video_symlinks))
FIRSTARCH_SYMLINKS_TARGET := $(SYMLINKS_TARGET) $(SYMLINKS_TARGET_VIDEO)
FIRSTARCH_BUILD_TARGET := $(AOSPEXT_INTERNAL_BUILD_TARGET)
ifdef TARGET_2ND_ARCH
LOCAL_MULTILIB := 32
include $(LOCAL_PATH)/aospext_cross_compile.mk
SYMLINKS_TARGET := $($(AOSPEXT_ARCH_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES)/dri/.symlinks.timestamp
$(eval $(call populate_dri_symlinks))
SYMLINKS_TARGET_VIDEO := $($(AOSPEXT_ARCH_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES)/dri/.symlinks.drv_video.timestamp
$(eval $(call populate_drv_video_symlinks))
SECONDARCH_SYMLINKS_TARGET := $(SYMLINKS_TARGET) $(SYMLINKS_TARGET_VIDEO)
SECONDARCH_BUILD_TARGET := $(AOSPEXT_INTERNAL_BUILD_TARGET)
endif
#-------------------------------------------------------------------------------
LOCAL_MULTILIB := first
AOSPEXT_EXTRA_DEPS := $(FIRSTARCH_SYMLINKS_TARGET)
AOSPEXT_INTERNAL_BUILD_TARGET := $(FIRSTARCH_BUILD_TARGET)
include $(LOCAL_PATH)/aospext_gen_targets.mk
ifdef TARGET_2ND_ARCH
LOCAL_MULTILIB := 32
AOSPEXT_EXTRA_DEPS := $(SECONDARCH_SYMLINKS_TARGET)
AOSPEXT_INTERNAL_BUILD_TARGET := $(SECONDARCH_BUILD_TARGET)
include $(LOCAL_PATH)/aospext_gen_targets.mk
endif
endif # BOARD_BUILD_AOSPEXT_MESA3D