コマンドラインコマンド

Mesonを起動する方法は2つあります。まず、ソースツリーから直接、/path/to/source/meson.pyコマンドで実行できます。Mesonがインストールされている場合は、単にmesonコマンドを使用します。このマニュアルでは、簡単にするために後者の形式のみを使用します。

Mesonは次の構文を使用して起動します: meson [COMMAND] [COMMAND_OPTIONS]

このセクションでは、利用可能なすべてのコマンドと、それらのオプションの引数について説明します。最も一般的なワークフローは、setupを実行し、次にcompileを実行し、最後にinstallを実行することです。

特定のコマンドで利用可能なすべてのオプションの完全なリストを表示するには、次の構文を使用します: meson COMMAND --help

configure

$ meson configure [-h] [--prefix PREFIX] [--bindir BINDIR]
                  [--datadir DATADIR] [--includedir INCLUDEDIR]
                  [--infodir INFODIR] [--libdir LIBDIR]
                  [--licensedir LICENSEDIR] [--libexecdir LIBEXECDIR]
                  [--localedir LOCALEDIR] [--localstatedir LOCALSTATEDIR]
                  [--mandir MANDIR] [--sbindir SBINDIR]
                  [--sharedstatedir SHAREDSTATEDIR]
                  [--sysconfdir SYSCONFDIR]
                  [--auto-features {enabled,disabled,auto}]
                  [--backend {ninja,vs,vs2010,vs2012,vs2013,vs2015,vs2017,vs2019,vs2022,xcode,none}]
                  [--genvslite {vs2022}]
                  [--buildtype {plain,debug,debugoptimized,release,minsize,custom}]
                  [--debug] [--default-library {shared,static,both}]
                  [--default-both-libraries {shared,static,auto}]
                  [--errorlogs] [--install-umask INSTALL_UMASK]
                  [--layout {mirror,flat}]
                  [--optimization {plain,0,g,1,2,3,s}] [--prefer-static]
                  [--stdsplit] [--strip] [--unity {on,off,subprojects}]
                  [--unity-size UNITY_SIZE]
                  [--warnlevel {0,1,2,3,everything}] [--werror]
                  [--wrap-mode {default,nofallback,nodownload,forcefallback,nopromote}]
                  [--force-fallback-for FORCE_FALLBACK_FOR] [--vsenv]
                  [--pkgconfig.relocatable]
                  [--python.bytecompile PYTHON.BYTECOMPILE]
                  [--python.install-env {auto,prefix,system,venv}]
                  [--python.platlibdir PYTHON.PLATLIBDIR]
                  [--python.purelibdir PYTHON.PURELIBDIR]
                  [--python.allow-limited-api]
                  [--pkg-config-path PKG_CONFIG_PATH]
                  [--build.pkg-config-path BUILD.PKG_CONFIG_PATH]
                  [--cmake-prefix-path CMAKE_PREFIX_PATH]
                  [--build.cmake-prefix-path BUILD.CMAKE_PREFIX_PATH]
                  [-D option] [--clearcache] [--no-pager]
                  [builddir]

設定済みのmesonプロジェクトのオプションを変更します。

positional arguments:
  builddir

options:
  -h, --help                            show this help message and exit
  --prefix PREFIX                       Installation prefix.
  --bindir BINDIR                       Executable directory.
  --datadir DATADIR                     Data file directory.
  --includedir INCLUDEDIR               Header file directory.
  --infodir INFODIR                     Info page directory.
  --libdir LIBDIR                       Library directory.
  --licensedir LICENSEDIR               Licenses directory (default: ).
  --libexecdir LIBEXECDIR               Library executable directory.
  --localedir LOCALEDIR                 Locale data directory.
  --localstatedir LOCALSTATEDIR         Localstate data directory.
  --mandir MANDIR                       Manual page directory.
  --sbindir SBINDIR                     System executable directory.
  --sharedstatedir SHAREDSTATEDIR       Architecture-independent data directory.
  --sysconfdir SYSCONFDIR               Sysconf data directory.
  --auto-features {enabled,disabled,auto}
                                        Override value of all 'auto' features
                                        (default: auto).
  --backend {ninja,vs,vs2010,vs2012,vs2013,vs2015,vs2017,vs2019,vs2022,xcode,none}
                                        Backend to use (default: ninja).
  --genvslite {vs2022}                  Setup multiple buildtype-suffixed ninja-
                                        backend build directories, and a
                                        [builddir]_vs containing a Visual Studio
                                        meta-backend with multiple
                                        configurations that calls into them
                                        (default: vs2022).
  --buildtype {plain,debug,debugoptimized,release,minsize,custom}
                                        Build type to use (default: debug).
  --debug                               Enable debug symbols and other
                                        information
  --default-library {shared,static,both}
                                        Default library type (default: shared).
  --default-both-libraries {shared,static,auto}
                                        Default library type for both_libraries
                                        (default: shared).
  --errorlogs                           Whether to print the logs from failing
                                        tests
  --install-umask INSTALL_UMASK         Default umask to apply on permissions of
                                        installed files (default: 022).
  --layout {mirror,flat}                Build directory layout (default:
                                        mirror).
  --optimization {plain,0,g,1,2,3,s}    Optimization level (default: 0).
  --prefer-static                       Whether to try static linking before
                                        shared linking
  --stdsplit                            Split stdout and stderr in test logs
  --strip                               Strip targets on install
  --unity {on,off,subprojects}          Unity build (default: off).
  --unity-size UNITY_SIZE               Unity block size (default: (2, None,
                                        4)).
  --warnlevel {0,1,2,3,everything}      Compiler warning level to use (default:
                                        1).
  --werror                              Treat warnings as errors
  --wrap-mode {default,nofallback,nodownload,forcefallback,nopromote}
                                        Wrap mode (default: default).
  --force-fallback-for FORCE_FALLBACK_FOR
                                        Force fallback for those subprojects
                                        (default: []).
  --vsenv                               Activate Visual Studio environment
  --pkgconfig.relocatable               Generate pkgconfig files as relocatable
  --python.bytecompile PYTHON.BYTECOMPILE
                                        Whether to compile bytecode (default:
                                        (-1, 2, 0)).
  --python.install-env {auto,prefix,system,venv}
                                        Which python environment to install to
                                        (default: prefix).
  --python.platlibdir PYTHON.PLATLIBDIR
                                        Directory for site-specific, platform-
                                        specific files (default: ).
  --python.purelibdir PYTHON.PURELIBDIR
                                        Directory for site-specific, non-
                                        platform-specific files (default: ).
  --python.allow-limited-api            Whether to allow use of the Python
                                        Limited API
  --pkg-config-path PKG_CONFIG_PATH     List of additional paths for pkg-config
                                        to search (default: []). (just for host
                                        machine)
  --build.pkg-config-path BUILD.PKG_CONFIG_PATH
                                        List of additional paths for pkg-config
                                        to search (default: []). (just for build
                                        machine)
  --cmake-prefix-path CMAKE_PREFIX_PATH
                                        List of additional prefixes for cmake to
                                        search (default: []). (just for host
                                        machine)
  --build.cmake-prefix-path BUILD.CMAKE_PREFIX_PATH
                                        List of additional prefixes for cmake to
                                        search (default: []). (just for build
                                        machine)
  -D option                             Set the value of an option, can be used
                                        several times to set multiple options.
  --clearcache                          Clear cached state (e.g. found
                                        dependencies)
  --no-pager                            Do not redirect output to a pager

