Commit graph

11 commits

Author SHA1 Message Date
Thomas Petazzoni 51bac54bbf package/pkg-meson: really generate the global cross-compilation.conf
Commit ccc9e05990 ("package/meson:
install cross-compilation.conf during toolchain install") moved the
logic to generate the global cross-compilation.conf from
package/meson/meson.mk to package/pkg-meson.mk. While doing so, it
renamed the macro from HOST_MESON_INSTALL_CROSS_CONF to
PKG_MESON_INSTALL_CROSS_CONF, but the registration of this hook in
TOOLCHAIN_POST_INSTALL_STAGING_HOOKS was not changed accordingly: it
is still registering HOST_MESON_INSTALL_CROSS_CONF.

Due to this, the global cross-compilation.conf file was no longer
generated.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Cc: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2019-11-08 21:41:39 +01:00
Arnout Vandecappelle (Essensium/Mind) 212adf32f3 toolchain/toolchain: set TOOLCHAIN_INSTALL_STAGING only once
Currently, we set TOOLCHAIN_INSTALL_STAGING three times: once
(conditionally) in toolchain.mk, and once each (unconditionally) in
pkg-cmake.mk and pkg-meson.mk.

This is a little bit messy... Set it just once, unconditionally, in
toolchain.mk where it belongs.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-10-27 14:56:52 +01:00
Thomas De Schampheleire ccc9e05990 package/meson: install cross-compilation.conf during toolchain install
package/meson installs a cross-compilation.conf file in
$(HOST_DIR)/etc/meson, via TARGET_FINALIZE_HOOKS.

package/pkg-cmake.mk installs a toolchainfile.cmake in
$(HOST_DIR)/share/buildroot, via TOOLCHAIN_POST_INSTALL_STAGING_HOOKS.

Both files have a similar concept, they describe some flags/paths needed for
compilation using respective build systems. One difference is that the meson
file is added for external compilation, from the SDK, while the cmake file
is used internally in Buildroot.

The 'problem' of using TARGET_FINALIZE_HOOKS for the meson file, is that it
installs a 'host' file from target-finalize, which is conceptually incorrect
since not just TARGET_DIR but also HOST_DIR is "regenerated" on a subsequent
'make' when everything was already built (i.e. only target-finalize is run).

This can easily be fixed, by using the same hook as cmake uses, i.e.
TOOLCHAIN_POST_INSTALL_STAGING_HOOKS.

Note that actually even for cmake, TOOLCHAIN_POST_INSTALL_STAGING_HOOKS is
not the best hook to install a host file. A better hook would have been
TOOLCHAIN_POST_INSTALL_HOOKS, but this triggers only for 'host' packages,
and 'toolchain' is treated as a 'target' package.

Also, the hook (and therefore also the definition of
PKG_MESON_INSTALL_CROSS_CONF) is moved to pkg-meson.mk, again to make it
more similar to how it's done for cmake. Otherwise check-package
complains that the meson package is setting variables that don't start
with MESON_.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
2019-10-27 14:34:25 +01:00
Yann E. MORIN 84470cba7e package/pkg-meson.mk: simplify sed-expression to add to [binaries]
There is no need to memorise the matched pattern; it's a left-over
from a previous attempt.

However, ensure the pattern is correctly anchored to the beginning and
end of the line, to avoid accidentally matching it anywhere else (e,g,
in a comment).

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Eric Le Bihan <eric.le.bihan.dev@free.fr>
Cc: Peter Seiderer <ps.report@gmx.net>
Cc: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-10-08 23:22:33 +02:00
Yann E. MORIN 3f6e5fb470 package/pkg-meson.mk: allow packages to add extra [binaries]
meson does not allow passing path to helper programs (e.g. pkgconfig)
using variables in the environment. Instead, it insists that those paths
be defined in the cross-compilation.conf file, in the [binaries]
section [0]

As such, allow packages to declare such a list of arbitrary entries to
add in the [binaries] section.

[0] https://github.com/mesonbuild/meson/issues/3327 for the LLVM_CONFIG
    example, which we'll address in a follow-up patch.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Eric Le Bihan <eric.le.bihan.dev@free.fr>
Cc: Peter Seiderer <ps.report@gmx.net>
Cc: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Reviewed-by: Romain Naour <romain.naour@gmail.com>
Tested-by: Romain Naour <romain.naour@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-10-05 22:15:39 +02:00
Peter Seiderer 74e574c8a6 infra/pkg-meson: allow packages to pass custom compiler/linker flags
Meson does not allow to pass CFLAGS/LDFLAGS/CXXFLAGS via the environment
or via command-line arguments or options (instead, those flags from the
environment are passed to the host compiler, which is seldom what we
need). The only way to pas those flags is via the cross-compilation.conf
file.

Add LIBFOO_CFLAGS, LIBFOO_LDFLAGS and LIBFOO_CXXFLAGS variables to allow
packages to provide their own flags, possibly overriding the generic
ones entirely, as we allow for other infras. Those per-package flags will
then be used to generate the per-package cross-compilation.conf.

This means that the meson infra is the first and only infra for which
FOO_CFLAGS, FOO_LDFLAGS, and FOO_CXXFLAGS are meaningful, while for the
other infras, they are just variables private to the package itself.
Instead of naming those variables after the meson infra (e.g.
FOO_MESON_CFLAGS), we name them with a generic name, as maybe, just
maybe, we could also change the other infras to also recognise those
variables.

Just like for the HOST_MESON_SED_CFLAGS etc., we need to add auxiliary
variables to do convert the shell-formatted argument list into the
JSON-formatted list that meson expects. We can't use a pure-make
construct because the CFLAGS can contain quoting that needs to be
expanded by the shell. Similarly, we need a condition on the strip'ed
variable to avoid passing empty arguments.

To mimic this feature for packages that are built from the SDK, we also
install a templatised version of cross-compilation.conf, with three new
placeholders for custom flags. If a user wants to build a package that
needs custom flags, they can use that template to generate a per-package
cross-compilation.conf.

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Adam Duskett <aduskett@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Peter Seiderer <ps.report@gmx.net>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
2019-07-01 09:51:16 +02:00
James Hilliard 3e4b82b996 package/pkg-meson: fix meson cpu_family format
meson requires a custom cpu_family format
https://mesonbuild.com/Reference-tables.html#cpu-families

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Reviewed-by: Peter Seiderer <ps.report@gmx.net>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-25 22:12:28 +01:00
Lionel Orry be0bb26f29 package/pkg-meson: <pkg>_SUBDIR cleanup
No functional change is brought by this modification.

This patch:
* removes a redundant <pkg>_SRCDIR declaration (already defined in
  pkg-generic.mk)
* documents the usage of <pkg>_SUBDIR in the meson-specific section of
  the manual.

Signed-off-by: Lionel Orry <lionel.orry@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-06 17:21:28 +01:00
Peter Seiderer 5d882b71a8 package/pkg-meson: support per-package directories
Currently, package/meson/meson.mk generates a single global
cross-compilation.conf file, with the path to the compiler, cflags,
ldflags, and various other details. This file is then used when
building all meson-based packages.

This causes two problems:

 - It is not compatible with per-package directories, because with
   per-package folders, we need to use a different compiler, and
   possibly CFLAGS/LDFLAGS for each package.

 - It is not possible to define per package CFLAGS. Indeed, when
   cross-compiling, meson doesn't support passing CFLAGS through the
   environment, only the CFLAGS from cross-compilation.conf are taken
   into account.

For this reason, this commit:

 - Introduces a per-package cross-compilation.conf, which is generated
   by the pkg-meson infrastructure in the "configure" step right
   before calling meson. The file is generated in $(@D)/build/, and
   because it is generated within a given package "configure" step,
   the compiler path is the one of this package.

 - Keeps the global cross-compilation.conf in $(HOST_DIR)/etc/meson/,
   for the SDK use-case of Buildroot. Since we want the final and
   global values of the compiler path, CFLAGS and LDFLAGS, generating
   this global cross-compilation.conf is moved to a
   TARGET_FINALIZE_HOOKS. If we were keeping this as a
   HOST_MESON_POST_INSTALL_HOOKS, it would contain values specific to
   the host-meson package.

For now, we don't yet support per-package CFLAGS/LDFLAGS, but having
such per-package cross-compilation.conf is a necessary preparation to
achieve this goal.

This commit has been tested by building all Buildroot packages that
use meson: json-glib, systemd, enlightenment, at-spi2-core, ncmpc,
libmpdclient and ncmpc.

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
[Thomas:
 - add extended commit log
 - in pkg-meson.mk, re-use variables defined in meson.mk to do the
   replacement of CFLAGS/LDFLAGS/CXXFLAGS
 - move the generation of the global cross-compilation.conf to a
   TARGET_FINALIZE_HOOKS
 - testing with per-package folders]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Peter Seiderer <ps.report@gmx.net>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2019-01-17 22:52:41 +01:00
Yann E. MORIN efb774bbda package/pkg-meson: allow meson packages to specify custom build rules
Some packages may want to build only specific targets, instead of the
default.

So, allow them to provide FOO_NINJA_OPTS (not really options, but we
just mimicked the naming we already have for autotools packages).

Update the manual accordingly.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Eric Le Bihan <eric.le.bihan.dev@free.fr>
Cc: James Hilliard <james.hilliard1@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2018-12-28 11:54:04 +01:00
Eric Le Bihan 91f7f38106 pkg-meson: new infrastructure
Add a new infrastructure to ease the development of packages that use Meson as
their build system.

Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
[Thomas:
 - move global variables definition outside of the inner-meson-package
   macro
 - for consistency, remove double quote around value passed to meson
   in the host configure step.
 - minor formatting fixes.]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2018-05-30 21:58:08 +02:00