Skip to contentSkip to conversation

Ninja, Meson: new build systems

PATCH New Eric Le Bihan 5 participants 10 messages Jun 24, 2016 – Mar 26, 2018 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v3 cover Ninja, Meson: new build systems

This small patch series provides two new build systems: Ninja and Meson.

v2 -> v3:

- bump meson to 0.3.2
- fix cross-compilation configuration template
- fix dependency on host-ninja

v1 -> v2:

- only provide host variants of ninja and python-meson.
- document integration of meson-based packages.
- drop removal of mesongui.py.

Eric Le Bihan (3):
ninja: new package
python-meson: new package
docs/manual: document meson-based packages

 docs/manual/adding-packages-meson.txt          | 84 ++++++++++++++++++++++++++
 docs/manual/adding-packages.txt                |  2 +
 package/ninja/ninja.hash                       |  2 +
 package/ninja/ninja.mk                         | 22 +++++++
 package/python-meson/cross-compilation.conf.in | 20 ++++++
 package/python-meson/meson-exe-wrapper.in      |  3 +
 package/python-meson/python-meson.hash         |  2 +
 package/python-meson/python-meson.mk           | 41 +++++++++++++
 8 files changed, 176 insertions(+)
 create mode 100644 docs/manual/adding-packages-meson.txt
 create mode 100644 package/ninja/ninja.hash
 create mode 100644 package/ninja/ninja.mk
 create mode 100644 package/python-meson/cross-compilation.conf.in
 create mode 100755 package/python-meson/meson-exe-wrapper.in
 create mode 100644 package/python-meson/python-meson.hash
 create mode 100644 package/python-meson/python-meson.mk

--
2.4.11

#1 lore raw

PATCH v3 1/3 ninja: new package

This new package provides the host variant of Ninja, a small build system with a focus on speed.

---
 package/ninja/ninja.hash |  2 ++
 package/ninja/ninja.mk   | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 package/ninja/ninja.hash
 create mode 100644 package/ninja/ninja.mk
package/ninja/ninja.hash new file +2 -0
new file mode 100644
index 0000000..47ec822
@@ -0,0 +1,2 @@
+# Locally generated
+sha256 51581de53cf4705b89eb6b14a85baa73288ad08bff256e7d30d529155813be19  ninja-v1.7.1.tar.gz
package/ninja/ninja.mk new file +22 -0
new file mode 100644
index 0000000..f8cada4
@@ -0,0 +1,22 @@
+################################################################################
+#
+# ninja
+#
+################################################################################
+
+NINJA_VERSION = v1.7.1
+NINJA_SITE = $(call github,ninja-build,ninja,$(NINJA_VERSION))
+NINJA_LICENSE = Apache-2.0
+NINJA_LICENSE_FILES = COPYING
+
+HOST_NINJA_DEPENDENCIES = $(if $(BR2_PACKAGE_PYTHON3),host-python3,host-python)
+
+define HOST_NINJA_BUILD_CMDS
+	(cd $(@D); ./configure.py --bootstrap)
+endef
+
+define HOST_NINJA_INSTALL_CMDS
+	$(INSTALL) -m 0755 $(@D)/ninja $(HOST_DIR)/usr/bin/ninja
+endef
+
+$(eval $(host-generic-package))
Signature · 1 line
2.4.11
#2 lore raw

PATCH v3 1/3 ninja: new package

?ric, All,

On 2016-06-24 21:22 +0200, Eric Le Bihan spake thusly:

Quoted 4 lines

This new package provides the host variant of Ninja, a small build system with a focus on speed.

Regards,
Yann E. MORIN.

Quoted 50 lines
---
 package/ninja/ninja.hash |  2 ++
 package/ninja/ninja.mk   | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 package/ninja/ninja.hash
 create mode 100644 package/ninja/ninja.mk