ほとんどの引数はsetupと同じです。

注: プロジェクトを再設定しても、オプションはデフォルト値にリセットされません(meson.buildで変更された場合でも)。

利用可能なすべてのオプションをリスト表示する

meson configure builddir

単一のオプションの値を変更する

meson configure builddir -Doption=new_value

compile

(0.54.0以降)

$ meson compile [-h] [--clean] [-C WD] [-j JOBS] [-l LOAD_AVERAGE] [-v]
                [--ninja-args NINJA_ARGS] [--vs-args VS_ARGS]
                [--xcode-args XCODE_ARGS]
                [TARGET ...]

設定済みのMesonプロジェクトのデフォルトまたは指定されたターゲットをビルドします。

positional arguments:
  TARGET                                Targets to build. Target has the
                                        following format: [PATH_TO_TARGET/]TARGE
                                        T_NAME.TARGET_SUFFIX[:TARGET_TYPE].

options:
  -h, --help                            show this help message and exit
  --clean                               Clean the build directory.
  -C WD                                 directory to cd into before running
  -j JOBS, --jobs JOBS                  The number of worker jobs to run (if
                                        supported). If the value is less than 1
                                        the build program will guess.
  -l LOAD_AVERAGE, --load-average LOAD_AVERAGE
                                        The system load average to try to
                                        maintain (if supported).
  -v, --verbose                         Show more verbose output.
  --ninja-args NINJA_ARGS               Arguments to pass to `ninja` (applied
                                        only on `ninja` backend).
  --vs-args VS_ARGS                     Arguments to pass to `msbuild` (applied
                                        only on `vs` backend).
  --xcode-args XCODE_ARGS               Arguments to pass to `xcodebuild`
                                        (applied only on `xcode` backend).

--verbose引数は0.55.0から利用可能です。

ターゲット

(0.55.0以降)

TARGETには、次の構文があります [PATH/]NAME.SUFFIX[:TYPE]、ここで

  • NAME: meson.buildからのターゲットの名前 (例: executable('foo', ...)からのfoo)。
  • SUFFIX: meson.buildからのターゲットの接尾辞の名前 (例: executable('foo', suffix: 'exe', ...)からのexe)。
  • PATH: ルートのmeson.buildファイルからのターゲットへの相対パス。注: ルートのmeson.buildで指定されたターゲットの相対パスは./です。
  • TYPE: ターゲットのタイプ。次のいずれかです: 'executable', 'static_library', 'shared_library', 'shared_module', 'custom', 'alias', 'run', 'jar'。

PATHSUFFIX、およびTYPEは、結果のTARGETを使用してmeson.buildでターゲットを一意に識別できる場合は、すべて省略できます。

SUFFIXは1.3.0より前には存在しなかったことに注意してください。

バックエンド固有の引数

(0.55.0以降)

BACKEND-argsは次の構文を使用します

単一の文字列のみを渡した場合、すべての値がコンマで区切られているとみなされます。したがって、次のコマンドを呼び出すと

$ meson compile --ninja-args=-n,-d,explain

-n-d、およびexplainの引数がninjaの呼び出しに追加されます。

文字列値にコンマまたはスペースを含める必要がある場合は、次のように適切なシェル引用符で値を渡す必要があります

