Cannot override Build/Compile for Meson builds

Hi;

Attempting to add new package: mesa which uses Meson toolchain and requires host python package "mako" which requires overriding Build/Compile.

Work in progress Makefile:

#
# Copyright (C) 2006-2020 OpenWrt.org
# Copyright (C) 2020 Valuetech Ltd.
#
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.

include $(TOPDIR)/rules.mk

PKG_NAME:=mesa
PKG_VERSION:=20.1.4
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=https://mesa.freedesktop.org/archive/
PKG_HASH:=6800271c2be2a0447510eb4e9b67edd9521859a4d565310617c4b359eb6799fe

PKG_MAINTAINER:=Bill Ross <redacted>
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
PKG_CPE_ID:=cpe:/a:mesa_project:mesa

PKG_BUILD_DIR:=$(BUILD_DIR)/mesa-$(PKG_VERSION)
PKG_BUILD_DEPENDS:=meson/host

HOST_PYTHON3_PACKAGE_BUILD_DEPENDS:="mako>=0.8.0"

PKG_BUILD_PARALLEL:=0
PYTHON3_PKG_BUILD:=0

#include $(TOPDIR)/feeds/packages/lang/python/pypi.mk
include $(INCLUDE_DIR)/package.mk
include ../python3-package.mk
include $(TOPDIR)/feeds/packages/devel/meson/meson.mk

MESON_ARGS += -Ddri-drivers= \
	      -Dvulkan-drivers= \
	      -Dgallium-drivers='lima,panfrost,kmsro' \
	      -Dgallium-vdpau='false'

define Package/mesa/Default
  SECTION:=xorg
  CATEGORY:=Xorg
  SUBMENU:=drivers
  TITLE:=Mesa OpenGL library
  URL:=https://mesa.freedesktop.org
endef

define Package/mesa
  $(call Package/mesa/Default)
  #TITLE:=
  #DEPENDS:=+kmod-crypto-md5
endef

export CMAKE=$(STAGING_DIR_HOST)/bin/cmake

define Build/Compile
	shit >> intentionally cause error if called
	echo HostPython3/PipInstall: $(HostPython3/PipInstall)
	$(call HostPython3/PipInstall,$(HOST_PYTHON3_PACKAGE_BUILD_DEPENDS))
	$(call Build/Compile/Meson)
endef

define Package/mesa/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(MESON_BUILD_DIR)/arping $(1)/usr/bin/
endef

$(eval $(call BuildPackage,mesa))

The key point is that the Build/Compile definition is not called, as evidenced by the intentional error (shit) if it is. Regular Build/Compile/Meson appears to be called instead and fails due to missing python host mako module.

I know I am in uncharted territory here since Meson support is relatively new and, I have been unable to find a Meson based package which overrides Build/Compile.

@lucize

Suggestions?
Thanks;
Bill

I'll come back to you
As I remember I have it compiled, but it was a problem with meson and worked only with cmake, don't remember exactly

add the Makefile on own folders then link them into the package/feeds/packages

ah it depends on many more packages

=+libdrm +libxcb +libx11 +libxext +libxdamage +libxshmfence \
        +libvdpau +libxxf86vm +libxrandr

please see the full commit https://github.com/openwrt/packages/pull/8314 and update from there

I have something updated but didn't pass the startup test of xorg and is not commited, I'll update it when I find time

Thanks;

I will absorb this and get back to you.

What I am doing is splitting mesa and friends (and making dependencies) from my (jhbuild based) xorg Makefile since I am targeting aarch64 (S9xx based) TV boxes which use Mali-T820 GPU which requires a newer mesa than my host jhbuild toolchain is capable of.

Any further thoughts (especially mesa config options) appreciated.

Regards;
Bill

if you need llvm for those drivers I also updated the llvm, but give it a try, I abandoned this at xterm not starting, I also wanted to test xorg on rockchip (lima)
and the updated packages gave segfault on xorg, maybe meson or glib2 problems, but now both of them are updated and maybe it will work

Wow! cursory inspection - you are way ahead of me on this

will share final results...

...B

just reuse the already work that was done :slight_smile: hopefully you have more time at your hand, I'm a bit busy for this right now

I note that you bypassed my Build/Compile override issue by defining a hostpkg for mako.

FYI, if includes are reversed:

include $(TOPDIR)/feeds/packages/devel/meson/meson.mk
include $(INCLUDE_DIR)/package.mk

for build #1, the regular process installs host/mako and then dies horribly. Reverse includes back and meson/mesa compile proceeds to more errors (my makefile)

I will proceed from where you left off

..B

issue

ERROR: Problem encountered: Python (3.x) mako module >= 0.8.0 required to build mesa.