Skip to content

meson build automation utility

Zeioth edited this page Mar 25, 2024 · 8 revisions

When compiler.nvim detects a mason.build file in the current working directory, Telescope will be populated with all its executable and custom_target entries.

Hello world

Create a meson.build file in your working directory and copy/paste this:

project('HelloWorld', 'cpp')

# Example of a target
hello_world = executable('hello_world', 'main.cpp')

# Example of custom target to run all tasks
build_all = custom_target('build_all', command: 'echo', output: 'echo', input: [hello_world])

Now let's create the file we are building on the example above: Create main.cpp in the same directory.

#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

When you open the compiler you will see the option to run it screenshot_2024-03-23_04-05-25_431130767

And this is the result screenshot_2024-03-23_04-56-59_219214553

In the same way you can run hello world, you can execute any command necessary to build your program.

More info

(optionally) You can define the next globals

global defaut value
MESON_CLEAN_FIRST false
MESON_BUILD_DIR ./build
MESON_BUILD_TYPE debug

Example:

let g:MESON_BUILD_TYPE='release'

Globals persist between Neovim sessions.