$ meson compile "--ninja-args=['a,b', 'c d']"

プロジェクトをビルドする

meson compile -C builddir

追加のデバッグ情報付きでninjaバックエンドでドライランを実行する

meson compile --ninja-args=-n,-d,explain

3つのターゲットをビルドします: 同じfoo名を持つが異なるタイプの2つのターゲットと、barターゲット

meson compile foo:shared_library foo:static_library bar

カバレッジHTMLレポートを作成する(利用可能な場合)

ninja coverage-html

dist

(0.52.0以降)

$ meson dist [-h] [-C WD] [--allow-dirty] [--formats FORMATS]
             [--include-subprojects] [--no-tests]

現在のソースツリーからリリースアーカイブを生成します。

options:
  -h, --help             show this help message and exit
  -C WD                  directory to cd into before running
  --allow-dirty          Allow even when repository contains uncommitted
                         changes.
  --formats FORMATS      Comma separated list of archive types to create.
                         Supports xztar (default), bztar, gztar, and zip.
  --include-subprojects  Include source code of subprojects that have been used
                         for the build.
  --no-tests             Do not build and test generated packages.

詳細については、リリース作成に関する注記を参照してください。

リリースアーカイブを作成する

meson dist -C builddir

init

(0.45.0以降)

$ meson init [-h] [-C WD] [-n NAME] [-e EXECUTABLE] [-d DEPS]
             [-l {c,cpp,cs,cuda,d,fortran,java,objc,objcpp,rust,vala}] [-b]
             [--builddir BUILDDIR] [-f] [--type {executable,library}]
             [--version VERSION]
             [sourcefile ...]

テンプレートに基づいて、ビルドファイルの基本セットを作成します。

positional arguments:
  sourcefile                            source files. default: all recognized
                                        files in current directory

options:
  -h, --help                            show this help message and exit
  -C WD                                 directory to cd into before running
  -n NAME, --name NAME                  project name. default: name of current
                                        directory
  -e EXECUTABLE, --executable EXECUTABLE
                                        executable name. default: project name
  -d DEPS, --deps DEPS                  dependencies, comma-separated
  -l {c,cpp,cs,cuda,d,fortran,java,objc,objcpp,rust,vala}, --language {c,cpp,cs,cuda,d,fortran,java,objc,objcpp,rust,vala}
                                        project language. default: autodetected
                                        based on source files
  -b, --build                           build after generation
  --builddir BUILDDIR                   directory for build
  -f, --force                           force overwrite of existing files and
                                        directories.
  --type {executable,library}           project type. default: executable based
                                        project
  --version VERSION                     project version. default: 0.1

sourcedirにプロジェクトを作成する

meson init -C sourcedir

env2mfile

このコマンドは実験的であり、変更される可能性があります。

{0.62.0以降}

$ meson env2mfile [-h] [--debarch DEBARCH] [--gccsuffix GCCSUFFIX] -o
                  OUTFILE [--cross] [--native] [--system SYSTEM]
                  [--subsystem SUBSYSTEM] [--kernel KERNEL] [--cpu CPU]
                  [--cpu-family CPU_FAMILY] [--endian {big,little}]

現在の環境からネイティブファイルとクロスファイルを作成します。通常は、CCCFLAGSのような環境変数をスニッフィングします。

options:
  -h, --help               show this help message and exit
  --debarch DEBARCH        The dpkg architecture to generate.
  --gccsuffix GCCSUFFIX    A particular gcc version suffix if necessary.
  -o OUTFILE               The output file.
  --cross                  Generate a cross compilation file.
  --native                 Generate a native compilation file.
  --system SYSTEM          Define system for cross compilation.
  --subsystem SUBSYSTEM    Define subsystem for cross compilation.
  --kernel KERNEL          Define kernel for cross compilation.
  --cpu CPU                Define cpu for cross compilation.
  --cpu-family CPU_FAMILY  Define cpu family for cross compilation.
  --endian {big,little}    Define endianness for cross compilation.

現在のクロスビルド環境を自動検出する

meson env2mfile --cross -o current_cross.txt --cpu=arm7a --cpu-family=arm --system=linux

Debianシステム情報を使用してクロスビルドを生成する

meson env2mfile --cross --debarch=armhf -o deb_arm_cross.txt

introspect

$ meson introspect [-h] [--ast] [--benchmarks] [--buildoptions]
                   [--buildsystem-files] [--compilers] [--dependencies]
                   [--scan-dependencies] [--installed] [--install-plan]
                   [--machines] [--projectinfo] [--targets] [--tests]
                   [--backend {ninja,none,vs,vs2010,vs2012,vs2013,vs2015,vs2017,vs2019,vs2022,xcode}]
                   [-a] [-i] [-f]
                   [builddir]

設定済みのMesonプロジェクトに関する情報を表示します。

positional arguments:
  builddir                              The build directory