package/ninja/ninja.hash new file +2 -0
new file mode 100644
index 0000000..47ec822
@@ -0,0 +1,2 @@
+# Locally generated
+sha256 51581de53cf4705b89eb6b14a85baa73288ad08bff256e7d30d529155813be19  ninja-v1.7.1.tar.gz
package/ninja/ninja.mk new file +22 -0
new file mode 100644
index 0000000..f8cada4
@@ -0,0 +1,22 @@
+################################################################################
+#
+# ninja
+#
+################################################################################
+
+NINJA_VERSION = v1.7.1
+NINJA_SITE = $(call github,ninja-build,ninja,$(NINJA_VERSION))
+NINJA_LICENSE = Apache-2.0
+NINJA_LICENSE_FILES = COPYING
+
+HOST_NINJA_DEPENDENCIES = $(if $(BR2_PACKAGE_PYTHON3),host-python3,host-python)
+
+define HOST_NINJA_BUILD_CMDS
+	(cd $(@D); ./configure.py --bootstrap)
+endef
+
+define HOST_NINJA_INSTALL_CMDS
+	$(INSTALL) -m 0755 $(@D)/ninja $(HOST_DIR)/usr/bin/ninja
+endef
+
+$(eval $(host-generic-package))
Signature · 6 lines
2.4.11

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH v3 1/3 ninja: new package

In reply to Eric Le Bihan
Quoted 36 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Eric" == Eric Le Bihan <[email protected]> writes:

This new package provides the host variant of Ninja, a small build system with a focus on speed.

---
 package/ninja/ninja.hash |  2 ++
 package/ninja/ninja.mk   | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 package/ninja/ninja.hash
 create mode 100644 package/ninja/ninja.mk
package/ninja/ninja.hash new file +2 -0
new file mode 100644
index 0000000..47ec822
@@ -0,0 +1,2 @@
+# Locally generated
+sha256 51581de53cf4705b89eb6b14a85baa73288ad08bff256e7d30d529155813be19  ninja-v1.7.1.tar.gz
package/ninja/ninja.mk new file +9 -0
new file mode 100644
index 0000000..f8cada4
@@ -0,0 +1,22 @@
+################################################################################
+#
+# ninja
+#
+################################################################################
+
+NINJA_VERSION = v1.7.1
+NINJA_SITE = $(call github,ninja-build,ninja,$(NINJA_VERSION))
+NINJA_LICENSE = Apache-2.0

package/ninja/ninja.mk line 19

Quoted 10 lines
package/ninja/ninja.mk new file +10 -0
+NINJA_LICENSE_FILES = COPYING
+
+HOST_NINJA_DEPENDENCIES = $(if $(BR2_PACKAGE_PYTHON3),host-python3,host-python)
+
+define HOST_NINJA_BUILD_CMDS
+	(cd $(@D); ./configure.py --bootstrap)
+endef
+
+define HOST_NINJA_INSTALL_CMDS
+	$(INSTALL) -m 0755 $(@D)/ninja $(HOST_DIR)/usr/bin/ninja

When the destination filename is passes then the -D option should be used with install.

Committed with that fixed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw

PATCH v3 1/3 ninja: new package

In reply to Eric Le Bihan

Hello Eric,

package/ninja/ninja.mk line 12

Quoted 6 lines · Eric Le Bihan
package/ninja/ninja.mk new file +6 -0
+NINJA_VERSION = v1.7.1
+NINJA_SITE = $(call github,ninja-build,ninja,$(NINJA_VERSION))
+NINJA_LICENSE = Apache-2.0
+NINJA_LICENSE_FILES = COPYING
+
+HOST_NINJA_DEPENDENCIES = $(if $(BR2_PACKAGE_PYTHON3),host-python3,host-python)

Sorry for reviving such an old thread, but do you remember why you need host-python3 or host-python ?

Indeed, this indicates that ninja supports both Python 2.x and Python 3.x, and Buildroot already guarantees that either Python 2.x or Python 3.x is available on the system, without the need to build host-python or host-python3.

Therefore, why do we have this dependency ?

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

