Skip to content

Commit

Permalink
meson: add new package
Browse files Browse the repository at this point in the history
This adds a host as well as a target package.

meson.mk is provided to build packages using meson.

Signed-off-by: Andre Heider <a.heider@gmail.com>
(cherry picked from commit d83cba7)
  • Loading branch information
dhewg authored and BKPepe committed Dec 10, 2019
1 parent fd5ef39 commit c61579b
Show file tree
Hide file tree
Showing 4 changed files with 220 additions and 0 deletions.
56 changes: 56 additions & 0 deletions devel/meson/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=meson
PKG_VERSION:=0.52.0
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/mesonbuild/meson/releases/download/$(PKG_VERSION)/
PKG_HASH:=d60f75f0dedcc4fd249dbc7519d6f3ce6df490033d276ef1cf27453ef4938d32

PKG_MAINTAINER:=Andre Heider <a.heider@gmail.com>
PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=COPYING

HOST_BUILD_DEPENDS:=ninja/host

include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/package.mk
include ../../lang/python/python3-package.mk

define Host/Configure
endef

define Host/Compile
endef

define Host/Install
$(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/lib/meson
$(CP) $(HOST_BUILD_DIR)/* $(STAGING_DIR_HOSTPKG)/lib/meson/
endef

define Host/Clean
$(call Host/Clean/Default)
rm -rf $(STAGING_DIR_HOSTPKG)/lib/meson
endef

define Package/meson
SECTION:=devel
CATEGORY:=Development
TITLE:=meson
URL:=https://mesonbuild.com/
DEPENDS:=+ninja +python3-pkg-resources
VARIANT:=python3
endef

define Package/meson/description
Meson is an open source build system meant to be both extremely fast, and, even more importantly, as user friendly as possible.
endef

define Package/meson/install
endef

$(eval $(call HostBuild))
$(eval $(call Py3Package,meson))
$(eval $(call BuildPackage,meson))
$(eval $(call BuildPackage,meson-src))
124 changes: 124 additions & 0 deletions devel/meson/meson.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# To build your package using meson:
#
# PKG_BUILD_DEPENDS:=meson/host
# include ../../devel/meson/meson.mk
# MESON_ARGS+=-Dfoo -Dbar=baz
#
# To pass additional environment variables to meson:
#
# MESON_VARS+=FOO=bar
#
# Default configure/compile/install targets are provided, but can be
# overwritten if required:
#
# define Build/Configure
# $(call Build/Configure/Meson)
# ...
# endef
#
# same for Build/Compile and Build/Install
#
# Host packages are built in the same fashion, just use these vars instead:
#
# HOST_BUILD_DEPENDS:=meson/host
# MESON_HOST_ARGS+=-Dfoo -Dbar=baz
# MESON_HOST_VARS+=FOO=bar

include $(dir $(lastword $(MAKEFILE_LIST)))/../../devel/ninja/ninja.mk

MESON_DIR:=$(STAGING_DIR_HOSTPKG)/lib/meson

MESON_HOST_BUILD_DIR:=$(HOST_BUILD_DIR)/openwrt-build
MESON_HOST_VARS:=
MESON_HOST_ARGS:=

MESON_BUILD_DIR:=$(PKG_BUILD_DIR)/openwrt-build
MESON_VARS:=
MESON_ARGS:=

define Meson
$(2) $(STAGING_DIR_HOST)/bin/$(PYTHON) $(MESON_DIR)/meson.py $(1)
endef

define Meson/CreateNativeFile
$(STAGING_DIR_HOST)/bin/sed \
-e "s|@CC@|$(HOSTCC)|" \
-e "s|@CXX@|$(HOSTCXX)|" \
-e "s|@PKGCONFIG@|$(PKG_CONFIG)|" \
-e "s|@CFLAGS@|$(foreach FLAG,$(HOST_CFLAGS) $(HOST_CPPFLAGS),'$(FLAG)',)|" \
-e "s|@CXXFLAGS@|$(foreach FLAG,$(HOST_CXXFLAGS) $(HOST_CPPFLAGS),'$(FLAG)',)|" \
-e "s|@LDFLAGS@|$(foreach FLAG,$(HOST_LDFLAGS),'$(FLAG)',)|" \
-e "s|@PREFIX@|$(STAGING_DIR_HOSTPKG)|" \
< $(MESON_DIR)/openwrt-native.txt.in \
> $(1)
endef

define Meson/CreateCrossFile
$(STAGING_DIR_HOST)/bin/sed \
-e "s|@CC@|$(TARGET_CC)|" \
-e "s|@CXX@|$(TARGET_CXX)|" \
-e "s|@AR@|$(TARGET_AR)|" \
-e "s|@STRIP@|$(TARGET_CROSS)strip|" \
-e "s|@NM@|$(TARGET_NM)|" \
-e "s|@LD@|$(TARGET_CROSS)ld|" \
-e "s|@PKGCONFIG@|$(PKG_CONFIG)|" \
-e "s|@CFLAGS@|$(foreach FLAG,$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS),'$(FLAG)',)|" \
-e "s|@CXXFLAGS@|$(foreach FLAG,$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS),'$(FLAG)',)|" \
-e "s|@LDFLAGS@|$(foreach FLAG,$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS),'$(FLAG)',)|" \
-e "s|@ARCH@|$(ARCH)|" \
-e "s|@CPU@|$(CONFIG_TARGET_SUBTARGET)|" \
-e "s|@ENDIAN@|$(if $(CONFIG_BIG_ENDIAN),big,little)|" \
< $(MESON_DIR)/openwrt-cross.txt.in \
> $(1)
endef

define Host/Configure/Meson
$(call Meson/CreateNativeFile,$(HOST_BUILD_DIR)/openwrt-native.txt)
$(call Meson, \
--native-file $(HOST_BUILD_DIR)/openwrt-native.txt \
$(MESON_HOST_ARGS) \
$(MESON_HOST_BUILD_DIR) \
$(HOST_BUILD_DIR), \
$(MESON_HOST_VARS))
endef

define Host/Compile/Meson
$(call Ninja,-C $(MESON_HOST_BUILD_DIR),)
endef

define Host/Install/Meson
$(call Ninja,-C $(MESON_HOST_BUILD_DIR) install,)
endef

define Host/Uninstall/Meson
-$(call Ninja,-C $(MESON_HOST_BUILD_DIR) uninstall,)
endef

define Build/Configure/Meson
$(call Meson/CreateNativeFile,$(PKG_BUILD_DIR)/openwrt-native.txt)
$(call Meson/CreateCrossFile,$(PKG_BUILD_DIR)/openwrt-cross.txt)
$(call Meson, \
--buildtype plain \
--native-file $(PKG_BUILD_DIR)/openwrt-native.txt \
--cross-file $(PKG_BUILD_DIR)/openwrt-cross.txt \
$(MESON_ARGS) \
$(MESON_BUILD_DIR) \
$(PKG_BUILD_DIR), \
$(MESON_VARS))
endef

define Build/Compile/Meson
$(call Ninja,-C $(MESON_BUILD_DIR),)
endef

define Build/Install/Meson
$(call Ninja,-C $(MESON_BUILD_DIR) install,DESTDIR="$(PKG_INSTALL_DIR)")
endef

Host/Configure=$(call Host/Configure/Meson)
Host/Compile=$(call Host/Compile/Meson)
Host/Install=$(call Host/Install/Meson)
Host/Uninstall=$(call Host/Uninstall/Meson)
Build/Configure=$(call Build/Configure/Meson)
Build/Compile=$(call Build/Compile/Meson)
Build/Install=$(call Build/Install/Meson)
25 changes: 25 additions & 0 deletions devel/meson/src/openwrt-cross.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[binaries]
c = '@CC@'
cpp = '@CXX@'
ar = '@AR@'
strip = '@STRIP@'
nm = '@NM@'
ld = '@LD@'
pkgconfig = '@PKGCONFIG@'

[properties]
c_args = [@CFLAGS@]
c_link_args = [@LDFLAGS@]
cpp_args = [@CXXFLAGS@]
cpp_link_args = [@LDFLAGS@]
needs_exe_wrapper = true

[host_machine]
system = 'linux'
cpu_family = '@ARCH@'
cpu = '@CPU@'
endian = '@ENDIAN@'

[paths]
prefix = '/usr'
libdir = 'lib'
15 changes: 15 additions & 0 deletions devel/meson/src/openwrt-native.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[binaries]
c = '@CC@'
cpp = '@CXX@'
pkgconfig = '@PKGCONFIG@'

[properties]
c_args = [@CFLAGS@]
c_link_args = [@LDFLAGS@]
cpp_args = [@CXXFLAGS@]
cpp_link_args = [@LDFLAGS@]

[paths]
prefix = '@PREFIX@'
sbindir = 'bin'
libdir = 'lib'

11 comments on commit c61579b

@manjuprajna
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhewg
WARNING: No feed for package 'python3-pkg-resources' found

@hnyman
Copy link
Contributor

@hnyman hnyman commented on c61579b Dec 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BKPepe

Please also backport the required other packages:

WARNING: Makefile 'package/feeds/packages/meson/Makefile' has a dependency on 'python3-pkg-resources', which does not exist

@mans0n
Copy link
Member

@mans0n mans0n commented on c61579b Dec 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cherry-picking ed0e77f seems to resolve this.

@hnyman
Copy link
Contributor

@hnyman hnyman commented on c61579b Jan 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@commodo @jefferyto @dhewg

A month ago @BKPepe backported meson to 19.07, but did not check the dependencies. Since then there has been config warning in 19.07 about meson depending on the non-existing package 'python3-pkg-resources'

There has been a suggestion that "Cherry-picking ed0e77f seems to resolve this."
(python,python3: split python[3]-pkg-resources from setuptools)

Any opinions? Safe to do that python cherry-pick?

@commodo
Copy link
Contributor

@commodo commodo commented on c61579b Jan 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, I made that change with the idea of being atomic and backwards compatible.
The idea was to try to keep setuptools to install everything as before, but have pkg-resources be selectable without setuptools.

Looking again at it, it looks like it is doing that [unless I am missing something; I am in weekend + post-vacation mode, so I may be a bit of an airhead now].

So, it should be safe to cherry-pick [from my side].

Thanks
Alex

@jefferyto
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with cherry picking the commit as well.

But looking at the Makefiles, I'm a little confused - why is Package/meson/install explicitly empty?

Having it defined should have caused this ifndef line in python3-package.mk to skip the default Python package install recipe, but the recipe is being called anyway (I downloaded the snapshot packages to check).

@jefferyto
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit off-topic: I would feel better if the meson package had an explicit dependency on Python (either python3 or python3-light) rather than relying on the implicit dependency from python3-pkg-resources.

@dhewg
Copy link
Contributor Author

@dhewg dhewg commented on c61579b Jan 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But looking at the Makefiles, I'm a little confused - why is Package/meson/install explicitly empty?

I don't recall the details, but there was some problem (I wouldn't have stubbed it out elsewise)...

A bit off-topic: I would feel better if the meson package had an explicit dependency on Python (either python3 or python3-light) rather than relying on the implicit dependency from python3-pkg-resources.

I chose python3-pkg-resources because that's exactly what meson requires. I wanted to install python3-light myself and always find it confusing if random packages force the full variant on me (which was the case when I wrote these patches). But I'm fine either way

@jefferyto
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've compiled meson for both armvirt-64 and malta-be (snapshot) with the empty Package/meson/install commented out and both completed without error.

If random packages install the full variant then (hopefully) it's because the maintainers have determined that the full variant is necessary. Part of our work as package maintainers is to be correct about dependencies.

I'm less concerned about meson (even though it may be considered as a "Python package") and more concerned about why code in python3-package.mk isn't working as it should.

@jefferyto
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, ifdef/ifndef doesn't test if the variable has been defined, it tests if the variable has a value 🤦‍♂️

So if you really wanted to bypass the default Python package install recipe and instead do nothing, you would need to do something like:

Package/meson/install:=:

@hnyman
Copy link
Contributor

@hnyman hnyman commented on c61579b Jan 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cherry-picked it as e847333 for 19.07
Hopefully it plays out ok.

Please sign in to comment.