options:
  -h, --help                            show this help message and exit
  --ast                                 Dump the AST of the meson file.
  --benchmarks                          List all benchmarks.
  --buildoptions                        List all build options.
  --buildsystem-files                   List files that make up the build
                                        system.
  --compilers                           List used compilers.
  --dependencies                        List external dependencies.
  --scan-dependencies                   Scan for dependencies used in the
                                        meson.build file.
  --installed                           List all installed files and
                                        directories.
  --install-plan                        List all installed files and directories
                                        with their details.
  --machines                            Information about host, build, and
                                        target machines.
  --projectinfo                         Information about projects.
  --targets                             List top level targets.
  --tests                               List all unit tests.
  --backend {ninja,none,vs,vs2010,vs2012,vs2013,vs2015,vs2017,vs2019,vs2022,xcode}
                                        The backend to use for the
                                        --buildoptions introspection.
  -a, --all                             Print all available information.
  -i, --indent                          Enable pretty printed JSON.
  -f, --force-object-output             Always use the new JSON format for
                                        multiple entries (even for 0 and 1
                                        introspection commands)

builddir内の設定済みプロジェクトに関する基本情報を表示する

meson introspect builddir --projectinfo

install

(0.47.0以降)

$ meson install [-h] [-C WD] [--no-rebuild] [--only-changed] [--quiet]
                [--destdir DESTDIR] [--dry-run]
                [--skip-subprojects [SKIP_SUBPROJECTS]] [--tags TAGS]
                [--strip]

setupで指定されたプレフィックスにプロジェクトをインストールします。

options:
  -h, --help                            show this help message and exit
  -C WD                                 directory to cd into before running
  --no-rebuild                          Do not rebuild before installing.
  --only-changed                        Only overwrite files that are older than
                                        the copied file.
  --quiet                               Do not print every file that was
                                        installed.
  --destdir DESTDIR                     Sets or overrides DESTDIR environment.
                                        (Since 0.57.0)
  --dry-run, -n                         Doesn't actually install, but print
                                        logs. (Since 0.57.0)
  --skip-subprojects [SKIP_SUBPROJECTS]
                                        Do not install files from given
                                        subprojects. (Since 0.58.0)
  --tags TAGS                           Install only targets having one of the
                                        given tags. (Since 0.60.0)
  --strip                               Strip targets even if strip option was
                                        not set during configure. (Since 0.62.0)

詳細については、インストールに関するドキュメントを参照してください。

プロジェクトをprefixにインストールする

meson install -C builddir

プロジェクトを$DESTDIR/prefixにインストールする

DESTDIR=/path/to/staging/area meson install -C builddir

0.60.0以降、DESTDIR--destdirはビルドディレクトリに対する相対パスにできます。スクリプトを実行するときに、絶対パスが環境に設定されます。

reprotest

(1.6.0以降)

$ meson reprotest [-h] [--intermediaries] [mesonargs ...]

プロジェクトを2回コンパイルし、最終結果が同一であるかどうかを確認する、シンプルな再現可能なビルドテスター。

このコマンドは、テストするプロジェクトのソースルートで実行する必要があります。

positional arguments:
  mesonargs         Arguments to pass to "meson setup".

options:
  -h, --help        show this help message and exit
  --intermediaries  Check intermediate files.

meson reprotest

デフォルト設定で現在のプロジェクトをビルドします。

meson reprotest --intermediaries -- --buildtype=debugoptimized

ターゲットをビルドし、オブジェクトファイルのようなすべての中間ファイルも同一であることを確認します。--以降のすべてのコマンドライン引数は、基礎となるmesonの呼び出しに直接渡されます。オプション引数、つまりダッシュで始まる引数のみを使用してください。Mesonはディレクトリ引数を自動的に設定します。

rewrite

(0.50.0以降)

$ meson rewrite [-h] [-s SRCDIR] [-V] [-S]
                {target,tgt,kwargs,default-options,def,command,cmd} ...

Mesonプロジェクトを変更します。

options:
  -h, --help                            show this help message and exit
  -s SRCDIR, --sourcedir SRCDIR         Path to source directory.
  -V, --verbose                         Enable verbose output
  -S, --skip-errors                     Skip errors instead of aborting

Rewriter commands:
  Rewrite command to execute

  {target,tgt,kwargs,default-options,def,command,cmd}
    target (tgt)                        Modify a target
    kwargs                              Modify keyword arguments
    default-options (def)               Modify the project default options
    command (cmd)                       Execute a JSON array of commands

詳細については、Mesonファイルリライターのドキュメントを参照してください。

setup

$ meson setup [-h] [--prefix PREFIX] [--bindir BINDIR] [--datadir DATADIR]
              [--includedir INCLUDEDIR] [--infodir INFODIR]
              [--libdir LIBDIR] [--licensedir LICENSEDIR]
              [--libexecdir LIBEXECDIR] [--localedir LOCALEDIR]
              [--localstatedir LOCALSTATEDIR] [--mandir MANDIR]
              [--sbindir SBINDIR] [--sharedstatedir SHAREDSTATEDIR]
              [--sysconfdir SYSCONFDIR]
              [--auto-features {enabled,disabled,auto}]
              [--backend {ninja,vs,vs2010,vs2012,vs2013,vs2015,vs2017,vs2019,vs2022,xcode,none}]
              [--genvslite {vs2022}]
              [--buildtype {plain,debug,debugoptimized,release,minsize,custom}]
              [--debug] [--default-library {shared,static,both}]
              [--default-both-libraries {shared,static,auto}] [--errorlogs]
              [--install-umask INSTALL_UMASK] [--layout {mirror,flat}]
              [--optimization {plain,0,g,1,2,3,s}] [--prefer-static]
              [--stdsplit] [--strip] [--unity {on,off,subprojects}]
              [--unity-size UNITY_SIZE] [--warnlevel {0,1,2,3,everything}]
              [--werror]
              [--wrap-mode {default,nofallback,nodownload,forcefallback,nopromote}]
              [--force-fallback-for FORCE_FALLBACK_FOR] [--vsenv]
              [--pkgconfig.relocatable]
              [--python.bytecompile PYTHON.BYTECOMPILE]
              [--python.install-env {auto,prefix,system,venv}]
              [--python.platlibdir PYTHON.PLATLIBDIR]
              [--python.purelibdir PYTHON.PURELIBDIR]
              [--python.allow-limited-api]
              [--pkg-config-path PKG_CONFIG_PATH]
              [--build.pkg-config-path BUILD.PKG_CONFIG_PATH]
              [--cmake-prefix-path CMAKE_PREFIX_PATH]
              [--build.cmake-prefix-path BUILD.CMAKE_PREFIX_PATH]
              [-D option] [--native-file NATIVE_FILE]
              [--cross-file CROSS_FILE] [-v] [--fatal-meson-warnings]
              [--reconfigure] [--wipe] [--clearcache]
              [builddir] [sourcedir]