PATCH v3 2/3 python-meson: new package

In reply to Eric Le Bihan

This new package provides the host variant of the Meson Build System, an open source build system meant to be both extremely fast, and as user friendly as possible.

More precisely, Meson creates configuration files for the Ninja build system.

Besides building Meson, it generates a cross-compilation configuration file ("$(HOST_DIR)/etc/meson/cross-compilation.conf") as well as a wrapper for QEMU ("$(HOST_DIR)/usr/bin/meson-exe-wrapper"), used to perform checks when cross-compiling (hence the dependency on host-qemu).

---
 package/python-meson/cross-compilation.conf.in | 20 +++++++++++++
 package/python-meson/meson-exe-wrapper.in      |  3 ++
 package/python-meson/python-meson.hash         |  2 ++
 package/python-meson/python-meson.mk           | 41 ++++++++++++++++++++++++++
 4 files changed, 66 insertions(+)
 create mode 100644 package/python-meson/cross-compilation.conf.in
 create mode 100755 package/python-meson/meson-exe-wrapper.in
 create mode 100644 package/python-meson/python-meson.hash
 create mode 100644 package/python-meson/python-meson.mk
package/python-meson/cross-compilation.conf.in new file +20 -0
new file mode 100644
index 0000000..fc9f1dd
@@ -0,0 +1,20 @@
+# Generated file - do not edit
+#
+# Note that, in Meson terminology, what Buildroot calls the "host" system is the
+# "build" system and the "target" system is called the "host" system.
+
+[host_machine]
+system = 'linux'
+cpu_family ='@TARGET_ARCH@'
+cpu = 'generic'
+endian = '@TARGET_ENDIAN@'
+
+[properties]
+
+[binaries]
+c = '@TARGET_CROSS at gcc'
+cpp = '@TARGET_CROSS at g++'
+ar = '@TARGET_CROSS at ar'
+strip = '@TARGET_CROSS at strip'
+exe_wrapper = '@HOST_DIR@/usr/bin/meson-exe-wrapper'
+pkgconfig = '@HOST_DIR@/usr/bin/pkg-config'
package/python-meson/meson-exe-wrapper.in new file +3 -0
new file mode 100755
index 0000000..5e4415c
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+ at HOST_DIR@/usr/bin/qemu- at TARGET_ARCH@ -L @TARGET_DIR@ "$@"
package/python-meson/python-meson.hash new file +2 -0
new file mode 100644
index 0000000..7540c45
@@ -0,0 +1,2 @@
+# Locally generated
+sha256 372c18e40ffc3fe101f4ab48e8077f048dd774eaf4e87bbea3221908fca74835 python-meson-0.32.0.tar.gz
package/python-meson/python-meson.mk new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.4.11
#6 lore raw

PATCH v3 2/3 python-meson: new package

Hi Eric,

package/python-meson/cross-compilation.conf.in line 1

Quoted 7 lines · Eric Le Bihan
package/python-meson/cross-compilation.conf.in new file +1 -0
new file mode 100644
index 0000000..fc9f1dd
@@ -0,0 +1,20 @@
+# Generated file - do not edit

This is not correct for this file. This is the source file that you sed to generate the generated one. Though I understand it's convenient to have this comment in the source file, it is also misleading.

Also, as there are many other generated files under $(HOST_DIR), I'm not sure this comment is helpful.

baruch

Quoted 19 lines
package/python-meson/cross-compilation.conf.in new file +19 -0
+#
+# Note that, in Meson terminology, what Buildroot calls the "host" system is the
+# "build" system and the "target" system is called the "host" system.
+
+[host_machine]
+system = 'linux'
+cpu_family ='@TARGET_ARCH@'
+cpu = 'generic'
+endian = '@TARGET_ENDIAN@'
+
+[properties]
+
+[binaries]
+c = '@TARGET_CROSS at gcc'
+cpp = '@TARGET_CROSS at g++'
+ar = '@TARGET_CROSS at ar'
+strip = '@TARGET_CROSS at strip'
+exe_wrapper = '@HOST_DIR@/usr/bin/meson-exe-wrapper'
+pkgconfig = '@HOST_DIR@/usr/bin/pkg-config'
Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
#7 lore raw

