Skip to content

Building with meson and ninja

Jonathan Hudson edited this page Oct 19, 2021 · 24 revisions

Overview

The mwptools suite is built using the meson and ninja toolchain. For most users these will be automatically provided by a build-essentials type of package transparently to the user.

Prior to late May 2021, the build system used a convoluted Makefile.

Rationale

In it's early days, make was a suitable build tool. As mwptools has gained in features and functionality, this has become un-maintainable. The migration to meson and ninja solves this problem and allows the project structure to be rationalised.

Usage

Migration

Please ensure your extant mwptools instance does not have untracked files:

git clean -fd -fx
git pull

First time

Set up the meson build system from the top level:

meson build --buildtype=release --strip [--prefix /usr]
  • For a Linux system wide install, set --prefix /usr
  • For FreeBSD (*BSD), don't set --prefix as the default (/usr/local) is suitable
  • For a user / non-system install, set --prefix $HOME/.local
    • This will install the binaries in $HOME/.local/bin, which should be added to $PATH as required.

Unless you need a multi-user setup, a local install is preferable, as you don't need sudo to install, and you'll not risk messing up build permissions.

  • If you're using a really old OS (e.g. Debian 10), you may also need export XDG_DATA_DIRS=/usr/share:$HOME/.local/share for a local install.

Build and update

cd build
# for a local install (and cygwin)
ninja install
# for system install
ninja && sudo ninja install

Legacy

For now, some of the legacy Makefiles remain, and can be used similar to before, e.g. :

cd mwptools/src/mwp
make && sudo make install

At some stage, more of the Makefiles will be removed.

Files built / installed

Default

Application Usage
bbsummary [1] Blackbox log summary
cliterm Interact with the CLI
fc-get, fc-set [2] Backup / restore CLI diff
mwp Mission planner, GCS, log relay etc.
mwp-area-planner Survey planner
mwp-plot-elevations [3] Mission elevation / terrain analysis
otxlog Replay OpenTX logs [1]
qproxy Proxy for certain commercial TMS
replay_bbox_ltm.rb [1] Legacy blackbox replay tool
inav_states.rb Summarise BBL state changes, also installed inav_states_data.rb
fcflash FC flashing tool, requires dfu-util and / or stmflash32

Notes:

  1. Modern, more functional tools provided by fl2x will be preferred if found
  2. fc-set is a hard link to fc-get
  3. This may either be the new Go executable or the legacy, less functional Ruby script.

Optional

These are only built by explicit target name; they will be installed if built.

# one of more of the following targets
ninja bproxy ublox-geo ublox-cli flashdl
sudo ninja install
Application Usage
flashdl Download, optionally delete BBL from flash
bproxy Black tile map proxy, for those anonymous needs
ublox-cli Ublox GPS tool
ublox-geo Graphical Ublox GPS tool

Supporting data files

File Target Usage
src/common/mwp_icon.svg $prefix/share/icons/hicolor/scalable/apps/ Desktop icon
src/mwp/org.mwptools.planner.gschema.xml $prefix/share/glib-2.0/schemas/ Settings schema
src/mwp/vcols.css $prefix/share/mwp/ Colours used by battery widget
src/mwp/default.layout $prefix/share/mwp/ Default dock layout
src/mwp/beep-sound.ogg $prefix/share/mwp/ Alert sound
src/mwp/bleet.ogg $prefix/share/mwp/ Alert sound
src/mwp/menubar.ui $prefix/share/mwp/ Menu definition
src/mwp/mwp.ui $prefix/share/mwp/ UI definition
src/mwp/orange.ogg $prefix/share/mwp/ Alert sound
src/mwp/sat_alert.ogg $prefix/share/mwp/ Alert sound
src/mwp/mwp.desktop $prefix/share/applications/ Desktop launcher
src/mwp/mwp_complete.sh $prefix/share/bash-completion/completions/ bash completion for mwp
src/mwp/pixmaps $prefix/share/mwp/pixmaps/ UI Icons
src/mwp/blackbox_decode_complete.sh $prefix/share/bash-completion/completions/ bash completion for blackbox-decode
src/samples/area-tool/mwp_area_icon.svg $prefix/share/icons/hicolor/scalable/apps/ Desktop icon
src/samples/area-tool/mwp-area-planner.desktop $prefix/share/applications/ Desktop launcher
docs/mwptools.pdf $prefix/share/doc/mwp/ (Obsolete) manual
docs/debian-ubuntu-dependencies.txt $prefix/share/doc/mwp/ Debian / Ubuntu dependencies
docs/fedora.txt $prefix/share/doc/mwp/ Fedora dependencies

Troubleshooting and Hints

Migrate from a system install to a user install

cd build
sudo ninja uninstall
meson --reconfigure --prefix=$HOME/.local
ninja install

Fixing build permissions

If you install to system locations, it is possible that sudo ninja install will write as root to some of the install files, and they become non-writable to the normal user.

  • In the build directory, run sudo chown -R $USER .
  • Consider migrating to a local install

Easy first-time install on Debian and Ubuntu

  • Download the first time build script
  • Make it executable chmod +x deb-install.sh
  • Run it ./deb-install.sh Y
  • Note that the script may ask for a password to install system packages
  • The resulting executables are in ~/.local/bin. Ensure this exists on $PATH
  • If you're using an old OS (e.g. Debian 10), you may also need export XDG_DATA_DIRS=/usr/share:$HOME/.local/share
Clone this wiki locally