diff options
author | Roman Stratiienko <r.stratiienko@gmail.com> | 2021-04-12 17:44:20 +0300 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-06-07 16:04:15 +0000 |
commit | 8621bd8d5e67173281c6a6dd64054d4b0366f023 (patch) | |
tree | 38339f9122dcf268330bce3934e3245fb417d5d5 /android | |
parent | 016e932cdae168d8db5a603ce17182f00dcee79a (diff) | |
download | mesa-8621bd8d5e67173281c6a6dd64054d4b0366f023.tar.gz mesa-8621bd8d5e67173281c6a6dd64054d4b0366f023.tar.bz2 mesa-8621bd8d5e67173281c6a6dd64054d4b0366f023.zip |
android: Add scripts to build using meson
How to use:
- For GALLIUM drivers:
1. Add gallium drivers into your board.mk file:
board.mk:
BOARD_MESA3D_USES_MESON_BUILD := true
BOARD_MESA3D_GALLIUM_DRIVERS := lima panfrost v3d
2. Add the following packages into your device.mk file:
device.mk:
PRODUCT_PACKAGES += \
libEGL_mesa \
libGLESv1_CM_mesa \
libGLESv2_mesa \
libgallium_dri \
libglapi
- For VULKAN drivers:
1. Add single vulkan driver into your board.mk file:
board.mk:
BOARD_MESA3D_USES_MESON_BUILD := true
BOARD_MESA3D_VULKAN_DRIVERS := freedreno broadcom
2. Add the following package configuration into your device.mk file:
device.mk:
PRODUCT_PACKAGES += \
vulkan.freedreno
PRODUCT_PROPERTY_OVERRIDES += \
ro.hardware.vulkan=freedreno
- To build 'libgbm' set definition in the board.mk:
BOARD_MESA3D_BUILD_LIBGBM := true
And add a package to the device.mk:
PRODUCT_PACKAGES += libgbm
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tested-by: Mauro Rossi <issor.oruam@gmail.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10183>
Diffstat (limited to 'android')
-rw-r--r-- | android/Android.mk | 144 | ||||
-rw-r--r-- | android/mesa3d_cross.mk | 293 |
2 files changed, 437 insertions, 0 deletions
diff --git a/android/Android.mk b/android/Android.mk new file mode 100644 index 00000000000..d5d2c68272f --- /dev/null +++ b/android/Android.mk @@ -0,0 +1,144 @@ +# Mesa 3-D graphics library +# +# Copyright (C) 2021 GlobalLogic Ukraine +# Copyright (C) 2021 Roman Stratiienko (r.stratiienko@gmail.com) +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +ifneq ($(filter true, $(BOARD_MESA3D_USES_MESON_BUILD)),) + +LOCAL_PATH := $(call my-dir) +MESA3D_TOP := $(dir $(LOCAL_PATH)) + +MESA_VK_LIB_SUFFIX_amd := radeon +MESA_VK_LIB_SUFFIX_intel := intel +MESA_VK_LIB_SUFFIX_freedreno := freedreno +MESA_VK_LIB_SUFFIX_broadcom := broadcom +MESA_VK_LIB_SUFFIX_virtio-experimental := virtio +MESA_VK_LIB_SUFFIX_swrast := lvp + +include $(CLEAR_VARS) + +LOCAL_SHARED_LIBRARIES := libc libdl libdrm libm liblog libcutils libz libc++ libnativewindow libsync libhardware +LOCAL_STATIC_LIBRARIES := libexpat libarect libelf +LOCAL_HEADER_LIBRARIES := libnativebase_headers hwvulkan_headers libbacktrace_headers +MESON_GEN_PKGCONFIGS := backtrace cutils expat hardware libdrm:2.4.105 nativewindow sync zlib:1.2.11 libelf + +ifneq ($(filter swr swrast,$(BOARD_MESA3D_GALLIUM_DRIVERS) $(BOARD_MESA3D_VULKAN_DRIVERS)),) +MESON_GEN_LLVM_STUB := true +endif + +ifneq ($(filter zink,$(BOARD_MESA3D_GALLIUM_DRIVERS)),) +LOCAL_SHARED_LIBRARIES += libvulkan +MESON_GEN_PKGCONFIGS += vulkan +endif + +ifneq ($(filter iris,$(BOARD_MESA3D_GALLIUM_DRIVERS)),) +LOCAL_SHARED_LIBRARIES += libdrm_intel +MESON_GEN_PKGCONFIGS += libdrm_intel:2.4.105 +endif + +ifneq ($(filter radeonsi amd,$(BOARD_MESA3D_GALLIUM_DRIVERS) $(BOARD_MESA3D_VULKAN_DRIVERS)),) +MESON_GEN_LLVM_STUB := true +LOCAL_CFLAGS += -DFORCE_BUILD_AMDGPU # instructs LLVM to declare LLVMInitializeAMDGPU* functions +LOCAL_SHARED_LIBRARIES += libdrm_amdgpu +MESON_GEN_PKGCONFIGS += libdrm_amdgpu:2.4.105 +endif + +ifneq ($(filter radeonsi r300 r600,$(BOARD_MESA3D_GALLIUM_DRIVERS)),) +LOCAL_SHARED_LIBRARIES += libdrm_radeon +MESON_GEN_PKGCONFIGS += libdrm_radeon:2.4.105 +endif + +ifneq ($(filter nouveau,$(BOARD_MESA3D_GALLIUM_DRIVERS)),) +LOCAL_SHARED_LIBRARIES += libdrm_nouveau +MESON_GEN_PKGCONFIGS += libdrm_nouveau:2.4.105 +endif + +ifneq ($(MESON_GEN_LLVM_STUB),) +MESON_LLVM_VERSION := 11.0.0 +# Required for swr gallium target +MESON_LLVM_IRBUILDER_PATH := external/llvm-project/llvm/include/llvm/IR/IRBuilder.h +LOCAL_SHARED_LIBRARIES += libLLVM11 +endif + +ifeq ($(TARGET_IS_64_BIT),true) +LOCAL_MULTILIB := 64 +else +LOCAL_MULTILIB := 32 +endif +include $(LOCAL_PATH)/mesa3d_cross.mk + +ifdef TARGET_2ND_ARCH +LOCAL_MULTILIB := 32 +include $(LOCAL_PATH)/mesa3d_cross.mk +endif + +#------------------------------------------------------------------------------- + +define mesa3d-lib +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_MODULE := $1 +LOCAL_VENDOR_MODULE := true +LOCAL_MODULE_RELATIVE_PATH := $3 +ifdef TARGET_2ND_ARCH +LOCAL_SRC_FILES_$(TARGET_ARCH) := $(call relative_top_path,$(LOCAL_PATH))$($4) +LOCAL_SRC_FILES_$(TARGET_2ND_ARCH) := $(call relative_top_path,$(LOCAL_PATH))$(2ND_$4) +LOCAL_MULTILIB := both +else +LOCAL_SRC_FILES := $(call relative_top_path,$(LOCAL_PATH))$($4) +endif +LOCAL_CHECK_ELF_FILES := false +LOCAL_MODULE_SUFFIX := .so +LOCAL_MODULE_SYMLINKS := $1$2 +include $(BUILD_PREBUILT) +include $(CLEAR_VARS) +endef + +__MY_SHARED_LIBRARIES := $(LOCAL_SHARED_LIBRARIES) +include $(CLEAR_VARS) +LOCAL_SHARED_LIBRARIES := $(__MY_SHARED_LIBRARIES) + +# Module 'libgallium_dri', produces '/vendor/lib{64}/dri/libgallium_dri.so' +# This module also trigger DRI symlinks creation process +$(eval $(call mesa3d-lib,libgallium_dri,.so.0,dri,MESA3D_GALLIUM_DRI_BIN)) +# Module 'libglapi', produces '/vendor/lib{64}/libglapi.so' +$(eval $(call mesa3d-lib,libglapi,.so.0,,MESA3D_LIBGLAPI_BIN)) + +# Module 'libEGL_mesa', produces '/vendor/lib{64}/egl/libEGL_mesa.so' +$(eval $(call mesa3d-lib,libEGL_mesa,.so.1,egl,MESA3D_LIBEGL_BIN)) +# Module 'libGLESv1_CM_mesa', produces '/vendor/lib{64}/egl/libGLESv1_CM_mesa.so' +$(eval $(call mesa3d-lib,libGLESv1_CM_mesa,.so.1,egl,MESA3D_LIBGLESV1_BIN)) +# Module 'libGLESv2_mesa', produces '/vendor/lib{64}/egl/libGLESv2_mesa.so' +$(eval $(call mesa3d-lib,libGLESv2_mesa,.so.2,egl,MESA3D_LIBGLESV2_BIN)) + +# Modules 'vulkan.{driver_name}', produces '/vendor/lib{64}/hw/vulkan.{driver_name}.so' HAL +$(foreach driver,$(BOARD_MESA3D_VULKAN_DRIVERS), \ + $(eval $(call mesa3d-lib,vulkan.$(MESA_VK_LIB_SUFFIX_$(driver)),.so.0,hw,MESA3D_VULKAN_$(driver)_BIN))) + +ifneq ($(filter true, $(BOARD_MESA3D_BUILD_LIBGBM)),) +LOCAL_EXPORT_C_INCLUDE_DIRS := $(MESA3D_TOP)/src/gbm/main + +# Modules 'libgbm', produces '/vendor/lib{64}/libgbm.so' +$(eval $(call mesa3d-lib,libgbm,.so.1,,MESA3D_LIBGBM_BIN)) +endif + +#------------------------------------------------------------------------------- + +endif diff --git a/android/mesa3d_cross.mk b/android/mesa3d_cross.mk new file mode 100644 index 00000000000..ac06efcee15 --- /dev/null +++ b/android/mesa3d_cross.mk @@ -0,0 +1,293 @@ +# Mesa 3-D graphics library +# +# Copyright (C) 2021 GlobalLogic Ukraine +# Copyright (C) 2021 Roman Stratiienko (r.stratiienko@gmail.com) +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +# Turn "dir1/dir2/dir3/dir4" into "../../../../" +define relative_top_path +$(eval __s:=) \ +$(foreach tmp,$(subst /,$(space),$1),$(eval __s:=$(__s)../)) \ +$(__s) +endef + +MY_PATH := $(call my-dir) + +AOSP_ABSOLUTE_PATH := $(realpath .) + +m_dummy_$(LOCAL_MULTILIB) := $(TARGET_OUT_INTERMEDIATES)/MESON_DUMMY_$(LOCAL_MULTILIB)/dummy.c + +$(m_dummy_$(LOCAL_MULTILIB)): + mkdir -p $(dir $@) + touch $@ + +LOCAL_SRC_FILES := $(call relative_top_path,$(MY_PATH))$(m_dummy_$(LOCAL_MULTILIB)) +LOCAL_VENDOR_MODULE := true +LOCAL_MODULE := meson.dummy.$(LOCAL_MULTILIB) + +# Prepare intermediate variables by AOSP make/core internals +include $(BUILD_SHARED_LIBRARY) + +LOCAL_PATH := $(MY_PATH) + +link_deps := \ + $(built_static_libraries) \ + $(built_shared_libraries) \ + $(built_whole_libraries) \ + $(strip $(all_objects)) \ + $(my_target_libatomic) \ + $(my_target_libcrt_builtins) \ + $(my_target_crtbegin_so_o) \ + $(my_target_crtend_so_o) + +# Build mesa3d using intermediate variables provided by AOSP make/core internals +M_TARGET_PREFIX := $(my_2nd_arch_prefix) + +MESA3D_LIB_DIR := lib$(subst 32,,$(LOCAL_MULTILIB)) + +MESON_OUT_DIR := $($(M_TARGET_PREFIX)TARGET_OUT_INTERMEDIATES)/MESON_MESA3D +MESON_GEN_DIR := $(MESON_OUT_DIR)_GEN +MESON_GEN_FILES_TARGET := $(MESON_GEN_DIR)/.timestamp + +MESA3D_GALLIUM_DRI_DIR := $(MESON_OUT_DIR)/install/usr/local/lib/dri +$(M_TARGET_PREFIX)MESA3D_GALLIUM_DRI_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libgallium_dri.so +$(M_TARGET_PREFIX)MESA3D_LIBEGL_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libEGL.so.1.0.0 +$(M_TARGET_PREFIX)MESA3D_LIBGLESV1_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libGLESv1_CM.so.1.1.0 +$(M_TARGET_PREFIX)MESA3D_LIBGLESV2_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libGLESv2.so.2.0.0 +$(M_TARGET_PREFIX)MESA3D_LIBGLAPI_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libglapi.so.0.0.0 +$(M_TARGET_PREFIX)MESA3D_LIBGBM_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libgbm.so.1.0.0 + + +MESA3D_GLES_BINS := \ + $($(M_TARGET_PREFIX)MESA3D_LIBEGL_BIN) \ + $($(M_TARGET_PREFIX)MESA3D_LIBGLESV1_BIN) \ + $($(M_TARGET_PREFIX)MESA3D_LIBGLESV2_BIN) \ + $($(M_TARGET_PREFIX)MESA3D_LIBGLAPI_BIN) \ + +MESON_GEN_NINJA := \ + cd $(MESON_OUT_DIR) && PATH=/usr/bin:/usr/local/bin:$$PATH meson ./build \ + --cross-file $(AOSP_ABSOLUTE_PATH)/$(MESON_GEN_DIR)/aosp_cross \ + --buildtype=release \ + -Ddri-search-path=/vendor/$(MESA3D_LIB_DIR)/dri \ + -Dplatforms=android \ + -Dplatform-sdk-version=$(PLATFORM_SDK_VERSION) \ + -Ddri-drivers= \ + -Dgallium-drivers=$(subst $(space),$(comma),$(BOARD_MESA3D_GALLIUM_DRIVERS)) \ + -Dvulkan-drivers=$(subst $(space),$(comma),$(subst radeon,amd,$(BOARD_MESA3D_VULKAN_DRIVERS))) \ + -Dgbm=enabled \ + -Degl=enabled \ + +MESON_BUILD := PATH=/usr/bin:/bin:/sbin:$$PATH ninja -C $(MESON_OUT_DIR)/build + +$(MESON_GEN_FILES_TARGET): MESON_CPU_FAMILY := $(subst arm64,aarch64,$(TARGET_$(M_TARGET_PREFIX)ARCH)) + +define create-pkgconfig +echo -e "Name: $2" \ + "\nDescription: $2" \ + "\nVersion: $3" > $1/$2.pc + +endef + +# Taken from build/make/core/binary.mk. We need this +# to use definitions from build/make/core/definitions.mk +$(MESON_GEN_FILES_TARGET): PRIVATE_GLOBAL_C_INCLUDES := $(my_target_global_c_includes) +$(MESON_GEN_FILES_TARGET): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_target_global_c_system_includes) + +$(MESON_GEN_FILES_TARGET): PRIVATE_2ND_ARCH_VAR_PREFIX := $(M_TARGET_PREFIX) +$(MESON_GEN_FILES_TARGET): PRIVATE_CC := $(my_cc) +$(MESON_GEN_FILES_TARGET): PRIVATE_LINKER := $(my_linker) +$(MESON_GEN_FILES_TARGET): PRIVATE_CXX := $(my_cxx) +$(MESON_GEN_FILES_TARGET): PRIVATE_CXX_LINK := $(my_cxx_link) +$(MESON_GEN_FILES_TARGET): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS) +$(MESON_GEN_FILES_TARGET): PRIVATE_ASFLAGS := $(my_asflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_CONLYFLAGS := $(my_conlyflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_CFLAGS := $(my_cflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_CPPFLAGS := $(my_cppflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_CFLAGS_NO_OVERRIDE := $(my_cflags_no_override) +$(MESON_GEN_FILES_TARGET): PRIVATE_CPPFLAGS_NO_OVERRIDE := $(my_cppflags_no_override) +$(MESON_GEN_FILES_TARGET): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG) +$(MESON_GEN_FILES_TARGET): PRIVATE_DEBUG_CFLAGS := $(debug_cflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_C_INCLUDES := $(my_c_includes) +$(MESON_GEN_FILES_TARGET): PRIVATE_IMPORTED_INCLUDES := $(imported_includes) +$(MESON_GEN_FILES_TARGET): PRIVATE_LDFLAGS := $(my_ldflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_LDLIBS := $(my_ldlibs) +$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_TIDY_CHECKS := $(my_tidy_checks) +$(MESON_GEN_FILES_TARGET): PRIVATE_TIDY_FLAGS := $(my_tidy_flags) +$(MESON_GEN_FILES_TARGET): PRIVATE_ARFLAGS := $(my_arflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries) +$(MESON_GEN_FILES_TARGET): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries) +$(MESON_GEN_FILES_TARGET): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries) +$(MESON_GEN_FILES_TARGET): PRIVATE_ALL_OBJECTS := $(strip $(all_objects)) + +$(MESON_GEN_FILES_TARGET): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) + +$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_LIBCRT_BUILTINS := $(my_target_libcrt_builtins) +$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic) +$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_CRTBEGIN_SO_O := $(my_target_crtbegin_so_o) +$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_CRTEND_SO_O := $(my_target_crtend_so_o) +## + +define m-lld-flags + -nostdlib -Wl,--gc-sections \ + $(PRIVATE_TARGET_CRTBEGIN_SO_O) \ + $(PRIVATE_ALL_OBJECTS) \ + -Wl,--whole-archive \ + $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \ + -Wl,--no-whole-archive \ + $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ + $(PRIVATE_ALL_STATIC_LIBRARIES) \ + $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ + $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \ + $(PRIVATE_TARGET_LIBCRT_BUILTINS) \ + $(PRIVATE_TARGET_LIBATOMIC) \ + $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ + $(PRIVATE_LDFLAGS) \ + $(PRIVATE_ALL_SHARED_LIBRARIES) \ + $(PRIVATE_TARGET_CRTEND_SO_O) \ + $(PRIVATE_LDLIBS) +endef + +define m-lld-flags-cleaned + $(subst prebuilts/,$(AOSP_ABSOLUTE_PATH)/prebuilts/, \ + $(subst out/,$(AOSP_ABSOLUTE_PATH)/out/, \ + $(subst -Wl$(comma)--fatal-warnings,, \ + $(subst -Wl$(comma)--no-undefined-version,, \ + $(patsubst %dummy.o,, \ + $(m-lld-flags)))))) +endef + +define m-cpp-flags + $(PRIVATE_TARGET_GLOBAL_CFLAGS) \ + $(PRIVATE_TARGET_GLOBAL_CPPFLAGS) \ + $(PRIVATE_ARM_CFLAGS) \ + $(PRIVATE_RTTI_FLAG) \ + $(PRIVATE_CFLAGS) \ + $(PRIVATE_CPPFLAGS) \ + $(PRIVATE_DEBUG_CFLAGS) \ + $(PRIVATE_CFLAGS_NO_OVERRIDE) \ + $(PRIVATE_CPPFLAGS_NO_OVERRIDE) +endef + +define m-c-flags + $(PRIVATE_TARGET_GLOBAL_CFLAGS) \ + $(PRIVATE_TARGET_GLOBAL_CONLYFLAGS) \ + $(PRIVATE_ARM_CFLAGS) \ + $(PRIVATE_CFLAGS) \ + $(PRIVATE_CONLYFLAGS) \ + $(PRIVATE_DEBUG_CFLAGS) \ + $(PRIVATE_CFLAGS_NO_OVERRIDE) +endef + +define filter-c-flags + $(subst -std=gnu++17,, \ + $(subst -fno-rtti,, \ + $(patsubst -W%,, \ + $1))) +endef + +define m-c-abs-includes + $(subst -isystem , -isystem $(AOSP_ABSOLUTE_PATH)/, \ + $(subst -I, -I$(AOSP_ABSOLUTE_PATH)/, \ + $(subst -I , -I, \ + $(c-includes)))) +endef + +$(MESON_GEN_FILES_TARGET): PREPROCESS_MESON_CONFIGS:=$(PREPROCESS_MESON_CONFIGS) +$(MESON_GEN_FILES_TARGET): MESON_GEN_DIR:=$(MESON_GEN_DIR) +$(MESON_GEN_FILES_TARGET): $(sort $(shell find -L $(MESA3D_TOP) -not -path '*/\.*')) + mkdir -p $(dir $@) + echo -e "[properties]\n" \ + "c_args = [$(foreach flag, $(call filter-c-flags,$(m-c-flags) $(m-c-abs-includes)),'$(flag)', )'']\n" \ + "cpp_args = [$(foreach flag, $(call filter-c-flags,$(m-cpp-flags) $(m-c-abs-includes)),'$(flag)', )'']\n" \ + "c_link_args = [$(foreach flag, $(m-lld-flags-cleaned),'$(flag)',)'']\n" \ + "cpp_link_args = [$(foreach flag, $(m-lld-flags-cleaned),'$(flag)',)'']\n" \ + "needs_exe_wrapper = true\n" \ + "[binaries]\n" \ + "ar = '$(AOSP_ABSOLUTE_PATH)/$($($(M_TARGET_PREFIX))TARGET_AR)'\n" \ + "c = [$(foreach arg,$(PRIVATE_CC),'$(subst prebuilts/,$(AOSP_ABSOLUTE_PATH)/prebuilts/,$(arg))',)'']\n" \ + "cpp = [$(foreach arg,$(PRIVATE_CXX),'$(subst prebuilts/,$(AOSP_ABSOLUTE_PATH)/prebuilts/,$(arg))',)'']\n" \ + "c_ld = 'lld'\n" \ + "cpp_ld = 'lld'\n\n" \ + "pkgconfig = ['env', 'PKG_CONFIG_LIBDIR=' + '$(AOSP_ABSOLUTE_PATH)/$(MESON_GEN_DIR)', '/usr/bin/pkg-config']\n\n" \ + "llvm-config = '/dev/null'\n" \ + "[host_machine]\n" \ + "system = 'linux'\n" \ + "cpu_family = '$(MESON_CPU_FAMILY)'\n" \ + "cpu = '$(MESON_CPU_FAMILY)'\n" \ + "endian = 'little'" > $(dir $@)/aosp_cross + + # + $(foreach pkg, $(MESON_GEN_PKGCONFIGS), $(call create-pkgconfig,$(dir $@),$(word 1, $(subst :, ,$(pkg))),$(word 2, $(subst :, ,$(pkg))))) + touch $@ + +$(MESON_OUT_DIR)/.build.timestamp: MESON_GEN_NINJA:=$(MESON_GEN_NINJA) +$(MESON_OUT_DIR)/.build.timestamp: MESON_BUILD:=$(MESON_BUILD) +$(MESON_OUT_DIR)/.build.timestamp: $(MESON_GEN_FILES_TARGET) $(link_deps) + rm -rf $(dir $@) + mkdir -p $(dir $@) + mkdir -p $(dir $@)/build + # Meson will update timestamps in sources directory, continuously retriggering the build + # even if nothing changed. Copy sources into intermediate dir to avoid this effect. + cp -r $(MESA3D_TOP)/* $(dir $@) +ifneq ($(MESON_GEN_LLVM_STUB),) + mkdir -p $(dir $@)/subprojects/llvm/ + echo -e "project('llvm', 'cpp', version : '$(MESON_LLVM_VERSION)')\n" \ + "dep_llvm = declare_dependency()\n" \ + "has_rtti = false\n" \ + "irbuilder_h = files('$(AOSP_ABSOLUTE_PATH)/$(MESON_LLVM_IRBUILDER_PATH)')" > $(dir $@)/subprojects/llvm/meson.build +endif + $(MESON_GEN_NINJA) + $(MESON_BUILD) + touch $@ + +MESON_COPY_LIBGALLIUM := \ + cp `ls -1 $(MESA3D_GALLIUM_DRI_DIR)/* | head -1` $($(M_TARGET_PREFIX)MESA3D_GALLIUM_DRI_BIN) + +$(MESON_OUT_DIR)/install/.install.timestamp: MESON_COPY_LIBGALLIUM:=$(MESON_COPY_LIBGALLIUM) +$(MESON_OUT_DIR)/install/.install.timestamp: MESON_BUILD:=$(MESON_BUILD) +$(MESON_OUT_DIR)/install/.install.timestamp: $(MESON_OUT_DIR)/.build.timestamp + rm -rf $(dir $@) + mkdir -p $(dir $@) + DESTDIR=$(AOSP_ABSOLUTE_PATH)/$(dir $@) $(MESON_BUILD) install + $(MESON_COPY_LIBGALLIUM) + touch $@ + +$($(M_TARGET_PREFIX)MESA3D_LIBGBM_BIN) $(MESA3D_GLES_BINS): $(MESON_OUT_DIR)/install/.install.timestamp + echo "Build $@"\ + +define vulkan_target +$(M_TARGET_PREFIX)MESA3D_VULKAN_$1_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libvulkan_$(MESA_VK_LIB_SUFFIX_$1).so +$(MESON_OUT_DIR)/install/usr/local/lib/libvulkan_$(MESA_VK_LIB_SUFFIX_$1).so: $(MESON_OUT_DIR)/install/.install.timestamp + echo $@ + +endef + +$(foreach driver,$(BOARD_MESA3D_VULKAN_DRIVERS), $(eval $(call vulkan_target,$(driver)))) + +$($(M_TARGET_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES)/dri/.symlinks.timestamp: MESA3D_GALLIUM_DRI_DIR:=$(MESA3D_GALLIUM_DRI_DIR) +$($(M_TARGET_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES)/dri/.symlinks.timestamp: $(MESON_OUT_DIR)/install/.install.timestamp + # Create Symlinks + mkdir -p $(dir $@) + ls -1 $(MESA3D_GALLIUM_DRI_DIR)/ | PATH=/usr/bin:$$PATH xargs -I{} ln -s -f libgallium_dri.so $(dir $@)/{} + touch $@ + +$($(M_TARGET_PREFIX)MESA3D_GALLIUM_DRI_BIN): $(TARGET_OUT_VENDOR)/$(MESA3D_LIB_DIR)/dri/.symlinks.timestamp + echo "Build $@" |