PATCH v3 2/3 python-meson: new package

In reply to Eric Le Bihan

?ric, All,

On 2016-06-24 21:22 +0200, Eric Le Bihan spake thusly:

Quoted 3 lines

This new package provides the host variant of the Meson Build System, an open source build system meant to be both extremely fast, and as user friendly as possible.

This should be named "meson", not "python-meson".

Quoted 7 lines

More precisely, Meson creates configuration files for the Ninja build system.

Besides building Meson, it generates a cross-compilation configuration file ("$(HOST_DIR)/etc/meson/cross-compilation.conf") as well as a wrapper for QEMU ("$(HOST_DIR)/usr/bin/meson-exe-wrapper"), used to perform checks when cross-compiling (hence the dependency on host-qemu).

We've (briefly) discussed this patch during the summer camp, and we all believe that this dependency on host-qemu is really ugly.

We're not very much interested in having this in Buildroot in the state it is in this patch. Especially since (as far as I could see) you do not provide a package that uses meson (do you plan on sending one?).

However, after looking a bit at the Meson documentation, especially about cross-compilation, it appears that we can avoid having to ru nsuch "target" tests.

For example (from the Meson doc itself):

sizeof_int = 4
sizeof_wchar_t = 4
sizeof_void* = 4

alignment_char = 1
alignment_void* = 4
alignment_double = 4

has_function_printf = true

c_args = ['-DCROSS=1', '-DSOMETHING=3']
c_link_args = ['-some_link_arg']

Also, if you look (in the meson sources) at cross/ubuntu-armhf.txt:

[binaries]
# we could set exe_wrapper = qemu-arm-static but to test the case # when cross compiled binaries can't be run we don't do that c = '/usr/bin/arm-linux-gnueabihf-gcc'
cpp = '/usr/bin/arm-linux-gnueabihf-g++'
ar = '/usr/arm-linux-gnueabihf/bin/ar'
strip = '/usr/arm-linux-gnueabihf/bin/strip'
pkgconfig = '/usr/bin/arm-linux-gnueabihf-pkg-config'

[properties]
root = '/usr/arm-linux-gnueabihf'

has_function_printf = true
has_function_hfkerhisadf = false

