aboutsummaryrefslogtreecommitdiff
path: root/docs/markdown/snippets/env2cross.md
blob: bb53145ce013957721fdea1526261d9671bbf7a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
## Experimental command to convert environments to cross files

Meson has a new command `env2mfile` that can be used to convert
"environment variable based" cross and native compilation environments
to Meson machine files. This is especially convenient for e.g. distro
packagers so they can easily generate unambiguous configuration files
for packge building.

As an example here's how you would generate a cross file that takes
its settings from the `CC`, `CXX`, `CFLAGS` etc environment variables.

    meson env2mfile --cross --system=baremetal --cpu=armv7 --cpu-family=arm -o armcross.txt

The command also has support for generating Debian build files using
system introspection:

    meson env2mfile --cross --debarch armhf -o debarmhf_cross.txt

Note how you don't need to specify any system details, the command
gets them transparently via `dpkg-architecture`.

Creating a native file is done in the same way:

    meson env2mfile --native -o current_system.txt

This system will detect if the `_FOR_BUILD` environment variables are
enabled and then uses them as needed.

With this you should be able to convert any envvar-based cross build
setup to cross and native files and then use those. Thit means, among
other things, that you can then run your compilations from any shell,
not just the special one that has all the environment variables set.

As this functionality is still a bit in flux, the specific behaviour
and command line arguments to use are subject to change. Because of
this the main documentation has not yet been updated.

Please try this for your use cases and report to us if it is working.
Patches to make the autodetection work on other distros and platforms
are also welcome.