跳转至

命令行参数

Bash
1
2
#查看特定命令帮助信息
meson command --help
下面列一些常用的,详细的请去官网查阅文档。

configure

Text Only
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
meson configure [-h] [--prefix PREFIX] [--bindir BINDIR]
                  [--datadir DATADIR] [--includedir INCLUDEDIR]
                  [--infodir INFODIR] [--libdir LIBDIR]
                  [--libexecdir LIBEXECDIR] [--localedir LOCALEDIR]
                  [--localstatedir LOCALSTATEDIR] [--mandir MANDIR]
                  [--sbindir SBINDIR] [--sharedstatedir SHAREDSTATEDIR]
                  [--sysconfdir SYSCONFDIR]
                  [--auto-features {enabled,disabled,auto}]
                  [--backend {ninja,vs,vs2010,vs2015,vs2017,vs2019,xcode}]
                  [--buildtype {plain,debug,debugoptimized,release,minsize,custom}]
                  [--debug] [--default-library {shared,static,both}]
                  [--errorlogs] [--install-umask INSTALL_UMASK]
                  [--layout {mirror,flat}] [--optimization {0,g,1,2,3,s}]
                  [--stdsplit] [--strip] [--unity {on,off,subprojects}]
                  [--unity-size UNITY_SIZE] [--warnlevel {0,1,2,3}]
                  [--werror]
                  [--wrap-mode {default,nofallback,nodownload,forcefallback,nopromote}]
                  [--force-fallback-for FORCE_FALLBACK_FOR]
                  [--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]
                  [builddir]
Text Only
1
2
positional arguments:
  builddir

optional arguments
-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.
--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 Override value of all 'auto' features(default: auto).
--backend Backend to use (default: ninja).
--buildtype Build type to use (default: debug).
--debug Debug
--default-library Default library type (default: shared).
--errorlogs Whether to print the logs from failingtests
--install-umask INSTALL_UMASK Default umask to apply on permissions of installed files (default: 022).
--layout Build directory layout (default:mirror).
--optimization Optimization level (default: 0).
--stdsplit Split stdout and stderr in test logs
--strip Strip targets on install
--unity Unity build (default: off).
--unity-size UNITY_SIZE Unity block size (default: (2, None,4)).
--warnlevel Compiler warning level to use (default:1).
--werror Treat warnings as errors
--wrap-mode Wrap mode (default: default).
--force-fallback-for FORCE_FALLBACK_FOR force fallback for those subprojects(default: []).
--pkg-config-path PKG_CONFIG_PATH List of additional paths for pkg-configto 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 earch (default: []). (just for host achine)
--build.cmake-prefix-path BUILD.CMAKE_PREFIX_PATH ist of additional prefixes for cmake to earch (default: []). (just for build achine)
-D option Set the value of an option, can be used everal times to set multiple ptions.
--clearcache Clear cached state (e.g. founddependencies)

Examples:

Bash
1
2
3
4
#List all available options:
meson configure builddir
#Change value of a single option:
meson configure builddir -Doption=new_value

compile

Text Only
1
2
3
4
$ meson compile [-h] [--clean] [-C BUILDDIR] [-j JOBS] [-l LOAD_AVERAGE]
                [-v] [--ninja-args NINJA_ARGS] [--vs-args VS_ARGS]
                [--xcode-args XCODE_ARGS]
                [TARGET ...]
optional arguments
-h, --help show this help message and exit
--clean Clean the build directory.
-C BUILDDIR The directory containing build files tobe built.
-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).

Targets

(since 0.55.0)
TARGET has the following syntax[PATH/]NAME[:TYPE], where:
* NAME: name of the target from meson.build (e.g. foo from executable('foo', ...)).
* PATH: path to the target relative to the root meson.build file. Note: relative path for a target specified in the root meson.build is ./.
* TYPE: type of the target. Can be one of the following: 'executable', 'static_library', 'shared_library', 'shared_module', 'custom', 'run', 'jar'.
PATH and/or TYPE can be omitted if the resulting TARGET can be used to uniquely identify the target inmeson.build.

Backend specific arguments

(since 0.55.0) BACKEND-args use the following syntax:

Bash
1
2
3
4
5
#If you only pass a single string, then it is considered to have all values separated by commas. Thus invoking the following command:
$ meson compile --ninja-args=-n,-d,explain
# would add -n, -d and explain arguments to ninja invocation.
#If you need to have commas or spaces in your string values, then you need to pass the value with proper shell quoting like this:
$ meson compile "--ninja-args=['a,b', 'c d']"

Examples

Bash
1
2
3
4
5
6
7
8
#Build the project:
meson compile -C builddir
#Execute a dry run on ninja backend with additional debug info:
meson compile --ninja-args=-n,-d,explain
#Build three targets: two targets that have the same foo name, but different type, and a bar target:
meson compile foo:shared_library foo:static_library bar
#Produce a coverage html report (if available):
meson compile coverage-html

subprojects

(since 0.49.0)

Bash
1
$ meson subprojects [-h] {update,checkout,download,foreach} ...
Manages subprojects of the Meson project.
Text Only
1
2
optional arguments:
  -h, --help                          show this help message and exit
Commands: {update,checkout,download,foreach} |command| | |---|---| |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.|

test

Text Only
1
2
3
4
5
6
7
8
$ meson test [-h] [--repeat REPEAT] [--no-rebuild] [--gdb]
             [--gdb-path GDB_PATH] [--list] [--wrapper WRAPPER] [-C WD]
             [--suite SUITE] [--no-suite SUITE] [--no-stdsplit]
             [--print-errorlogs] [--benchmark] [--logbase LOGBASE]
             [--num-processes NUM_PROCESSES] [-v] [-q]
             [-t TIMEOUT_MULTIPLIER] [--setup SETUP]
             [--test-args TEST_ARGS]
             [args ...]
args
-h, --help show this help message and exit
--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).
--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.
--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

example

Bash
1
2
3
4
#启动测试
meson test -C builddir
#启动测试用例1和2
meson test -C builddir specific_test_1 specific_test_2