Mesonプロジェクトのビルドディレクトリを設定します。

0.64.0から非推奨: これはデフォルトのMesonコマンドです(COMMANDが指定されていない場合に呼び出されます)。ただし、将来追加されるコマンドとの衝突を避けるために、コマンドを指定する必要があります。そのため、「setup」を明示的に使用する必要があります。

1.1.0以降 --reconfigureは、ビルドディレクトリがまだ存在しない場合でも許可されます。その場合、その引数は無視されます。

1.3.0以降 ビルドディレクトリがすでに存在する場合、オプションはコマンドラインで指定された新しい値で更新されます(-Dopt=value)。--reconfigureも指定されていない限り、これはすぐに再設定しません。これは、meson configure <builddir> -Dopt=valueと同じ動作をします。

1.3.0以降 meson setup --clearcache --reconfigure <builddir>を使用して、キャッシュをクリアして1つのコマンドで再設定できます。

positional arguments:
  builddir
  sourcedir

options:
  -h, --help                            show this help message and exit
  --prefix PREFIX                       Installation prefix.
  --bindir BINDIR                       Executable directory.
  --datadir DATADIR                     Data file directory.
  --includedir INCLUDEDIR               Header file directory.
  --infodir INFODIR                     Info page directory.
  --libdir LIBDIR                       Library directory.
  --licensedir LICENSEDIR               Licenses directory (default: ).
  --libexecdir LIBEXECDIR               Library executable directory.
  --localedir LOCALEDIR                 Locale data directory.
  --localstatedir LOCALSTATEDIR         Localstate data directory.
  --mandir MANDIR                       Manual page directory.
  --sbindir SBINDIR                     System executable directory.
  --sharedstatedir SHAREDSTATEDIR       Architecture-independent data directory.
  --sysconfdir SYSCONFDIR               Sysconf data directory.
  --auto-features {enabled,disabled,auto}
                                        Override value of all 'auto' features
                                        (default: auto).
  --backend {ninja,vs,vs2010,vs2012,vs2013,vs2015,vs2017,vs2019,vs2022,xcode,none}
                                        Backend to use (default: ninja).
  --genvslite {vs2022}                  Setup multiple buildtype-suffixed ninja-
                                        backend build directories, and a
                                        [builddir]_vs containing a Visual Studio
                                        meta-backend with multiple
                                        configurations that calls into them
                                        (default: vs2022).
  --buildtype {plain,debug,debugoptimized,release,minsize,custom}
                                        Build type to use (default: debug).
  --debug                               Enable debug symbols and other
                                        information
  --default-library {shared,static,both}
                                        Default library type (default: shared).
  --default-both-libraries {shared,static,auto}
                                        Default library type for both_libraries
                                        (default: shared).
  --errorlogs                           Whether to print the logs from failing
                                        tests
  --install-umask INSTALL_UMASK         Default umask to apply on permissions of
                                        installed files (default: 022).
  --layout {mirror,flat}                Build directory layout (default:
                                        mirror).
  --optimization {plain,0,g,1,2,3,s}    Optimization level (default: 0).
  --prefer-static                       Whether to try static linking before
                                        shared linking
  --stdsplit                            Split stdout and stderr in test logs
  --strip                               Strip targets on install
  --unity {on,off,subprojects}          Unity build (default: off).
  --unity-size UNITY_SIZE               Unity block size (default: (2, None,
                                        4)).
  --warnlevel {0,1,2,3,everything}      Compiler warning level to use (default:
                                        1).
  --werror                              Treat warnings as errors
  --wrap-mode {default,nofallback,nodownload,forcefallback,nopromote}
                                        Wrap mode (default: default).
  --force-fallback-for FORCE_FALLBACK_FOR
                                        Force fallback for those subprojects
                                        (default: []).
  --vsenv                               Activate Visual Studio environment
  --pkgconfig.relocatable               Generate pkgconfig files as relocatable
  --python.bytecompile PYTHON.BYTECOMPILE
                                        Whether to compile bytecode (default:
                                        (-1, 2, 0)).
  --python.install-env {auto,prefix,system,venv}
                                        Which python environment to install to
                                        (default: prefix).
  --python.platlibdir PYTHON.PLATLIBDIR
                                        Directory for site-specific, platform-
                                        specific files (default: ).
  --python.purelibdir PYTHON.PURELIBDIR
                                        Directory for site-specific, non-
                                        platform-specific files (default: ).
  --python.allow-limited-api            Whether to allow use of the Python
                                        Limited API
  --pkg-config-path PKG_CONFIG_PATH     List of additional paths for pkg-config
                                        to search (default: []). (just for host
                                        machine)
  --build.pkg-config-path BUILD.PKG_CONFIG_PATH
                                        List of additional paths for pkg-config
                                        to search (default: []). (just for build
                                        machine)
  --cmake-prefix-path CMAKE_PREFIX_PATH
                                        List of additional prefixes for cmake to
                                        search (default: []). (just for host
                                        machine)
  --build.cmake-prefix-path BUILD.CMAKE_PREFIX_PATH
                                        List of additional prefixes for cmake to
                                        search (default: []). (just for build
                                        machine)
  -D option                             Set the value of an option, can be used
                                        several times to set multiple options.
  --native-file NATIVE_FILE             File containing overrides for native
                                        compilation environment.
  --cross-file CROSS_FILE               File describing cross compilation
                                        environment.
  -v, --version                         show program's version number and exit
  --fatal-meson-warnings                Make all Meson warnings fatal
  --reconfigure                         Set options and reconfigure the project.
                                        Useful when new options have been added
                                        to the project and the default value is
                                        not working.
  --wipe                                Wipe build directory and reconfigure
                                        using previous command line options.
                                        Useful when build directory got
                                        corrupted, or when rebuilding with a
                                        newer version of meson.
  --clearcache                          Clear cached state (e.g. found
                                        dependencies). Since 1.3.0.

