関数
このドキュメントでは、meson.build
ファイルで使用可能なすべての関数をリストしています。すべての機能の概要については、ルートマニュアルドキュメントを参照してください。
add_global_arguments()
グローバルな引数をコンパイラのコマンドラインに追加します。
シグネチャ
# Adds global arguments to the compiler command line
void add_global_arguments(
str Compiler argument..., # The compiler arguments to add
# Keyword arguments:
language : list[str] [required] # Specifies the language(s) that the arguments should be
native : bool # A boolean specifying whether the arguments should be
)
通常はadd_project_arguments()
を使用するべきです。なぜなら、プロジェクトがサブプロジェクトとして使用される場合でも機能するからです。
'arg1 arg2', ...
のような文字列ではなく、常にarg1, arg2, ...
のように引数を個別に渡す必要があります。
引数
この関数は、0
から無限大
の可変引数(Compiler argument...
)を
型で受け取ります。str
追加するコンパイラの引数
関数add_global_arguments()
は、次のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
language |
list [str ] |
引数を適用する言語を指定します。言語のリストが指定された場合、引数は対応する各コンパイラコマンドラインに追加されます。この方法で設定された引数を削除する方法はないことに注意してください。ターゲットのサブセットでのみ使用される引数がある場合は、ターゲットごとのフラグで指定する必要があります。 |
|
native |
bool |
引数をネイティブコンパイルまたはクロスコンパイルに適用するかどうかを指定するブール値。 |
(0.48.0以降)
|
add_global_link_arguments()
グローバルな引数をリンカーのコマンドラインに追加します。
add_global_arguments()
と同様ですが、引数はリンカーに渡されます。
シグネチャ
# Adds global arguments to the linker command line
void add_global_link_arguments(
str Linker argument..., # The linker arguments to add
# Keyword arguments:
language : list[str] [required] # Specifies the language(s) that the arguments should be
native : bool # A boolean specifying whether the arguments should be
)
通常はadd_project_link_arguments()
を使用するべきです。なぜなら、プロジェクトがサブプロジェクトとして使用される場合でも機能するからです。
'arg1 arg2', ...
のような文字列ではなく、常にarg1, arg2, ...
のように引数を個別に渡す必要があります。
引数
この関数は、0
から無限大
の可変引数(Linker argument...
)を
型で受け取ります。str
追加するリンカーの引数
関数add_global_link_arguments()
は、次のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
language |
list [str ] |
引数を適用する言語を指定します。言語のリストが指定された場合、引数は対応する各コンパイラコマンドラインに追加されます。この方法で設定された引数を削除する方法はないことに注意してください。ターゲットのサブセットでのみ使用される引数がある場合は、ターゲットごとのフラグで指定する必要があります。 |
|
native |
bool |
引数をネイティブコンパイルまたはクロスコンパイルに適用するかどうかを指定するブール値。 |
(0.48.0以降)
|
add_languages()
プロジェクトで使用されるプログラミング言語を追加します。
これは、project
宣言に言語を含めることと同等です。この関数は通常、特定の条件下でのみ使用される言語を追加するために使用されます。
指定されたすべての言語が見つかった場合はtrue
、そうでない場合はfalse
を返します。
native
が省略された場合、言語はビルドマシンまたはホストマシンのいずれかに使用できますが、ビルドマシンには必須ではありません。(つまり、add_languages(*langs*, native: false, required: *required*) and add_languages(*langs*, native: true, required: false)
と同等です。このデフォルトの動作は、将来のMesonバージョンでnative: false
に変更される可能性があります。)
シグネチャ
# Add programming languages used by the project
bool add_languages(
str Language..., # The languages to add
# Keyword arguments:
native : bool # If set to `true`, the language will be used to compile for the build
required : bool | feature # If set to `true`, Meson will halt if any of the languages
)
例
project('foobar', 'c')
if compiling_for_osx
add_languages('objc')
endif
if add_languages('cpp', required : false)
executable('cpp-app', 'main.cpp')
endif
# More code...
引数
この関数は、0
から無限大
の可変引数(Language...
)を
型で受け取ります。str
追加する言語
関数add_languages()
は、次のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
native |
bool |
|
(0.54.0以降) |
required |
bool | feature |
|
|
add_project_arguments()
プロジェクト固有の引数をコンパイラのコマンドラインに追加します。
この関数は、add_global_arguments()
と同じように動作しますが、引数は現在のプロジェクトでのみ使用され、他のサブプロジェクトでは使用されません。
シグネチャ
# Adds project specific arguments to the compiler command line
void add_project_arguments(
str Compiler argument..., # The compiler arguments to add
# Keyword arguments:
language : list[str] [required] # Specifies the language(s) that the arguments should be
native : bool # A boolean specifying whether the arguments should be
)
'arg1 arg2', ...
のような文字列ではなく、常にarg1, arg2, ...
のように引数を個別に渡す必要があります。
引数
この関数は、0
から無限大
の可変引数(Compiler argument...
)を
型で受け取ります。str
追加するコンパイラの引数
関数add_project_arguments()
は、次のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
language |
list [str ] |
引数を適用する言語を指定します。言語のリストが指定された場合、引数は対応する各コンパイラコマンドラインに追加されます。この方法で設定された引数を削除する方法はないことに注意してください。ターゲットのサブセットでのみ使用される引数がある場合は、ターゲットごとのフラグで指定する必要があります。 |
|
native |
bool |
引数をネイティブコンパイルまたはクロスコンパイルに適用するかどうかを指定するブール値。 |
(0.48.0以降)
|
add_project_dependencies()
コンパイラとリンカーのコマンドラインに引数を追加して、指定された依存関係のセットがこのプロジェクトのすべてのビルド製品に含まれるようにします。
シグネチャ
(0.63.0以降)
# Adds arguments to the compiler and linker command line, so that the
void add_project_dependencies(
dep dependencies..., # The dependencies to add; if internal dependencies are included, they must not include any built object
# Keyword arguments:
language : list[str] [required] # Specifies the language(s) that the arguments should be
native : bool # A boolean specifying whether the arguments should be
)
引数
この関数は、0
から無限大
の可変引数(dependencies...
)を
型で受け取ります。dep
追加する依存関係。内部依存関係が含まれる場合、ビルドされたオブジェクトを含めてはなりません。
関数add_project_dependencies()
は、次のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
language |
list [str ] |
引数を適用する言語を指定します。言語のリストが指定された場合、引数は対応する各コンパイラコマンドラインに追加されます。この方法で設定された引数を削除する方法はないことに注意してください。ターゲットのサブセットでのみ使用される引数がある場合は、ターゲットごとのフラグで指定する必要があります。 |
|
native |
bool |
引数をネイティブコンパイルまたはクロスコンパイルに適用するかどうかを指定するブール値。 |
(0.48.0以降)
|
add_project_link_arguments()
プロジェクト固有の引数をリンカーのコマンドラインに追加します。
add_project_arguments()
と同様ですが、引数はリンカーに渡されます。
シグネチャ
# Adds project specific arguments to the linker command line
void add_project_link_arguments(
str Linker argument..., # The linker arguments to add
# Keyword arguments:
language : list[str] [required] # Specifies the language(s) that the arguments should be
native : bool # A boolean specifying whether the arguments should be
)
'arg1 arg2', ...
のような文字列ではなく、常にarg1, arg2, ...
のように引数を個別に渡す必要があります。
引数
この関数は、0
から無限大
の可変引数(Linker argument...
)を
型で受け取ります。str
追加するリンカーの引数
関数add_project_link_arguments()
は、次のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
language |
list [str ] |
引数を適用する言語を指定します。言語のリストが指定された場合、引数は対応する各コンパイラコマンドラインに追加されます。この方法で設定された引数を削除する方法はないことに注意してください。ターゲットのサブセットでのみ使用される引数がある場合は、ターゲットごとのフラグで指定する必要があります。 |
|
native |
bool |
引数をネイティブコンパイルまたはクロスコンパイルに適用するかどうかを指定するブール値。 |
(0.48.0以降)
|
add_test_setup()
カスタムテスト設定を追加します。この設定は、例えばValgrindの下でカスタム設定でテストを実行するために使用できます。
テスト設定を使用するには、ビルドディレクトリ内でmeson test --setup=*name*
を実行します。
これらのオプションはすべて、バックエンドに応じてninja test
またはmsbuild RUN_TESTS.vcxproj
などの代わりにテストを実行するためのmeson test
スクリプトの実行中にも使用できることに注意してください。
シグネチャ
# Add a custom test setup
void add_test_setup(
str name, # The name of the test setup
# Keyword arguments:
env : env | list[str] | dict[str] # environment variables to set
exclude_suites : list[str] # A list of test suites that should be excluded when using this setup
exe_wrapper : list[str | external_program] # The command or script followed by the arguments to it
gdb : bool # If `true`, the tests are also run under `gdb`
is_default : bool # Set whether this is the default test setup
timeout_multiplier : int # A number to multiply the test timeout with
)
引数
関数add_test_setup()
は、次の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
name |
str |
テスト設定の名前 |
|
最後に、add_test_setup()
は、次のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
env |
env | list [str ] | dict [str ] |
|
|
exclude_suites |
list [str ] |
この設定を使用するときに除外する必要があるテストスイートのリスト。 |
(0.57.0以降) |
exe_wrapper |
list [str | external_program ] |
コマンドまたはスクリプトの後にその引数が続きます |
|
gdb |
bool |
|
|
is_default |
bool |
これがデフォルトのテスト設定であるかどうかを設定します。 |
(0.49.0以降)
|
timeout_multiplier |
int |
テストタイムアウトを乗算する数値。0.57以降、timeout_multiplierが |
|
alias_target()
この関数は、新しいトップレベルターゲットを作成します。すべてのトップレベルターゲットと同様に、これは選択されたバックエンドと統合されます。たとえば、meson compile target_name
として実行できます。これは、コマンドを実行しないダミーターゲットですが、すべての依存関係がビルドされることを保証します。依存関係は、任意のビルドターゲットにすることができます。0.60.0以降、これにはrun_tgt
が含まれます。
1.6.0以降、both_libs
オブジェクトを渡すと、共有ライブラリと静的ライブラリの両方がビルドされます。
シグネチャ
(0.52.0以降)
# This function creates a new top-level target
alias_tgt alias_target(
str target_name, # The name of the alias target
tgt Dep..., # The targets to depend on
)
引数
関数alias_target()
は、次の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
target_name |
str |
エイリアスターゲットの名前 |
|
さらに、この関数は、1
から無限大
の可変引数(Dep...
)を
型で受け取ります。tgt
依存するターゲット
assert()
condition
がfalse
と評価された場合、エラーメッセージで中止します。
シグネチャ
# Abort with an error message if `condition` evaluates to `false`
void assert(
bool condition, # Abort if this evaluates to `false`
str [message], # The error message to print
)
message
引数は0.53.0以降はオプションであり、デフォルトで条件文を出力します。
引数
関数assert()
は、次の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
condition |
bool |
これが |
|
message |
str |
出力するエラーメッセージ。 |
[オプション] |
benchmark()
ベンチマークターゲットが実行されたときに実行されるベンチマーク項目を作成します。この関数の動作は、次の点を除いてtest()
と同じです。
- ベンチマークは並行して実行されないため、benchmark()には
is_parallel
キーワードがありません - benchmark()は、
MALLOC_PERTURB_
環境変数を自動的に追加しません
定義されたベンチマークは、ビルドディレクトリ内でmeson test --benchmark
を呼び出すか、ninja benchmark
またはmsbuild RUN_TESTS.vcxproj
などのバックエンド固有のコマンドを使用して、バックエンドに依存しない方法で実行できます。
シグネチャ
# Creates a benchmark item that will be run when the benchmark target is
void benchmark(
str name, # The *unique* test id
exe | jar | external_program | file | custom_tgt | custom_idx executable, # The program to execute
# Keyword arguments:
args : list[str | file | tgt | external_program] # Arguments to pass to the executable
depends : list[build_tgt | custom_tgt] # specifies that this test depends on the specified
env : env | list[str] | dict[str] # environment variables to set, such as `['NAME1=value1',
priority : int # specifies the priority of a test
protocol : str # specifies how the test results are parsed and can
should_fail : bool # when true the test is considered passed if the
suite : str | list[str] # `'label'` (or list of labels `['label1', 'label2']`)
timeout : int # the amount of seconds the test is allowed to run, a test
verbose : bool # if true, forces the test results to be logged as if `--verbose` was passed
workdir : str # absolute path that will be used as the working directory
)
0.52.0より前のベンチマークでは、depends
とpriority
がサポートされていないという警告が表示されていましたが、これは誤りです。
引数
関数benchmark()
は、次の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
name |
str |
一意のテストID |
|
executable |
exe | jar | external_program | file | custom_tgt | custom_idx |
実行するプログラム。(1.4.0以降)CustomTargetも受け入れられます。 |
|
最後に、benchmark()
は、次のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
args |
list [str | file | tgt | external_program ] |
実行可能ファイルに渡す引数 |
|
depends |
list [build_tgt | custom_tgt ] |
このテストが、コマンドライン引数として使用しない場合でも、指定されたターゲットに依存することを指定します。これは、テストが内部的にこれらのターゲット、たとえばプラグインまたはグロブを見つける場合に役立ちます。これらのターゲットは、 |
(0.46.0以降) |
env |
env | list [str ] | dict [str ] |
|
|
priority |
int |
テストの優先度を指定します。優先度が高いテストは、優先度が低いテストよりも先に開始されます。同一の優先度を持つテストの開始順序は実装によって定義されます。デフォルトの優先度は0で、負の数も許可されます。 |
(0.52.0以降)
|
protocol |
str |
テスト結果の解析方法を指定します。
|
(0.50.0以降)
|
should_fail |
bool |
trueの場合、実行ファイルがゼロ以外のリターン値を返した場合(つまりエラーを報告した場合)にテストは成功とみなされます。 |
|
suite |
str | list [str ] |
このテストに付加される |
|
timeout |
int |
テストの実行が許可される秒数。制限時間を超えたテストは常に失敗とみなされます。デフォルトは30秒です。0.57以降、タイムアウトが |
|
verbose |
bool |
trueの場合、 |
(0.62.0以降)
|
workdir |
str |
テストの作業ディレクトリとして使用される絶対パス |
|
both_libraries()
指定されたソースから、スタティックライブラリと共有ライブラリの両方をビルドします。位置引数とキーワード引数は、library()
と同じです。ソースファイルは1回だけコンパイルされ、オブジェクトファイルは共有ライブラリとスタティックライブラリの両方のビルドに再利用されます。ただし、b_staticpic
ユーザーオプションまたはpic
引数がfalseに設定されている場合は、ソースが2回コンパイルされます。
シグネチャ
(0.46.0以降)
# Builds both a static and shared library with the given sources
both_libs both_libraries(
str target_name, # The *unique* name of the build target
str | file | custom_tgt | custom_idx | generated_list source..., # Input source to compile
# Keyword arguments:
<lang>_args : list[str] # compiler flags to use for the given language;
<lang>_pch : str # precompiled header file to use for the given language
<lang>_shared_args : list[str] # Arguments that are only passed to a shared library
<lang>_static_args : list[str] # Arguments that are only passed to a static library
build_by_default : bool # Causes, when set to `true`, to have this target be built by default
build_rpath : str # A string to add to target's rpath definition in the build dir,
d_debug : list[str] # The [D version identifiers](https://dlang
d_import_dirs : list[inc | str] # the directories to add to the string search path (i
d_module_versions : list[str | int] # List of module version identifiers set when compiling D sources
d_unittest : bool # When set to true, the D modules are compiled in debug mode
darwin_versions : str | int | list[str] # Defines the `compatibility version` and `current version` for the dylib on macOS
dependencies : list[dep] # one or more dependency objects
extra_files : str | file | custom_tgt | custom_idx # Not used for the build itself but are shown as source files in IDEs
gnu_symbol_visibility : str # Specifies how symbols should be exported, see
gui_app : bool # When set to true flags this target as a GUI application
implicit_include_directories : bool # Controls whether Meson adds the current source and build directories to the include path
include_directories : list[inc | str] # one or more objects created with the include_directories()
function,
install : bool # When set to true, this executable should be installed
install_dir : str # override install directory for this file
install_mode : list[str | int] # Specify the file mode in symbolic format
install_rpath : str # A string to set the target's rpath to after install
install_tag : str # A string used by the `meson install --tags` command
link_args : list[str] # Flags to use during linking
link_depends : str | file | custom_tgt | custom_idx # Strings, files, or custom targets the link step depends on
link_language : str # Makes the linker for this target be for the specified language
link_whole : list[lib | custom_tgt | custom_idx] # Links all contents of the given static libraries whether they are used or
link_with : list[lib | custom_tgt | custom_idx] # One or more shared or static libraries
name_prefix : str | list[void] # The string that will be used as the prefix for the
name_suffix : str | list[void] # The string that will be used as the extension for the
native : bool # Controls whether the target is compiled for the build or host machines
objects : list[extracted_obj | file | str] # List of object files that should be linked in this target
override_options : list[str] | dict[str | bool | int | list[str]] # takes an array of strings in the same format as `project`'s `default_options`
pic : bool # Builds the library as positional independent code
prelink : bool # If `true` the object files in the target will be prelinked,
rust_abi : str # Set the specific ABI to compile (when compiling rust)
rust_crate_type : str # Set the specific type of rust crate to compile (when compiling rust)
rust_dependency_map : dict[str] # On rust targets this provides a map of library names to the crate name
sources : str | file | custom_tgt | custom_idx | generated_list | structured_src # Additional source files
soversion : str | int # A string or integer specifying the soversion of this shared library,
vala_args : list[str | file] # Compiler flags for Vala
vala_shared_args : list[str | file] # Arguments that are only passed to a shared library
vala_static_args : list[str | file] # Arguments that are only passed to a static library
version : str # A string specifying the version of this shared library,
vs_module_defs : str | file | custom_tgt | custom_idx # Specify a Microsoft module definition file for controlling symbol exports,
win_subsystem : str # Specifies the subsystem type to use
)
引数
関数both_libraries()
は、以下の位置引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
target_name |
str |
ビルドターゲットの一意な名前 |
|
さらに、関数は0
から無限
の可変長引数(source...
)を、
型で受け付けます。str
| file
| custom_tgt
| custom_idx
| generated_list
コンパイルする入力ソース。以下の型がサポートされています。
- 現在のソースディレクトリからの相対パスを表す文字列
-
先行するビルドファイルで定義された
file
オブジェクト configure_file()
などの設定時ジェネレーターの戻り値custom_target()
やgenerator.process()
などのビルド時ジェネレーターの戻り値
これらの入力ファイルは、ソース、オブジェクト、ライブラリ、その他のファイルにすることができます。Mesonは、拡張子に基づいて自動的に分類し、それに応じて使用します。たとえば、ソース(.c
、.cpp
、.vala
、.rs
など)はコンパイルされ、オブジェクト(.o
、.obj
)とライブラリ(.so
、.dll
など)はリンクされます。
Ninjaバックエンドでは、Mesonは、不明なファイルを含め、すべての生成された入力ファイルに対するビルド時順序のみの依存関係を作成します。これは、コンパイラーによって生成されたdepfileで実際の依存関係の生成をブートストラップし、ソースをいつリビルドするかを判断するために必要です。Ninjaは、生成されたファイルと生成されていないファイルの両方について、すべての入力ファイルに対してこの依存関係ファイルを使用します。この動作は他のバックエンドでも同様です。
最後に、both_libraries()
は以下のキーワード引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
<lang>_args |
list [str ] |
特定の言語で使用するコンパイラーフラグ。例:C++の場合は |
|
<lang>_pch |
str |
特定の言語で使用するプリコンパイル済みヘッダーファイル |
|
<lang>_shared_args |
list [str ] |
共有ライブラリにのみ渡される引数 |
(1.3.0以降) |
<lang>_static_args |
list [str ] |
スタティックライブラリにのみ渡される引数 |
(1.3.0以降) |
build_by_default |
bool |
|
(0.38.0以降)
|
build_rpath |
str |
ビルドディレクトリでターゲットのrpath定義に追加される文字列ですが、インストール時に削除されます。 |
(0.42.0以降) |
d_debug |
list [str ] |
Dソースファイルのコンパイル中に追加するDバージョン識別子。 |
|
d_import_dirs |
list [inc | str ] |
文字列検索パスに追加するディレクトリ(つまりDMDの |
(0.62.0以降) |
d_module_versions |
list [str | int ] |
Dソースのコンパイル時に設定されるモジュールバージョン識別子のリスト。 |
|
d_unittest |
bool |
trueに設定すると、Dモジュールはデバッグモードでコンパイルされます。 |
|
darwin_versions |
str | int | list [str ] |
macOSのdylibの |
(0.48.0以降) |
dependencies |
list [dep ] |
|
|
extra_files |
str | file | custom_tgt | custom_idx |
ビルド自体には使用されませんが、ターゲット別にファイルをグループ化するIDE(Visual Studioなど)ではソースファイルとして表示されます。 |
|
gnu_symbol_visibility |
str |
シンボルをエクスポートする方法を指定します。詳細については、たとえばGCC Wikiを参照してください。この値は、空の文字列または |
(0.48.0以降) |
gui_app |
bool |
trueに設定すると、このターゲットをGUIアプリケーションとしてプラットフォームで区別する必要がある場合にフラグを立てます。0.56.0以降は非推奨です。代わりに |
非推奨 0.56.0で
|
implicit_include_directories |
bool |
Mesonが現在のソースディレクトリとビルドディレクトリをインクルードパスに追加するかどうかを制御します |
(0.42.0以降)
|
include_directories |
list [inc | str ] |
|
|
install |
bool |
trueに設定すると、この実行可能ファイルがインストールされます。 |
|
install_dir |
str |
このファイルのインストールディレクトリを上書きします。値が相対パスの場合、 |
|
install_mode |
list [str | int ] |
インストールされたファイルのシンボリック形式でのファイルモード、およびオプションで所有者/uidとグループ/gidを指定します。 詳細については、 |
(0.47.0以降) |
install_rpath |
str |
インストール後にターゲットのrpathを設定する文字列(ただし、その前ではありません)。Windowsでは、この引数は効果がありません。 |
|
install_tag |
str |
|
(0.60.0以降) |
link_args |
list [str ] |
リンク中に使用するフラグ。すべてのプラットフォームでUNIXスタイルのフラグを使用できます。 |
|
link_depends |
str | file | custom_tgt | custom_idx |
シンボルvisibilityマップなど、リンクステップが依存する文字列、ファイル、またはカスタムターゲット。目的は、このファイルが変更されたときにターゲットの再リンク(ただし再コンパイルではない)を自動的にトリガーすることです。 |
|
link_language |
str |
このターゲットのリンカーを特定の言語にするようにします。通常、Mesonはほとんどの場合正しいリンカーを検出するため、これを設定する必要はありません。これが必要になるのは2つのケースだけです。1つは、実行可能ファイルのメイン関数がMesonが選択した言語ではない場合、もう1つは、ライブラリに1つのABIのみを使用するように強制する場合です。 (0.55.0まで破損) |
(0.51.0以降) |
link_whole |
list [lib | custom_tgt | custom_idx ] |
与えられた静的ライブラリのすべてのコンテンツを、使用されているかどうかに関わらずリンクします。GCCの (0.41.0以降)リストが渡された場合、そのリストは平坦化されます。 (0.51.0以降)この引数は、カスタムターゲットによって生成された出力も受け入れます。ユーザーは、出力が正しい形式のライブラリであることを確認する必要があります。 |
(0.40.0以降) |
link_with |
list [lib | custom_tgt | custom_idx ] |
このターゲットがリンクされるべき、このプロジェクトでビルドされた1つ以上の共有または静的ライブラリ。(0.41.0以降)リストが渡された場合、このリストは平坦化されます。(0.51.0以降)引数はカスタムターゲットにすることもできます。この場合、Mesonはリンカーコマンドラインに出力ファイルを追加するだけでリンクが機能すると想定します。これが十分でない場合、ビルドシステムの作成者は他のすべてのステップを手動で記述する必要があります。 |
|
name_prefix |
str | list [void ] |
ターゲット出力ファイル名のプレフィックスとして使用される文字列。デフォルトを上書きします(ライブラリでのみ使用)。デフォルトでは、MSVC共有ライブラリでは規約に従って省略され、Cygwin共有ライブラリでは デフォルトの動作を使用するには、これを |
|
name_suffix |
str | list [void ] |
デフォルトを上書きして、ターゲットの拡張子として使用される文字列。デフォルトでは、Windowsでは実行可能ファイルは 共有ライブラリの場合、デフォルト値はmacOSでは デフォルトの動作を使用するには、これを |
|
native |
bool |
ターゲットがビルドマシンまたはホストマシン用にコンパイルされるかどうかを制御します。 |
|
objects |
list [extracted_obj | file | str ] |
このターゲットにリンクする必要があるオブジェクトファイルのリスト。 1.1.0以降、ソースがないオブジェクトファイルや、他のビルドターゲットによって生成されたオブジェクトファイルに加えて、生成されたファイルを含めることができます。以前のリリースでは、生成されたオブジェクトファイルを |
|
override_options |
list [str ] | dict [str | bool | int | list [str ]] |
|
(0.40.0以降) |
pic |
bool |
ライブラリを位置独立コードとしてビルドします(共有ライブラリにリンクできるように)。このオプションはWindowsとOS Xでは意味がないため、効果がありません。Windowsでは意味がなく、OS XではPICを無効にできないためです。 |
(0.36.0以降) |
prelink |
bool |
|
(0.57.0以降) |
rust_abi |
str |
(Rustをコンパイルする際に)コンパイルする特定のABIを設定します。
|
(1.3.0以降) |
rust_crate_type |
str |
(Rustをコンパイルする際に)コンパイルする特定のRustクレートのタイプを設定します。 ターゲットが それが それが 「proc-macro」は0.62.0の新機能です。 1.3.0以降、これは非推奨となり、「rust_abi」キーワード引数に置き換えられました。 |
(0.42.0以降) 非推奨 1.3.0で |
rust_dependency_map |
dict [str ] |
Rustターゲットの場合、これはライブラリ名から、Rustコード内で利用可能になるクレート名へのマップを提供します。 これにより、cargoの依存関係の名前変更機能や、Rustコード内の |
(1.2.0以降) |
sources |
str | file | custom_tgt | custom_idx | generated_list | structured_src |
追加のソースファイル。source可変長引数と同じです。 |
|
soversion |
str | int |
この共有ライブラリのsoversionを指定する文字列または整数( |
|
vala_args |
list [str | file ] |
Valaのコンパイラフラグ。他の言語とは異なり、これにはファイルを含めることができます。 |
|
vala_shared_args |
list [str | file ] |
共有ライブラリにのみ渡される引数。 |
(1.3.0以降) |
vala_static_args |
list [str | file ] |
静的ライブラリにのみ渡される引数。 |
(1.3.0以降) |
version |
str |
この共有ライブラリのバージョンを指定する文字列( |
|
vs_module_defs |
str | file | custom_tgt | custom_idx |
シンボルのエクスポートなどを制御するためのMicrosoftモジュール定義ファイルを、それが可能なプラットフォーム(例:Windows)で指定します。 (1.3.0以降) |
|
win_subsystem |
str |
Windowsプラットフォームで使用するサブシステムタイプを指定します。一般的な値には、テキストモードプログラムの場合は |
(0.56.0以降)
|
build_target()
target_type
キーワード引数を使用して、型を動的に設定できるビルドターゲットを作成します。
target_type
は、次のいずれかに設定できます。
-
executable
(executable()
を参照) -
shared_library
(shared_library()
を参照) -
shared_module
(shared_module()
を参照) -
static_library
(static_library()
を参照) -
both_libraries
(both_libraries()
を参照) -
library
(library()
を参照) -
jar
(jar()
を参照)*
この宣言
executable(<arguments and keyword arguments>)
はこれと同等です
build_target(<arguments and keyword arguments>, target_type : 'executable')
kwargs(sources
、objects
、dependencies
など)のリストは常に平坦化されます。つまり、最終的なリストを作成する際に、自由にリストをネストおよび追加できます。
返されたオブジェクトには、build_tgt
で説明されているメソッドもあります。
*「jar」は、他のbuild_targetタイプとは根本的に異なるため、非推奨になりました。
シグネチャ
# Creates a build target whose type can be set dynamically with the
build_tgt build_target(
str target_name, # The *unique* name of the build target
str | file | custom_tgt | custom_idx | generated_list source..., # Input source to compile
# Keyword arguments:
<lang>_args : list[str] # compiler flags to use for the given language;
<lang>_pch : str # precompiled header file to use for the given language
<lang>_shared_args : list[str] # Arguments that are only passed to a shared library
<lang>_static_args : list[str] # Arguments that are only passed to a static library
build_by_default : bool # Causes, when set to `true`, to have this target be built by default
build_rpath : str # A string to add to target's rpath definition in the build dir,
d_debug : list[str] # The [D version identifiers](https://dlang
d_import_dirs : list[inc | str] # the directories to add to the string search path (i
d_module_versions : list[str | int] # List of module version identifiers set when compiling D sources
d_unittest : bool # When set to true, the D modules are compiled in debug mode
darwin_versions : str | int | list[str] # Defines the `compatibility version` and `current version` for the dylib on macOS
dependencies : list[dep] # one or more dependency objects
export_dynamic : bool # when set to true causes the target's symbols to be
extra_files : str | file | custom_tgt | custom_idx # Not used for the build itself but are shown as source files in IDEs
gnu_symbol_visibility : str # Specifies how symbols should be exported, see
gui_app : bool # When set to true flags this target as a GUI application
implib : bool | str # When set to true, an import library is generated for the
implicit_include_directories : bool # Controls whether Meson adds the current source and build directories to the include path
include_directories : list[inc | str] # one or more objects created with the include_directories()
function,
install : bool # When set to true, this executable should be installed
install_dir : str # override install directory for this file
install_mode : list[str | int] # Specify the file mode in symbolic format
install_rpath : str # A string to set the target's rpath to after install
install_tag : str # A string used by the `meson install --tags` command
java_resources : structured_src # Resources to be added to the jar
link_args : list[str] # Flags to use during linking
link_depends : str | file | custom_tgt | custom_idx # Strings, files, or custom targets the link step depends on
link_language : str # Makes the linker for this target be for the specified language
link_whole : list[lib | custom_tgt | custom_idx] # Links all contents of the given static libraries whether they are used or
link_with : list[lib | custom_tgt | custom_idx] # One or more shared or static libraries
main_class : str # Main class for running the built jar
name_prefix : str | list[void] # The string that will be used as the prefix for the
name_suffix : str | list[void] # The string that will be used as the extension for the
native : bool # Controls whether the target is compiled for the build or host machines
objects : list[extracted_obj | file | str] # List of object files that should be linked in this target
override_options : list[str] | dict[str | bool | int | list[str]] # takes an array of strings in the same format as `project`'s `default_options`
pic : bool # Builds the library as positional independent code
pie : bool # Build a position-independent executable
prelink : bool # If `true` the object files in the target will be prelinked,
rust_abi : str # Set the specific ABI to compile (when compiling rust)
rust_crate_type : str # Set the specific type of rust crate to compile (when compiling rust)
rust_dependency_map : dict[str] # On rust targets this provides a map of library names to the crate name
sources : str | file | custom_tgt | custom_idx | generated_list | structured_src # Additional source files
soversion : str | int # A string or integer specifying the soversion of this shared library,
target_type : str # The actual target type to build
vala_args : list[str | file] # Compiler flags for Vala
vala_shared_args : list[str | file] # Arguments that are only passed to a shared library
vala_static_args : list[str | file] # Arguments that are only passed to a static library
version : str # A string specifying the version of this shared library,
vs_module_defs : str | file | custom_tgt | custom_idx # Specify a Microsoft module definition file for controlling symbol exports,
win_subsystem : str # Specifies the subsystem type to use
)
引数
関数build_target()
は、次の位置引数を受け入れます
名前 | 型 | 説明 | タグ |
---|---|---|---|
target_name |
str |
ビルドターゲットの一意な名前 |
|
さらに、関数は0
から無限
の可変長引数(source...
)を、
型で受け付けます。str
| file
| custom_tgt
| custom_idx
| generated_list
コンパイルする入力ソース。以下の型がサポートされています。
- 現在のソースディレクトリからの相対パスを表す文字列
-
先行するビルドファイルで定義された
file
オブジェクト configure_file()
などの設定時ジェネレーターの戻り値custom_target()
やgenerator.process()
などのビルド時ジェネレーターの戻り値
これらの入力ファイルは、ソース、オブジェクト、ライブラリ、その他のファイルにすることができます。Mesonは、拡張子に基づいて自動的に分類し、それに応じて使用します。たとえば、ソース(.c
、.cpp
、.vala
、.rs
など)はコンパイルされ、オブジェクト(.o
、.obj
)とライブラリ(.so
、.dll
など)はリンクされます。
Ninjaバックエンドでは、Mesonは、不明なファイルを含め、すべての生成された入力ファイルに対するビルド時順序のみの依存関係を作成します。これは、コンパイラーによって生成されたdepfileで実際の依存関係の生成をブートストラップし、ソースをいつリビルドするかを判断するために必要です。Ninjaは、生成されたファイルと生成されていないファイルの両方について、すべての入力ファイルに対してこの依存関係ファイルを使用します。この動作は他のバックエンドでも同様です。
最後に、build_target()
は次のキーワード引数を受け入れます
名前 | 型 | 説明 | タグ |
---|---|---|---|
<lang>_args |
list [str ] |
特定の言語で使用するコンパイラーフラグ。例:C++の場合は |
|
<lang>_pch |
str |
特定の言語で使用するプリコンパイル済みヘッダーファイル |
|
<lang>_shared_args |
list [str ] |
共有ライブラリにのみ渡される引数 |
(1.3.0以降) |
<lang>_static_args |
list [str ] |
スタティックライブラリにのみ渡される引数 |
(1.3.0以降) |
build_by_default |
bool |
|
(0.38.0以降)
|
build_rpath |
str |
ビルドディレクトリでターゲットのrpath定義に追加される文字列ですが、インストール時に削除されます。 |
(0.42.0以降) |
d_debug |
list [str ] |
Dソースファイルのコンパイル中に追加するDバージョン識別子。 |
|
d_import_dirs |
list [inc | str ] |
文字列検索パスに追加するディレクトリ(つまりDMDの |
(0.62.0以降) |
d_module_versions |
list [str | int ] |
Dソースのコンパイル時に設定されるモジュールバージョン識別子のリスト。 |
|
d_unittest |
bool |
trueに設定すると、Dモジュールはデバッグモードでコンパイルされます。 |
|
darwin_versions |
str | int | list [str ] |
macOSのdylibの |
(0.48.0以降) |
dependencies |
list [dep ] |
|
|
export_dynamic |
bool |
trueに設定すると、ターゲットのシンボルが動的にエクスポートされ、 |
(0.45.0以降) |
extra_files |
str | file | custom_tgt | custom_idx |
ビルド自体には使用されませんが、ターゲット別にファイルをグループ化するIDE(Visual Studioなど)ではソースファイルとして表示されます。 |
|
gnu_symbol_visibility |
str |
シンボルをエクスポートする方法を指定します。詳細については、たとえばGCC Wikiを参照してください。この値は、空の文字列または |
(0.48.0以降) |
gui_app |
bool |
trueに設定すると、このターゲットをGUIアプリケーションとしてプラットフォームで区別する必要がある場合にフラグを立てます。0.56.0以降は非推奨です。代わりに |
非推奨 0.56.0で
|
implib |
bool | str |
trueに設定すると、実行可能ファイルのインポートライブラリが生成されます(インポートライブラリの名前はexe_nameに基づいています)。または、文字列に設定すると、インポートライブラリのベース名が指定されます。返されたビルドターゲットオブジェクトが別の場所の |
(0.42.0以降) |
implicit_include_directories |
bool |
Mesonが現在のソースディレクトリとビルドディレクトリをインクルードパスに追加するかどうかを制御します |
(0.42.0以降)
|
include_directories |
list [inc | str ] |
|
|
install |
bool |
trueに設定すると、この実行可能ファイルがインストールされます。 |
|
install_dir |
str |
このファイルのインストールディレクトリを上書きします。値が相対パスの場合、 |
|
install_mode |
list [str | int ] |
インストールされたファイルのシンボリック形式でのファイルモード、およびオプションで所有者/uidとグループ/gidを指定します。 詳細については、 |
(0.47.0以降) |
install_rpath |
str |
インストール後にターゲットのrpathを設定する文字列(ただし、その前ではありません)。Windowsでは、この引数は効果がありません。 |
|
install_tag |
str |
|
(0.60.0以降) |
java_resources |
structured_src |
jarに追加されるリソース |
(0.62.0以降) |
link_args |
list [str ] |
リンク中に使用するフラグ。すべてのプラットフォームでUNIXスタイルのフラグを使用できます。 |
|
link_depends |
str | file | custom_tgt | custom_idx |
シンボルvisibilityマップなど、リンクステップが依存する文字列、ファイル、またはカスタムターゲット。目的は、このファイルが変更されたときにターゲットの再リンク(ただし再コンパイルではない)を自動的にトリガーすることです。 |
|
link_language |
str |
このターゲットのリンカーを特定の言語にするようにします。通常、Mesonはほとんどの場合正しいリンカーを検出するため、これを設定する必要はありません。これが必要になるのは2つのケースだけです。1つは、実行可能ファイルのメイン関数がMesonが選択した言語ではない場合、もう1つは、ライブラリに1つのABIのみを使用するように強制する場合です。 (0.55.0まで破損) |
(0.51.0以降) |
link_whole |
list [lib | custom_tgt | custom_idx ] |
与えられた静的ライブラリのすべてのコンテンツを、使用されているかどうかに関わらずリンクします。GCCの (0.41.0以降)リストが渡された場合、そのリストは平坦化されます。 (0.51.0以降)この引数は、カスタムターゲットによって生成された出力も受け入れます。ユーザーは、出力が正しい形式のライブラリであることを確認する必要があります。 |
(0.40.0以降) |
link_with |
list [lib | custom_tgt | custom_idx ] |
このターゲットがリンクされるべき、このプロジェクトでビルドされた1つ以上の共有または静的ライブラリ。(0.41.0以降)リストが渡された場合、このリストは平坦化されます。(0.51.0以降)引数はカスタムターゲットにすることもできます。この場合、Mesonはリンカーコマンドラインに出力ファイルを追加するだけでリンクが機能すると想定します。これが十分でない場合、ビルドシステムの作成者は他のすべてのステップを手動で記述する必要があります。 |
|
main_class |
str |
ビルドされたjarを実行するためのメインクラス |
|
name_prefix |
str | list [void ] |
ターゲット出力ファイル名のプレフィックスとして使用される文字列。デフォルトを上書きします(ライブラリでのみ使用)。デフォルトでは、MSVC共有ライブラリでは規約に従って省略され、Cygwin共有ライブラリでは デフォルトの動作を使用するには、これを |
|
name_suffix |
str | list [void ] |
デフォルトを上書きして、ターゲットの拡張子として使用される文字列。デフォルトでは、Windowsでは実行可能ファイルは 共有ライブラリの場合、デフォルト値はmacOSでは デフォルトの動作を使用するには、これを |
|
native |
bool |
ターゲットがビルドマシンまたはホストマシン用にコンパイルされるかどうかを制御します。 |
|
objects |
list [extracted_obj | file | str ] |
このターゲットにリンクする必要があるオブジェクトファイルのリスト。 1.1.0以降、ソースがないオブジェクトファイルや、他のビルドターゲットによって生成されたオブジェクトファイルに加えて、生成されたファイルを含めることができます。以前のリリースでは、生成されたオブジェクトファイルを |
|
override_options |
list [str ] | dict [str | bool | int | list [str ]] |
|
(0.40.0以降) |
pic |
bool |
ライブラリを位置独立コードとしてビルドします(共有ライブラリにリンクできるように)。このオプションはWindowsとOS Xでは意味がないため、効果がありません。Windowsでは意味がなく、OS XではPICを無効にできないためです。 |
(0.36.0以降) |
pie |
bool |
位置独立実行可能ファイルをビルドします。 |
(0.49.0以降) |
prelink |
bool |
|
(0.57.0以降) |
rust_abi |
str |
(Rustをコンパイルする際に)コンパイルする特定のABIを設定します。
|
(1.3.0以降) |
rust_crate_type |
str |
(Rustをコンパイルする際に)コンパイルする特定のRustクレートのタイプを設定します。 ターゲットが それが それが 「proc-macro」は0.62.0の新機能です。 1.3.0以降、これは非推奨となり、「rust_abi」キーワード引数に置き換えられました。 |
(0.42.0以降) 非推奨 1.3.0で |
rust_dependency_map |
dict [str ] |
Rustターゲットの場合、これはライブラリ名から、Rustコード内で利用可能になるクレート名へのマップを提供します。 これにより、cargoの依存関係の名前変更機能や、Rustコード内の |
(1.2.0以降) |
sources |
str | file | custom_tgt | custom_idx | generated_list | structured_src |
追加のソースファイル。source可変長引数と同じです。 |
|
soversion |
str | int |
この共有ライブラリのsoversionを指定する文字列または整数( |
|
target_type |
str |
ビルドする実際のターゲットタイプ |
|
vala_args |
list [str | file ] |
Valaのコンパイラフラグ。他の言語とは異なり、これにはファイルを含めることができます。 |
|
vala_shared_args |
list [str | file ] |
共有ライブラリにのみ渡される引数。 |
(1.3.0以降) |
vala_static_args |
list [str | file ] |
静的ライブラリにのみ渡される引数。 |
(1.3.0以降) |
version |
str |
この共有ライブラリのバージョンを指定する文字列( |
|
vs_module_defs |
str | file | custom_tgt | custom_idx |
シンボルのエクスポートなどを制御するためのMicrosoftモジュール定義ファイルを、それが可能なプラットフォーム(例:Windows)で指定します。 これは、実行可能ファイルによってロードされた共有モジュールがどの関数を使用できるかを公開するために使用できます。 |
(1.3.0以降) |
win_subsystem |
str |
Windowsプラットフォームで使用するサブシステムタイプを指定します。一般的な値には、テキストモードプログラムの場合は |
(0.56.0以降)
|
configuration_data()
空の構成オブジェクトを作成します。構成はcfg_data
メソッド呼び出しで追加し、最後にconfigure_file()
の呼び出しで使用する必要があります。
シグネチャ
# Creates an empty configuration object
cfg_data configuration_data(
dict[str | bool | int] [data], # Optional dictionary to specify an initial data set
)
引数
関数configuration_data()
は、以下の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
data |
dict [str | bool | int ] |
初期データセットを指定するためのオプションの辞書。指定された場合、各キー/値ペアは、 |
(0.49.0以降) [オプション] |
configure_file()
この関数は、渡されるキーワード引数に応じて3つのモードで実行できます。
cfg_data
オブジェクトがconfiguration:
キーワード引数に渡されると、input:
(オプション)としてテンプレートファイルを受け取り、構成ファイルドキュメントで詳述されているように、構成データからの値を置換することで、output:
(必須)を生成します。(0.49.0以降) cfg_data
オブジェクトの代わりに辞書を渡すことができます。
文字列のリストがcommand:
キーワード引数に渡されると、任意のソースファイルまたは構成済みファイルをinput:
として受け取り、指定されたコマンドが実行されたときにoutput:
が生成されると想定します。
(0.47.0以降) copy:
キーワード引数がtrue
に設定されている場合、この関数は、input:
で提供されたファイルを、現在のディレクトリのビルドディレクトリ内のoutput:
という名前のファイルにコピーします。
シグネチャ
# This function can run in three modes depending on the keyword arguments
file configure_file(
capture : bool # When this argument is set to true,
command : list[str | file] # As explained above, if specified, Meson does not create
configuration : cfg_data | dict[str | int | bool] # As explained above, when passed this will provide the replacement
copy : bool # As explained above, if specified Meson only
depfile : str # A dependency file that the command can write listing
encoding : str # Set the file encoding for the input and output file
format : str # The format of defines
input : str | file # The input file name
install : bool # When true, this generated file is installed during
install_dir : str # The subdirectory to install the generated file to
install_mode : list[str | int] # Specify the file mode in symbolic format
install_tag : str # A string used by the `meson install --tags` command
macro_name : str # When specified, macro guards will be used instead of '#pragma once'
output : str # The output file name
output_format : str # The format of the output to generate when no input
)
install_mode
kwargは、0.62~1.1.0の間の整数値を無視しました。
引数
関数configure_file()
は、以下のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
capture |
bool |
この引数がtrueに設定されている場合、Mesonは |
(0.41.0以降)
|
command |
list [str | file ] |
上記のように、指定された場合、Mesonはファイル自体を作成するのではなく、指定されたコマンドを実行します。これにより、完全にカスタムのファイル生成を実行できます。(0.52.0以降) コマンドにはファイルオブジェクトを含めることができ、 |
|
configuration |
cfg_data | dict [str | int | bool ] |
上記のように、渡されると、これは入力ファイル(指定されている場合)の置換データ、または出力に書き込まれるキーと値のペアを提供します。 |
|
copy |
bool |
上記のように、指定された場合、Mesonは入力から出力にファイルをコピーするだけです。 |
(0.47.0以降)
|
depfile |
str |
コマンドが、このターゲットが依存する追加のファイルをすべてリストする依存関係ファイル。これらのファイルのいずれかが変更されると、再構成がトリガーされます。 |
(0.52.0以降) |
encoding |
str |
入力ファイルと出力ファイルのファイルエンコーディングを設定します。サポートされているエンコーディングはpython3のエンコーディングであり、standard-encodingsを参照してください。 |
(0.47.0以降)
|
format |
str |
定義の形式。デフォルトは |
(0.46.0以降)
|
input |
str | file |
入力ファイル名。構成モードで指定されていない場合、 |
|
install |
bool |
trueの場合、この生成されたファイルはインストールステップ中にインストールされ、 |
(0.50.0以降)
|
install_dir |
str |
生成されたファイルをインストールするサブディレクトリ(例: |
|
install_mode |
list [str | int ] |
インストールされたファイルのシンボリック形式でのファイルモード、およびオプションで所有者/uidとグループ/gidを指定します。 詳細については、 |
(0.47.0以降) |
install_tag |
str |
|
(0.60.0以降) |
macro_name |
str |
指定された場合、'#pragma once'の代わりにマクロガードが使用されます。マクロガード名は、指定された名前になります。 |
(1.3.0以降) |
output |
str |
出力ファイル名。(0.41.0以降) |
|
output_format |
str |
入力が指定されていない場合に出力を生成する形式。デフォルトは |
(0.47.0以降) |
custom_target()
カスタムのトップレベルのビルドターゲットを作成します。唯一の位置引数は、このターゲットの名前であり、パス区切り文字(/
または\
)を含めることはできません。カスタムターゲットの名前は、すべてのバックエンドで使用されるとは限りません。たとえば、Ninjaバックエンドでは、以下の例を含むsubdir/meson.build
、ninja -C builddir foo
またはninja -C builddir subdir/foo
は機能しません。代わりに、ninja -C builddir subdir/file.txt
になります。ただし、meson compile subdir/foo
は受け入れられます。
custom_target('foo', output: 'file.txt', ...)
0.60.0以降、名前引数はオプションであり、最初の出力のベース名(上記の例ではfile.txt
)がデフォルトになります。
command
キーワード引数に渡される文字列のリストは、以下の特別な文字列置換を受け入れます。
-
@INPUT@
:input
に渡された入力のフルパス。複数の入力が指定されている場合、コマンドがスタンドアロン引数として'@INPUT@'
を使用する場合にのみ、それらすべてが個別の引数として置換されます。たとえば、command : ['cp', './@INPUT@']
は機能しませんが、command : ['cp', '@INPUT@']
は機能します。 -
@OUTPUT@
:output
に渡された出力のフルパス。複数の出力が指定されている場合、動作は@INPUT@
と同じです。 -
@INPUT0@
@INPUT1@
...
:input
で指定された配列インデックスを持つ入力のフルパス -
@OUTPUT0@
@OUTPUT1@
...
:output
で指定された配列インデックスを持つ出力のフルパス -
@OUTDIR@
:出力が書き込まれるディレクトリのフルパス -
@DEPFILE@
:depfile
に渡された依存関係ファイルのフルパス -
@PLAINNAME@
:パスなしの入力ファイル名 -
@PLAINNAME0@
@PLAINNAME1@
...
(1.5.0以降):パスなしの入力ファイル名、input
で指定された配列インデックスを持つ -
@BASENAME@
:拡張子を削除した入力ファイル名 -
@BASENAME0@
@BASENAME1@
...
(1.5.0以降):拡張子を削除した入力ファイル名、input
で指定された配列インデックスを持つ -
@PRIVATE_DIR@
(0.50.1以降):カスタムターゲットがすべての中間ファイルを格納する必要があるディレクトリへのパス。 -
@SOURCE_ROOT@
:ソースツリーのルートへのパス。バックエンドによっては、これは絶対パスであるか、現在の作業ディレクトリへの相対パスである可能性があります。 -
@BUILD_ROOT@
:ビルドツリーのルートへのパス。バックエンドによっては、これは絶対パスであるか、現在の作業ディレクトリへの相対パスである可能性があります。 -
@CURRENT_SOURCE_DIR@
:これは現在処理されているmeson.buildがあるディレクトリです。バックエンドによっては、これは絶対パスであるか、現在の作業ディレクトリへの相対パスである可能性があります。
(0.47.0以降) depfile
キーワード引数も、@BASENAME@
および@PLAINNAME@
置換を受け入れます。
返されるオブジェクトには、custom_tgt
で説明されているメソッドもあります。
シグネチャ
# Create a custom top level build target
custom_tgt custom_target(
str [name], # The *unique* id of the custom target
# Keyword arguments:
build_always : bool # If `true` this target is always considered out of
build_always_stale : bool # If `true` the target is always considered out of date
build_by_default : bool # Causes, when set to true, to
capture : bool # There are some compilers that can't be told to write
command : list[str | file | exe | external_program] # Command to run to create outputs from inputs
console : bool # Keyword argument conflicts with `capture`, and is meant
depend_files : list[str | file] # files (str
,
depends : list[build_tgt | custom_tgt | custom_idx] # Specifies that this target depends on the specified
depfile : str # A dependency file that the command can write listing
env : env | list[str] | dict[str] # environment variables to set, such as
feed : bool # There are some compilers that can't be told to read
input : list[str | file] # List of source files
install : bool # When true, one or more files of this target are installed during the install step (see `install_dir` for details)
install_dir : str | list[str | bool] # If only one install_dir is provided, all outputs are installed there
install_mode : list[str | int] # The file mode and optionally the owner/uid and group/gid
install_tag : list[str] # A list of strings, one per output, used by the `meson install --tags` command
output : list[str] # List of output files
)
command:
がPOSIX sh
シェルによって実行されると想定することは、特にWindowsには移植可能ではありません。代わりに、native: true
executable()
、またはpythonスクリプトを使用することを検討してください。
install_mode
kwargは、0.60.0~1.1.0の間の整数値を無視しました。
引数
関数custom_target()
は、以下の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
name |
str |
カスタムターゲットの一意のID このposargは0.60.0以降オプションです。デフォルトは最初の出力のベース名です。 |
[オプション] |
最後に、custom_target()
は以下のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
build_always |
bool |
|
非推奨 0.47.0で |
build_always_stale |
bool |
|
(0.47.0以降)
|
build_by_default |
bool |
trueに設定すると、このターゲットがデフォルトでビルドされるようになります。これは、引数なしで (0.50.0以降) |
(0.38.0以降) |
capture |
bool |
出力をファイルに書き込むように指示できないが、代わりに標準出力に書き込むことができるコンパイラがいくつかあります。この引数がtrueに設定されている場合、Mesonは |
|
command |
list [str | file | exe | external_program ] |
入力から出力を生成するために実行するコマンド。コマンドには、文字列または |
|
console |
bool |
キーワード引数は |
(0.48.0以降) |
depend_files |
list [str | file ] |
ファイル( |
|
depends |
list [build_tgt | custom_tgt | custom_idx ] |
コマンドライン引数として使用しない場合でも、このターゲットが指定されたターゲットに依存することを指定します。これは、たとえば、内部でグロブ処理を行うツールがある場合に役立ちます。通常、生成されたソースを入力として指定するだけで、Mesonがすべての依存関係を自動的に設定します(custom_idxは0.60から1.4.0の間は型として利用できませんでした)。 |
|
depfile |
str |
このターゲットが依存するすべての追加ファイルをリストするコマンドが書き込むことができる依存関係ファイル。たとえば、Cコンパイラーは、インクルードしたすべてのヘッダーファイルをリストし、これらのファイルのいずれかの変更によって再コンパイルがトリガーされます。 (0.47.0以降) |
|
env |
env | list [str ] | dict [str ] |
|
(0.57.0以降) |
feed |
bool |
ファイルから入力を読み取るように指示できず、代わりに標準入力から読み取る一部のコンパイラーがあります。この引数が |
(0.59.0以降)
|
input |
list [str | file ] |
ソースファイルのリスト。(0.41.0以降)リストは平坦化されます。 |
|
install |
bool |
trueの場合、このターゲットの1つ以上のファイルがインストールステップ中にインストールされます(詳細は |
|
install_dir |
str | list [str | bool ] |
1つのinstall_dirのみが指定されている場合、すべての出力がそこにインストールされます。0.40.0以降対応する出力ごとにインストールディレクトリを指定できます。たとえば、
これは、 一部の出力のみをインストールするには、インストールしたくない出力に
これは、 |
|
install_mode |
list [str | int ] |
ファイルモード、およびオプションで所有者/uidとグループ/gid。 |
(0.47.0以降) |
install_tag |
list [str ] |
デフォルトでは、すべての出力にはインストールタグがないため、 |
(0.60.0以降) |
output |
list [str ] |
出力ファイルのリスト。 |
|
debug()
引数文字列をMesonビルドログに書き込みます。
シグネチャ
(0.63.0以降)
# Write the argument string to the meson build log
void debug(
str | int | bool | list[str | int | bool] | dict[str | int | bool] message, # The message to print
str | int | bool | list[str | int | bool] | dict[str | int | bool] msg..., # Additional parameters will be separated by spaces
)
引数
関数debug()
は、次の位置引数を受け入れます
名前 | 型 | 説明 | タグ |
---|---|---|---|
message |
str | int | bool | list [str | int | bool ] | dict [str | int | bool ] |
印刷するメッセージ |
|
さらに、関数は0
から無限
までの可変長引数(msg...
)を
の型で受け入れます。str
| int
| bool
| list
[str
| int
| bool
] | dict
[str
| int
| bool
]
追加のパラメーターはスペースで区切られます
declare_dependency()
この関数は、dependency()
の戻り値のように動作するが、現在のビルド内部のdep
オブジェクトを返します。これの主なユースケースはサブプロジェクトです。これにより、サブプロジェクトは、どのように使用されるべきかを簡単に指定できます。これにより、システムによって外部から提供される同じ依存関係と相互に交換可能になります。
シグネチャ
# This function returns a dep
object that
dep declare_dependency(
compile_args : list[str] # Compile arguments to use
d_import_dirs : list[inc | str] # the directories to add to the string search path (i
d_module_versions : str | int | list[str | int] # The [D version identifiers](https://dlang
dependencies : list[dep] # Other dependencies needed to use this dependency
extra_files : list[str | file] # extra files to add to targets
include_directories : list[inc | str] # the directories to add to header search path,
link_args : list[str] # Link arguments to use
link_whole : list[lib] # Libraries to link fully, same as executable()
.
link_with : list[lib] # Libraries to link against
objects : list[extracted_obj] # a list of object files, to be linked directly into the targets that use the
sources : list[str | file | custom_tgt | custom_idx | generated_list] # sources to add to targets
variables : dict[str] | list[str] # a dictionary of arbitrary strings,
version : str # the version of this dependency,
)
引数
関数declare_dependency()
は、次のキーワード引数を受け入れます
名前 | 型 | 説明 | タグ |
---|---|---|---|
compile_args |
list [str ] |
使用するコンパイル引数。 |
|
d_import_dirs |
list [inc | str ] |
文字列検索パスに追加するディレクトリ(つまりDMDの |
(0.62.0以降) |
d_module_versions |
str | int | list [str | int ] |
Dソースファイルのコンパイル中に追加するDバージョン識別子。 |
(0.62.0以降) |
dependencies |
list [dep ] |
この依存関係を使用するために必要なその他の依存関係。 |
|
extra_files |
list [str | file ] |
ターゲットに追加する追加ファイル。主にIDE統合に使用されます。 |
(1.2.0以降) |
include_directories |
list [inc | str ] |
ヘッダー検索パスに追加するディレクトリ。 |
|
link_args |
list [str ] |
使用するリンク引数。 |
|
link_whole |
list [lib ] |
|
(0.46.0以降) |
link_with |
list [lib ] |
リンクするライブラリ。 |
|
objects |
list [extracted_obj ] |
依存関係を使用するターゲットに直接リンクされるオブジェクトファイルのリスト。 |
(1.1.0以降) |
sources |
list [str | file | custom_tgt | custom_idx | generated_list ] |
ターゲットに追加するソース(または、それらを含むソースがビルドされる前にビルドされる必要のある生成されたヘッダーファイル) |
|
variables |
dict [str ] | list [str ] |
任意の文字列のディクショナリ。これは、特別な変数がcmakeまたはpkg-configを介して提供されるサブプロジェクトで使用されることを目的としています。0.56.0以降 |
(0.54.0以降) |
version |
str |
|
|
dependency()
pkg-config
を使用し、pkg-config
が失敗した場合はCMakeを使用して、指定された名前の外部依存関係(通常はシステムにインストールされているライブラリ)を検索します。さらに、フレームワーク(OSXのみ)とライブラリ固有のフォールバック検出ロジックもサポートされています。
0.60.0以降複数の名前を指定できます。それらは順番に試行され、最初に見つかった名前が使用されます。システムで名前が見つからない場合にのみ、フォールバックサブプロジェクトが使用されます。名前のいずれかが見つかると、他のすべての名前がキャッシュに追加されるため、それらの名前に対する後続の呼び出しは同じ値を返します。これは、依存関係にpng
やlibpng
などの異なる名前がある場合に役立ちます。
- 0.64.0以降WrapDBから依存関係のフォールバックを提供できます。
meson wrap update-db
コマンドを使用してデータベースをローカルにダウンロードするだけで、依存関係がシステムで見つからず、プロジェクトに独自の.wrap
ファイルが付属していない場合、MesonはWrapDBによって提供されるサブプロジェクトに自動的にフォールバックします。
依存関係は、他の2つの方法でも解決できます
-
dependency
の呼び出しの前にmeson.override_dependency
で同じ名前が使用された場合、オーバーライド依存関係は無条件に返されます。つまり、オーバーライド依存関係は、外部依存関係がシステムにインストールされているかどうかに関係なく使用されます。通常、meson.override_dependency
はサブプロジェクトによって使用されています。 -
フォールバックサブプロジェクトによって、必要に応じて、あたかも
subproject()
が呼び出されたかのように現在のビルド仕様に組み込まれます。サブプロジェクトは、fallback
引数で指定できます。または、fallback
引数が存在しない場合、0.55.0以降、Mesonは、ラップファイルが依存関係を提供している場合、またはサブプロジェクトが依存関係と同じ名前を持っている場合、サブプロジェクトをフォールバックとして自動的に識別できます。後者の場合、サブプロジェクトは、置換を指定するためにmeson.override_dependency
を使用する必要があります。そうしないと、Mesonはハードエラーを報告します。詳細については、ラップドキュメントを参照してください。この自動検索は、allow_fallback
キーワード引数を使用して制御できます。
dependency_name
が''
の場合、依存関係は常に検出されません。したがって、required: false
の場合、これは常にfound()
メソッドがfalse
を返し、build_target
のdependencies:
キーワード引数に他の依存関係と同様に渡すことができる依存関係オブジェクトを返します。これは、条件分岐の一部など、時々必要とされない依存関係を実装するために使用できます。または、fallback:
kwargとともに、指定されたサブプロジェクトのみを検索し、--wrap-mode
で許可されている場合にのみ検索するオプションの依存関係を宣言するために使用できます。
返されたオブジェクトdep
には、追加のメソッドもあります。
シグネチャ
# Finds an external dependency (usually a library installed on your
dep dependency(
str names..., # The names of the dependency to look up
# Keyword arguments:
allow_fallback : bool # Specifies whether Meson should automatically pick a fallback subproject
default_options : list[str] | dict[str | bool | int | list[str]] # An array of default option values
disabler : bool # Returns a disabler()
object instead of a not-found dependency
fallback : list[str] | str # Manually specifies a subproject fallback
include_type : str # An enum flag, marking how the dependency
language : str # Defines what language-specific dependency to find
method : str # Defines the way the dependency is detected, the default is
native : bool # If set to `true`, causes Meson to find the dependency on
not_found_message : str # An optional string that will be printed as a message()
if the dependency was not found.
required : bool | feature # When set to `false`, Meson will proceed with the build
static : bool # Tells the dependency provider to try to get static
version : list[str] | str # Specifies the required version,
)
この関数は、受け入れられる可能性のある追加のライブラリ固有のキーワード引数もサポートします(たとえば、modules
はQt5やBoostなどの依存関係に使用するサブモジュールを指定します。components
を使用すると、ユーザーはCMake COMPONENTS
をfind_package
ルックアップに手動で追加できます)。
引数
関数は、型
のstr
1
から無限大
までの可変引数(names...
)を受け入れます。
ルックアップする依存関係の名前。依存関係は、ここに指定された順序でルックアップされます。最初に見つかった依存関係が使用されます。フォールバックサブプロジェクトは、システム上で名前が見つからない場合にのみ使用されます。名前の1つが見つかると、他のすべての名前がキャッシュに追加されるため、それらの名前に対する後続の呼び出しは同じ値を返します。これは、依存関係にpng
やlibpng
のように異なる名前がある場合に役立ちます。
注:0.60.0より前は、単一の依存関係名のみが許可されていました。
(0.60.0以降)
関数dependency()
は、次のキーワード引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
allow_fallback |
bool |
依存関係がシステムで見つからない場合に、Mesonがフォールバックサブプロジェクトを自動的に選択するかどうかを指定します。 |
(0.56.0以降) |
default_options |
list [str ] | dict [str | bool | int | list [str ]] |
サブプロジェクトの |
(0.38.0以降) |
disabler |
bool |
このkwargが |
(0.49.0以降)
|
fallback |
list [str ] | str |
依存関係がシステムで見つからない場合に、使用するサブプロジェクトのフォールバックを手動で指定します。これは、自動検索が適用できない場合や、0.55.0より古いバージョンのMesonをサポートする場合に役立ちます。値が配列 |
|
include_type |
str |
依存関係フラグを変換する方法を示すenumフラグ。サポートされている値は、 |
(0.52.0以降)
|
language |
str |
複数の言語で利用可能な場合、どの言語固有の依存関係を検索するかを定義します。 |
(0.42.0以降) |
method |
str |
依存関係が検出される方法を定義します。デフォルトは |
(0.40.0以降)
|
native |
bool |
|
|
not_found_message |
str |
依存関係が見つからなかった場合に |
(0.50.0以降) |
required |
bool | feature |
(0.47.0以降) |
|
static |
bool |
依存関係プロバイダーに、動的ライブラリではなく静的ライブラリを取得するように指示します(これは、すべての依存関係バックエンドでサポートされているわけではありません)。 0.60.0以降、フォールバックサブプロジェクトで 0.63.0以降、 |
|
version |
list [str ] | str |
必要なバージョンを指定します。比較演算子とその後に続くバージョン文字列を含む文字列。例には、 |
(0.37.0以降) |
disabler()
disabler
オブジェクトを返します。
シグネチャ
(0.44.0以降)
disabler disabler()
environment()
空のenv
オブジェクトを返します。
シグネチャ
(0.35.0以降)
# Returns an empty env
object.
env environment(
str | list[str] | dict[str] | dict[list[str]] [env], # If provided, each key/value pair is added into the env
object
# Keyword arguments:
method : str # Must be one of 'set', 'prepend', or 'append'
separator : str # The separator to use for the initial values defined in
)
引数
引数の平坦化は、この関数ではサポートされていません。
関数environment()
は、次の位置引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
env |
str | list [str ] | dict [str ] | dict [list [str ]] |
提供されている場合、各キー/値ペアは、 |
(0.52.0以降) [オプション] |
最後に、environment()
は、次のキーワード引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
method |
str |
'set'、'prepend'、または'append'のいずれかである必要があります(デフォルトは'set')。最初の位置引数で定義された初期値を、環境変数の現在の値の前に追加するか、追加するか、または置換するかを制御します。 |
(0.62.0以降) |
separator |
str |
最初の位置引数で定義された初期値に使用する区切り文字。明示的に指定されていない場合、ホストオペレーティングシステムのデフォルトのパス区切り文字が使用されます。つまり、Windowsの場合は';'、UNIX/POSIXシステムの場合は':'です。 |
(0.62.0以降) |
error()
引数文字列を出力し、ビルドプロセスを停止します。
シグネチャ
# Print the argument string and halts the build process
void error(
str message, # The message to print
str msg..., # Additional parameters will be separated by spaces
)
引数
引数の平坦化は、この関数ではサポートされていません。
関数error()
は、次の位置引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
message |
str |
印刷するメッセージ |
|
さらに、関数は、型
のstr
0
から無限大
までの可変引数(msg...
)を受け入れます。
追加のパラメーターはスペースで区切られます
(0.58.0以降)
executable()
新しい実行可能ファイルを作成します。最初の引数はその名前を指定し、残りの位置引数は使用する入力ファイルを定義します。
kwargs(sources
、objects
、dependencies
など)のリストは常に平坦化されます。つまり、最終的なリストを作成する際に、自由にリストをネストおよび追加できます。
返されたオブジェクトには、exe
にドキュメント化されているメソッドもあります。
1.3.0以降、各ターゲットに異なるname_suffix
がある限り、実行可能ファイル名は複数のターゲットで同じにすることができます。
シグネチャ
# Creates a new executable
exe executable(
str target_name, # The *unique* name of the build target
str | file | custom_tgt | custom_idx | generated_list source..., # Input source to compile
# Keyword arguments:
<lang>_args : list[str] # compiler flags to use for the given language;
<lang>_pch : str # precompiled header file to use for the given language
build_by_default : bool # Causes, when set to `true`, to have this target be built by default
build_rpath : str # A string to add to target's rpath definition in the build dir,
d_debug : list[str] # The [D version identifiers](https://dlang
d_import_dirs : list[inc | str] # the directories to add to the string search path (i
d_module_versions : list[str | int] # List of module version identifiers set when compiling D sources
d_unittest : bool # When set to true, the D modules are compiled in debug mode
dependencies : list[dep] # one or more dependency objects
export_dynamic : bool # when set to true causes the target's symbols to be
extra_files : str | file | custom_tgt | custom_idx # Not used for the build itself but are shown as source files in IDEs
gnu_symbol_visibility : str # Specifies how symbols should be exported, see
gui_app : bool # When set to true flags this target as a GUI application
implib : bool | str # When set to true, an import library is generated for the
implicit_include_directories : bool # Controls whether Meson adds the current source and build directories to the include path
include_directories : list[inc | str] # one or more objects created with the include_directories()
function,
install : bool # When set to true, this executable should be installed
install_dir : str # override install directory for this file
install_mode : list[str | int] # Specify the file mode in symbolic format
install_rpath : str # A string to set the target's rpath to after install
install_tag : str # A string used by the `meson install --tags` command
link_args : list[str] # Flags to use during linking
link_depends : str | file | custom_tgt | custom_idx # Strings, files, or custom targets the link step depends on
link_language : str # Makes the linker for this target be for the specified language
link_whole : list[lib | custom_tgt | custom_idx] # Links all contents of the given static libraries whether they are used or
link_with : list[lib | custom_tgt | custom_idx] # One or more shared or static libraries
name_prefix : str | list[void] # The string that will be used as the prefix for the
name_suffix : str | list[void] # The string that will be used as the extension for the
native : bool # Controls whether the target is compiled for the build or host machines
objects : list[extracted_obj | file | str] # List of object files that should be linked in this target
override_options : list[str] | dict[str | bool | int | list[str]] # takes an array of strings in the same format as `project`'s `default_options`
pie : bool # Build a position-independent executable
rust_crate_type : str # Set the specific type of rust crate to compile (when compiling rust)
rust_dependency_map : dict[str] # On rust targets this provides a map of library names to the crate name
sources : str | file | custom_tgt | custom_idx | generated_list | structured_src # Additional source files
vala_args : list[str | file] # Compiler flags for Vala
vs_module_defs : str | file | custom_tgt | custom_idx # Specify a Microsoft module definition file for controlling symbol exports,
win_subsystem : str # Specifies the subsystem type to use
)
link_language
kwargは0.55.0まで壊れていました。
引数
関数executable()
は、次の位置引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
target_name |
str |
ビルドターゲットの一意な名前 |
|
さらに、関数は0
から無限
の可変長引数(source...
)を、
型で受け付けます。str
| file
| custom_tgt
| custom_idx
| generated_list
コンパイルする入力ソース。以下の型がサポートされています。
- 現在のソースディレクトリからの相対パスを表す文字列
-
先行するビルドファイルで定義された
file
オブジェクト configure_file()
などの設定時ジェネレーターの戻り値custom_target()
やgenerator.process()
などのビルド時ジェネレーターの戻り値
これらの入力ファイルは、ソース、オブジェクト、ライブラリ、その他のファイルにすることができます。Mesonは、拡張子に基づいて自動的に分類し、それに応じて使用します。たとえば、ソース(.c
、.cpp
、.vala
、.rs
など)はコンパイルされ、オブジェクト(.o
、.obj
)とライブラリ(.so
、.dll
など)はリンクされます。
Ninjaバックエンドでは、Mesonは、不明なファイルを含め、すべての生成された入力ファイルに対するビルド時順序のみの依存関係を作成します。これは、コンパイラーによって生成されたdepfileで実際の依存関係の生成をブートストラップし、ソースをいつリビルドするかを判断するために必要です。Ninjaは、生成されたファイルと生成されていないファイルの両方について、すべての入力ファイルに対してこの依存関係ファイルを使用します。この動作は他のバックエンドでも同様です。
最後に、executable()
は、次のキーワード引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
<lang>_args |
list [str ] |
特定の言語で使用するコンパイラーフラグ。例:C++の場合は |
|
<lang>_pch |
str |
特定の言語で使用するプリコンパイル済みヘッダーファイル |
|
build_by_default |
bool |
|
(0.38.0以降)
|
build_rpath |
str |
ビルドディレクトリでターゲットのrpath定義に追加される文字列ですが、インストール時に削除されます。 |
(0.42.0以降) |
d_debug |
list [str ] |
Dソースファイルのコンパイル中に追加するDバージョン識別子。 |
|
d_import_dirs |
list [inc | str ] |
文字列検索パスに追加するディレクトリ(つまりDMDの |
(0.62.0以降) |
d_module_versions |
list [str | int ] |
Dソースのコンパイル時に設定されるモジュールバージョン識別子のリスト。 |
|
d_unittest |
bool |
trueに設定すると、Dモジュールはデバッグモードでコンパイルされます。 |
|
dependencies |
list [dep ] |
|
|
export_dynamic |
bool |
trueに設定すると、ターゲットのシンボルが動的にエクスポートされ、 |
(0.45.0以降) |
extra_files |
str | file | custom_tgt | custom_idx |
ビルド自体には使用されませんが、ターゲット別にファイルをグループ化するIDE(Visual Studioなど)ではソースファイルとして表示されます。 |
|
gnu_symbol_visibility |
str |
シンボルをエクスポートする方法を指定します。詳細については、たとえばGCC Wikiを参照してください。この値は、空の文字列または |
(0.48.0以降) |
gui_app |
bool |
trueに設定すると、このターゲットをGUIアプリケーションとしてプラットフォームで区別する必要がある場合にフラグを立てます。0.56.0以降は非推奨です。代わりに |
非推奨 0.56.0で
|
implib |
bool | str |
trueに設定すると、実行可能ファイルのインポートライブラリが生成されます(インポートライブラリの名前はexe_nameに基づいています)。または、文字列に設定すると、インポートライブラリのベース名が指定されます。返されたビルドターゲットオブジェクトが別の場所の |
(0.42.0以降) |
implicit_include_directories |
bool |
Mesonが現在のソースディレクトリとビルドディレクトリをインクルードパスに追加するかどうかを制御します |
(0.42.0以降)
|
include_directories |
list [inc | str ] |
|
|
install |
bool |
trueに設定すると、この実行可能ファイルがインストールされます。 |
|
install_dir |
str |
このファイルのインストールディレクトリを上書きします。値が相対パスの場合、 |
|
install_mode |
list [str | int ] |
インストールされたファイルのシンボリック形式でのファイルモード、およびオプションで所有者/uidとグループ/gidを指定します。 詳細については、 |
(0.47.0以降) |
install_rpath |
str |
インストール後にターゲットのrpathを設定する文字列(ただし、その前ではありません)。Windowsでは、この引数は効果がありません。 |
|
install_tag |
str |
|
(0.60.0以降) |
link_args |
list [str ] |
リンク中に使用するフラグ。すべてのプラットフォームでUNIXスタイルのフラグを使用できます。 |
|
link_depends |
str | file | custom_tgt | custom_idx |
シンボルvisibilityマップなど、リンクステップが依存する文字列、ファイル、またはカスタムターゲット。目的は、このファイルが変更されたときにターゲットの再リンク(ただし再コンパイルではない)を自動的にトリガーすることです。 |
|
link_language |
str |
このターゲットのリンカーを特定の言語にするようにします。通常、Mesonはほとんどの場合正しいリンカーを検出するため、これを設定する必要はありません。これが必要になるのは2つのケースだけです。1つは、実行可能ファイルのメイン関数がMesonが選択した言語ではない場合、もう1つは、ライブラリに1つのABIのみを使用するように強制する場合です。 (0.55.0まで破損) |
(0.51.0以降) |
link_whole |
list [lib | custom_tgt | custom_idx ] |
与えられた静的ライブラリのすべてのコンテンツを、使用されているかどうかに関わらずリンクします。GCCの (0.41.0以降)リストが渡された場合、そのリストは平坦化されます。 (0.51.0以降)この引数は、カスタムターゲットによって生成された出力も受け入れます。ユーザーは、出力が正しい形式のライブラリであることを確認する必要があります。 |
(0.40.0以降) |
link_with |
list [lib | custom_tgt | custom_idx ] |
このターゲットがリンクされるべき、このプロジェクトでビルドされた1つ以上の共有または静的ライブラリ。(0.41.0以降)リストが渡された場合、このリストは平坦化されます。(0.51.0以降)引数はカスタムターゲットにすることもできます。この場合、Mesonはリンカーコマンドラインに出力ファイルを追加するだけでリンクが機能すると想定します。これが十分でない場合、ビルドシステムの作成者は他のすべてのステップを手動で記述する必要があります。 |
|
name_prefix |
str | list [void ] |
ターゲット出力ファイル名のプレフィックスとして使用される文字列。デフォルトを上書きします(ライブラリでのみ使用)。デフォルトでは、MSVC共有ライブラリでは規約に従って省略され、Cygwin共有ライブラリでは デフォルトの動作を使用するには、これを |
|
name_suffix |
str | list [void ] |
デフォルトを上書きして、ターゲットの拡張子として使用される文字列。デフォルトでは、Windowsでは実行可能ファイルは 共有ライブラリの場合、デフォルト値はmacOSでは デフォルトの動作を使用するには、これを |
|
native |
bool |
ターゲットがビルドマシンまたはホストマシン用にコンパイルされるかどうかを制御します。 |
|
objects |
list [extracted_obj | file | str ] |
このターゲットにリンクする必要があるオブジェクトファイルのリスト。 1.1.0以降、ソースがないオブジェクトファイルや、他のビルドターゲットによって生成されたオブジェクトファイルに加えて、生成されたファイルを含めることができます。以前のリリースでは、生成されたオブジェクトファイルを |
|
override_options |
list [str ] | dict [str | bool | int | list [str ]] |
|
(0.40.0以降) |
pie |
bool |
位置独立実行可能ファイルをビルドします。 |
(0.49.0以降) |
rust_crate_type |
str |
(Rustをコンパイルする際に)コンパイルする特定のRustクレートのタイプを設定します。 ターゲットが それが それが 「proc-macro」は0.62.0の新機能です。 1.3.0以降、これは非推奨となり、「rust_abi」キーワード引数に置き換えられました。 |
(0.42.0以降) 非推奨 1.3.0で |
rust_dependency_map |
dict [str ] |
Rustターゲットの場合、これはライブラリ名から、Rustコード内で利用可能になるクレート名へのマップを提供します。 これにより、cargoの依存関係の名前変更機能や、Rustコード内の |
(1.2.0以降) |
sources |
str | file | custom_tgt | custom_idx | generated_list | structured_src |
追加のソースファイル。source可変長引数と同じです。 |
|
vala_args |
list [str | file ] |
Valaのコンパイラフラグ。他の言語とは異なり、これにはファイルを含めることができます。 |
|
vs_module_defs |
str | file | custom_tgt | custom_idx |
シンボルのエクスポートなどを制御するためのMicrosoftモジュール定義ファイルを、それが可能なプラットフォーム(例:Windows)で指定します。 これは、実行可能ファイルによってロードされた共有モジュールがどの関数を使用できるかを公開するために使用できます。 |
(1.3.0以降) |
win_subsystem |
str |
Windowsプラットフォームで使用するサブシステムタイプを指定します。一般的な値には、テキストモードプログラムの場合は |
(0.56.0以降)
|
files()
このコマンドは、引数で与えられた文字列を取得し、ビルドターゲットのソースとして使用できる対応するファイルオブジェクトを返します。違いは、ファイルオブジェクトは定義されたサブディレクトリを記憶し、ソースツリーのどこでも使用できることです。
シグネチャ
# This command takes the strings given to it in arguments and returns
list[file] files(
str file..., # Path to the file
)
例
例として、サブディレクトリbar1
にソースファイルfoo.cpp
があり、bar2
で定義されたビルドターゲットで使用したいとします。これを行うには、最初にbar1
に次のようにオブジェクトを作成します。
foofile = files('foo.cpp')
次に、次のようにbar2
で使用できます。
executable('myprog', 'myprog.cpp', foofile, ...)
Mesonはその後、適切な処理を行います。
引数
関数は、型
のstr
0
から無限大
までの可変引数(file...
)を受け入れます。
ファイルへのパス。
find_program()
ここでのprogram_name
は、PATH
またはプロジェクト内の他の場所で検索される実行可能ファイルまたはスクリプトにすることができる文字列です。検索順序は次のとおりです。
meson.override_find_program()
を介して設定されたプログラムのオーバーライド。-
wrap_mode
がforcefallback
に設定されている場合、サブプロジェクトのラップファイルの[provide]
セクション。 -
マシンファイルの
[binaries]
セクション。 dirs:
kwargを使用して提供されるディレクトリ(下記参照)。- 現在のサブディレクトリを基準としたプロジェクトのソースツリー。
configure_file()
の戻り値を使用する場合、ビルドツリー内の現在のサブディレクトリが代わりに使用されます。
-
PATH
環境変数。 -
wrap_mode
がnofallback
以外の何かに設定されている場合、サブプロジェクトのラップファイルの[provide]
セクション。
また、Mesonは、Windows(コマンドインボーカーがそれ以外の場合コマンドを拒否するため)とUnix系(スクリプトファイルに実行可能ビットが設定されていない場合)の両方で、シェバン行を持つスクリプトを自動検出して、その中で指定された実行可能ファイル/インタープリターで実行します。したがって、このスクリプトをコマンドのリストの一部として使用している間は、インタープリターを手動で追加してはいけません。0.50.0以降、システムで「python3」プログラムが要求されていて見つからない場合、Mesonは現在のインタープリターを返します。
標準的な場所以外にあるプログラムをチェックする必要がある場合は、find_program
に絶対パスを渡すだけで済みます。例:
setcap = find_program('setcap', '/usr/sbin/setcap', '/sbin/setcap', required : false)
検索パスのセットを動的に構築する必要がある場合は、find_program
に配列を渡すことも可能です。
setcap = find_program(['setcap', '/usr/sbin/setcap', '/sbin/setcap'], required : false)
1.2.0 以降 find_program('meson')
は、ビルドスクリプトの実行に使用される Meson コマンドに自動的にオーバーライドされます。
返される external_program
オブジェクトには、ドキュメント化されたメソッドもあります。
シグネチャ
# `program_name` here is a string that can be an executable or script
external_program find_program(
str | file program_name, # The name of the program to search, or a file
object to be used
str | file fallback..., # These parameters are used as fallback names to search for
# Keyword arguments:
default_options : list[str] | dict[str | bool | int | list[str]] # An array of default option values
dirs : list[str] # extra list of absolute paths where to look for program names
disabler : bool # If `true` and the program couldn't be found, return a disabler
object
native : bool # Defines how this executable should be searched
required : bool | feature # When `true`, Meson will abort if no program can be found
version : str | list[str] # Specifies the required version, see
version_argument : str # Specifies the argument to pass when trying to find the version of the program
)
引数
関数 find_program()
は、次の位置引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
program_name |
str | file |
検索するプログラムの名前、または検索なしで使用される |
|
さらに、関数は 0
から infinity
までの可変長引数 (fallback...
) を、型
で受け入れます。str
| file
これらのパラメータは、検索するフォールバック名として使用されます。これは、プログラムに foo
や foo.py
など、多くの代替名がある場合に使用することを意図しています。関数は引数を1つずつチェックし、最初に見つかったものが返されます。
(0.37.0以降)
最後に、find_program()
は次のキーワード引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
default_options |
list [str ] | dict [str | bool | int | list [str ]] |
サブプロジェクトの |
(1.3.0以降) |
dirs |
list [str ] |
プログラム名を検索する追加の絶対パスのリスト。 |
(0.53.0 以降) |
disabler |
bool |
|
(0.49.0以降)
|
native |
bool |
この実行可能ファイルをどのように検索するかを定義します。デフォルトでは |
(0.43.0 以降)
|
required |
bool | feature |
|
|
version |
str | list [str ] |
必要なバージョンを指定します。引数の形式については |
(0.52.0以降) |
version_argument |
str |
プログラムのバージョンを検索するときに渡す引数を指定します。これが指定されていない場合は、 |
(1.5.0 以降) |
generator()
こちらも参照: custom_target()
この関数は、カスタムコンパイルコマンドを実行するために使用できる generator
オブジェクトを作成します。唯一の位置引数は、使用する実行可能ファイルです。これは、自己構築された実行可能ファイル、または find_program によって返された実行可能ファイルのいずれかです。
すべてのキーワード引数に渡されるテンプレート文字列は、次の特別な置換を受け入れます。
-
@PLAINNAME@
: 完全な入力ファイル名。例:foo.c
はfoo.c
(変更なし) になります -
@BASENAME@
: 入力ファイル名のベース。例:foo.c.y
はfoo.c
(拡張子が削除される) になります
output
キーワード引数に渡される各文字列は、これらの2つの置換の1つ以上を使用して構築する必要があります。
上記の置換に加えて、arguments
キーワード引数は次のものも受け入れます。
-
@OUTPUT@
: 出力ファイルへのフルパス -
@INPUT@
: 入力ファイルへのフルパス -
@DEPFILE@
: depfile へのフルパス -
@SOURCE_DIR@
: ソースツリーのルートへのフルパス -
@CURRENT_SOURCE_DIR@
: これは、現在処理されている meson.build があるディレクトリです -
@BUILD_DIR@
: 出力が配置されるビルドディレクトリのルートへのフルパス
注: ジェネレーターは、build_target()
または custom_target()
の入力としてのみ使用される出力に対してのみ使用する必要があります。ジェネレーターの処理済み出力を複数のターゲットで使用する場合、ジェネレーターは各ターゲットの出力を生成するために複数回実行されます。各出力は、ターゲット固有のディレクトリ @BUILD_DIR@
に作成されます。
複数のソースで使用されるヘッダーの生成や、インストールされるデータの生成など、一般的な目的でファイルを生成する場合は、代わりに custom_target()
を使用してください。
シグネチャ
# See also: custom_target()
generator generator(
exe | external_program exe, # Executable for the command to run
# Keyword arguments:
arguments : list[str] # A list of template strings that will be the command line arguments passed to the executable
capture : bool # When this argument is set to true, Meson captures `stdout`
depends : list[build_tgt | custom_tgt | custom_idx] # An array of build targets that must be built before
depfile : str # A template string pointing to a dependency file that a
output : list[str] # Template string (or list of template strings) defining
)
引数
関数 generator()
は、次の位置引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
exe |
exe | external_program |
実行するコマンドの実行可能ファイル |
|
最後に、generator()
は次のキーワード引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
arguments |
list [str ] |
実行可能ファイルに渡されるコマンドライン引数となるテンプレート文字列のリスト。 |
|
capture |
bool |
この引数が true に設定されている場合、Meson は |
(0.43.0 以降)
|
depends |
list [build_tgt | custom_tgt | custom_idx ] |
このジェネレーターを実行する前にビルドする必要があるビルドターゲットの配列。これは、このプロジェクトでビルドされる2番目の実行可能ファイルを呼び出すジェネレーターがある場合に使用されます (0.60 から 1.4.0 の間は custom_idx は利用できませんでした)。 |
(0.51.0以降) |
depfile |
str |
ジェネレーターが書き込むことができる依存関係ファイルを指すテンプレート文字列。このターゲットが依存する追加ファイルをすべて一覧表示します。たとえば、Cコンパイラーは、含めたすべてのヘッダーファイルを一覧表示し、これらのファイルのいずれかの変更は再コンパイルをトリガーします。 |
|
output |
list [str ] |
1つのソースファイル名から出力ファイル名 (または複数の出力名) がどのように生成されるかを定義するテンプレート文字列 (またはテンプレート文字列のリスト)。 |
|
get_option()
位置引数で指定された プロジェクトビルドオプション の値を取得します。
bindir
や libdir
など、dir
で終わる組み込みオプションに返される値は、通常、prefix
を基準とする (および内部にある) パスですが、場合によっては 絶対パスになる可能性もあるため、それを信頼すべきではありません。install_dir
引数はそれを期待どおりに処理しますが、定義などで使用するために絶対パスが必要な場合は、get_option('prefix') / get_option('localstatedir')
のようにパス連結演算子を使用する必要があります。パスを文字列であるかのように手動で結合しないでください。
タイプ feature
のオプションの場合、文字列の代わりに feature
オプションオブジェクトが返されます。詳細については、feature
オプションのドキュメントを参照してください。
シグネチャ
# Obtains the value of the [project build option](Build-options
str | int | bool | feature | list[str | int | bool] get_option(
str option_name, # Name of the option to query
)
引数
関数 get_option()
は、次の位置引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
option_name |
str |
クエリするオプションの名前 |
|
get_variable()
この関数は、変数を動的に取得するために使用できます。res = get_variable(varname, fallback)
は、varname
(文字列である必要があります) の値を取得し、その名前の変数を res
に格納します。変数が存在しない場合、変数 fallback
が res
の代わりに格納されます。フォールバックが指定されていない場合、存在しない変数を読み取ろうとすると、致命的なエラーが発生します。
シグネチャ
# This function can be used to dynamically obtain a variable
any get_variable(
str variable_name, # Name of the variable to get
any [default], # Fallback value to return when the variable does not exist
)
引数
引数の平坦化は、この関数ではサポートされていません。
関数 get_variable()
は、次の位置引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
variable_name |
str |
取得する変数の名前 |
|
default |
任意 |
変数が存在しない場合に返すフォールバック値 |
[オプション] |
import()
指定された拡張モジュールをインポートします。モジュールのメソッドを呼び出すために使用できるオブジェクトを返します。仮想の testmod
モジュールの例を次に示します。
シグネチャ
# Imports the given extension module
module import(
str module_name, # Name of the module to import
# Keyword arguments:
disabler : bool # Returns a disabler
object when not found.
required : bool | feature # When set to `false`, Meson will proceed with the build even if the module is not found
)
例
tmod = import('testmod')
tmod.do_something()
引数
関数 import()
は、次の位置引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
module_name |
str |
インポートするモジュールの名前。 |
|
最後に、import()
は次のキーワード引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
disabler |
bool |
見つからない場合は、 |
(0.59.0以降) |
required |
bool | feature |
|
(0.59.0以降)
|
include_directories()
位置引数で指定されたディレクトリ (現在のディレクトリからの相対) を含む不透明なオブジェクトを返します。結果は、実行可能ファイルまたはライブラリをビルドするときに include_directories:
キーワード引数に渡すことができます。返されたオブジェクトは任意のサブディレクトリで使用できます。Meson はパスを自動的に機能させます。
この関数呼び出し自体は、グローバル検索パスがないため、ディレクトリを検索パスに追加しないことに注意してください。そのようなものについては、add_project_arguments()
を参照してください。
また、現在のソースディレクトリとビルドディレクトリをインクルードパスに追加する executable()
の implicit_include_directories
パラメータも参照してください。
指定された各ディレクトリは、ソースルートを基準とするものとビルドルートを基準とするものの2つのインクルードパスに変換されます。
シグネチャ
# Returns an opaque object which contains the directories (relative to
inc include_directories(
str includes..., # Include paths to add
# Keyword arguments:
is_system : bool # If set to `true`, flags the specified directories as system directories
)
例
たとえば、/home/user/project.git
に次のソースツリーレイアウトがある場合
meson.build
:
project(...)
subdir('include')
subdir('src')
...
include/meson.build
:
inc = include_directories('.')
...
src/meson.build
:
sources = [...]
executable('some-tool', sources,
include_directories : inc,
...)
...
ビルドツリーが /tmp/build-tree
の場合、次のインクルードパスが executable()
呼び出しに追加されます: -I/tmp/build-tree/include -I/home/user/project.git/include
。
引数
関数は、型
の str
0
から infinity
までの可変長引数 (includes...
) を受け入れます。
追加するインクルードパス。
関数 include_directories()
は、次のキーワード引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
is_system |
bool |
|
|
install_data()
位置引数としてリストされているソースツリーからファイルをインストールします。
より多くの例については、インストールを参照してください。
シグネチャ
# Installs files from the source tree that are listed as positional arguments
void install_data(
file | str file..., # Files to install
# Keyword arguments:
follow_symlinks : bool # If true, dereferences links and copies their target instead
install_dir : str # The absolute or relative path to the installation directory
install_mode : list[str | int] # specify the file mode in symbolic format and
install_tag : str # A string used by the `meson install --tags` command
preserve_path : bool # Disable stripping child-directories from data files when installing
rename : list[str] # If specified renames each source file into corresponding file from `rename` list
sources : list[file | str] # Additional files to install
)
install_mode
kwarg は、0.59.0 から 1.1.0 の間の整数値を無視していました。
省略された install_dir
kwarg は、1.3.0 までサブプロジェクト内で正しく動作しませんでした。
省略された install_dir
kwarg は、1.3.0 まで preserve_path
kwarg と組み合わせると正しく動作しませんでした。
引数
この関数は、
型の可変長引数(file
| str
file...
)を 0
個から 無限
個まで受け付けます。
インストールするファイル。
関数 install_data()
は、以下のキーワード引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
follow_symlinks |
bool |
true の場合、リンクを解決し、代わりにそのターゲットをコピーします。デフォルト値は将来的に false になります。 |
(1.3.0以降)
|
install_dir |
str |
インストールディレクトリへの絶対パスまたは相対パス。これが相対パスの場合、プレフィックスからの相対パスと見なされます。 省略した場合、ディレクトリのデフォルトは |
|
install_mode |
list [str | int ] |
インストールするファイルのファイルモードをシンボリック形式で指定し、オプションで所有者/uid およびグループ/gid を指定します。例: ファイルモードのみの場合は ファイルモードとユーザー/グループの場合は ファイルモードと uid/gid の場合は これら 3 つのいずれかをデフォルトのままにするには、 |
(0.38.0以降) |
install_tag |
str |
ファイルのサブセットのみをインストールするために |
(0.60.0以降) |
preserve_path |
bool |
インストール時にデータファイルから子ディレクトリを削除しないようにします。 これは GNU Automake の |
(0.64.0 以降)
|
rename |
list [str ] |
指定した場合、各ソースファイルは |
(0.46.0以降) |
sources |
list [file | str ] |
インストールする追加ファイル。 |
|
install_emptydir()
位置引数で指定された場所に新しいディレクトリ エントリをインストールします。ディレクトリが存在し、空でない場合は、内容はそのまま残されます。
シグネチャ
(0.60.0以降)
# Installs a new directory entry to the location specified by the positional
void install_emptydir(
str dirpath..., # Directory to create during installation
# Keyword arguments:
install_mode : list[str | int] # Specify the file mode in symbolic format and optionally the owner/uid and
install_tag : str # A string used by the `meson install --tags` command to install only a
)
install_mode
kwarg は、1.1.0 より前の整数値を無視していました。
引数
この関数は、
型の可変長引数(str
dirpath...
)を 0
個から 無限
個まで受け付けます。
インストール中に作成するディレクトリ。
関数 install_emptydir()
は、以下のキーワード引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
install_mode |
list [str | int ] |
作成されたディレクトリのファイルモードをシンボリック形式で指定し、オプションで所有者/uid およびグループ/gid を指定します。 詳細については、 |
|
install_tag |
str |
ファイルのサブセットのみをインストールするために |
|
install_headers()
指定されたヘッダーファイルを、インストールステップ中にソースツリーからシステムヘッダーディレクトリ(通常は/{prefix}/include
)にインストールします。このディレクトリは、install_dir
キーワード引数で指定することによりオーバーライドできます。システムヘッダーディレクトリのサブディレクトリにのみインストールする場合は、subdir
引数を使用します。例として、これが値myproj
を持つ場合、ヘッダーは/{prefix}/include/myproj
にインストールされます。
シグネチャ
# Installs the specified header files from the source tree into the
void install_headers(
file | str file..., # Header files to install
# Keyword arguments:
follow_symlinks : bool # If true, dereferences links and copies their target instead
install_dir : str # Where to install to
install_mode : list[str | int] # Specify the file mode in symbolic format
preserve_path : bool # Disable stripping child-directories from header files when installing
subdir : str # Install to the `subdir` subdirectory of the default includedir
)
例
たとえば、これは common.h
と kola.h
を /{prefix}/include
にインストールします。
install_headers('common.h', 'proj/kola.h')
これは common.h
と kola.h
を /{prefix}/include/myproj
にインストールします。
install_headers('common.h', 'proj/kola.h', subdir : 'myproj')
これは common.h
と kola.h
を /{prefix}/cust/myproj
にインストールします。
install_headers('common.h', 'proj/kola.h', install_dir : 'cust', subdir : 'myproj')
これは common.h
を /{prefix}/include
に、kola.h
を /{prefix}/include/proj/
にインストールします。
install_headers('common.h, 'proj/kola.h', preserve_path : true)
install_mode
kwarg は、0.59.0 から 1.1.0 の間の整数値を無視していました。
引数
この関数は、
型の可変長引数(file
| str
file...
)を 0
個から 無限
個まで受け付けます。
インストールするヘッダーファイル。
関数 install_headers()
は、以下のキーワード引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
follow_symlinks |
bool |
true の場合、リンクを解決し、代わりにそのターゲットをコピーします。デフォルト値は将来的に false になります。 |
(1.3.0以降)
|
install_dir |
str |
インストール先。 |
|
install_mode |
list [str | int ] |
インストールされたファイルのシンボリック形式でのファイルモード、およびオプションで所有者/uidとグループ/gidを指定します。 詳細については、 |
(0.47.0以降) |
preserve_path |
bool |
インストール時にヘッダーファイルから子ディレクトリを削除しないようにします。 これは GNU Automake の |
(0.63.0以降)
|
subdir |
str |
デフォルトの includedir の
|
|
install_man()
指定された man ファイルを、インストールステップ中にソースツリーからシステムの man ディレクトリにインストールします。このディレクトリは、install_dir
キーワード引数で指定することによりオーバーライドできます。
(0.49.0 以降) man ページは暗黙的に圧縮されなくなりました。
シグネチャ
# Installs the specified man files from the source tree into system's man directory
void install_man(
file | str file..., # Man pages to install
# Keyword arguments:
install_dir : str # Where to install to
install_mode : list[str | int] # Specify the file mode in symbolic format
locale : str # Can be used to specify the locale
)
install_mode
kwarg は、0.59.0 から 1.1.0 の間の整数値を無視していました。
引数
この関数は、
型の可変長引数(file
| str
file...
)を 0
個から 無限
個まで受け付けます。
インストールする man ページ。
関数 install_man()
は、以下のキーワード引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
install_dir |
str |
インストール先。 |
|
install_mode |
list [str | int ] |
インストールされたファイルのシンボリック形式でのファイルモード、およびオプションで所有者/uidとグループ/gidを指定します。 詳細については、 |
(0.47.0以降) |
locale |
str |
man ページをマニュアルページディレクトリツリー内のインストール先となるロケールを指定するために使用できます。たとえば、 |
(0.58.0以降) |
install_subdir()
指定されたサブディレクトリとその内容全体を、ソースツリーからキーワード引数 install_dir
で指定された場所にインストールします。
(0.45.0 以降、0.60.0 以降で非推奨) サブディレクトリがソースツリーに存在しない場合、指定された場所に空のディレクトリが作成されます。新しく作成されたサブディレクトリは、キーワード引数 install_dir
でのみ作成できます。この方法には多くの欠点があり、意図的にこのように動作するように設計されたものではありません。代わりに install_emptydir()
を使用してください。
シグネチャ
# Installs the entire given subdirectory and its contents from the
void install_subdir(
str subdir_name, # The sub-directory to install
# Keyword arguments:
exclude_directories : list[str] # A list of directory names that should not be installed
exclude_files : list[str] # A list of file names that should not be installed
follow_symlinks : bool # If true, dereferences links and copies their target instead
install_dir : str # Where to install to
install_mode : list[str | int] # Specify the file mode in symbolic format
install_tag : str # A string used by the `meson install --tags` command
strip_directory : bool # Install directory contents
)
例
特定のディレクトリ foo
の場合
foo/
bar/
file1
file2
install_subdir('foo', install_dir : 'share', strip_directory : false)
は以下を作成します
share/
foo/
bar/
file1
file2
install_subdir('foo', install_dir : 'share', strip_directory : true)
は以下を作成します
share/
bar/
file1
file2
install_subdir('foo/bar', install_dir : 'share', strip_directory : false)
は以下を作成します
share/
bar/
file1
install_subdir('foo/bar', install_dir : 'share', strip_directory : true)
は以下を作成します
share/
file1
install_subdir('new_directory', install_dir : 'share')
は以下を作成します
share/
new_directory/
install_mode
kwarg は、0.59.0 から 1.1.0 の間の整数値を無視していました。
引数
関数 install_subdir()
は、以下の位置引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
subdir_name |
str |
インストールするサブディレクトリ |
|
最後に、install_subdir()
は、以下のキーワード引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
exclude_directories |
list [str ] |
インストールしないディレクトリ名のリスト。名前は、 |
(0.47.0以降) |
exclude_files |
list [str ] |
インストールしないファイル名のリスト。名前は、 |
|
follow_symlinks |
bool |
true の場合、リンクを解決し、代わりにそのターゲットをコピーします。デフォルト値は将来的に false になります。 |
(1.3.0以降)
|
install_dir |
str |
インストール先。 |
|
install_mode |
list [str | int ] |
インストールされたファイルのシンボリック形式でのファイルモード、およびオプションで所有者/uidとグループ/gidを指定します。 詳細については、 |
(0.47.0以降) |
install_tag |
str |
ファイルのサブセットのみをインストールするために |
(0.60.0以降) |
strip_directory |
bool |
ディレクトリの内容をインストールします。 |
(0.45.0以降)
|
install_symlink()
install_dir
の下に pointing_to
ターゲットへのシンボリックリンクをインストールします。
シグネチャ
(0.61.0 以降)
# Installs a symbolic link to `pointing_to` target under install_dir
void install_symlink(
str link_name, # Name of the created link under `install_dir`
# Keyword arguments:
install_dir : str [required] # The absolute or relative path to the installation directory for the links
install_tag : str # A string used by the `meson install --tags` command
pointing_to : str [required] # Target to point the link to
)
引数
関数 install_symlink()
は、以下の位置引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
link_name |
str |
|
|
最後に、install_symlink()
は、以下のキーワード引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
install_dir |
str |
リンクのインストールディレクトリへの絶対パスまたは相対パス。これが相対パスの場合、プレフィックスからの相対パスと見なされます。 |
|
install_tag |
str |
ファイルのサブセットのみをインストールするために |
|
pointing_to |
str |
リンクが指すターゲット。絶対または相対のいずれも可能で、リンクを作成する際に尊重されます。 |
|
is_disabler()
変数がディセーブラの場合は true を、それ以外の場合は false を返します。
シグネチャ
(0.52.0以降)
# Returns true if a variable is a disabler and false otherwise
bool is_disabler(
any var, # The variable to test
)
引数
関数 is_disabler()
は、以下の位置引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
var |
任意 |
テストする変数 |
|
is_variable()
指定された名前の変数が存在する場合は true を、それ以外の場合は false を返します。
シグネチャ
(0.52.0以降)
# Returns true if a variable of the given name exists and false otherwise
bool is_variable(
str var, # The variable to test
)
引数
関数 is_variable()
は、以下の位置引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
var |
str |
テストする変数 |
|
jar()
指定された Java ソースファイルから jar をビルドします。キーワード引数は executable()
と同じですが、java -jar file.jar
で jar を実行するときに実行するメインクラスを指定する main_class
が追加されています。
シグネチャ
# Build a jar from the specified Java source files
jar jar(
str target_name, # The *unique* name of the build target
str | file | custom_tgt | custom_idx | generated_list source..., # Input source to compile
# Keyword arguments:
<lang>_args : list[str] # compiler flags to use for the given language;
<lang>_pch : str # precompiled header file to use for the given language
build_by_default : bool # Causes, when set to `true`, to have this target be built by default
build_rpath : str # A string to add to target's rpath definition in the build dir,
d_debug : list[str] # The [D version identifiers](https://dlang
d_import_dirs : list[inc | str] # the directories to add to the string search path (i
d_module_versions : list[str | int] # List of module version identifiers set when compiling D sources
d_unittest : bool # When set to true, the D modules are compiled in debug mode
dependencies : list[dep] # one or more dependency objects
extra_files : str | file | custom_tgt | custom_idx # Not used for the build itself but are shown as source files in IDEs
gnu_symbol_visibility : str # Specifies how symbols should be exported, see
gui_app : bool # When set to true flags this target as a GUI application
implicit_include_directories : bool # Controls whether Meson adds the current source and build directories to the include path
include_directories : list[inc | str] # one or more objects created with the include_directories()
function,
install : bool # When set to true, this executable should be installed
install_dir : str # override install directory for this file
install_mode : list[str | int] # Specify the file mode in symbolic format
install_rpath : str # A string to set the target's rpath to after install
install_tag : str # A string used by the `meson install --tags` command
java_resources : structured_src # Resources to be added to the jar
link_args : list[str] # Flags to use during linking
link_depends : str | file | custom_tgt | custom_idx # Strings, files, or custom targets the link step depends on
link_language : str # Makes the linker for this target be for the specified language
link_whole : list[lib | custom_tgt | custom_idx] # Links all contents of the given static libraries whether they are used or
link_with : list[lib | custom_tgt | custom_idx] # One or more shared or static libraries
main_class : str # Main class for running the built jar
name_prefix : str | list[void] # The string that will be used as the prefix for the
name_suffix : str | list[void] # The string that will be used as the extension for the
native : bool # Controls whether the target is compiled for the build or host machines
objects : list[extracted_obj | file | str] # List of object files that should be linked in this target
override_options : list[str] | dict[str | bool | int | list[str]] # takes an array of strings in the same format as `project`'s `default_options`
rust_crate_type : str # Set the specific type of rust crate to compile (when compiling rust)
rust_dependency_map : dict[str] # On rust targets this provides a map of library names to the crate name
sources : str | file | custom_tgt | custom_idx | generated_list | structured_src # Additional source files
vala_args : list[str | file] # Compiler flags for Vala
win_subsystem : str # Specifies the subsystem type to use
)
引数
関数 jar()
は、以下の位置引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
target_name |
str |
ビルドターゲットの一意な名前 |
|
さらに、関数は0
から無限
の可変長引数(source...
)を、
型で受け付けます。str
| file
| custom_tgt
| custom_idx
| generated_list
コンパイルする入力ソース。以下の型がサポートされています。
- 現在のソースディレクトリからの相対パスを表す文字列
-
先行するビルドファイルで定義された
file
オブジェクト configure_file()
などの設定時ジェネレーターの戻り値custom_target()
やgenerator.process()
などのビルド時ジェネレーターの戻り値
これらの入力ファイルは、ソース、オブジェクト、ライブラリ、その他のファイルにすることができます。Mesonは、拡張子に基づいて自動的に分類し、それに応じて使用します。たとえば、ソース(.c
、.cpp
、.vala
、.rs
など)はコンパイルされ、オブジェクト(.o
、.obj
)とライブラリ(.so
、.dll
など)はリンクされます。
Ninjaバックエンドでは、Mesonは、不明なファイルを含め、すべての生成された入力ファイルに対するビルド時順序のみの依存関係を作成します。これは、コンパイラーによって生成されたdepfileで実際の依存関係の生成をブートストラップし、ソースをいつリビルドするかを判断するために必要です。Ninjaは、生成されたファイルと生成されていないファイルの両方について、すべての入力ファイルに対してこの依存関係ファイルを使用します。この動作は他のバックエンドでも同様です。
最後に、jar()
は、以下のキーワード引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
<lang>_args |
list [str ] |
特定の言語で使用するコンパイラーフラグ。例:C++の場合は |
|
<lang>_pch |
str |
特定の言語で使用するプリコンパイル済みヘッダーファイル |
|
build_by_default |
bool |
|
(0.38.0以降)
|
build_rpath |
str |
ビルドディレクトリでターゲットのrpath定義に追加される文字列ですが、インストール時に削除されます。 |
(0.42.0以降) |
d_debug |
list [str ] |
Dソースファイルのコンパイル中に追加するDバージョン識別子。 |
|
d_import_dirs |
list [inc | str ] |
文字列検索パスに追加するディレクトリ(つまりDMDの |
(0.62.0以降) |
d_module_versions |
list [str | int ] |
Dソースのコンパイル時に設定されるモジュールバージョン識別子のリスト。 |
|
d_unittest |
bool |
trueに設定すると、Dモジュールはデバッグモードでコンパイルされます。 |
|
dependencies |
list [dep ] |
|
|
extra_files |
str | file | custom_tgt | custom_idx |
ビルド自体には使用されませんが、ターゲット別にファイルをグループ化するIDE(Visual Studioなど)ではソースファイルとして表示されます。 |
|
gnu_symbol_visibility |
str |
シンボルをエクスポートする方法を指定します。詳細については、たとえばGCC Wikiを参照してください。この値は、空の文字列または |
(0.48.0以降) |
gui_app |
bool |
trueに設定すると、このターゲットをGUIアプリケーションとしてプラットフォームで区別する必要がある場合にフラグを立てます。0.56.0以降は非推奨です。代わりに |
非推奨 0.56.0で
|
implicit_include_directories |
bool |
Mesonが現在のソースディレクトリとビルドディレクトリをインクルードパスに追加するかどうかを制御します |
(0.42.0以降)
|
include_directories |
list [inc | str ] |
|
|
install |
bool |
trueに設定すると、この実行可能ファイルがインストールされます。 |
|
install_dir |
str |
このファイルのインストールディレクトリを上書きします。値が相対パスの場合、 |
|
install_mode |
list [str | int ] |
インストールされたファイルのシンボリック形式でのファイルモード、およびオプションで所有者/uidとグループ/gidを指定します。 詳細については、 |
(0.47.0以降) |
install_rpath |
str |
インストール後にターゲットのrpathを設定する文字列(ただし、その前ではありません)。Windowsでは、この引数は効果がありません。 |
|
install_tag |
str |
|
(0.60.0以降) |
java_resources |
structured_src |
jarに追加されるリソース |
(0.62.0以降) |
link_args |
list [str ] |
リンク中に使用するフラグ。すべてのプラットフォームでUNIXスタイルのフラグを使用できます。 |
|
link_depends |
str | file | custom_tgt | custom_idx |
シンボルvisibilityマップなど、リンクステップが依存する文字列、ファイル、またはカスタムターゲット。目的は、このファイルが変更されたときにターゲットの再リンク(ただし再コンパイルではない)を自動的にトリガーすることです。 |
|
link_language |
str |
このターゲットのリンカーを特定の言語にするようにします。通常、Mesonはほとんどの場合正しいリンカーを検出するため、これを設定する必要はありません。これが必要になるのは2つのケースだけです。1つは、実行可能ファイルのメイン関数がMesonが選択した言語ではない場合、もう1つは、ライブラリに1つのABIのみを使用するように強制する場合です。 (0.55.0まで破損) |
(0.51.0以降) |
link_whole |
list [lib | custom_tgt | custom_idx ] |
与えられた静的ライブラリのすべてのコンテンツを、使用されているかどうかに関わらずリンクします。GCCの (0.41.0以降)リストが渡された場合、そのリストは平坦化されます。 (0.51.0以降)この引数は、カスタムターゲットによって生成された出力も受け入れます。ユーザーは、出力が正しい形式のライブラリであることを確認する必要があります。 |
(0.40.0以降) |
link_with |
list [lib | custom_tgt | custom_idx ] |
このターゲットがリンクされるべき、このプロジェクトでビルドされた1つ以上の共有または静的ライブラリ。(0.41.0以降)リストが渡された場合、このリストは平坦化されます。(0.51.0以降)引数はカスタムターゲットにすることもできます。この場合、Mesonはリンカーコマンドラインに出力ファイルを追加するだけでリンクが機能すると想定します。これが十分でない場合、ビルドシステムの作成者は他のすべてのステップを手動で記述する必要があります。 |
|
main_class |
str |
ビルドされたjarを実行するためのメインクラス |
|
name_prefix |
str | list [void ] |
ターゲット出力ファイル名のプレフィックスとして使用される文字列。デフォルトを上書きします(ライブラリでのみ使用)。デフォルトでは、MSVC共有ライブラリでは規約に従って省略され、Cygwin共有ライブラリでは デフォルトの動作を使用するには、これを |
|
name_suffix |
str | list [void ] |
デフォルトを上書きして、ターゲットの拡張子として使用される文字列。デフォルトでは、Windowsでは実行可能ファイルは 共有ライブラリの場合、デフォルト値はmacOSでは デフォルトの動作を使用するには、これを |
|
native |
bool |
ターゲットがビルドマシンまたはホストマシン用にコンパイルされるかどうかを制御します。 |
|
objects |
list [extracted_obj | file | str ] |
このターゲットにリンクする必要があるオブジェクトファイルのリスト。 1.1.0以降、ソースがないオブジェクトファイルや、他のビルドターゲットによって生成されたオブジェクトファイルに加えて、生成されたファイルを含めることができます。以前のリリースでは、生成されたオブジェクトファイルを |
|
override_options |
list [str ] | dict [str | bool | int | list [str ]] |
|
(0.40.0以降) |
rust_crate_type |
str |
(Rustをコンパイルする際に)コンパイルする特定のRustクレートのタイプを設定します。 ターゲットが それが それが 「proc-macro」は0.62.0の新機能です。 1.3.0以降、これは非推奨となり、「rust_abi」キーワード引数に置き換えられました。 |
(0.42.0以降) 非推奨 1.3.0で |
rust_dependency_map |
dict [str ] |
Rustターゲットの場合、これはライブラリ名から、Rustコード内で利用可能になるクレート名へのマップを提供します。 これにより、cargoの依存関係の名前変更機能や、Rustコード内の |
(1.2.0以降) |
sources |
str | file | custom_tgt | custom_idx | generated_list | structured_src |
追加のソースファイル。source可変長引数と同じです。 |
|
vala_args |
list [str | file ] |
Valaのコンパイラフラグ。他の言語とは異なり、これにはファイルを含めることができます。 |
|
win_subsystem |
str |
Windowsプラットフォームで使用するサブシステムタイプを指定します。一般的な値には、テキストモードプログラムの場合は |
(0.56.0以降)
|
join_paths()
指定された文字列をファイルシステムパスセグメントに結合します。たとえば、join_paths('foo', 'bar')
は foo/bar
になります。個々のセグメントのいずれかが絶対パスの場合、その前のすべてのセグメントは削除されます。つまり、join_paths('foo', '/bar')
は /bar
を返します。
(0.49.0 以降) 文字列に対する /
演算子の使用は、join_paths()
を呼び出すことと同等です。
# res1 and res2 will have identical values
res1 = join_paths(foo, bar)
res2 = foo / bar
シグネチャ
(0.36.0以降)
# Joins the given strings into a file system path segment
str join_paths(
str part..., # The path parts to join
)
library()
および executable()
のソースには、join_paths()
を使用しないでください。代わりに files()
を使用する必要があります。
引数
この関数は、
型の可変長引数(str
part...
)を 1
個から 無限
個まで受け付けます。
結合するパス部分。
library()
ユーザーの オプション の default_library
の値に応じて、静的、共有、またはその両方のライブラリをビルドします。ほとんどの場合、shared_library()
、static_library()
、または both_libraries()
の代わりにこれを使用する必要があります。これにより、プロジェクト全体(サブプロジェクトを含む)を、1 つのオプションのみで共有から静的に切り替えることができます。このオプションは、プロジェクト内部でビルドされるライブラリに適用されます。外部依存関係の場合、優先されるデフォルトのライブラリタイプは共有です。これは、dependency()
の static
キーワードを使用して、ライブラリごとに適合させることができます。
これのキーワード引数は、build_target()
と同じです。
シグネチャ
# Builds a library that is either static, shared or both depending on
lib library(
str target_name, # The *unique* name of the build target
str | file | custom_tgt | custom_idx | generated_list source..., # Input source to compile
# Keyword arguments:
<lang>_args : list[str] # compiler flags to use for the given language;
<lang>_pch : str # precompiled header file to use for the given language
<lang>_shared_args : list[str] # Arguments that are only passed to a shared library
<lang>_static_args : list[str] # Arguments that are only passed to a static library
build_by_default : bool # Causes, when set to `true`, to have this target be built by default
build_rpath : str # A string to add to target's rpath definition in the build dir,
d_debug : list[str] # The [D version identifiers](https://dlang
d_import_dirs : list[inc | str] # the directories to add to the string search path (i
d_module_versions : list[str | int] # List of module version identifiers set when compiling D sources
d_unittest : bool # When set to true, the D modules are compiled in debug mode
darwin_versions : str | int | list[str] # Defines the `compatibility version` and `current version` for the dylib on macOS
dependencies : list[dep] # one or more dependency objects
extra_files : str | file | custom_tgt | custom_idx # Not used for the build itself but are shown as source files in IDEs
gnu_symbol_visibility : str # Specifies how symbols should be exported, see
gui_app : bool # When set to true flags this target as a GUI application
implicit_include_directories : bool # Controls whether Meson adds the current source and build directories to the include path
include_directories : list[inc | str] # one or more objects created with the include_directories()
function,
install : bool # When set to true, this executable should be installed
install_dir : str # override install directory for this file
install_mode : list[str | int] # Specify the file mode in symbolic format
install_rpath : str # A string to set the target's rpath to after install
install_tag : str # A string used by the `meson install --tags` command
link_args : list[str] # Flags to use during linking
link_depends : str | file | custom_tgt | custom_idx # Strings, files, or custom targets the link step depends on
link_language : str # Makes the linker for this target be for the specified language
link_whole : list[lib | custom_tgt | custom_idx] # Links all contents of the given static libraries whether they are used or
link_with : list[lib | custom_tgt | custom_idx] # One or more shared or static libraries
name_prefix : str | list[void] # The string that will be used as the prefix for the
name_suffix : str | list[void] # The string that will be used as the extension for the
native : bool # Controls whether the target is compiled for the build or host machines
objects : list[extracted_obj | file | str] # List of object files that should be linked in this target
override_options : list[str] | dict[str | bool | int | list[str]] # takes an array of strings in the same format as `project`'s `default_options`
pic : bool # Builds the library as positional independent code
prelink : bool # If `true` the object files in the target will be prelinked,
rust_abi : str # Set the specific ABI to compile (when compiling rust)
rust_crate_type : str # Set the specific type of rust crate to compile (when compiling rust)
rust_dependency_map : dict[str] # On rust targets this provides a map of library names to the crate name
sources : str | file | custom_tgt | custom_idx | generated_list | structured_src # Additional source files
soversion : str | int # A string or integer specifying the soversion of this shared library,
vala_args : list[str | file] # Compiler flags for Vala
vala_shared_args : list[str | file] # Arguments that are only passed to a shared library
vala_static_args : list[str | file] # Arguments that are only passed to a static library
version : str # A string specifying the version of this shared library,
vs_module_defs : str | file | custom_tgt | custom_idx # Specify a Microsoft module definition file for controlling symbol exports,
win_subsystem : str # Specifies the subsystem type to use
)
using
引数
関数 library()
は、以下の位置引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
target_name |
str |
ビルドターゲットの一意な名前 |
|
さらに、関数は0
から無限
の可変長引数(source...
)を、
型で受け付けます。str
| file
| custom_tgt
| custom_idx
| generated_list
コンパイルする入力ソース。以下の型がサポートされています。
- 現在のソースディレクトリからの相対パスを表す文字列
-
先行するビルドファイルで定義された
file
オブジェクト configure_file()
などの設定時ジェネレーターの戻り値custom_target()
やgenerator.process()
などのビルド時ジェネレーターの戻り値
これらの入力ファイルは、ソース、オブジェクト、ライブラリ、その他のファイルにすることができます。Mesonは、拡張子に基づいて自動的に分類し、それに応じて使用します。たとえば、ソース(.c
、.cpp
、.vala
、.rs
など)はコンパイルされ、オブジェクト(.o
、.obj
)とライブラリ(.so
、.dll
など)はリンクされます。
Ninjaバックエンドでは、Mesonは、不明なファイルを含め、すべての生成された入力ファイルに対するビルド時順序のみの依存関係を作成します。これは、コンパイラーによって生成されたdepfileで実際の依存関係の生成をブートストラップし、ソースをいつリビルドするかを判断するために必要です。Ninjaは、生成されたファイルと生成されていないファイルの両方について、すべての入力ファイルに対してこの依存関係ファイルを使用します。この動作は他のバックエンドでも同様です。
最後に、library()
は、以下のキーワード引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
<lang>_args |
list [str ] |
特定の言語で使用するコンパイラーフラグ。例:C++の場合は |
|
<lang>_pch |
str |
特定の言語で使用するプリコンパイル済みヘッダーファイル |
|
<lang>_shared_args |
list [str ] |
共有ライブラリにのみ渡される引数 |
(1.3.0以降) |
<lang>_static_args |
list [str ] |
スタティックライブラリにのみ渡される引数 |
(1.3.0以降) |
build_by_default |
bool |
|
(0.38.0以降)
|
build_rpath |
str |
ビルドディレクトリでターゲットのrpath定義に追加される文字列ですが、インストール時に削除されます。 |
(0.42.0以降) |
d_debug |
list [str ] |
Dソースファイルのコンパイル中に追加するDバージョン識別子。 |
|
d_import_dirs |
list [inc | str ] |
文字列検索パスに追加するディレクトリ(つまりDMDの |
(0.62.0以降) |
d_module_versions |
list [str | int ] |
Dソースのコンパイル時に設定されるモジュールバージョン識別子のリスト。 |
|
d_unittest |
bool |
trueに設定すると、Dモジュールはデバッグモードでコンパイルされます。 |
|
darwin_versions |
str | int | list [str ] |
macOSのdylibの |
(0.48.0以降) |
dependencies |
list [dep ] |
|
|
extra_files |
str | file | custom_tgt | custom_idx |
ビルド自体には使用されませんが、ターゲット別にファイルをグループ化するIDE(Visual Studioなど)ではソースファイルとして表示されます。 |
|
gnu_symbol_visibility |
str |
シンボルをエクスポートする方法を指定します。詳細については、たとえばGCC Wikiを参照してください。この値は、空の文字列または |
(0.48.0以降) |
gui_app |
bool |
trueに設定すると、このターゲットをGUIアプリケーションとしてプラットフォームで区別する必要がある場合にフラグを立てます。0.56.0以降は非推奨です。代わりに |
非推奨 0.56.0で
|
implicit_include_directories |
bool |
Mesonが現在のソースディレクトリとビルドディレクトリをインクルードパスに追加するかどうかを制御します |
(0.42.0以降)
|
include_directories |
list [inc | str ] |
|
|
install |
bool |
trueに設定すると、この実行可能ファイルがインストールされます。 |
|
install_dir |
str |
このファイルのインストールディレクトリを上書きします。値が相対パスの場合、 |
|
install_mode |
list [str | int ] |
インストールされたファイルのシンボリック形式でのファイルモード、およびオプションで所有者/uidとグループ/gidを指定します。 詳細については、 |
(0.47.0以降) |
install_rpath |
str |
インストール後にターゲットのrpathを設定する文字列(ただし、その前ではありません)。Windowsでは、この引数は効果がありません。 |
|
install_tag |
str |
|
(0.60.0以降) |
link_args |
list [str ] |
リンク中に使用するフラグ。すべてのプラットフォームでUNIXスタイルのフラグを使用できます。 |
|
link_depends |
str | file | custom_tgt | custom_idx |
シンボルvisibilityマップなど、リンクステップが依存する文字列、ファイル、またはカスタムターゲット。目的は、このファイルが変更されたときにターゲットの再リンク(ただし再コンパイルではない)を自動的にトリガーすることです。 |
|
link_language |
str |
このターゲットのリンカーを特定の言語にするようにします。通常、Mesonはほとんどの場合正しいリンカーを検出するため、これを設定する必要はありません。これが必要になるのは2つのケースだけです。1つは、実行可能ファイルのメイン関数がMesonが選択した言語ではない場合、もう1つは、ライブラリに1つのABIのみを使用するように強制する場合です。 (0.55.0まで破損) |
(0.51.0以降) |
link_whole |
list [lib | custom_tgt | custom_idx ] |
与えられた静的ライブラリのすべてのコンテンツを、使用されているかどうかに関わらずリンクします。GCCの (0.41.0以降)リストが渡された場合、そのリストは平坦化されます。 (0.51.0以降)この引数は、カスタムターゲットによって生成された出力も受け入れます。ユーザーは、出力が正しい形式のライブラリであることを確認する必要があります。 |
(0.40.0以降) |
link_with |
list [lib | custom_tgt | custom_idx ] |
このターゲットがリンクされるべき、このプロジェクトでビルドされた1つ以上の共有または静的ライブラリ。(0.41.0以降)リストが渡された場合、このリストは平坦化されます。(0.51.0以降)引数はカスタムターゲットにすることもできます。この場合、Mesonはリンカーコマンドラインに出力ファイルを追加するだけでリンクが機能すると想定します。これが十分でない場合、ビルドシステムの作成者は他のすべてのステップを手動で記述する必要があります。 |
|
name_prefix |
str | list [void ] |
ターゲット出力ファイル名のプレフィックスとして使用される文字列。デフォルトを上書きします(ライブラリでのみ使用)。デフォルトでは、MSVC共有ライブラリでは規約に従って省略され、Cygwin共有ライブラリでは デフォルトの動作を使用するには、これを |
|
name_suffix |
str | list [void ] |
デフォルトを上書きして、ターゲットの拡張子として使用される文字列。デフォルトでは、Windowsでは実行可能ファイルは 共有ライブラリの場合、デフォルト値はmacOSでは デフォルトの動作を使用するには、これを |
|
native |
bool |
ターゲットがビルドマシンまたはホストマシン用にコンパイルされるかどうかを制御します。 |
|
objects |
list [extracted_obj | file | str ] |
このターゲットにリンクする必要があるオブジェクトファイルのリスト。 1.1.0以降、ソースがないオブジェクトファイルや、他のビルドターゲットによって生成されたオブジェクトファイルに加えて、生成されたファイルを含めることができます。以前のリリースでは、生成されたオブジェクトファイルを |
|
override_options |
list [str ] | dict [str | bool | int | list [str ]] |
|
(0.40.0以降) |
pic |
bool |
ライブラリを位置独立コードとしてビルドします(共有ライブラリにリンクできるように)。このオプションはWindowsとOS Xでは意味がないため、効果がありません。Windowsでは意味がなく、OS XではPICを無効にできないためです。 |
(0.36.0以降) |
prelink |
bool |
|
(0.57.0以降) |
rust_abi |
str |
(Rustをコンパイルする際に)コンパイルする特定のABIを設定します。
|
(1.3.0以降) |
rust_crate_type |
str |
(Rustをコンパイルする際に)コンパイルする特定のRustクレートのタイプを設定します。 ターゲットが それが それが 「proc-macro」は0.62.0の新機能です。 1.3.0以降、これは非推奨となり、「rust_abi」キーワード引数に置き換えられました。 |
(0.42.0以降) 非推奨 1.3.0で |
rust_dependency_map |
dict [str ] |
Rustターゲットの場合、これはライブラリ名から、Rustコード内で利用可能になるクレート名へのマップを提供します。 これにより、cargoの依存関係の名前変更機能や、Rustコード内の |
(1.2.0以降) |
sources |
str | file | custom_tgt | custom_idx | generated_list | structured_src |
追加のソースファイル。source可変長引数と同じです。 |
|
soversion |
str | int |
この共有ライブラリのsoversionを指定する文字列または整数( |
|
vala_args |
list [str | file ] |
Valaのコンパイラフラグ。他の言語とは異なり、これにはファイルを含めることができます。 |
|
vala_shared_args |
list [str | file ] |
共有ライブラリにのみ渡される引数。 |
(1.3.0以降) |
vala_static_args |
list [str | file ] |
静的ライブラリにのみ渡される引数。 |
(1.3.0以降) |
version |
str |
この共有ライブラリのバージョンを指定する文字列( |
|
vs_module_defs |
str | file | custom_tgt | custom_idx |
シンボルのエクスポートなどを制御するためのMicrosoftモジュール定義ファイルを、それが可能なプラットフォーム(例:Windows)で指定します。 (1.3.0以降) |
|
win_subsystem |
str |
Windowsプラットフォームで使用するサブシステムタイプを指定します。一般的な値には、テキストモードプログラムの場合は |
(0.56.0以降)
|
message()
この関数は、引数を stdout に出力します。
シグネチャ
# This function prints its argument to stdout
void message(
str | int | bool | list[str | int | bool] | dict[str | int | bool] text, # The message to print
str | int | bool | list[str | int | bool] | dict[str | int | bool] more_text..., # Additional text that will be printed separated by spaces
)
引数
引数の平坦化は、この関数ではサポートされていません。
関数 message()
は、以下の位置引数を受け付けます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
text |
str | int | bool | list [str | int | bool ] | dict [str | int | bool ] |
出力するメッセージ。 |
|
さらに、この関数は、0
個から無限
個の可変長引数(more_text...
)を、型が
であるものを、受け入れます。str
| int
| bool
| list
[str
| int
| bool
] | dict
[str
| int
| bool
]
スペースで区切られて出力される追加のテキスト。
(0.54.0以降)
project()
Mesonを初期化するために、各プロジェクトで最初に呼び出される関数です。
この関数の最初の引数は、このプロジェクトの名前を定義する文字列でなければなりません。
プロジェクト名は任意の文字列で構いません。説明目的以外には使用されません。ただし、依存関係マニフェストなどに書き込まれるため、通常はプロジェクトのtarballやpkg-config名と同じにするのが理にかなっています。したがって、たとえば、The Foobar Libraryではなく、libfoobarという名前を使用するのが適切でしょう。
その後には、プロジェクトで使用するプログラミング言語のリストを続けることができます。
(0.40.0以降) 言語のリストはオプションです。
これらの言語は、native: false
(デフォルト)(ホストマシン)ターゲットと、native: true
(ビルドマシン)ターゲットの両方で使用できます。(0.56.0以降) 指定された言語のビルドマシンコンパイラは必須ではありません。
言語のサポートされている値は、c
、cpp
(C++
の場合)、cuda
、cython
、d
、objc
、objcpp
、fortran
、java
、cs
(C#
の場合)、vala
、rust
です。
シグネチャ
# The first function called in each project, to initialize Meson
void project(
str project_name, # The name of the project
str language..., # The languages that Meson should initialize
# Keyword arguments:
default_options : list[str] | dict[str | bool | int | list[str]] # Accepts strings in the form `key=value`
license : str | list[str] # Takes a string or array of strings describing the license(s) the code is under
license_files : str | list[str] # Takes a string or array of strings with the paths to the license file(s)
meson_version : str # Takes a string describing which Meson version the project requires
subproject_dir : str # Specifies the top level directory name that holds Meson subprojects
version : str | file # A free form string describing the version of this project
)
引数
関数project()
は、次の位置引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
project_name |
str |
プロジェクトの名前。 |
|
さらに、この関数は、0
個から無限
個の可変長引数(language...
)を、型が
であるものを受け入れます。str
Mesonが初期化する必要がある言語。
最後に、project()
は、次のキーワード引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
default_options |
list [str ] | dict [str | bool | int | list [str ]] |
一部のオプションはデフォルトの動作をオーバーライドできることに注意してください。たとえば、ここで (1.2.0以降): 辞書を渡せるようになりました。 |
|
license |
str | list [str ] |
コードが準拠するライセンスを記述する文字列または文字列の配列を受け取ります。 これは、SPDXライセンス式であり、SPDXライセンスリストからの標準化されたライセンス識別子を使用する必要があります。通常、これは 下位互換性の理由から、ここでライセンスの配列を渡すこともできます。これは曖昧であるため推奨されません。 テキストは非公式であり、依存関係マニフェストにのみ書き込まれることに注意してください。Mesonはライセンス検証を行いません。すべてのライセンス条項を遵守していることを確認するのはあなたの責任です。Mesonビルドファイルで |
|
license_files |
str | list [str ] |
コードが準拠するライセンスファイルへのパスを持つ文字列または文字列の配列を受け取ります。 これにより、短いライセンス名と完全なライセンステキストの両方を指定できることで、 ファイルは非公式であり、依存関係マニフェストと一緒にのみインストールされることに注意してください。Mesonはライセンス検証を行いません。すべてのライセンス条項を遵守していることを確認するのはあなたの責任です。Mesonビルドファイルで |
(1.1.0以降) |
meson_version |
str |
プロジェクトに必要なMesonバージョンを記述する文字列を受け取ります。通常は |
|
subproject_dir |
str |
Mesonサブプロジェクトを保持するトップレベルのディレクトリ名を指定します。これは、カスタムディレクトリに埋め込みソースコードを格納する既存のコードベースとの互換性オプションとしてのみ使用されます。すべての新しいプロジェクトでは、これを設定するのではなく、デフォルト値を使用する必要があります。このキーワード引数はサブプロジェクト内では無視されることに注意してください。サブプロジェクトディレクトリは1つしか存在できず、トップレベルのMesonファイルで設定されます。 |
|
version |
str | file |
このプロジェクトのバージョンを記述する自由形式の文字列。Mesonビルドファイルで |
|
range()
foreach
ステートメントでのみ使用できる不透明なオブジェクトを返します。
range
range(int
stop)
range
range(int
start, int
stop[, int
step])
-
start
は0以上の整数である必要があります。デフォルトは0です。 -
stop
は、start
以上の整数である必要があります。 -
step
は1以上の整数である必要があります。デフォルトは1です。
これにより、foreach
ループは、start
からstop
を含まず、各ループ後にstep
ずつインクリメントされた値で呼び出されます。
シグネチャ
(0.58.0以降)
# Return an opaque object that can be only be used in `foreach` statements
range range(
int [start], # The start of the range
int [stop], # The end of the range
int [step], # The loop increment
)
例
# Loop 15 times with i from 0 to 14 included.
foreach i : range(15)
...
endforeach
rangeオブジェクトは変数に割り当てて、インデックスを付けることもできます。
r = range(5, 10, 2)
assert(r[2] == 9)
引数
関数range()
は、次の位置引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
start |
int |
範囲の開始 |
[オプション]
|
stop |
int |
範囲の終了 |
[オプション] |
step |
int |
ループの増分 |
[オプション]
|
run_command()
位置引数で指定されたコマンドを実行します。command
は、文字列、またはfind_program()
、files()
、またはconfigure_file()
の出力、またはコンパイラオブジェクトにすることができます。
呼び出しの結果を含むrunresult
オブジェクトを返します。コマンドは指定されていないディレクトリから実行され、Mesonはソースディレクトリ、ビルドディレクトリ、およびターゲットが定義されたサブディレクトリをそれぞれ指定する3つの環境変数MESON_SOURCE_ROOT
、MESON_BUILD_ROOT
、およびMESON_SUBDIR
を設定します。
外部コマンドも参照してください。
シグネチャ
# Runs the command specified in positional arguments
runresult run_command(
str | file | external_program command..., # The command to execute during the setup process
# Keyword arguments:
capture : bool # If `true`, any output generated on stdout will be captured and returned by
check : bool # If `true`, the exit status code of the command will be checked,
env : env | list[str] | dict[str] # environment variables to set,
)
引数
この関数は、0
個から無限
個の可変長引数(command...
)を、型が
であるものを受け入れます。str
| file
| external_program
セットアッププロセス中に実行するコマンド。
関数run_command()
は、次のキーワード引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
capture |
bool |
|
(0.47.0以降)
|
check |
bool |
|
(0.47.0以降)
|
env |
env | list [str ] | dict [str ] |
|
(0.50.0以降) |
run_target()
この関数は、指定されたコマンドを指定された引数で実行する新しいトップレベルターゲットを作成します。すべてのトップレベルターゲットと同様に、これは選択されたバックエンドと統合されます。たとえば、meson compile target_name
として実行できます。実行ターゲットは、Mesonに関する限り、出力を生成しないことに注意してください。コードフォーマッターの実行や、ビルドされたファイルを使用した外部デバイスのファームウェアのフラッシュなどのタスクのみを目的としています。
コマンドは指定されていないディレクトリから実行され、Mesonはソースディレクトリ、ビルドディレクトリ、およびターゲットが定義されたサブディレクトリをそれぞれ指定する3つの環境変数MESON_SOURCE_ROOT
、MESON_BUILD_ROOT
、およびMESON_SUBDIR
を設定します。
0.57.0以降 command
キーワード引数に渡されるテンプレート文字列は、次の特別な置換を受け入れます。
-
@SOURCE_ROOT@
:ソースツリーのルートへのパス。バックエンドによっては、これは絶対パスであるか、現在の作業ディレクトリへの相対パスである可能性があります。 -
@BUILD_ROOT@
:ビルドツリーのルートへのパス。バックエンドによっては、これは絶対パスであるか、現在の作業ディレクトリへの相対パスである可能性があります。 -
@CURRENT_SOURCE_DIR@
0.57.1以降: これは、現在処理中のmeson.buildがあるディレクトリです。バックエンドによっては、絶対パスまたは現在の作業ディレクトリからの相対パスになります。
シグネチャ
# This function creates a new top-level target that runs a specified
run_tgt run_target(
str target_name, # The name of the run target
# Keyword arguments:
command : list[exe | external_program | custom_tgt | file | str] # A list containing the command to run and the arguments
depends : list[build_tgt | custom_tgt | custom_idx] # A list of targets that this target depends on but which
env : env | list[str] | dict[str] # environment variables to set, such as
)
引数
関数run_target()
は、次の位置引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
target_name |
str |
実行ターゲットの名前 |
|
最後に、run_target()
は、次のキーワード引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
command |
list [exe | external_program | custom_tgt | file | str ] |
実行するコマンドとそれに渡す引数を含むリスト。各リスト項目は、文字列またはターゲットにすることができます。たとえば、 |
|
depends |
list [build_tgt | custom_tgt | custom_idx ] |
このターゲットが依存するが、コマンド配列にリストされていないターゲットのリスト(たとえば、スクリプトが内部でファイルグロビングを実行するため、custom_idxは0.60〜1.4.0の間の型として使用できなかった)。 |
|
env |
env | list [str ] | dict [str ] |
|
(0.57.0以降) |
set_variable()
指定された変数名に値を割り当てます。set_variable('foo', bar)
を呼び出すことは、foo = bar
と同じです。
(0.46.1以降) value
パラメーターは配列型にすることができます。
シグネチャ
# Assigns a value to the given variable name
void set_variable(
str variable_name, # The name of the variable to set
any value, # The value to set the variable to
)
引数
引数の平坦化は、この関数ではサポートされていません。
関数set_variable()
は、次の位置引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
variable_name |
str |
設定する変数の名前 |
|
値 |
任意 |
変数を設定する値 |
|
shared_library()
指定されたソースを使用して共有ライブラリをビルドします。
シグネチャ
# Builds a shared library with the given sources
lib shared_library(
str target_name, # The *unique* name of the build target
str | file | custom_tgt | custom_idx | generated_list source..., # Input source to compile
# Keyword arguments:
<lang>_args : list[str] # compiler flags to use for the given language;
<lang>_pch : str # precompiled header file to use for the given language
build_by_default : bool # Causes, when set to `true`, to have this target be built by default
build_rpath : str # A string to add to target's rpath definition in the build dir,
d_debug : list[str] # The [D version identifiers](https://dlang
d_import_dirs : list[inc | str] # the directories to add to the string search path (i
d_module_versions : list[str | int] # List of module version identifiers set when compiling D sources
d_unittest : bool # When set to true, the D modules are compiled in debug mode
darwin_versions : str | int | list[str] # Defines the `compatibility version` and `current version` for the dylib on macOS
dependencies : list[dep] # one or more dependency objects
extra_files : str | file | custom_tgt | custom_idx # Not used for the build itself but are shown as source files in IDEs
gnu_symbol_visibility : str # Specifies how symbols should be exported, see
gui_app : bool # When set to true flags this target as a GUI application
implicit_include_directories : bool # Controls whether Meson adds the current source and build directories to the include path
include_directories : list[inc | str] # one or more objects created with the include_directories()
function,
install : bool # When set to true, this executable should be installed
install_dir : str # override install directory for this file
install_mode : list[str | int] # Specify the file mode in symbolic format
install_rpath : str # A string to set the target's rpath to after install
install_tag : str # A string used by the `meson install --tags` command
link_args : list[str] # Flags to use during linking
link_depends : str | file | custom_tgt | custom_idx # Strings, files, or custom targets the link step depends on
link_language : str # Makes the linker for this target be for the specified language
link_whole : list[lib | custom_tgt | custom_idx] # Links all contents of the given static libraries whether they are used or
link_with : list[lib | custom_tgt | custom_idx] # One or more shared or static libraries
name_prefix : str | list[void] # The string that will be used as the prefix for the
name_suffix : str | list[void] # The string that will be used as the extension for the
native : bool # Controls whether the target is compiled for the build or host machines
objects : list[extracted_obj | file | str] # List of object files that should be linked in this target
override_options : list[str] | dict[str | bool | int | list[str]] # takes an array of strings in the same format as `project`'s `default_options`
rust_abi : str # Set the specific ABI to compile (when compiling rust)
rust_crate_type : str # Set the specific type of rust crate to compile (when compiling rust)
rust_dependency_map : dict[str] # On rust targets this provides a map of library names to the crate name
sources : str | file | custom_tgt | custom_idx | generated_list | structured_src # Additional source files
soversion : str | int # A string or integer specifying the soversion of this shared library,
vala_args : list[str | file] # Compiler flags for Vala
version : str # A string specifying the version of this shared library,
vs_module_defs : str | file | custom_tgt | custom_idx # Specify a Microsoft module definition file for controlling symbol exports,
win_subsystem : str # Specifies the subsystem type to use
)
引数
関数shared_library()
は、以下の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
target_name |
str |
ビルドターゲットの一意な名前 |
|
さらに、関数は0
から無限
の可変長引数(source...
)を、
型で受け付けます。str
| file
| custom_tgt
| custom_idx
| generated_list
コンパイルする入力ソース。以下の型がサポートされています。
- 現在のソースディレクトリからの相対パスを表す文字列
-
先行するビルドファイルで定義された
file
オブジェクト configure_file()
などの設定時ジェネレーターの戻り値custom_target()
やgenerator.process()
などのビルド時ジェネレーターの戻り値
これらの入力ファイルは、ソース、オブジェクト、ライブラリ、その他のファイルにすることができます。Mesonは、拡張子に基づいて自動的に分類し、それに応じて使用します。たとえば、ソース(.c
、.cpp
、.vala
、.rs
など)はコンパイルされ、オブジェクト(.o
、.obj
)とライブラリ(.so
、.dll
など)はリンクされます。
Ninjaバックエンドでは、Mesonは、不明なファイルを含め、すべての生成された入力ファイルに対するビルド時順序のみの依存関係を作成します。これは、コンパイラーによって生成されたdepfileで実際の依存関係の生成をブートストラップし、ソースをいつリビルドするかを判断するために必要です。Ninjaは、生成されたファイルと生成されていないファイルの両方について、すべての入力ファイルに対してこの依存関係ファイルを使用します。この動作は他のバックエンドでも同様です。
最後に、shared_library()
は、以下のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
<lang>_args |
list [str ] |
特定の言語で使用するコンパイラーフラグ。例:C++の場合は |
|
<lang>_pch |
str |
特定の言語で使用するプリコンパイル済みヘッダーファイル |
|
build_by_default |
bool |
|
(0.38.0以降)
|
build_rpath |
str |
ビルドディレクトリでターゲットのrpath定義に追加される文字列ですが、インストール時に削除されます。 |
(0.42.0以降) |
d_debug |
list [str ] |
Dソースファイルのコンパイル中に追加するDバージョン識別子。 |
|
d_import_dirs |
list [inc | str ] |
文字列検索パスに追加するディレクトリ(つまりDMDの |
(0.62.0以降) |
d_module_versions |
list [str | int ] |
Dソースのコンパイル時に設定されるモジュールバージョン識別子のリスト。 |
|
d_unittest |
bool |
trueに設定すると、Dモジュールはデバッグモードでコンパイルされます。 |
|
darwin_versions |
str | int | list [str ] |
macOSのdylibの |
(0.48.0以降) |
dependencies |
list [dep ] |
|
|
extra_files |
str | file | custom_tgt | custom_idx |
ビルド自体には使用されませんが、ターゲット別にファイルをグループ化するIDE(Visual Studioなど)ではソースファイルとして表示されます。 |
|
gnu_symbol_visibility |
str |
シンボルをエクスポートする方法を指定します。詳細については、たとえばGCC Wikiを参照してください。この値は、空の文字列または |
(0.48.0以降) |
gui_app |
bool |
trueに設定すると、このターゲットをGUIアプリケーションとしてプラットフォームで区別する必要がある場合にフラグを立てます。0.56.0以降は非推奨です。代わりに |
非推奨 0.56.0で
|
implicit_include_directories |
bool |
Mesonが現在のソースディレクトリとビルドディレクトリをインクルードパスに追加するかどうかを制御します |
(0.42.0以降)
|
include_directories |
list [inc | str ] |
|
|
install |
bool |
trueに設定すると、この実行可能ファイルがインストールされます。 |
|
install_dir |
str |
このファイルのインストールディレクトリを上書きします。値が相対パスの場合、 |
|
install_mode |
list [str | int ] |
インストールされたファイルのシンボリック形式でのファイルモード、およびオプションで所有者/uidとグループ/gidを指定します。 詳細については、 |
(0.47.0以降) |
install_rpath |
str |
インストール後にターゲットのrpathを設定する文字列(ただし、その前ではありません)。Windowsでは、この引数は効果がありません。 |
|
install_tag |
str |
|
(0.60.0以降) |
link_args |
list [str ] |
リンク中に使用するフラグ。すべてのプラットフォームでUNIXスタイルのフラグを使用できます。 |
|
link_depends |
str | file | custom_tgt | custom_idx |
シンボルvisibilityマップなど、リンクステップが依存する文字列、ファイル、またはカスタムターゲット。目的は、このファイルが変更されたときにターゲットの再リンク(ただし再コンパイルではない)を自動的にトリガーすることです。 |
|
link_language |
str |
このターゲットのリンカーを特定の言語にするようにします。通常、Mesonはほとんどの場合正しいリンカーを検出するため、これを設定する必要はありません。これが必要になるのは2つのケースだけです。1つは、実行可能ファイルのメイン関数がMesonが選択した言語ではない場合、もう1つは、ライブラリに1つのABIのみを使用するように強制する場合です。 (0.55.0まで破損) |
(0.51.0以降) |
link_whole |
list [lib | custom_tgt | custom_idx ] |
与えられた静的ライブラリのすべてのコンテンツを、使用されているかどうかに関わらずリンクします。GCCの (0.41.0以降)リストが渡された場合、そのリストは平坦化されます。 (0.51.0以降)この引数は、カスタムターゲットによって生成された出力も受け入れます。ユーザーは、出力が正しい形式のライブラリであることを確認する必要があります。 |
(0.40.0以降) |
link_with |
list [lib | custom_tgt | custom_idx ] |
このターゲットがリンクされるべき、このプロジェクトでビルドされた1つ以上の共有または静的ライブラリ。(0.41.0以降)リストが渡された場合、このリストは平坦化されます。(0.51.0以降)引数はカスタムターゲットにすることもできます。この場合、Mesonはリンカーコマンドラインに出力ファイルを追加するだけでリンクが機能すると想定します。これが十分でない場合、ビルドシステムの作成者は他のすべてのステップを手動で記述する必要があります。 |
|
name_prefix |
str | list [void ] |
ターゲット出力ファイル名のプレフィックスとして使用される文字列。デフォルトを上書きします(ライブラリでのみ使用)。デフォルトでは、MSVC共有ライブラリでは規約に従って省略され、Cygwin共有ライブラリでは デフォルトの動作を使用するには、これを |
|
name_suffix |
str | list [void ] |
デフォルトを上書きして、ターゲットの拡張子として使用される文字列。デフォルトでは、Windowsでは実行可能ファイルは 共有ライブラリの場合、デフォルト値はmacOSでは デフォルトの動作を使用するには、これを |
|
native |
bool |
ターゲットがビルドマシンまたはホストマシン用にコンパイルされるかどうかを制御します。 |
|
objects |
list [extracted_obj | file | str ] |
このターゲットにリンクする必要があるオブジェクトファイルのリスト。 1.1.0以降、ソースがないオブジェクトファイルや、他のビルドターゲットによって生成されたオブジェクトファイルに加えて、生成されたファイルを含めることができます。以前のリリースでは、生成されたオブジェクトファイルを |
|
override_options |
list [str ] | dict [str | bool | int | list [str ]] |
|
(0.40.0以降) |
rust_abi |
str |
(Rustをコンパイルする際に)コンパイルする特定のABIを設定します。
|
(1.3.0以降) |
rust_crate_type |
str |
(Rustをコンパイルする際に)コンパイルする特定のRustクレートのタイプを設定します。 ターゲットが それが それが 「proc-macro」は0.62.0の新機能です。 1.3.0以降、これは非推奨となり、「rust_abi」キーワード引数に置き換えられました。 |
(0.42.0以降) 非推奨 1.3.0で |
rust_dependency_map |
dict [str ] |
Rustターゲットの場合、これはライブラリ名から、Rustコード内で利用可能になるクレート名へのマップを提供します。 これにより、cargoの依存関係の名前変更機能や、Rustコード内の |
(1.2.0以降) |
sources |
str | file | custom_tgt | custom_idx | generated_list | structured_src |
追加のソースファイル。source可変長引数と同じです。 |
|
soversion |
str | int |
この共有ライブラリのsoversionを指定する文字列または整数( |
|
vala_args |
list [str | file ] |
Valaのコンパイラフラグ。他の言語とは異なり、これにはファイルを含めることができます。 |
|
version |
str |
この共有ライブラリのバージョンを指定する文字列( |
|
vs_module_defs |
str | file | custom_tgt | custom_idx |
シンボルのエクスポートなどを制御するためのMicrosoftモジュール定義ファイルを、それが可能なプラットフォーム(例:Windows)で指定します。 (1.3.0以降) |
|
win_subsystem |
str |
Windowsプラットフォームで使用するサブシステムタイプを指定します。一般的な値には、テキストモードプログラムの場合は |
(0.56.0以降)
|
shared_module()
指定されたソースを使用して共有モジュールをビルドします。
これは、dlopen()
されるモジュールをビルドする場合に便利です。そのため、それをロードするライブラリによって提供される未定義のシンボルが含まれる場合があります。
共有モジュールが、ロード元のexecutable()
で定義された関数や変数を参照できるようにするには、実行可能ファイルのexport_dynamic
引数をtrue
に設定する必要があります。
シグネチャ
(0.37.0以降)
# Builds a shared module with the given sources
build_tgt shared_module(
str target_name, # The *unique* name of the build target
str | file | custom_tgt | custom_idx | generated_list source..., # Input source to compile
# Keyword arguments:
<lang>_args : list[str] # compiler flags to use for the given language;
<lang>_pch : str # precompiled header file to use for the given language
build_by_default : bool # Causes, when set to `true`, to have this target be built by default
build_rpath : str # A string to add to target's rpath definition in the build dir,
d_debug : list[str] # The [D version identifiers](https://dlang
d_import_dirs : list[inc | str] # the directories to add to the string search path (i
d_module_versions : list[str | int] # List of module version identifiers set when compiling D sources
d_unittest : bool # When set to true, the D modules are compiled in debug mode
dependencies : list[dep] # one or more dependency objects
extra_files : str | file | custom_tgt | custom_idx # Not used for the build itself but are shown as source files in IDEs
gnu_symbol_visibility : str # Specifies how symbols should be exported, see
gui_app : bool # When set to true flags this target as a GUI application
implicit_include_directories : bool # Controls whether Meson adds the current source and build directories to the include path
include_directories : list[inc | str] # one or more objects created with the include_directories()
function,
install : bool # When set to true, this executable should be installed
install_dir : str # override install directory for this file
install_mode : list[str | int] # Specify the file mode in symbolic format
install_rpath : str # A string to set the target's rpath to after install
install_tag : str # A string used by the `meson install --tags` command
link_args : list[str] # Flags to use during linking
link_depends : str | file | custom_tgt | custom_idx # Strings, files, or custom targets the link step depends on
link_language : str # Makes the linker for this target be for the specified language
link_whole : list[lib | custom_tgt | custom_idx] # Links all contents of the given static libraries whether they are used or
link_with : list[lib | custom_tgt | custom_idx] # One or more shared or static libraries
name_prefix : str | list[void] # The string that will be used as the prefix for the
name_suffix : str | list[void] # The string that will be used as the extension for the
native : bool # Controls whether the target is compiled for the build or host machines
objects : list[extracted_obj | file | str] # List of object files that should be linked in this target
override_options : list[str] | dict[str | bool | int | list[str]] # takes an array of strings in the same format as `project`'s `default_options`
rust_abi : str # Set the specific ABI to compile (when compiling rust)
rust_crate_type : str # Set the specific type of rust crate to compile (when compiling rust)
rust_dependency_map : dict[str] # On rust targets this provides a map of library names to the crate name
sources : str | file | custom_tgt | custom_idx | generated_list | structured_src # Additional source files
vala_args : list[str | file] # Compiler flags for Vala
vs_module_defs : str | file | custom_tgt | custom_idx # Specify a Microsoft module definition file for controlling symbol exports,
win_subsystem : str # Specifies the subsystem type to use
)
Android以外のプラットフォームでの共有モジュールへのリンクは非推奨であり、将来エラーになる予定です。以前は、未定義のシンボルへの参照を含む共有ライブラリのようなターゲットを持つ唯一の方法であったため許可されていました。ただし、0.40.0以降では、override_options:
build_target()
キーワード引数を使用して、override_options: 'b_lundef=false'
を渡すことで、そのようなshared_library()
を作成できます。共有モジュールには、SONAMEの欠如など、リンクと互換性がない他の特性があります。macOSとiOSでは、共有モジュールへのリンクはリンカーによって許可されていないため、構成時に許可していません。Androidでは、共有モジュールfoo
が別の共有モジュールbar
のシンボルを使用する場合、foo
もbar
にリンクする必要があります。したがって、Android向けにビルドする場合、ある共有モジュールを別の共有モジュールにリンクすることは常に許可されます。
引数
関数shared_module()
は、以下の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
target_name |
str |
ビルドターゲットの一意な名前 |
|
さらに、関数は0
から無限
の可変長引数(source...
)を、
型で受け付けます。str
| file
| custom_tgt
| custom_idx
| generated_list
コンパイルする入力ソース。以下の型がサポートされています。
- 現在のソースディレクトリからの相対パスを表す文字列
-
先行するビルドファイルで定義された
file
オブジェクト configure_file()
などの設定時ジェネレーターの戻り値custom_target()
やgenerator.process()
などのビルド時ジェネレーターの戻り値
これらの入力ファイルは、ソース、オブジェクト、ライブラリ、その他のファイルにすることができます。Mesonは、拡張子に基づいて自動的に分類し、それに応じて使用します。たとえば、ソース(.c
、.cpp
、.vala
、.rs
など)はコンパイルされ、オブジェクト(.o
、.obj
)とライブラリ(.so
、.dll
など)はリンクされます。
Ninjaバックエンドでは、Mesonは、不明なファイルを含め、すべての生成された入力ファイルに対するビルド時順序のみの依存関係を作成します。これは、コンパイラーによって生成されたdepfileで実際の依存関係の生成をブートストラップし、ソースをいつリビルドするかを判断するために必要です。Ninjaは、生成されたファイルと生成されていないファイルの両方について、すべての入力ファイルに対してこの依存関係ファイルを使用します。この動作は他のバックエンドでも同様です。
最後に、shared_module()
は、以下のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
<lang>_args |
list [str ] |
特定の言語で使用するコンパイラーフラグ。例:C++の場合は |
|
<lang>_pch |
str |
特定の言語で使用するプリコンパイル済みヘッダーファイル |
|
build_by_default |
bool |
|
(0.38.0以降)
|
build_rpath |
str |
ビルドディレクトリでターゲットのrpath定義に追加される文字列ですが、インストール時に削除されます。 |
(0.42.0以降) |
d_debug |
list [str ] |
Dソースファイルのコンパイル中に追加するDバージョン識別子。 |
|
d_import_dirs |
list [inc | str ] |
文字列検索パスに追加するディレクトリ(つまりDMDの |
(0.62.0以降) |
d_module_versions |
list [str | int ] |
Dソースのコンパイル時に設定されるモジュールバージョン識別子のリスト。 |
|
d_unittest |
bool |
trueに設定すると、Dモジュールはデバッグモードでコンパイルされます。 |
|
dependencies |
list [dep ] |
|
|
extra_files |
str | file | custom_tgt | custom_idx |
ビルド自体には使用されませんが、ターゲット別にファイルをグループ化するIDE(Visual Studioなど)ではソースファイルとして表示されます。 |
|
gnu_symbol_visibility |
str |
シンボルをエクスポートする方法を指定します。詳細については、たとえばGCC Wikiを参照してください。この値は、空の文字列または |
(0.48.0以降) |
gui_app |
bool |
trueに設定すると、このターゲットをGUIアプリケーションとしてプラットフォームで区別する必要がある場合にフラグを立てます。0.56.0以降は非推奨です。代わりに |
非推奨 0.56.0で
|
implicit_include_directories |
bool |
Mesonが現在のソースディレクトリとビルドディレクトリをインクルードパスに追加するかどうかを制御します |
(0.42.0以降)
|
include_directories |
list [inc | str ] |
|
|
install |
bool |
trueに設定すると、この実行可能ファイルがインストールされます。 |
|
install_dir |
str |
このファイルのインストールディレクトリを上書きします。値が相対パスの場合、 |
|
install_mode |
list [str | int ] |
インストールされたファイルのシンボリック形式でのファイルモード、およびオプションで所有者/uidとグループ/gidを指定します。 詳細については、 |
(0.47.0以降) |
install_rpath |
str |
インストール後にターゲットのrpathを設定する文字列(ただし、その前ではありません)。Windowsでは、この引数は効果がありません。 |
|
install_tag |
str |
|
(0.60.0以降) |
link_args |
list [str ] |
リンク中に使用するフラグ。すべてのプラットフォームでUNIXスタイルのフラグを使用できます。 |
|
link_depends |
str | file | custom_tgt | custom_idx |
シンボルvisibilityマップなど、リンクステップが依存する文字列、ファイル、またはカスタムターゲット。目的は、このファイルが変更されたときにターゲットの再リンク(ただし再コンパイルではない)を自動的にトリガーすることです。 |
|
link_language |
str |
このターゲットのリンカーを特定の言語にするようにします。通常、Mesonはほとんどの場合正しいリンカーを検出するため、これを設定する必要はありません。これが必要になるのは2つのケースだけです。1つは、実行可能ファイルのメイン関数がMesonが選択した言語ではない場合、もう1つは、ライブラリに1つのABIのみを使用するように強制する場合です。 (0.55.0まで破損) |
(0.51.0以降) |
link_whole |
list [lib | custom_tgt | custom_idx ] |
与えられた静的ライブラリのすべてのコンテンツを、使用されているかどうかに関わらずリンクします。GCCの (0.41.0以降)リストが渡された場合、そのリストは平坦化されます。 (0.51.0以降)この引数は、カスタムターゲットによって生成された出力も受け入れます。ユーザーは、出力が正しい形式のライブラリであることを確認する必要があります。 |
(0.40.0以降) |
link_with |
list [lib | custom_tgt | custom_idx ] |
このターゲットがリンクされるべき、このプロジェクトでビルドされた1つ以上の共有または静的ライブラリ。(0.41.0以降)リストが渡された場合、このリストは平坦化されます。(0.51.0以降)引数はカスタムターゲットにすることもできます。この場合、Mesonはリンカーコマンドラインに出力ファイルを追加するだけでリンクが機能すると想定します。これが十分でない場合、ビルドシステムの作成者は他のすべてのステップを手動で記述する必要があります。 |
|
name_prefix |
str | list [void ] |
ターゲット出力ファイル名のプレフィックスとして使用される文字列。デフォルトを上書きします(ライブラリでのみ使用)。デフォルトでは、MSVC共有ライブラリでは規約に従って省略され、Cygwin共有ライブラリでは デフォルトの動作を使用するには、これを |
|
name_suffix |
str | list [void ] |
デフォルトを上書きして、ターゲットの拡張子として使用される文字列。デフォルトでは、Windowsでは実行可能ファイルは 共有ライブラリの場合、デフォルト値はmacOSでは デフォルトの動作を使用するには、これを |
|
native |
bool |
ターゲットがビルドマシンまたはホストマシン用にコンパイルされるかどうかを制御します。 |
|
objects |
list [extracted_obj | file | str ] |
このターゲットにリンクする必要があるオブジェクトファイルのリスト。 1.1.0以降、ソースがないオブジェクトファイルや、他のビルドターゲットによって生成されたオブジェクトファイルに加えて、生成されたファイルを含めることができます。以前のリリースでは、生成されたオブジェクトファイルを |
|
override_options |
list [str ] | dict [str | bool | int | list [str ]] |
|
(0.40.0以降) |
rust_abi |
str |
(Rustをコンパイルする際に)コンパイルする特定のABIを設定します。
|
(1.3.0以降) |
rust_crate_type |
str |
(Rustをコンパイルする際に)コンパイルする特定のRustクレートのタイプを設定します。 ターゲットが それが それが 「proc-macro」は0.62.0の新機能です。 1.3.0以降、これは非推奨となり、「rust_abi」キーワード引数に置き換えられました。 |
(0.42.0以降) 非推奨 1.3.0で |
rust_dependency_map |
dict [str ] |
Rustターゲットの場合、これはライブラリ名から、Rustコード内で利用可能になるクレート名へのマップを提供します。 これにより、cargoの依存関係の名前変更機能や、Rustコード内の |
(1.2.0以降) |
sources |
str | file | custom_tgt | custom_idx | generated_list | structured_src |
追加のソースファイル。source可変長引数と同じです。 |
|
vala_args |
list [str | file ] |
Valaのコンパイラフラグ。他の言語とは異なり、これにはファイルを含めることができます。 |
|
vs_module_defs |
str | file | custom_tgt | custom_idx |
シンボルのエクスポートなどを制御するためのMicrosoftモジュール定義ファイルを、それが可能なプラットフォーム(例:Windows)で指定します。 (1.3.0以降) |
(0.52.0以降) |
win_subsystem |
str |
Windowsプラットフォームで使用するサブシステムタイプを指定します。一般的な値には、テキストモードプログラムの場合は |
(0.56.0以降)
|
static_library()
指定されたソースを使用して静的ライブラリをビルドします。
シグネチャ
# Builds a static library with the given sources
lib static_library(
str target_name, # The *unique* name of the build target
str | file | custom_tgt | custom_idx | generated_list source..., # Input source to compile
# Keyword arguments:
<lang>_args : list[str] # compiler flags to use for the given language;
<lang>_pch : str # precompiled header file to use for the given language
build_by_default : bool # Causes, when set to `true`, to have this target be built by default
build_rpath : str # A string to add to target's rpath definition in the build dir,
d_debug : list[str] # The [D version identifiers](https://dlang
d_import_dirs : list[inc | str] # the directories to add to the string search path (i
d_module_versions : list[str | int] # List of module version identifiers set when compiling D sources
d_unittest : bool # When set to true, the D modules are compiled in debug mode
dependencies : list[dep] # one or more dependency objects
extra_files : str | file | custom_tgt | custom_idx # Not used for the build itself but are shown as source files in IDEs
gnu_symbol_visibility : str # Specifies how symbols should be exported, see
gui_app : bool # When set to true flags this target as a GUI application
implicit_include_directories : bool # Controls whether Meson adds the current source and build directories to the include path
include_directories : list[inc | str] # one or more objects created with the include_directories()
function,
install : bool # When set to true, this executable should be installed
install_dir : str # override install directory for this file
install_mode : list[str | int] # Specify the file mode in symbolic format
install_rpath : str # A string to set the target's rpath to after install
install_tag : str # A string used by the `meson install --tags` command
link_args : list[str] # Flags to use during linking
link_depends : str | file | custom_tgt | custom_idx # Strings, files, or custom targets the link step depends on
link_language : str # Makes the linker for this target be for the specified language
link_whole : list[lib | custom_tgt | custom_idx] # Links all contents of the given static libraries whether they are used or
link_with : list[lib | custom_tgt | custom_idx] # One or more shared or static libraries
name_prefix : str | list[void] # The string that will be used as the prefix for the
name_suffix : str | list[void] # The string that will be used as the extension for the
native : bool # Controls whether the target is compiled for the build or host machines
objects : list[extracted_obj | file | str] # List of object files that should be linked in this target
override_options : list[str] | dict[str | bool | int | list[str]] # takes an array of strings in the same format as `project`'s `default_options`
pic : bool # Builds the library as positional independent code
prelink : bool # If `true` the object files in the target will be prelinked,
rust_abi : str # Set the specific ABI to compile (when compiling rust)
rust_crate_type : str # Set the specific type of rust crate to compile (when compiling rust)
rust_dependency_map : dict[str] # On rust targets this provides a map of library names to the crate name
sources : str | file | custom_tgt | custom_idx | generated_list | structured_src # Additional source files
vala_args : list[str | file] # Compiler flags for Vala
win_subsystem : str # Specifies the subsystem type to use
)
引数
関数static_library()
は、以下の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
target_name |
str |
ビルドターゲットの一意な名前 |
|
さらに、関数は0
から無限
の可変長引数(source...
)を、
型で受け付けます。str
| file
| custom_tgt
| custom_idx
| generated_list
コンパイルする入力ソース。以下の型がサポートされています。
- 現在のソースディレクトリからの相対パスを表す文字列
-
先行するビルドファイルで定義された
file
オブジェクト configure_file()
などの設定時ジェネレーターの戻り値custom_target()
やgenerator.process()
などのビルド時ジェネレーターの戻り値
これらの入力ファイルは、ソース、オブジェクト、ライブラリ、その他のファイルにすることができます。Mesonは、拡張子に基づいて自動的に分類し、それに応じて使用します。たとえば、ソース(.c
、.cpp
、.vala
、.rs
など)はコンパイルされ、オブジェクト(.o
、.obj
)とライブラリ(.so
、.dll
など)はリンクされます。
Ninjaバックエンドでは、Mesonは、不明なファイルを含め、すべての生成された入力ファイルに対するビルド時順序のみの依存関係を作成します。これは、コンパイラーによって生成されたdepfileで実際の依存関係の生成をブートストラップし、ソースをいつリビルドするかを判断するために必要です。Ninjaは、生成されたファイルと生成されていないファイルの両方について、すべての入力ファイルに対してこの依存関係ファイルを使用します。この動作は他のバックエンドでも同様です。
最後に、static_library()
は、以下のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
<lang>_args |
list [str ] |
特定の言語で使用するコンパイラーフラグ。例:C++の場合は |
|
<lang>_pch |
str |
特定の言語で使用するプリコンパイル済みヘッダーファイル |
|
build_by_default |
bool |
|
(0.38.0以降)
|
build_rpath |
str |
ビルドディレクトリでターゲットのrpath定義に追加される文字列ですが、インストール時に削除されます。 |
(0.42.0以降) |
d_debug |
list [str ] |
Dソースファイルのコンパイル中に追加するDバージョン識別子。 |
|
d_import_dirs |
list [inc | str ] |
文字列検索パスに追加するディレクトリ(つまりDMDの |
(0.62.0以降) |
d_module_versions |
list [str | int ] |
Dソースのコンパイル時に設定されるモジュールバージョン識別子のリスト。 |
|
d_unittest |
bool |
trueに設定すると、Dモジュールはデバッグモードでコンパイルされます。 |
|
dependencies |
list [dep ] |
|
|
extra_files |
str | file | custom_tgt | custom_idx |
ビルド自体には使用されませんが、ターゲット別にファイルをグループ化するIDE(Visual Studioなど)ではソースファイルとして表示されます。 |
|
gnu_symbol_visibility |
str |
シンボルをエクスポートする方法を指定します。詳細については、たとえばGCC Wikiを参照してください。この値は、空の文字列または |
(0.48.0以降) |
gui_app |
bool |
trueに設定すると、このターゲットをGUIアプリケーションとしてプラットフォームで区別する必要がある場合にフラグを立てます。0.56.0以降は非推奨です。代わりに |
非推奨 0.56.0で
|
implicit_include_directories |
bool |
Mesonが現在のソースディレクトリとビルドディレクトリをインクルードパスに追加するかどうかを制御します |
(0.42.0以降)
|
include_directories |
list [inc | str ] |
|
|
install |
bool |
trueに設定すると、この実行可能ファイルがインストールされます。 |
|
install_dir |
str |
このファイルのインストールディレクトリを上書きします。値が相対パスの場合、 |
|
install_mode |
list [str | int ] |
インストールされたファイルのシンボリック形式でのファイルモード、およびオプションで所有者/uidとグループ/gidを指定します。 詳細については、 |
(0.47.0以降) |
install_rpath |
str |
インストール後にターゲットのrpathを設定する文字列(ただし、その前ではありません)。Windowsでは、この引数は効果がありません。 |
|
install_tag |
str |
|
(0.60.0以降) |
link_args |
list [str ] |
リンク中に使用するフラグ。すべてのプラットフォームでUNIXスタイルのフラグを使用できます。 |
|
link_depends |
str | file | custom_tgt | custom_idx |
シンボルvisibilityマップなど、リンクステップが依存する文字列、ファイル、またはカスタムターゲット。目的は、このファイルが変更されたときにターゲットの再リンク(ただし再コンパイルではない)を自動的にトリガーすることです。 |
|
link_language |
str |
このターゲットのリンカーを特定の言語にするようにします。通常、Mesonはほとんどの場合正しいリンカーを検出するため、これを設定する必要はありません。これが必要になるのは2つのケースだけです。1つは、実行可能ファイルのメイン関数がMesonが選択した言語ではない場合、もう1つは、ライブラリに1つのABIのみを使用するように強制する場合です。 (0.55.0まで破損) |
(0.51.0以降) |
link_whole |
list [lib | custom_tgt | custom_idx ] |
与えられた静的ライブラリのすべてのコンテンツを、使用されているかどうかに関わらずリンクします。GCCの (0.41.0以降)リストが渡された場合、そのリストは平坦化されます。 (0.51.0以降)この引数は、カスタムターゲットによって生成された出力も受け入れます。ユーザーは、出力が正しい形式のライブラリであることを確認する必要があります。 |
(0.40.0以降) |
link_with |
list [lib | custom_tgt | custom_idx ] |
このターゲットがリンクされるべき、このプロジェクトでビルドされた1つ以上の共有または静的ライブラリ。(0.41.0以降)リストが渡された場合、このリストは平坦化されます。(0.51.0以降)引数はカスタムターゲットにすることもできます。この場合、Mesonはリンカーコマンドラインに出力ファイルを追加するだけでリンクが機能すると想定します。これが十分でない場合、ビルドシステムの作成者は他のすべてのステップを手動で記述する必要があります。 |
|
name_prefix |
str | list [void ] |
ターゲット出力ファイル名のプレフィックスとして使用される文字列。デフォルトを上書きします(ライブラリでのみ使用)。デフォルトでは、MSVC共有ライブラリでは規約に従って省略され、Cygwin共有ライブラリでは デフォルトの動作を使用するには、これを |
|
name_suffix |
str | list [void ] |
デフォルトを上書きして、ターゲットの拡張子として使用される文字列。デフォルトでは、Windowsでは実行可能ファイルは 共有ライブラリの場合、デフォルト値はmacOSでは デフォルトの動作を使用するには、これを |
|
native |
bool |
ターゲットがビルドマシンまたはホストマシン用にコンパイルされるかどうかを制御します。 |
|
objects |
list [extracted_obj | file | str ] |
このターゲットにリンクする必要があるオブジェクトファイルのリスト。 1.1.0以降、ソースがないオブジェクトファイルや、他のビルドターゲットによって生成されたオブジェクトファイルに加えて、生成されたファイルを含めることができます。以前のリリースでは、生成されたオブジェクトファイルを |
|
override_options |
list [str ] | dict [str | bool | int | list [str ]] |
|
(0.40.0以降) |
pic |
bool |
ライブラリを位置独立コードとしてビルドします(共有ライブラリにリンクできるように)。このオプションはWindowsとOS Xでは意味がないため、効果がありません。Windowsでは意味がなく、OS XではPICを無効にできないためです。 |
(0.36.0以降) |
prelink |
bool |
|
(0.57.0以降) |
rust_abi |
str |
(Rustをコンパイルする際に)コンパイルする特定のABIを設定します。
|
(1.3.0以降) |
rust_crate_type |
str |
(Rustをコンパイルする際に)コンパイルする特定のRustクレートのタイプを設定します。 ターゲットが それが それが 「proc-macro」は0.62.0の新機能です。 1.3.0以降、これは非推奨となり、「rust_abi」キーワード引数に置き換えられました。 |
(0.42.0以降) 非推奨 1.3.0で |
rust_dependency_map |
dict [str ] |
Rustターゲットの場合、これはライブラリ名から、Rustコード内で利用可能になるクレート名へのマップを提供します。 これにより、cargoの依存関係の名前変更機能や、Rustコード内の |
(1.2.0以降) |
sources |
str | file | custom_tgt | custom_idx | generated_list | structured_src |
追加のソースファイル。source可変長引数と同じです。 |
|
vala_args |
list [str | file ] |
Valaのコンパイラフラグ。他の言語とは異なり、これにはファイルを含めることができます。 |
|
win_subsystem |
str |
Windowsプラットフォームで使用するサブシステムタイプを指定します。一般的な値には、テキストモードプログラムの場合は |
(0.56.0以降)
|
structured_sources()
不透明であり、static_library、shared_library、executableなどの任意のbuild_targetへのソースとして渡すことができるStructuredSourceオブジェクトを作成します。これは、インポート名を決定するためにファイルシステムレイアウトを使用するRustなどの言語で役立ちます。これはRustターゲットでのみ許可されており、構造化されていない入力と混在させることはできません。
シグネチャ
(0.62.0以降)
# Create a StructuredSource object, which is opaque and may be passed as a source
structured_src structured_sources(
list[str | file | custom_tgt | custom_idx | generated_list] root, # Sources to put at the root of the generated structure
dict[str | file | custom_tgt | custom_idx | generated_list] [additional], # Additional sources, where the key is the directory under the root to place
)
引数
関数structured_sources()
は、以下の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
root |
list [str | file | custom_tgt | custom_idx | generated_list ] |
生成された構造のルートに配置するソース |
|
additional |
dict [str | file | custom_tgt | custom_idx | generated_list ] |
追加のソース。キーは、値を配置するルート下のディレクトリです。 |
[オプション] |
subdir()
指定されたサブディレクトリに入り、その中のmeson.build
ファイルを実行します。それが完了すると、戻り、このsubdir()
コマンドに続く行で実行が続行されます。そのmeson.build
ファイルで定義された変数は、現在のビルドファイルの後の部分、およびsubdir()
で実行される後続のすべてのビルドファイルで使用できるようになります。
これは、ソースツリー内の各meson.build
ファイルは1回だけ実行でき、実行する必要があることを意味します。
シグネチャ
# Enters the specified subdirectory and executes the `meson
void subdir(
str dir_name, # Directory relative to the current `meson
# Keyword arguments:
if_found : list[dep] # Only enter the subdir if all dep.found()
methods return `true`.
)
引数
関数subdir()
は、以下の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
dir_name |
str |
現在の
|
|
最後に、subdir()
は、以下のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
if_found |
list [dep ] |
すべての |
(0.44.0以降) |
subdir_done()
呼び出し時点から、Mesonスクリプトファイルのそれ以上の解釈を停止します。この時点までに実行されたすべての手順は有効であり、Mesonによって実行されます。これは、subdir_done()
の呼び出し前に定義されたすべてのターゲットがビルドされることを意味します。
現在のスクリプトがsubdir
によって呼び出された場合、実行は呼び出し元のディレクトリに戻り、スクリプトが最後に到達した場合と同様に続行されます。現在のスクリプトがトップレベルのスクリプトである場合、Mesonはこの時点までに定義されたプロジェクトを構成します。
シグネチャ
(0.46.0以降)
void subdir_done()
例
project('example exit', 'cpp')
executable('exe1', 'exe1.cpp')
subdir_done()
executable('exe2', 'exe2.cpp')
実行可能ファイルexe1
がビルドされ、実行可能ファイルexe2
はビルドされません。
subproject()
位置引数で指定されたプロジェクトを取得し、subproject
オブジェクトを返すことによって、現在のビルド仕様に取り込みます。サブプロジェクトは、常にトップソースディレクトリのsubprojects
ディレクトリ内に配置する必要があります。たとえば、foo
という名前のサブプロジェクトは、${MESON_SOURCE_ROOT}/subprojects/foo
に配置する必要があります。
-
default_options
(0.37.0以降): サブプロジェクトのmeson.options
で設定されたものをオーバーライドするデフォルトオプション値の配列(project
のdefault_options
と同様、Mesonが最初に実行されたときにのみ有効になり、コマンドライン引数はビルドファイル内のデフォルトオプションをオーバーライドします)。(0.54.0以降):default_library
組み込みオプションもオーバーライドできます。(1.2.0以降): 配列の代わりに辞書を渡すことができます。 -
version
:dependency
と同じように機能します。サブプロジェクトがどのバージョンである必要があるかを、たとえば>=1.0.1
のように指定します。 -
required
(0.48.0以降): デフォルトでは、required
はtrue
であり、サブプロジェクトを設定できなかった場合、Mesonは中止します。これをfalse
に設定し、subproject
オブジェクトで.found()
メソッドを使用できます。feature
オプションの値を、dependency()
と同じように渡すこともできます。
返されたsubproject
オブジェクトを使用して、サブプロジェクト内の任意の変数にアクセスできることに注意してください。ただし、サブプロジェクト内から依存関係オブジェクトを使用する場合は、dependency()
のfallback:
キーワード引数を使用する方が簡単です。
シグネチャ
# Takes the project specified in the positional argument and brings that
subproject subproject(
str subproject_name, # Name of the subproject
# Keyword arguments:
default_options : list[str] | dict[str | bool | int | list[str]] # An array of default option values
required : bool | feature # Works just the same as in dependency()
.
version : str # Works just like the same as in dependency()
.
)
引数
関数subproject()
は、以下の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
subproject_name |
str |
サブプロジェクトの名前。サブプロジェクトは、 |
|
最後に、subproject()
は、以下のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
default_options |
list [str ] | dict [str | bool | int | list [str ]] |
サブプロジェクトの |
(0.37.0以降) |
required |
bool | feature |
|
(0.48.0以降)
|
version |
str |
|
|
summary()
この関数は、ビルドプロセスの最後にビルド構成を要約するために使用されます。この関数は、プロジェクト(およびサブプロジェクト)がこの情報を明確な方法で報告するための方法を提供します。
コンテンツは、セクションにグループ化された一連のキー/値ペアです。セクションのキーワード引数が省略されている場合、これらのキー/値ペアは、タイトルなしのセクションに暗黙的にグループ化されます。キー/値ペアはオプションで辞書にグループ化できますが、辞書は順序を保証しないことに注意してください。key
は文字列である必要があり、value
は次のいずれかになります。
- 整数、ブール値、または文字列
- 0.57.0以降 外部プログラムまたは依存関係
- 0.58.0以降 機能オプション
- それらのリスト。
summary(key, value)
としてsummaryを呼び出す代わりに、以下の例に見られるように、辞書をsummary()
関数に直接渡すこともできます。
同じセクション/キーペアが2回表示されない限り、summary()
を複数回呼び出すことができます。すべてのセクションが収集され、呼び出された順序と同じ順序で構成の最後に印刷されます。
シグネチャ
(0.53.0 以降)
# This function is used to summarize build configuration at the end of the build
void summary(
str | dict[str | bool | int | dep | external_program | list[str | bool | int | dep | external_program]] key_or_dict, # The name of the new entry, or a dict containing multiple entries
str | bool | int | dep | external_program | list[str | bool | int | dep | external_program] [value], # The value to print for the `key`
# Keyword arguments:
bool_yn : bool # Convert bool values to yes and no
list_sep : str # The separator to use when printing list values in this summary
section : str # The section to put this summary information under
)
例
例meson.build
project('My Project', version : '1.0')
summary({'bindir': get_option('bindir'),
'libdir': get_option('libdir'),
'datadir': get_option('datadir'),
}, section: 'Directories')
summary({'Some boolean': false,
'Another boolean': true,
'Some string': 'Hello World',
'A list': ['string', 1, true],
}, section: 'Configuration')
出力
My Project 1.0
Directories
prefix : /opt/gnome
bindir : bin
libdir : lib/x86_64-linux-gnu
datadir : share
Configuration
Some boolean : False
Another boolean: True
Some string : Hello World
A list : string
1
True
引数
引数の平坦化は、この関数ではサポートされていません。
関数summary()
は、以下の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
key_or_dict |
str | dict [str | bool | int | dep | external_program | list [str | bool | int | dep | external_program ]] |
新しいエントリの名前、または複数のエントリを含む辞書。辞書が渡された場合は、キーと値のペアごとにsummary()を1回呼び出すのと同じです。辞書は順序を保証しないことに注意してください。 |
|
値 |
str | bool | int | dep | external_program | list [str | bool | int | dep | external_program ] |
|
[オプション] |
最後に、summary()
は、以下のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
bool_yn |
bool |
ブール値をyesとnoに変換します |
|
list_sep |
str |
この概要でリスト値を印刷するときに使用する区切り記号。区切り記号が指定されていない場合は、各リスト項目が独自の行に印刷されます。 |
(0.54.0以降) |
section |
str |
この要約情報を配置するセクション。セクションのキーワード引数が省略されている場合、キー/値ペアは、タイトルなしのセクションに暗黙的にグループ化されます。 |
|
test()
テストハーネスで実行するテストを定義します。2つの位置引数を取ります。1つ目はテストの名前、2つ目は実行する実行可能ファイルです。実行可能ファイルは、executable()
によって返されるexe
オブジェクト、またはfind_program()
によって返されるexternal_program
オブジェクトにすることができます。
(0.55.0以降) クロスコンパイル時、exe_wrapperが必要で定義されている場合、環境変数MESON_EXE_WRAPPER
にはそのラッパーの文字列値が設定されます(実装の詳細:mesonlib.join_args
を使用)。テストスクリプトは、これを使ってクロスビルドされたバイナリを実行できます。テストがクロスビルド環境でMESON_EXE_WRAPPER
を必要とする場合、「スキップ」を報告するようにハーネスに伝えるために、コード77を返すのはあなたの責任です。
デフォルトでは、環境変数MALLOC_PERTURB_
は、meson test
によって1〜255のランダムな値に自動的に設定されます。これは、非GCCコンパイラを含むglibcを使用する構成でのメモリリークの発見に役立ちます。ただし、これはパフォーマンスに影響を与える可能性があり、ユーザーが制御できない内部を持つ外部ライブラリが原因でテストに失敗する可能性があります。この機能が予期されるランタイムクラッシュを引き起こしているかどうかを確認するには、環境変数MALLOC_PERTURB_=0
を一時的に設定して機能を無効にします。このチェックの一時的な無効化のみが望ましいですが、プロジェクトでmeson.build
でこのチェックを永続的に無効にする必要がある場合は、次のようにします。
nomalloc = environment({'MALLOC_PERTURB_': '0'})
test(..., env: nomalloc, ...)
デフォルトでは、環境変数ASAN_OPTIONS
、UBSAN_OPTIONS
、およびMSAN_OPTIONS
は、検出された違反でアボートし、バックトレースを提供するように設定されています。これを抑制するには、環境でASAN_OPTIONS
、UBSAN_OPTIONS
、またはMSAN_OPTIONS
を設定できます。
個々の実行可能ファイルをテストケースとして実行することに加えて、test()
を使用して外部テストハーネスを起動することもできます。この場合、verbose: true
(0.62.0以降)を使用し、外部ハーネスでサポートされている場合はprotocol: 'tap'
(0.50.0以降)を使用するのが最適です。これにより、Mesonは実行の最後にログ全体を含める代わりに、各サブテストを実行時にログに記録するようになります。
定義されたテストは、ビルドディレクトリ内でmeson test
を呼び出すか、ninja test
やmsbuild RUN_TESTS.vcxproj
などのバックエンド固有のコマンドを使用して、バックエンドに依存しない方法で実行できます。
シグネチャ
# Defines a test to run with the test harness
void test(
str name, # The *unique* test id
exe | jar | external_program | file | custom_tgt | custom_idx executable, # The program to execute
# Keyword arguments:
args : list[str | file | tgt | external_program] # Arguments to pass to the executable
depends : list[build_tgt | custom_tgt] # specifies that this test depends on the specified
env : env | list[str] | dict[str] # environment variables to set, such as `['NAME1=value1',
is_parallel : bool # when false, specifies that no other test must be
priority : int # specifies the priority of a test
protocol : str # specifies how the test results are parsed and can
should_fail : bool # when true the test is considered passed if the
suite : str | list[str] # `'label'` (or list of labels `['label1', 'label2']`)
timeout : int # the amount of seconds the test is allowed to run, a test
verbose : bool # if true, forces the test results to be logged as if `--verbose` was passed
workdir : str # absolute path that will be used as the working directory
)
引数
関数test()
は、次の位置引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
name |
str |
一意のテストID |
|
executable |
exe | jar | external_program | file | custom_tgt | custom_idx |
実行するプログラム。(1.4.0以降)CustomTargetも受け入れられます。 |
|
最後に、test()
は次のキーワード引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
args |
list [str | file | tgt | external_program ] |
実行可能ファイルに渡す引数 |
|
depends |
list [build_tgt | custom_tgt ] |
このテストが、コマンドライン引数として使用しない場合でも、指定されたターゲットに依存することを指定します。これは、テストが内部的にこれらのターゲット、たとえばプラグインまたはグロブを見つける場合に役立ちます。これらのターゲットは、 |
(0.46.0以降) |
env |
env | list [str ] | dict [str ] |
|
|
is_parallel |
bool |
falseの場合、このテストと同じ時間に他のテストを実行してはならないことを指定します。 |
|
priority |
int |
テストの優先度を指定します。優先度が高いテストは、優先度が低いテストよりも先に開始されます。同一の優先度を持つテストの開始順序は実装によって定義されます。デフォルトの優先度は0で、負の数も許可されます。 |
(0.52.0以降)
|
protocol |
str |
テスト結果の解析方法を指定します。
|
(0.50.0以降)
|
should_fail |
bool |
trueの場合、実行ファイルがゼロ以外のリターン値を返した場合(つまりエラーを報告した場合)にテストは成功とみなされます。 |
|
suite |
str | list [str ] |
このテストに付加される |
|
timeout |
int |
テストの実行が許可される秒数。制限時間を超えたテストは常に失敗とみなされます。デフォルトは30秒です。0.57以降、タイムアウトが |
|
verbose |
bool |
trueの場合、 |
(0.62.0以降)
|
workdir |
str |
テストの作業ディレクトリとして使用される絶対パス |
|
unset_variable()
変数をunsetします。unsetされた変数を参照すると、再度設定されるまでエラーになります。
シグネチャ
(0.60.0以降)
# Unsets a variable
void unset_variable(
str varname, # The variable to unset
)
引数
関数unset_variable()
は、次の位置引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
varname |
str |
unsetする変数。 |
|
vcs_tag()
このコマンドは、ビルド時にリビジョン管理のコミット情報を検出し、指定された出力ファイルに配置します。このファイルは、すべてのビルドで最新の状態であることが保証されています。キーワードは、custom_target()
に似ています。
Mesonはinput
の内容を読み取り、replace_string
を検出されたリビジョン番号で置き換え、結果をoutput
に書き込みます。このメソッドは、(通常どおり)他のターゲットがこれが出力するファイルを使用する場合に、依存関係を知らせるために使用する必要があるcustom_tgt
オブジェクトを返します。
たとえば、これでヘッダーを生成し、それをビルドターゲットで使用する場合は、そのビルドターゲットのソースに返り値を追加する必要があります。それがなければ、Mesonはターゲットをビルドする順序を認識しません。
このコマンドが提供するよりも具体的な動作が必要な場合は、custom_target()
を使用する必要があります。
シグネチャ
# This command detects revision control commit information at build time
custom_tgt vcs_tag(
command : list[exe | external_program | custom_tgt | file | str] # The command to execute, see custom_target()
for details
fallback : str # Version number to use when no revision control information is present,
input : str [required] # File to modify (e
output : str [required] # File to write the results to (e
replace_string : str # String in the input file to substitute with the commit information
)
引数
関数vcs_tag()
は、次のキーワード引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
command |
list [exe | external_program | custom_tgt | file | str ] |
実行するコマンド。このコマンドをどのように指定する必要があるかについての詳細は、 このパラメータはオプションです。省略した場合、Mesonは適切なデフォルトコマンドを検索します。 (0.62.0以降) (0.63.0以降) |
|
fallback |
str |
リリースtarballからビルドする場合など、リビジョン管理情報が存在しない場合に使用するバージョン番号。 |
|
input |
str |
変更するファイル(例: |
|
output |
str |
結果を書き込むファイル(例: |
|
replace_string |
str |
コミット情報で置き換える入力ファイル内の文字列。 |
|
warning()
この関数は、引数を「WARNING:」というプレフィックスを付けて標準出力に出力します。
シグネチャ
(0.44.0以降)
# This function prints its argument to stdout prefixed with WARNING:
void warning(
str | int | bool | list[str | int | bool] | dict[str | int | bool] text, # The message to print
str | int | bool | list[str | int | bool] | dict[str | int | bool] more_text..., # Additional text that will be printed separated by spaces
)
引数
引数の平坦化は、この関数ではサポートされていません。
関数warning()
は、次の位置引数を受け入れます。
名前 | 型 | 説明 | タグ |
---|---|---|---|
text |
str | int | bool | list [str | int | bool ] | dict [str | int | bool ] |
出力するメッセージ。 |
|
さらに、この関数は、0
個から無限
個の可変長引数(more_text...
)を、型が
であるものを、受け入れます。str
| int
| bool
| list
[str
| int
| bool
] | dict
[str
| int
| bool
]
スペースで区切られて出力される追加のテキスト。
(0.54.0以降)
検索結果は次のとおりです