[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'armv7' # Not sure if correct.
endian = 'little'

So, if we can feed it all the required config options, we can probably avoid running qemu.

The basic idea is that we start with a simple such config file, which we preseed with the obvious things. Then, as we add more packages, we can complement that file step by step.

We'd basically have a few start-point files:
- per architecture
- per C library
- optionally, a meson-basd package would generate its own blob

Those files would be concatenated to form the cross-compilation.conf.

Or so this is the overall idea.

Do you think this is an possible solution? Would mind looking into it?

Regards,
Yann E. MORIN.

Quoted 109 lines
---
 package/python-meson/cross-compilation.conf.in | 20 +++++++++++++
 package/python-meson/meson-exe-wrapper.in      |  3 ++
 package/python-meson/python-meson.hash         |  2 ++
 package/python-meson/python-meson.mk           | 41 ++++++++++++++++++++++++++
 4 files changed, 66 insertions(+)
 create mode 100644 package/python-meson/cross-compilation.conf.in
 create mode 100755 package/python-meson/meson-exe-wrapper.in
 create mode 100644 package/python-meson/python-meson.hash
 create mode 100644 package/python-meson/python-meson.mk
package/python-meson/cross-compilation.conf.in new file +20 -0
new file mode 100644
index 0000000..fc9f1dd
@@ -0,0 +1,20 @@
+# Generated file - do not edit
+#
+# Note that, in Meson terminology, what Buildroot calls the "host" system is the
+# "build" system and the "target" system is called the "host" system.
+
+[host_machine]
+system = 'linux'
+cpu_family ='@TARGET_ARCH@'
+cpu = 'generic'
+endian = '@TARGET_ENDIAN@'
+
+[properties]
+
+[binaries]
+c = '@TARGET_CROSS at gcc'
+cpp = '@TARGET_CROSS at g++'
+ar = '@TARGET_CROSS at ar'
+strip = '@TARGET_CROSS at strip'
+exe_wrapper = '@HOST_DIR@/usr/bin/meson-exe-wrapper'
+pkgconfig = '@HOST_DIR@/usr/bin/pkg-config'
package/python-meson/meson-exe-wrapper.in new file +3 -0
new file mode 100755
index 0000000..5e4415c
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+ at HOST_DIR@/usr/bin/qemu- at TARGET_ARCH@ -L @TARGET_DIR@ "$@"
package/python-meson/python-meson.hash new file +2 -0
new file mode 100644
index 0000000..7540c45
@@ -0,0 +1,2 @@
+# Locally generated
+sha256 372c18e40ffc3fe101f4ab48e8077f048dd774eaf4e87bbea3221908fca74835 python-meson-0.32.0.tar.gz
package/python-meson/python-meson.mk new file +41 -0
new file mode 100644
index 0000000..97a42e6
@@ -0,0 +1,41 @@
+################################################################################
+#
+# python-meson
+#
+################################################################################
+
+PYTHON_MESON_VERSION = 0.32.0
+PYTHON_MESON_SITE = $(call github,mesonbuild,meson,$(PYTHON_MESON_VERSION))
+PYTHON_MESON_LICENSE = Apache-2.0
+PYTHON_MESON_LICENSE_FILES = COPYING
+PYTHON_MESON_SETUP_TYPE = setuptools
+
+HOST_PYTHON_MESON_DEPENDENCIES = host-qemu host-ninja
+HOST_PYTHON_MESON_NEEDS_HOST_PYTHON = python3
+
+HOST_PYTHON_MESON_TARGET_ENDIAN = $(shell echo $(BR2_ENDIAN) | tr 'A-Z' 'a-z')
+
+define HOST_PYTHON_MESON_INSTALL_CROSS_CONF
+	$(INSTALL) -D -m 0644 package/python-meson/cross-compilation.conf.in \
+		$(HOST_DIR)/etc/meson/cross-compilation.conf
+	$(SED) 's;@TARGET_CROSS@;$(TARGET_CROSS);g' \
+		-e 's;@TARGET_ARCH@;$(ARCH);g' \
+		-e 's;@TARGET_ENDIAN@;$(HOST_PYTHON_MESON_TARGET_ENDIAN);g' \
+		-e 's;@HOST_DIR@;$(HOST_DIR);g' \
+		$(HOST_DIR)/etc/meson/cross-compilation.conf
+endef
+
+define HOST_PYTHON_MESON_INSTALL_EXE_WRAPPER
+	$(INSTALL) -D -m 0755 package/python-meson/meson-exe-wrapper.in \
+		$(HOST_DIR)/usr/bin/meson-exe-wrapper
+	$(SED) 's;@TARGET_ARCH@;$(ARCH);g' \
+		-e 's;@HOST_DIR@;$(HOST_DIR);g' \
+		-e 's;@TARGET_DIR@;$(TARGET_DIR);g' \
+		$(HOST_DIR)/usr/bin/meson-exe-wrapper
+endef
+
+HOST_PYTHON_MESON_POST_INSTALL_HOOKS += \
+	HOST_PYTHON_MESON_INSTALL_CROSS_CONF \
+	HOST_PYTHON_MESON_INSTALL_EXE_WRAPPER
+
+$(eval $(host-python-package))
Signature · 6 lines
2.4.11

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#8 lore raw

PATCH v3 2/3 python-meson: new package

Hi all!

Le Sun, 3 Jul 2016 22:24:21 +0200,
"Yann E. MORIN" <[email protected]> a ?crit :

Quoted 6 lines

On 2016-06-24 21:22 +0200, Eric Le Bihan spake thusly:

Quoted 3 lines

This new package provides the host variant of the Meson Build System, an open source build system meant to be both extremely fast, and as user friendly as possible.

This should be named "meson", not "python-meson".

OK.

Quoted 71 lines
Quoted 8 lines

More precisely, Meson creates configuration files for the Ninja build system.

Besides building Meson, it generates a cross-compilation configuration file ("$(HOST_DIR)/etc/meson/cross-compilation.conf") as well as a wrapper for QEMU ("$(HOST_DIR)/usr/bin/meson-exe-wrapper"), used to perform checks when cross-compiling (hence the dependency on host-qemu).

We've (briefly) discussed this patch during the summer camp, and we all believe that this dependency on host-qemu is really ugly.

We're not very much interested in having this in Buildroot in the state it is in this patch. Especially since (as far as I could see) you do not provide a package that uses meson (do you plan on sending one?).

However, after looking a bit at the Meson documentation, especially about cross-compilation, it appears that we can avoid having to ru nsuch "target" tests.

For example (from the Meson doc itself):

sizeof_int = 4
sizeof_wchar_t = 4
sizeof_void* = 4

alignment_char = 1
alignment_void* = 4
alignment_double = 4

has_function_printf = true

c_args = ['-DCROSS=1', '-DSOMETHING=3']
c_link_args = ['-some_link_arg']

Also, if you look (in the meson sources) at cross/ubuntu-armhf.txt:

[binaries]
# we could set exe_wrapper = qemu-arm-static but to test the case # when cross compiled binaries can't be run we don't do that c = '/usr/bin/arm-linux-gnueabihf-gcc'
cpp = '/usr/bin/arm-linux-gnueabihf-g++'
ar = '/usr/arm-linux-gnueabihf/bin/ar'
strip = '/usr/arm-linux-gnueabihf/bin/strip'
pkgconfig = '/usr/bin/arm-linux-gnueabihf-pkg-config'

[properties]
root = '/usr/arm-linux-gnueabihf'

has_function_printf = true
has_function_hfkerhisadf = false

[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'armv7' # Not sure if correct.
endian = 'little'

So, if we can feed it all the required config options, we can probably avoid running qemu.

The basic idea is that we start with a simple such config file, which we preseed with the obvious things. Then, as we add more packages, we can complement that file step by step.

We'd basically have a few start-point files:
- per architecture
- per C library
- optionally, a meson-basd package would generate its own blob

Quoted 5 lines

Those files would be concatenated to form the cross-compilation.conf.

Or so this is the overall idea.

Do you think this is an possible solution? Would mind looking into it?

Indeed, for the basic cases, defining an "exe_wrapper" which uses host-qemu is not mandatory. I'll post a new series for a new package named "meson", where the dependency has been removed and the cross-compilation configuration file simplified. This should be sufficient for the users wanting to add a package which uses pkg-config for dependency management and does not require exotic platform checks.

ATM, there are not many new projects using Meson, so I will not provided packages using it. But some projects, like Gstreamer [1] are being ported from autotools to Meson.

[1] http://blog.nirbheek.in/2016/05/gstreamer-and-meson-new-hope.html

Regards,

Signature · 1 line
ELB
#9 lore raw

PATCH v3 3/3 docs/manual: document meson-based packages

In reply to Eric Le Bihan

Add instructions for adding a package which uses the Meson build system.

---
 docs/manual/adding-packages-meson.txt | 84 +++++++++++++++++++++++++++++++++++
 docs/manual/adding-packages.txt       |  2 +
 2 files changed, 86 insertions(+)
 create mode 100644 docs/manual/adding-packages-meson.txt
docs/manual/adding-packages-meson.txt new file +84 -0
new file mode 100644
index 0000000..b8202ed
@@ -0,0 +1,84 @@
+// -*- mode:doc; -*-
+// vim: set syntax=asciidoc:
+
+=== Integration of Meson-based packages
+
+[[meson-package-tutorial]]
+
+==== +meson-package+ tutorial
+
+http://mesonbuild.com[Meson] is an open source build system meant to be both
+extremely fast, and, even more importantly, as user friendly as possible.
+
+Buildroot does not (yet) provide a dedicated package infrastructure for
+meson-based packages. So, we will explain how to write a +.mk+ file for such a
+package. Let's start with an example:
+
+------------------------------
+01: ################################################################################
+02: #
+03: # foo
+04: #
+05: ################################################################################
+06:
+07: FOO_VERSION = 1.0
+08: FOO_SOURCE = foo-$(FOO_VERSION).tar.gz
+09: FOO_SITE = http://www.foosoftware.org/download
+10: FOO_LICENSE = GPLv3+
+11: FOO_LICENSE_FILES = COPYING
+12:
+13: FOO_DEPENDENCIES = host-python-meson host-pkgconf bar
+14:
+15: ifeq ($(BR2_ENABLE_DEBUG),y)
+16: FOO_MESON_MODE = debug
+17: else
+18: FOO_MESON_MODE = release
+19: endif
+20:
+21: FOO_MESON_OPTS += \
+22: 	--prefix=/usr \
+23: 	--buildtype $(FOO_MESON_MODE) \
+24: 	--cross-file $(HOST_DIR)/etc/meson/cross-compilation.conf
+25:
+26: define FOO_CONFIGURE_CMDS
+27: 	rm -rf $(@D)/build
+28: 	mkdir -p $(@D)/build
+29: 	$(TARGET_MAKE_ENV) meson.py $(FOO_MESON_OPTS) $(@D) $(@D)/build
+30: endef
+31:
+32: define FOO_BUILD_CMDS
+33: 	$(TARGET_MAKE_ENV) ninja -C $(@D)/build
+34: endef
+35:
+36: define FOO_INSTALL_TARGET_CMDS
+37: 	$(TARGET_MAKE_ENV) DESTDIR=$(TARGET_DIR) ninja -C $(@D)/build install
+38: endef
+39:
+40: $(eval $(generic-package))
+--------------------------------
+
+The Makefile starts with the definition of the standard variables for package
+declaration (lines 7 to 11).
+
+As seen in line 40, it is based on the
+xref:generic-package-tutorial[+generic-package+ infrastructure]. So, it defines
+the variables required by this particular infrastructure, where Meson and its
+companion tool, Ninja, are invoked:
+
+* +FOO_CONFIGURE_CMDS+: the build directory required by Meson is created, and
+  Meson is invoked to generate the Ninja build file. The options required to
+  configure the cross-compilation of the package are passed via +FOO_MESON_OPTS+.
+
+* +FOO_BUILD_CMDS+: Ninja is invoked to perform the build.
+
+* +FOO_INSTALL_TARGET_CMDS+: Ninja is invoked to install the files generated
+  during the build step.
+
+In order to have Meson available for the build, +FOO_DEPENDENCIES+ needs to
+contain +host-python-meson+. In the example, +host-pkgconf+ and +bar+ are also
+declared as dependencies because the Meson build file of +foo+ uses `pkg-config`
+to determine the compilation flags and libraries of package +bar+.
+
+To sum it up, to add a new meson-based package, the Makefile example can be
+copied verbatim then edited to replace all occurences of +FOO+ with the uppercase
+name of the new package and update the values of the standard variables.
docs/manual/adding-packages.txt +2 -0
index 76f90c9..8b80a63 100644
@@ -29,6 +29,8 @@ include::adding-packages-kconfig.txt[]
 
 include::adding-packages-rebar.txt[]
 
+include::adding-packages-meson.txt[]
+
 include::adding-packages-kernel-module.txt[]
 
 include::adding-packages-asciidoc.txt[]
Signature · 1 line
2.4.11