詳細については、Meson紹介ページを参照してください。

デフォルト値でbuilddirを設定する

meson setup builddir

subprojects

(0.49.0以降)

$ meson subprojects [-h]
                    {update,checkout,download,foreach,purge,packagefiles}
                    ...

Mesonプロジェクトのサブプロジェクトを管理します。0.59.0以降 コマンドはデフォルトで複数のサブプロジェクトで並行して実行されます。不要な場合は、--num-processes=1を使用してください。

0.64.0以降、updateサブコマンドはWrapDBから新しいラップファイルをダウンロードしなくなりました。代わりにmeson wrap updateコマンドを使用してください。

options:
  -h, --help                            show this help message and exit

Commands:
  {update,checkout,download,foreach,purge,packagefiles}
    update                              Update all subprojects from wrap files
    checkout                            Checkout a branch (git only)
    download                            Ensure subprojects are fetched, even if
                                        not in use. Already downloaded
                                        subprojects are not modified. This can
                                        be used to pre-fetch all subprojects and
                                        avoid downloads during configure.
    foreach                             Execute a command in each subproject
                                        directory.
    purge                               Remove all wrap-based subproject
                                        artifacts
    packagefiles                        Manage the packagefiles overlay

test

$ meson test [-h] [--maxfail MAXFAIL] [--repeat REPEAT] [--no-rebuild]
             [--gdb] [--gdb-path GDB_PATH] [-i] [--list]
             [--wrapper WRAPPER] [-C WD] [--suite SUITE] [--no-suite SUITE]
             [--no-stdsplit] [--print-errorlogs] [--benchmark]
             [--logbase LOGBASE] [-j NUM_PROCESSES] [-v] [-q]
             [-t TIMEOUT_MULTIPLIER] [--setup SETUP]
             [--test-args TEST_ARGS] [--max-lines MAX_LINES]
             [args ...]

設定済みのMesonプロジェクトのテストを実行します。

positional arguments:
  args                                  Optional list of test names to run.
                                        "testname" to run all tests with that
                                        name, "subprojname:testname" to
                                        specifically run "testname" from
                                        "subprojname", "subprojname:" to run all
                                        tests defined by "subprojname".

options:
  -h, --help                            show this help message and exit
  --maxfail MAXFAIL                     Number of failing tests before aborting
                                        the test run. (default: 0, to disable
                                        aborting on failure)
  --repeat REPEAT                       Number of times to run the tests.
  --no-rebuild                          Do not rebuild before running tests.
  --gdb                                 Run test under gdb.
  --gdb-path GDB_PATH                   Path to the gdb binary (default: gdb).
  -i, --interactive                     Run tests with interactive input/output.
  --list                                List available tests.
  --wrapper WRAPPER                     wrapper to run tests with (e.g.
                                        Valgrind)
  -C WD                                 directory to cd into before running
  --suite SUITE                         Only run tests belonging to the given
                                        suite.
  --no-suite SUITE                      Do not run tests belonging to the given
                                        suite.
  --no-stdsplit                         Do not split stderr and stdout in test
                                        logs.
  --print-errorlogs                     Whether to print failing tests' logs.
  --benchmark                           Run benchmarks instead of tests.
  --logbase LOGBASE                     Base name for log file.
  -j NUM_PROCESSES, --num-processes NUM_PROCESSES
                                        How many parallel processes to use.
  -v, --verbose                         Do not redirect stdout and stderr
  -q, --quiet                           Produce less output to the terminal.
  -t TIMEOUT_MULTIPLIER, --timeout-multiplier TIMEOUT_MULTIPLIER
                                        Define a multiplier for test timeout,
                                        for example when running tests in
                                        particular conditions they might take
                                        more time to execute. (<= 0 to disable
                                        timeout)
  --setup SETUP                         Which test setup to use.
  --test-args TEST_ARGS                 Arguments to pass to the specified
                                        test(s) or all tests
  --max-lines MAX_LINES                 Maximum number of lines to show from a
                                        long test log. Since 1.5.0.

詳細については、単体テストのドキュメントを参照してください。

1.2.0以降、テスト名にargsでワイルドカードを使用できます。たとえば、「bas*」は「bas」で始まる名前のすべてのテストに一致します。

1.2.0以降、どのテストにも一致しないテスト名またはワイルドカードを指定するとエラーになります。

プロジェクトのテストを実行する

meson test -C builddir

specific_test_1specific_test_2のみを実行する

meson test -C builddir specific_test_1 specific_test_2

wrap

$ meson wrap [-h]
             {list,search,install,update,info,status,promote,update-db} ...

WrapDBの依存関係を管理するためのユーティリティ。

options:
  -h, --help                            show this help message and exit

Commands:
  {list,search,install,update,info,status,promote,update-db}
    list                                show all available projects
    search                              search the db by name
    install                             install the specified project
    update                              Update wrap files from WrapDB (Since
                                        0.63.0)
    info                                show available versions of a project
    status                              show installed and available versions of
                                        your projects
    promote                             bring a subsubproject up to the master
                                        project
    update-db                           Update list of projects available in
                                        WrapDB (Since 0.61.0)

詳細については、WrapDBツールのドキュメントを参照してください。

devenv

(0.58.0以降)

$ meson devenv [-h] [-C BUILDDIR] [--workdir WORKDIR] [--dump [DUMP]]
               [--dump-format {sh,export,vscode}]
               ...

インストールせずに、ビルドディレクトリからプロジェクトを実行するように環境を設定した状態でコマンドを実行するか、コマンドが指定されていない場合はインタラクティブシェルを開きます。

bashは自動的に処理され、それに応じて$PS1が設定されます。自動的な$PS1の上書きが望ましくない場合(おそらく凝ったカスタムプロンプトがある場合)、$MESON_DISABLE_PS1_OVERRIDE環境変数を設定し、カスタムプロンプトを設定するときに$MESON_PROJECT_NAMEを使用します。たとえば、次のスニペットを使用します

...
if [[ -n "${MESON_PROJECT_NAME-}" ]];
then
  PS1+="[ ${MESON_PROJECT_NAME} ]"
fi
...

これらの変数は、meson.add_devenv()を使用して設定されたものに加えて、環境に設定されます。

  • MESON_DEVENV'1'として定義されます。
  • MESON_PROJECT_NAMEはメインプロジェクトの名前に定義されます。
  • PKG_CONFIG_PATHには、Mesonが-uninstalled.pcファイルを生成するディレクトリが含まれます。
  • PATHには、bindirにインストールされる実行可能ファイルがあるすべてのディレクトリが含まれます。Windowsでは、それらの実行可能ファイルを実行するために必要なDLLがあるすべてのディレクトリも含まれます。
  • LD_LIBRARY_PATHには、libdirにインストールされる共有ライブラリがあるすべてのディレクトリが含まれます。これにより、いくつかのライブラリのカスタムビルドを使用してシステムアプリケーションを実行できます。たとえば、gitからGTKをビルドするときにシステムのGEditを実行します。OSXでは、環境変数はDYLD_LIBRARY_PATHであり、WindowsではPATHです。
  • GI_TYPELIB_PATHには、GObject Introspection typelibがビルドされるすべてのディレクトリが含まれます。これは、gnome.generate_gir()を使用すると自動的に設定されます。
  • GSETTINGS_SCHEMA_DIR 0.59.0以降 GSettingsスキーマがコンパイルされるすべてのディレクトリが含まれます。これは、gnome.compile_schemas()を使用すると自動的に設定されます。gnome.compile_schemas()が複数のディレクトリで使用される場合は、GLib >= 2.64が必要です。
  • QEMU_LD_PREFIX 1.0.0以降 クロスコンパイル時にクロスファイルからsys_root値に設定され、そのプロパティが定義されます。

0.62.0以降 bash-completionスクリプトがインストールされていて、シェルがbashの場合、それらは自動的にソースされます。

0.62.0以降 GDBヘルパースクリプト(*-gdb.py、*-gdb.gdb、および*-gdb.csm)が、ビルド中のいずれかに一致するライブラリ名でインストールされている場合、Mesonは必要な自動ロードコマンドを<builddir>/.gdbinitファイルに追加します。トップビルドディレクトリからgdbを実行すると、そのファイルはgdbによって自動的にロードされます。他のPythonモジュールをロードする必要があるPythonスクリプトの場合、meson.add_devenv()を使用してPYTHONPATHを変更する必要がある場合があります。

0.63.0以降 Windows用にクロスコンパイルする場合、PATHの代わりにWINEPATHが使用され、wineを使用してWindows実行可能ファイルを実行できます。WINEPATHのサイズは現在1024文字に制限されているため、ビルドディレクトリのルートに対する相対パスが使用されることに注意してください。つまり、wineを実行するときは、現在の作業ディレクトリがビルドディレクトリのルートである必要があります。

1.1.0以降 meson devenv --dump [<filename>]コマンドは、オプションのファイル名引数を受け取って、環境をstdoutに出力する代わりにファイルに書き込みます。

1.1.0以降 --dump-format引数が追加され、どのシェル形式を使用するかを選択できるようになりました。現在、3つの形式がサポートされています

  • sh: 行はVAR=/prepend:$VAR:/appendの形式です。
  • export: shと同じですが、追加のexport VAR行があります。
  • vscode: shと同じですが、$VAR置換はありません。これはvscodeで適切にサポートされていないように見えるためです。
positional arguments:
  command                           Command to run in developer environment
                                    (default: interactive shell)

options:
  -h, --help                        show this help message and exit
  -C BUILDDIR                       Path to build directory
  --workdir WORKDIR, -w WORKDIR     Directory to cd into before running
                                    (default: builddir, Since 1.0.0)
  --dump [DUMP]                     Only print required environment (Since
                                    0.62.0) Takes an optional file path (Since
                                    1.1.0)
  --dump-format {sh,export,vscode}  Format used with --dump (Since 1.1.0)

format

(1.5.0以降)

$ meson format [-h] [-q | -i] [-r] [-c meson.format] [-e] [-o OUTPUT]
               [sources ...]

指定されたmeson.buildドキュメントをフォーマットします。muonとの互換性のために、fmtformatのエイリアスです。

positional arguments:
  sources                               meson source files

options:
  -h, --help                            show this help message and exit
  -q, --check-only                      exit with 1 if files would be modified
                                        by meson format
  -i, --inplace                         format files in-place
  -r, --recursive                       recurse subdirs (requires --check-only
                                        or --inplace option)
  -c meson.format, --configuration meson.format
                                        read configuration from meson.format
  -e, --editor-config                   try to read configuration from
                                        .editorconfig
  -o OUTPUT, --output OUTPUT            output file (implies having exactly one
                                        input)

構成ファイルは.iniファイルです。分析対象の指定されたビルドファイルの横にmeson.formatファイルが存在し、コマンドラインで構成ファイルが指定されていない場合は、meson.formatファイルが自動的に使用されます。

コマンドラインでビルドファイルが指定されていない場合は、現在のディレクトリにあるmeson.buildファイルが分析されます。

次のオプションが認識されます

  • max_line_length (int): 配列、辞書、関数、またはメソッドがこれより長くなると、1行に1つの引数としてフォーマットされます(デフォルトは80)。
  • indent_by (str): 使用するインデント(デフォルトは4つのスペース' ')。
  • space_array (bool): []と配列引数の間にスペースを追加するかどうか(デフォルトはfalse)。
  • kwargs_force_multiline (bool): trueの場合、キーワード引数が存在するとすぐに、引数が1行に1つずつフォーマットされます(デフォルトはfalse)。
  • wide_colon (bool): trueの場合、dict内およびキーワード引数内のコロンの前にスペースが配置されます(デフォルトはfalse)。
  • no_single_comma_function (bool): trueの場合、引数が1つだけの場合、複数行引数を使用している場合でも、関数の引数にカンマが付加されることはありません(デフォルトはfalse)。
  • end_of_line ('cr', 'lf', 'crlf', 'native'): 使用する行末(--outputまたは--inline引数を使用する場合に適用されます)(デフォルトは'native')。
  • indent_before_comments (str): インラインコメントの前で使用するインデント(デフォルトは2つのスペース' ')。
  • simplify_string_literals (bool): trueの場合、複数行文字列に改行が含まれていない場合は、単一行文字列に変換されます。フォーマットされた文字列に置換が含まれていない場合は、通常の文字列に変換されます(デフォルトはtrue)。
  • insert_final_newline (bool): trueの場合、meson.buildファイルを強制的に改行文字で終了させます(デフォルトはtrue)。
  • tab_width (int): タブストップの幅。indent_byでタブ文字を使用する場合、行の長さを計算するために使用されます(デフォルトは4)。
  • sort_files (bool): trueの場合、files()関数の引数はアルファベット順にソートされます(デフォルトはfalse)。
  • group_arg_value (bool): trueの場合、--プレフィックスを持つ文字列引数の後に--プレフィックスを持たない文字列引数が続くと、複数行引数で同じ行にグループ化されます(デフォルトはfalse)。
  • use_editor_config (bool): trueの場合、.editorconfigの設定も使用します。

最初の6つのオプションは、muon fmtコマンドと同じです。

コマンドラインで--editor-configオプションを指定するか、設定ファイルのuse_editor_configオプションを使用して、.editorconfigファイルを使用することも可能です。

--recursiveオプションが指定されている場合、subdirmeson.buildファイルも分析されます(--inplaceまたは--check-onlyオプションと組み合わせて使用する必要があります)。

muon fmtとの違い

meson formatコマンドはmuon fmtコマンドと互換性があるはずです。ただし、機能がより多く、いくつかの違いがあります。

  • デフォルトでは、meson formatはインラインコメントの前に2つのスペースを配置しますが、muon fmtは1つしか配置しません。
  • muon fmtは行末を認識しないため、crlfとlfの行末を混在させる可能性があります。meson formatは、生成する出力において常に一貫性があります。
  • muon fmtは、.editorconfigファイルからindent_byオプションのみを認識します。meson formatは、max_line_lengthend_of_lineinsert_final_newlinetab_widthオプションも認識します。
  • meson formatには、他にも多くのフォーマットルールがあります(上記のオプションリストを参照)。

検索結果は以下のとおりです。