コンパイラオブジェクト (compiler)

このオブジェクトは、meson.get_compiler()によって返されます。これは、特定の言語のコンパイラを表し、そのプロパティを照会することができます。

返される場所

コンパイラオブジェクトは、以下の関数とメソッドによって返されます

注意

これらのコンパイラチェックでは、add_*_arguments()で追加されたコンパイラ引数、コマンドラインの-Dlang_args、または環境変数のCFLAGS/LDFLAGSなどを使いません。したがって、テストは完全に自己完結しており、ビルドファイルの他の部分やユーザーによって追加されたカスタムフラグが原因で失敗することはないと信頼できます。

注意

すべての依存関係が単一のプレフィックスにある場合、GCC/Clangでは環境変数C_INCLUDE_PATHに、MSVCではINCLUDEに追加してデフォルトのインクルードパスを拡張し、GCC/ClangではLIBRARY_PATHに、MSVCではLIBに追加してデフォルトのライブラリ検索パスを拡張する方が簡単かもしれません。

ただし、GCCの場合、これらの変数はクロスコンパイル時には無視されます。その場合は、specsファイルを使用する必要があります。以下を参照してください: http://www.mingw.org/wiki/SpecsFileHOWTO

コンパイラオブジェクトのメソッド

compiler.alignment()

指定された型の配置を返します。C系言語の場合、ネイティブコンパイルではヘッダーstddef.hstdio.hが暗黙的にインクルードされ、クロスコンパイルではstddef.hのみがインクルードされます。

シグネチャ

# Returns the alignment of the specified type
int alignment(
  str typename,     # The name of the type to check

  # Keyword arguments:
  args         : list[str]        # Used to pass a list of compiler arguments
  dependencies : dep | list[dep]  # Additionally dependencies required for compiling and / or linking
  prefix       : str | list[str]  # Used to add `#include`s and other things that are required
)

引数

メソッドcompiler.alignment()は、以下の位置引数を受け取ります

名前 説明 タグ
typename str

チェックする型の名前。

最後に、compiler.alignment()は、以下のキーワード引数を受け取ります

名前 説明 タグ
args list[str]

コンパイラ引数のリストを渡すために使用します。デフォルトのインクルードパスにないヘッダーのインクルードパスを-Isome/path/to/headerで定義することは一般的にサポートされていますが、通常は推奨されません。

これは、インクルードディレクトリもinclude_directoriesまたはdependency kwarg(存在する場合)で指定できるためです。リンクするライブラリを-lfooで渡す場合も同様です。

dependencies dep | list[dep]

コンパイルおよび/またはリンクに必要な追加の依存関係。

prefix str | list[str]

#includeや、シンボルを宣言するために必要なその他のものを追加するために使用します。1.0.0以降、配列も受け入れられるようになりました。配列が渡された場合、アイテムは改行で区切られて連結されます。システム定義は、コンパイラ引数(例:_GNU_SOURCEは、Linuxで一部のシンボルを公開するためによく必要とされ、argsキーワード引数で渡されるべきです)を介して渡される必要があります。


compiler.check_header()

指定されたヘッダーが、指定されたプレフィックス、依存関係、および引数で使用可能な場合にtrueを返します。

シグネチャ

(0.47.0以降)

# Returns true if the specified header is *usable*
bool check_header(
  str header_name,     # The header to check

  # Keyword arguments:
  args                : list[str]        # Used to pass a list of compiler arguments
  dependencies        : dep | list[dep]  # Additionally dependencies required for compiling and / or linking
  include_directories : inc | list[inc]  # Extra directories for header searches
  no_builtin_args     : bool             # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
  prefix              : str | list[str]  # Used to add `#include`s and other things that are required
  required            : bool | feature   # When set to `true`, Meson will halt if the header check fails
)

引数

メソッドcompiler.check_header()は、以下の位置引数を受け取ります

名前 説明 タグ
header_name str

チェックするヘッダー。

最後に、compiler.check_header()は、以下のキーワード引数を受け取ります

名前 説明 タグ
args list[str]

コンパイラ引数のリストを渡すために使用します。デフォルトのインクルードパスにないヘッダーのインクルードパスを-Isome/path/to/headerで定義することは一般的にサポートされていますが、通常は推奨されません。

これは、インクルードディレクトリもinclude_directoriesまたはdependency kwarg(存在する場合)で指定できるためです。リンクするライブラリを-lfooで渡す場合も同様です。

dependencies dep | list[dep]

コンパイルおよび/またはリンクに必要な追加の依存関係。

include_directories inc | list[inc]

ヘッダー検索用の追加ディレクトリ。

(0.38.0以降)

no_builtin_args bool

trueに設定すると、組み込み構成オプションによって制御されるコンパイラ引数が追加されません。

default = false

prefix str | list[str]

#includeや、シンボルを宣言するために必要なその他のものを追加するために使用します。1.0.0以降、配列も受け入れられるようになりました。配列が渡された場合、アイテムは改行で区切られて連結されます。システム定義は、コンパイラ引数(例:_GNU_SOURCEは、Linuxで一部のシンボルを公開するためによく必要とされ、argsキーワード引数で渡されるべきです)を介して渡される必要があります。

required bool | feature

trueに設定すると、ヘッダーチェックが失敗した場合、Mesonは停止します。featureオプションに設定すると、その機能によって検索するかどうか、および見つからない場合に失敗するかどうかを制御します。

(0.50.0以降)

default = false


compiler.cmd_array()

コンパイラのコマンドを含む配列を返します。

シグネチャ

list[str] cmd_array()


compiler.compiles()

コードがコンパイルされる場合にtrueを返します。

シグネチャ

# Returns true if the code compiles
bool compiles(
  str | file code,     # The source code to check

  # Keyword arguments:
  args                : list[str]        # Used to pass a list of compiler arguments
  dependencies        : dep | list[dep]  # Additionally dependencies required for compiling and / or linking
  include_directories : inc | list[inc]  # Extra directories for header searches
  name                : str              # The name to use for printing a message about the compiler check
  no_builtin_args     : bool             # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
  required            : bool | feature   # When set to `true`, Meson will halt if the check fails
  werror              : bool             # When set to `true`, compiler warnings are treated as error
)

引数

メソッドcompiler.compiles()は、以下の位置引数を受け取ります

名前 説明 タグ
code str | file

チェックするソースコード。

文字列が渡された場合、コードは直接使用されます。fileオブジェクトが渡された場合、その内容はコンパイラチェックに使用されます。

最後に、compiler.compiles()は、以下のキーワード引数を受け取ります

名前 説明 タグ
args list[str]

コンパイラ引数のリストを渡すために使用します。デフォルトのインクルードパスにないヘッダーのインクルードパスを-Isome/path/to/headerで定義することは一般的にサポートされていますが、通常は推奨されません。

これは、インクルードディレクトリもinclude_directoriesまたはdependency kwarg(存在する場合)で指定できるためです。リンクするライブラリを-lfooで渡す場合も同様です。

dependencies dep | list[dep]

コンパイルおよび/またはリンクに必要な追加の依存関係。

include_directories inc | list[inc]

ヘッダー検索用の追加ディレクトリ。

(0.38.0以降)

name str

コンパイラチェックに関するメッセージを印刷するために使用する名前。このキーワード引数が渡されない場合、チェックに関するメッセージは印刷されません。

no_builtin_args bool

trueに設定すると、組み込み構成オプションによって制御されるコンパイラ引数が追加されません。

default = false

required bool | feature

trueに設定すると、チェックが失敗した場合、Mesonは停止します。featureオプションに設定すると、その機能によって検索するかどうか、および見つからない場合に失敗するかどうかを制御します。

(1.5.0以降)

default = false

werror bool

trueに設定すると、コンパイラの警告はエラーとして扱われます。

(1.3.0以降)

default = false


compiler.compute_int()

与えられた式の値(例:1 + 2)を計算します。クロスコンパイルの場合、これは反復アルゴリズムで評価されます。キーワード引数low(デフォルトは-1024)、high(デフォルトは1024)、およびguessを指定して、検索の最大値と最小値、および最初に試す値を指定できます。C系言語の場合、ネイティブコンパイルではヘッダーstddef.hstdio.hが暗黙的にインクルードされ、クロスコンパイルではstddef.hのみがインクルードされます。

シグネチャ

(0.40.0以降)

# Computes the value of the given expression
int compute_int(
  str expr,     # The expression to compute

  # Keyword arguments:
  args                : list[str]        # Used to pass a list of compiler arguments
  dependencies        : dep | list[dep]  # Additionally dependencies required for compiling and / or linking
  guess               : int              # The value to try first
  high                : int              # The max value
  include_directories : inc | list[inc]  # Extra directories for header searches
  low                 : int              # The min value
  no_builtin_args     : bool             # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
  prefix              : str | list[str]  # Used to add `#include`s and other things that are required
)

引数

メソッドcompiler.compute_int()は、以下の位置引数を受け取ります

名前 説明 タグ
expr str

計算する式。

最後に、compiler.compute_int()は、以下のキーワード引数を受け取ります

名前 説明 タグ
args list[str]

コンパイラ引数のリストを渡すために使用します。デフォルトのインクルードパスにないヘッダーのインクルードパスを-Isome/path/to/headerで定義することは一般的にサポートされていますが、通常は推奨されません。

これは、インクルードディレクトリもinclude_directoriesまたはdependency kwarg(存在する場合)で指定できるためです。リンクするライブラリを-lfooで渡す場合も同様です。

dependencies dep | list[dep]

コンパイルおよび/またはリンクに必要な追加の依存関係。

guess int

最初に試す値。

high int

最大値。

default = 1024

include_directories inc | list[inc]

ヘッダー検索用の追加ディレクトリ。

(0.38.0以降)

low int

最小値。

default = -1024

no_builtin_args bool

trueに設定すると、組み込み構成オプションによって制御されるコンパイラ引数が追加されません。

default = false

prefix str | list[str]

#includeや、シンボルを宣言するために必要なその他のものを追加するために使用します。1.0.0以降、配列も受け入れられるようになりました。配列が渡された場合、アイテムは改行で区切られて連結されます。システム定義は、コンパイラ引数(例:_GNU_SOURCEは、Linuxで一部のシンボルを公開するためによく必要とされ、argsキーワード引数で渡されるべきです)を介して渡される必要があります。


compiler.find_library()

位置引数で指定されたライブラリを検索しようとします。

シグネチャ

# Tries to find the library specified in the positional argument
dep find_library(
  str libname,     # The library to find

  # Keyword arguments:
  dirs                       : list[str]        # Additional directories to search in
  disabler                   : bool             # If `true`, this method will return a disabler on a failed check.
  has_headers                : list[str]        # List of headers that must be found as well
  header_args                : list[str]        # When the `has_headers` kwarg is also used, this argument is passed to
  header_dependencies        : dep | list[dep]  # When the `has_headers` kwarg is also used, this argument is passed to
  header_include_directories : inc | list[inc]  # When the `has_headers` kwarg is also used, this argument is passed to
  header_no_builtin_args     : bool             # When the `has_headers` kwarg is also used, this argument is passed to
  header_prefix              : str              # When the `has_headers` kwarg is also used, this argument is passed to
  required                   : bool | feature   # If set `true`, Meson will abort with an error if the library could not
  static                     : bool             # If `true`, the search is limited to static libraries only
)

引数

メソッドcompiler.find_library()は、以下の位置引数を受け取ります

名前 説明 タグ
libname str

検索するライブラリ。

最後に、compiler.find_library()は、以下のキーワード引数を受け取ります

名前 説明 タグ
dirs list[str]

検索する追加のディレクトリ。

デフォルトでは、ライブラリはシステムライブラリディレクトリ(例:/usr/lib)で検索されます。ここにさらに多くのディレクトリを指定すると、Mesonはシステムディレクトリだけでなく、これらのディレクトリも検索します。

disabler bool

trueの場合、このメソッドは失敗したチェックでdisablerを返します。

(0.49.0以降)

default = false

has_headers list[str]

同様に見つかる必要があるヘッダーのリスト。このチェックは、compiler.has_header()呼び出しで各ヘッダーをチェックすることと同等です。

使用すると、compiler.has_header()が受け入れるkwargをheader_をプレフィックスとしてここで渡すことができ、ヘッダーチェックで同じ効果が得られます。

(0.50.0以降)

header_args list[str]

has_headers kwargも使用されている場合、この引数はcompiler.has_header()argsとして渡されます。

(0.51.0以降)

header_dependencies dep | list[dep]

has_headers kwargも使用されている場合、この引数はcompiler.has_header()dependenciesとして渡されます。

(0.51.0以降)

header_include_directories inc | list[inc]

has_headers kwargも使用されている場合、この引数はcompiler.has_header()include_directoriesとして渡されます。

(0.51.0以降)

header_no_builtin_args bool

has_headers kwargも使用されている場合、この引数はcompiler.has_header()no_builtin_argsとして渡されます。

(0.51.0以降)

default = false

header_prefix str

has_headers kwargも使用されている場合、この引数はcompiler.has_header()prefixとして渡されます。

(0.51.0以降)

required bool | feature

trueに設定すると、ライブラリが見つからなかった場合、Mesonはエラーで中止します。それ以外の場合、Mesonは続行し、返されたオブジェクトのfoundメソッドはfalseを返します。

featureオプションに設定すると、その機能によって検索するかどうか、および見つからない場合に失敗するかどうかを制御します。

(0.47.0以降) featureオプションの値もここで渡すことができます。

default = true

static bool

trueの場合、検索は静的ライブラリのみに限定されます。この値をfalse(デフォルト)に設定すると、共有ライブラリと静的ライブラリの両方が検索されます。

(0.51.0以降)

default = false


compiler.first_supported_argument()

文字列のリストが与えられた場合、compiler.has_argument()テストに合格する最初の引数を含む単一要素リストを返すか、合格するものがない場合は空の配列を返します。

シグネチャ

(0.43.0以降)

# Given a list of strings, returns a single-element list containing the first
list[str] first_supported_argument(
  str arg...,  # The arguments to check
)

引数

このメソッドは、0からinfinityの可変引数(arg...)を受け入れ、型はstrです。

チェックする引数。


文字列のリストが与えられた場合、compiler.has_link_argument()テストに合格する最初の引数を返すか、合格するものがない場合は空の配列を返します。

シグネチャ

(0.46.0以降)

# Given a list of strings, returns the first argument that passes the
list[str] first_supported_link_argument(
  str arg...,  # The link arguments to check
)

引数

このメソッドは、0からinfinityの可変引数(arg...)を受け入れ、型はstrです。

チェックするリンク引数。


compiler.get_argument_syntax()

コンパイラが受け取る引数の種類を識別する文字列を返します。gccmsvc、または未定義の文字列値のいずれかになります。このメソッドは、gccやmsvcではないが、clangやiccなど、それらの2つのコンパイラのいずれかと同じ引数構文を使用するコンパイラを識別するのに役立ちます。特に、オペレーティングシステムによって異なる構文を使用する場合に役立ちます。

シグネチャ

(0.49.0以降)

str get_argument_syntax()


compiler.get_define()

指定されたプリプロセッサシンボルの値を文字列として返すか、定義されていない場合は空の文字列を返します。

(0.47.0以降) このメソッドは、コンパイラが実行するのと同じように、文字列リテラルを連結します。例:"a" "b""ab"になります。

シグネチャ

(0.40.0以降)

# Returns the given preprocessor symbol's value
str get_define(
  str definename,     # The define to check

  # Keyword arguments:
  args                : list[str]        # Used to pass a list of compiler arguments
  dependencies        : dep | list[dep]  # Additionally dependencies required for compiling and / or linking
  include_directories : inc | list[inc]  # Extra directories for header searches
  no_builtin_args     : bool             # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
  prefix              : str | list[str]  # Used to add `#include`s and other things that are required
)

引数

メソッドcompiler.get_define()は、以下の位置引数を受け取ります

名前 説明 タグ
definename str

チェックする定義。

最後に、compiler.get_define()は、以下のキーワード引数を受け取ります

名前 説明 タグ
args list[str]

コンパイラ引数のリストを渡すために使用します。デフォルトのインクルードパスにないヘッダーのインクルードパスを-Isome/path/to/headerで定義することは一般的にサポートされていますが、通常は推奨されません。

これは、インクルードディレクトリもinclude_directoriesまたはdependency kwarg(存在する場合)で指定できるためです。リンクするライブラリを-lfooで渡す場合も同様です。

dependencies dep | list[dep]

コンパイルおよび/またはリンクに必要な追加の依存関係。

include_directories inc | list[inc]

ヘッダー検索用の追加ディレクトリ。

(0.38.0以降)

no_builtin_args bool

trueに設定すると、組み込み構成オプションによって制御されるコンパイラ引数が追加されません。

default = false

prefix str | list[str]

#includeや、シンボルを宣言するために必要なその他のものを追加するために使用します。1.0.0以降、配列も受け入れられるようになりました。配列が渡された場合、アイテムは改行で区切られて連結されます。システム定義は、コンパイラ引数(例:_GNU_SOURCEは、Linuxで一部のシンボルを公開するためによく必要とされ、argsキーワード引数で渡されるべきです)を介して渡される必要があります。


compiler.get_id()

コンパイラを識別する文字列を返します。例:gccmsvcその他

シグネチャ

str get_id()


compiler.get_linker_id()

リンカーを識別する文字列を返します。例:ld.bfdlinkその他

シグネチャ

(0.53.0以降)

str get_linker_id()


compiler.get_supported_arguments()

compiler.has_argument()が個別に呼び出されたかのように、コンパイラでサポートされている引数のみを含む配列を返します。

シグネチャ

(0.43.0以降)

# Returns an array containing only the arguments supported by the compiler,
list[str] get_supported_arguments(
  str arg...,  # The arguments to check

  # Keyword arguments:
  checked : str  # Supported values:
)

引数

このメソッドは、0からinfinityの可変引数(arg...)を受け入れ、型はstrです。

チェックする引数。

メソッドcompiler.get_supported_arguments()は、以下のキーワード引数を受け取ります

名前 説明 タグ
checked str

サポートされている値

  • 'off':サポートされていない引数を静かに無視する
  • 'warn':サポートされていない引数に対して警告を出力する
  • 'require':少なくとも1つの引数がサポートされていない場合は中止する

(0.59.0以降)

default = 'off'


compiler.get_supported_function_attributes()

サポートされているGCCスタイルの属性名を格納した配列を返します。compiler.has_function_attribute() をそれぞれの属性名に対して個別に呼び出した場合と同じです。

シグネチャ

(since 0.48.0)

list[str] get_supported_function_attributes()


compiler.has_link_argument() を個別に呼び出した場合と同様に、コンパイラがサポートする引数のみを格納した配列を返します。

シグネチャ

(0.46.0以降)

# Returns an array containing only the arguments supported by the compiler,
list[str] get_supported_link_arguments(
  str arg...,  # The link arguments to check
)

引数

このメソッドは、0からinfinityの可変引数(arg...)を受け入れ、型はstrです。

チェックするリンク引数。


compiler.has_argument()

指定されたコマンドライン引数をコンパイラが受け入れる場合、つまり、エラーを発生させたり、不明なフラグに関する警告を出力したりせずにコードをコンパイルできる場合は、true を返します。

シグネチャ

# Returns `true` if the compiler accepts the specified command line argument,
bool has_argument(
  str argument,     # The argument to check

  # Keyword arguments:
  required : bool | feature  # When set to `true`, Meson will halt if the check fails
)

引数

compiler.has_argument() メソッドは、以下の位置引数を受け入れます。

名前 説明 タグ
argument str

チェックする引数。

最後に、compiler.has_argument() は以下のキーワード引数を受け入れます。

名前 説明 タグ
required bool | feature

trueに設定すると、チェックが失敗した場合、Mesonは停止します。featureオプションに設定すると、その機能によって検索するかどうか、および見つからない場合に失敗するかどうかを制御します。

(1.3.0以降)

default = false


compiler.has_define()

指定されたプリプロセッサシンボルが定義されている場合は true を返します。

シグネチャ

(1.3.0以降)

# Returns true if the given preprocessor symbol is *defined*
bool has_define(
  str definename,     # The define to check

  # Keyword arguments:
  args                : list[str]        # Used to pass a list of compiler arguments
  dependencies        : dep | list[dep]  # Additionally dependencies required for compiling and / or linking
  include_directories : inc | list[inc]  # Extra directories for header searches
  no_builtin_args     : bool             # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
  prefix              : str | list[str]  # Used to add `#include`s and other things that are required
)

引数

compiler.has_define() メソッドは、以下の位置引数を受け入れます。

名前 説明 タグ
definename str

チェックする定義。

最後に、compiler.has_define() は以下のキーワード引数を受け入れます。

名前 説明 タグ
args list[str]

コンパイラ引数のリストを渡すために使用します。デフォルトのインクルードパスにないヘッダーのインクルードパスを-Isome/path/to/headerで定義することは一般的にサポートされていますが、通常は推奨されません。

これは、インクルードディレクトリもinclude_directoriesまたはdependency kwarg(存在する場合)で指定できるためです。リンクするライブラリを-lfooで渡す場合も同様です。

dependencies dep | list[dep]

コンパイルおよび/またはリンクに必要な追加の依存関係。

include_directories inc | list[inc]

ヘッダー検索用の追加ディレクトリ。

(0.38.0以降)

no_builtin_args bool

trueに設定すると、組み込み構成オプションによって制御されるコンパイラ引数が追加されません。

default = false

prefix str | list[str]

#includeや、シンボルを宣言するために必要なその他のものを追加するために使用します。1.0.0以降、配列も受け入れられるようになりました。配列が渡された場合、アイテムは改行で区切られて連結されます。システム定義は、コンパイラ引数(例:_GNU_SOURCEは、Linuxで一部のシンボルを公開するためによく必要とされ、argsキーワード引数で渡されるべきです)を介して渡される必要があります。


compiler.has_function()

標準ライブラリまたは args キーワードで渡されたライブラリによって指定された関数が提供されている場合は true を返します。

シグネチャ

# Returns true if the given function is provided
bool has_function(
  str funcname,     # The function to check

  # Keyword arguments:
  args                : list[str]        # Used to pass a list of compiler arguments
  dependencies        : dep | list[dep]  # Additionally dependencies required for compiling and / or linking
  include_directories : inc | list[inc]  # Extra directories for header searches
  no_builtin_args     : bool             # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
  prefix              : str | list[str]  # Used to add `#include`s and other things that are required
  required            : bool | feature   # When set to `true`, Meson will halt if the check fails
)

引数

compiler.has_function() メソッドは、以下の位置引数を受け入れます。

名前 説明 タグ
funcname str

チェックする関数。

最後に、compiler.has_function() は以下のキーワード引数を受け入れます。

名前 説明 タグ
args list[str]

コンパイラ引数のリストを渡すために使用します。デフォルトのインクルードパスにないヘッダーのインクルードパスを-Isome/path/to/headerで定義することは一般的にサポートされていますが、通常は推奨されません。

これは、インクルードディレクトリもinclude_directoriesまたはdependency kwarg(存在する場合)で指定できるためです。リンクするライブラリを-lfooで渡す場合も同様です。

dependencies dep | list[dep]

コンパイルおよび/またはリンクに必要な追加の依存関係。

include_directories inc | list[inc]

ヘッダー検索用の追加ディレクトリ。

(0.38.0以降)

no_builtin_args bool

trueに設定すると、組み込み構成オプションによって制御されるコンパイラ引数が追加されません。

default = false

prefix str | list[str]

#includeや、シンボルを宣言するために必要なその他のものを追加するために使用します。1.0.0以降、配列も受け入れられるようになりました。配列が渡された場合、アイテムは改行で区切られて連結されます。システム定義は、コンパイラ引数(例:_GNU_SOURCEは、Linuxで一部のシンボルを公開するためによく必要とされ、argsキーワード引数で渡されるべきです)を介して渡される必要があります。

required bool | feature

trueに設定すると、チェックが失敗した場合、Mesonは停止します。featureオプションに設定すると、その機能によって検索するかどうか、および見つからない場合に失敗するかどうかを制御します。

(1.3.0以降)

default = false


compiler.has_function_attribute()

コンパイラがGNUスタイルの(__attribute__(...)name をサポートしている場合は true を返します。このような属性をサポートしないコンパイラ向けに最適化できる可能性があるため、手動のコンパイルチェックよりも望ましい方法です。この表に、サポートされているすべての属性が記載されています。

シグネチャ

(since 0.48.0)

# Returns `true` if the compiler supports the GNU style (`__attribute__(
bool has_function_attribute(
  str name,     # The attribute name to check

  # Keyword arguments:
  required : bool | feature  # When set to `true`, Meson will halt if the check fails
)

引数

compiler.has_function_attribute() メソッドは、以下の位置引数を受け入れます。

名前 説明 タグ
name str

チェックする属性名。

最後に、compiler.has_function_attribute() は以下のキーワード引数を受け入れます。

名前 説明 タグ
required bool | feature

trueに設定すると、チェックが失敗した場合、Mesonは停止します。featureオプションに設定すると、その機能によって検索するかどうか、および見つからない場合に失敗するかどうかを制御します。

(1.3.0以降)

default = false


compiler.has_header()

指定されたヘッダーが指定されたプレフィックス、依存関係、および引数で存在する場合に true を返します。

このメソッドはプリプロセッサチェックのみを実行するため、compiler.check_header() よりも高速です。

シグネチャ

# Returns true if the specified header is *exists*
bool has_header(
  str header_name,     # The header to check

  # Keyword arguments:
  args                : list[str]        # Used to pass a list of compiler arguments
  dependencies        : dep | list[dep]  # Additionally dependencies required for compiling and / or linking
  include_directories : inc | list[inc]  # Extra directories for header searches
  no_builtin_args     : bool             # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
  prefix              : str | list[str]  # Used to add `#include`s and other things that are required
  required            : bool | feature   # When set to `true`, Meson will halt if the header check fails
)

引数

compiler.has_header() メソッドは、以下の位置引数を受け入れます。

名前 説明 タグ
header_name str

チェックするヘッダー。

最後に、compiler.has_header() は以下のキーワード引数を受け入れます。

名前 説明 タグ
args list[str]

コンパイラ引数のリストを渡すために使用します。デフォルトのインクルードパスにないヘッダーのインクルードパスを-Isome/path/to/headerで定義することは一般的にサポートされていますが、通常は推奨されません。

これは、インクルードディレクトリもinclude_directoriesまたはdependency kwarg(存在する場合)で指定できるためです。リンクするライブラリを-lfooで渡す場合も同様です。

dependencies dep | list[dep]

コンパイルおよび/またはリンクに必要な追加の依存関係。

include_directories inc | list[inc]

ヘッダー検索用の追加ディレクトリ。

(0.38.0以降)

no_builtin_args bool

trueに設定すると、組み込み構成オプションによって制御されるコンパイラ引数が追加されません。

default = false

prefix str | list[str]

#includeや、シンボルを宣言するために必要なその他のものを追加するために使用します。1.0.0以降、配列も受け入れられるようになりました。配列が渡された場合、アイテムは改行で区切られて連結されます。システム定義は、コンパイラ引数(例:_GNU_SOURCEは、Linuxで一部のシンボルを公開するためによく必要とされ、argsキーワード引数で渡されるべきです)を介して渡される必要があります。

required bool | feature

trueに設定すると、ヘッダーチェックが失敗した場合、Mesonは停止します。featureオプションに設定すると、その機能によって検索するかどうか、および見つからない場合に失敗するかどうかを制御します。

(0.50.0以降)

default = false


compiler.has_header_symbol()

指定されたヘッダーに特定のシンボルが宣言されているかどうかを検出します。

ここでいうシンボルには、関数、変数、#define、型定義などが含まれます。

シグネチャ

# Detects whether a particular symbol is declared in the specified header
bool has_header_symbol(
  str header,     # The header to check
  str symbol,     # The symbol to check

  # Keyword arguments:
  args                : list[str]        # Used to pass a list of compiler arguments
  dependencies        : dep | list[dep]  # Additionally dependencies required for compiling and / or linking
  include_directories : inc | list[inc]  # Extra directories for header searches
  no_builtin_args     : bool             # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
  prefix              : str | list[str]  # Used to add `#include`s and other things that are required
  required            : bool | feature   # When set to `true`, Meson will halt if the header check fails
)

引数

compiler.has_header_symbol() メソッドは、以下の位置引数を受け入れます。

名前 説明 タグ
header str

チェックするヘッダー。

symbol str

チェックするシンボル。

最後に、compiler.has_header_symbol() は以下のキーワード引数を受け入れます。

名前 説明 タグ
args list[str]

コンパイラ引数のリストを渡すために使用します。デフォルトのインクルードパスにないヘッダーのインクルードパスを-Isome/path/to/headerで定義することは一般的にサポートされていますが、通常は推奨されません。

これは、インクルードディレクトリもinclude_directoriesまたはdependency kwarg(存在する場合)で指定できるためです。リンクするライブラリを-lfooで渡す場合も同様です。

dependencies dep | list[dep]

コンパイルおよび/またはリンクに必要な追加の依存関係。

include_directories inc | list[inc]

ヘッダー検索用の追加ディレクトリ。

(0.38.0以降)

no_builtin_args bool

trueに設定すると、組み込み構成オプションによって制御されるコンパイラ引数が追加されません。

default = false

prefix str | list[str]

#includeや、シンボルを宣言するために必要なその他のものを追加するために使用します。1.0.0以降、配列も受け入れられるようになりました。配列が渡された場合、アイテムは改行で区切られて連結されます。システム定義は、コンパイラ引数(例:_GNU_SOURCEは、Linuxで一部のシンボルを公開するためによく必要とされ、argsキーワード引数で渡されるべきです)を介して渡される必要があります。

required bool | feature

trueに設定すると、ヘッダーチェックが失敗した場合、Mesonは停止します。featureオプションに設定すると、その機能によって検索するかどうか、および見つからない場合に失敗するかどうかを制御します。

(0.50.0以降)

default = false


リンカが指定されたコマンドライン引数を受け入れる場合、つまり、エラーを発生させたり、不明なフラグに関する警告を出力したりせずにコードをコンパイルおよびリンクできる場合は true を返します。リンク引数はコンパイラに渡されるため、通常は -Wl, プレフィックスが付いている必要があります。VisualStudioでは、/link 引数が先頭に追加されます。

シグネチャ

(0.46.0以降)

# Returns `true` if the linker accepts the specified command line argument,
bool has_link_argument(
  str argument,     # The argument to check

  # Keyword arguments:
  required : bool | feature  # When set to `true`, Meson will halt if the check fails
)

引数

compiler.has_link_argument() メソッドは、以下の位置引数を受け入れます。

名前 説明 タグ

最後に、compiler.has_link_argument() は以下のキーワード引数を受け入れます。

名前 説明 タグ


compiler.has_member()

型に指定されたメンバーがある場合は true を返します。

シグネチャ

# Returns true if the type has the specified member
bool has_member(
  str typename,       # The type to check
  str membername,     # The member to check

  # Keyword arguments:
  args                : list[str]        # Used to pass a list of compiler arguments
  dependencies        : dep | list[dep]  # Additionally dependencies required for compiling and / or linking
  include_directories : inc | list[inc]  # Extra directories for header searches
  no_builtin_args     : bool             # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
  prefix              : str | list[str]  # Used to add `#include`s and other things that are required
  required            : bool | feature   # When set to `true`, Meson will halt if the check fails
)

引数

compiler.has_member() メソッドは、以下の位置引数を受け入れます。

名前 説明 タグ
typename str

チェックする型。

membername str

チェックするメンバー。

最後に、compiler.has_member() は以下のキーワード引数を受け入れます。

名前 説明 タグ
args list[str]

コンパイラ引数のリストを渡すために使用します。デフォルトのインクルードパスにないヘッダーのインクルードパスを-Isome/path/to/headerで定義することは一般的にサポートされていますが、通常は推奨されません。

これは、インクルードディレクトリもinclude_directoriesまたはdependency kwarg(存在する場合)で指定できるためです。リンクするライブラリを-lfooで渡す場合も同様です。

dependencies dep | list[dep]

コンパイルおよび/またはリンクに必要な追加の依存関係。

include_directories inc | list[inc]

ヘッダー検索用の追加ディレクトリ。

(0.38.0以降)

no_builtin_args bool

trueに設定すると、組み込み構成オプションによって制御されるコンパイラ引数が追加されません。

default = false

prefix str | list[str]

#includeや、シンボルを宣言するために必要なその他のものを追加するために使用します。1.0.0以降、配列も受け入れられるようになりました。配列が渡された場合、アイテムは改行で区切られて連結されます。システム定義は、コンパイラ引数(例:_GNU_SOURCEは、Linuxで一部のシンボルを公開するためによく必要とされ、argsキーワード引数で渡されるべきです)を介して渡される必要があります。

required bool | feature

trueに設定すると、チェックが失敗した場合、Mesonは停止します。featureオプションに設定すると、その機能によって検索するかどうか、および見つからない場合に失敗するかどうかを制御します。

(1.3.0以降)

default = false


compiler.has_members()

型が指定されたすべてのメンバーを持っている場合は、true を返します。

シグネチャ

# Returns `true` if the type has *all* the specified members
bool has_members(
  str typename,     # The type to check
  str member...,    # The members to check

  # Keyword arguments:
  args                : list[str]        # Used to pass a list of compiler arguments
  dependencies        : dep | list[dep]  # Additionally dependencies required for compiling and / or linking
  include_directories : inc | list[inc]  # Extra directories for header searches
  no_builtin_args     : bool             # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
  prefix              : str | list[str]  # Used to add `#include`s and other things that are required
  required            : bool | feature   # When set to `true`, Meson will halt if the check fails
)

引数

compiler.has_members() メソッドは、以下の位置引数を受け入れます。

名前 説明 タグ
typename str

チェックする型。

さらに、このメソッドは 1 個から無限個の可変引数 (member...) (型 str) を受け入れます。

チェックするメンバー

最後に、compiler.has_members() は以下のキーワード引数を受け入れます。

名前 説明 タグ
args list[str]

コンパイラ引数のリストを渡すために使用します。デフォルトのインクルードパスにないヘッダーのインクルードパスを-Isome/path/to/headerで定義することは一般的にサポートされていますが、通常は推奨されません。

これは、インクルードディレクトリもinclude_directoriesまたはdependency kwarg(存在する場合)で指定できるためです。リンクするライブラリを-lfooで渡す場合も同様です。

dependencies dep | list[dep]

コンパイルおよび/またはリンクに必要な追加の依存関係。

include_directories inc | list[inc]

ヘッダー検索用の追加ディレクトリ。

(0.38.0以降)

no_builtin_args bool

trueに設定すると、組み込み構成オプションによって制御されるコンパイラ引数が追加されません。

default = false

prefix str | list[str]

#includeや、シンボルを宣言するために必要なその他のものを追加するために使用します。1.0.0以降、配列も受け入れられるようになりました。配列が渡された場合、アイテムは改行で区切られて連結されます。システム定義は、コンパイラ引数(例:_GNU_SOURCEは、Linuxで一部のシンボルを公開するためによく必要とされ、argsキーワード引数で渡されるべきです)を介して渡される必要があります。

required bool | feature

trueに設定すると、チェックが失敗した場合、Mesonは停止します。featureオプションに設定すると、その機能によって検索するかどうか、および見つからない場合に失敗するかどうかを制御します。

(1.3.0以降)

default = false


compiler.has_multi_arguments()

compiler.has_argument() と同じですが、複数の引数を受け取り、それらをすべて 1 回のコンパイラ呼び出しで使用します。

シグネチャ

(since 0.37.0)

# the same as compiler.has_argument() but takes multiple arguments
bool has_multi_arguments(
  str arg...,  # The arguments to check

  # Keyword arguments:
  required : bool | feature  # When set to `true`, Meson will halt if the check fails
)

引数

このメソッドは、0からinfinityの可変引数(arg...)を受け入れ、型はstrです。

チェックする引数。

compiler.has_multi_arguments() メソッドは、以下のキーワード引数を受け入れます。

名前 説明 タグ
required bool | feature

trueに設定すると、チェックが失敗した場合、Mesonは停止します。featureオプションに設定すると、その機能によって検索するかどうか、および見つからない場合に失敗するかどうかを制御します。

(1.3.0以降)

default = false


compiler.has_link_argument() と同じですが、複数の引数を受け取り、それらをすべて 1 回のコンパイラ呼び出しで使用します。

シグネチャ

(0.46.0以降)

# the same as compiler.has_link_argument() but takes multiple arguments
bool has_multi_link_arguments(
  str arg...,  # The link arguments to check

  # Keyword arguments:
  required : bool | feature  # When set to `true`, Meson will halt if the check fails
)

引数

このメソッドは、0からinfinityの可変引数(arg...)を受け入れ、型はstrです。

チェックするリンク引数。

compiler.has_multi_link_arguments() メソッドは、以下のキーワード引数を受け入れます。

名前 説明 タグ


compiler.has_type()

指定されたトークンが型の場合は、true を返します。

シグネチャ

# Returns `true` if the specified token is a type
bool has_type(
  str typename,     # The type to check

  # Keyword arguments:
  args                : list[str]        # Used to pass a list of compiler arguments
  dependencies        : dep | list[dep]  # Additionally dependencies required for compiling and / or linking
  include_directories : inc | list[inc]  # Extra directories for header searches
  no_builtin_args     : bool             # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
  prefix              : str | list[str]  # Used to add `#include`s and other things that are required
  required            : bool | feature   # When set to `true`, Meson will halt if the check fails
)

引数

compiler.has_type() メソッドは、以下の位置引数を受け入れます。

名前 説明 タグ
typename str

チェックする型。

最後に、compiler.has_type() は以下のキーワード引数を受け入れます。

名前 説明 タグ
args list[str]

コンパイラ引数のリストを渡すために使用します。デフォルトのインクルードパスにないヘッダーのインクルードパスを-Isome/path/to/headerで定義することは一般的にサポートされていますが、通常は推奨されません。

これは、インクルードディレクトリもinclude_directoriesまたはdependency kwarg(存在する場合)で指定できるためです。リンクするライブラリを-lfooで渡す場合も同様です。

dependencies dep | list[dep]

コンパイルおよび/またはリンクに必要な追加の依存関係。

include_directories inc | list[inc]

ヘッダー検索用の追加ディレクトリ。

(0.38.0以降)

no_builtin_args bool

trueに設定すると、組み込み構成オプションによって制御されるコンパイラ引数が追加されません。

default = false

prefix str | list[str]

#includeや、シンボルを宣言するために必要なその他のものを追加するために使用します。1.0.0以降、配列も受け入れられるようになりました。配列が渡された場合、アイテムは改行で区切られて連結されます。システム定義は、コンパイラ引数(例:_GNU_SOURCEは、Linuxで一部のシンボルを公開するためによく必要とされ、argsキーワード引数で渡されるべきです)を介して渡される必要があります。

required bool | feature

trueに設定すると、チェックが失敗した場合、Mesonは停止します。featureオプションに設定すると、その機能によって検索するかどうか、および見つからない場合に失敗するかどうかを制御します。

(1.3.0以降)

default = false


コードがコンパイルされてリンクする場合は true を返します。

0.60.0以降file オブジェクトのサフィックスがコンパイラオブジェクトの言語と一致しない場合、サフィックスに対応するコンパイラがソースのコンパイルに使用され、links メソッドのターゲットが結果のオブジェクトファイルのリンクに使用されます。

シグネチャ

# Returns true if the code compiles and links
bool links(
  str | file code,     # The source code to check

  # Keyword arguments:
  args                : list[str]        # Used to pass a list of compiler arguments
  dependencies        : dep | list[dep]  # Additionally dependencies required for compiling and / or linking
  include_directories : inc | list[inc]  # Extra directories for header searches
  name                : str              # The name to use for printing a message about the compiler check
  no_builtin_args     : bool             # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
  required            : bool | feature   # When set to `true`, Meson will halt if the check fails
  werror              : bool             # When set to `true`, compiler warnings are treated as error
)

引数

compiler.links() メソッドは、以下の位置引数を受け入れます。

名前 説明 タグ

最後に、compiler.links() は以下のキーワード引数を受け入れます。

名前 説明 タグ


compiler.preprocess()

ソースファイルのリストをプリプロセスしますが、コンパイルはしません。プリプロセッサは、通常のコンパイルと同じ引数(インクルードディレクトリ、定義など)を受け取ります。これには、たとえば、add_project_arguments() で追加された引数や、コマンドラインで -Dc_args=-DFOO を使用して追加された引数が含まれます。

シグネチャ

(since 0.64.0)

# Preprocess a list of source files but do not compile them
list[custom_idx] preprocess(
  str | file | custom_tgt | custom_idx | generated_list source...,  # Input source to preprocess

  # Keyword arguments:
  compile_args        : list[str]                     # Extra flags to pass to the preprocessor
  dependencies        : dep | list[dep]               # Additionally dependencies required
  depends             : list[build_tgt | custom_tgt]  # Specifies that this target depends on the specified
  include_directories : inc | list[inc]               # Extra directories for header searches
  output              : str                           # Template for name of preprocessed files: `@PLAINNAME@` is replaced by
)

引数

このメソッドは、0 個から無限個の可変引数 (source...) (型 str | file | custom_tgt | custom_idx | generated_list) を受け入れます。

プリプロセスする入力ソース。次の型がサポートされています。

  • 現在のソースディレクトリに対する相対パス文字列

  • 先行するビルドファイルで定義された file オブジェクト

  • configure_file() などの設定時ジェネレーターの戻り値

  • custom_target()generator.process() などのビルド時ジェネレーターの戻り値

    compiler.preprocess() メソッドは、以下のキーワード引数を受け入れます。

    名前 説明 タグ
    compile_args list[str]

    プリプロセッサに渡す追加のフラグ

    dependencies dep | list[dep]

    追加の必要な依存関係。

    (since 1.1.0)

    depends list[build_tgt | custom_tgt]

    このターゲットが指定されたターゲットに依存することを指定します。これらのターゲットは、入力をプリプロセスする前にビルドする必要があります。

    (since 1.4.0)

    include_directories inc | list[inc]

    ヘッダー検索用の追加ディレクトリ。

    (0.38.0以降)

    output str

    プリプロセスされたファイルの名前のテンプレート:@PLAINNAME@ はソースファイル名に置き換えられ、@BASENAME@ は拡張子なしのソースファイル名に置き換えられます。


compiler.run()

指定されたコードフラグメントのコンパイルと実行を試みます。

シグネチャ

# Attempts to compile and execute the given code fragment
runresult run(
  str | file code,     # The source code to check

  # Keyword arguments:
  args                : list[str]        # Used to pass a list of compiler arguments
  dependencies        : dep | list[dep]  # Additionally dependencies required for compiling and / or linking
  include_directories : inc | list[inc]  # Extra directories for header searches
  name                : str              # The name to use for printing a message about the compiler check
  no_builtin_args     : bool             # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
  required            : bool | feature   # When set to `true`, Meson will halt if the check fails
  werror              : bool             # When set to `true`, compiler warnings are treated as error
)

引数

compiler.run() メソッドは、以下の位置引数を受け入れます。

名前 説明 タグ
code str | file

チェックするソースコード。

文字列が渡された場合、コードは直接使用されます。fileオブジェクトが渡された場合、その内容はコンパイラチェックに使用されます。

最後に、compiler.run() は以下のキーワード引数を受け入れます。

名前 説明 タグ
args list[str]

コンパイラ引数のリストを渡すために使用します。デフォルトのインクルードパスにないヘッダーのインクルードパスを-Isome/path/to/headerで定義することは一般的にサポートされていますが、通常は推奨されません。

これは、インクルードディレクトリもinclude_directoriesまたはdependency kwarg(存在する場合)で指定できるためです。リンクするライブラリを-lfooで渡す場合も同様です。

dependencies dep | list[dep]

コンパイルおよび/またはリンクに必要な追加の依存関係。

include_directories inc | list[inc]

ヘッダー検索用の追加ディレクトリ。

(0.38.0以降)

name str

コンパイラチェックに関するメッセージを印刷するために使用する名前。このキーワード引数が渡されない場合、チェックに関するメッセージは印刷されません。

no_builtin_args bool

trueに設定すると、組み込み構成オプションによって制御されるコンパイラ引数が追加されません。

default = false

required bool | feature

trueに設定すると、チェックが失敗した場合、Mesonは停止します。featureオプションに設定すると、その機能によって検索するかどうか、および見つからない場合に失敗するかどうかを制御します。

(1.5.0以降)

default = false

werror bool

trueに設定すると、コンパイラの警告はエラーとして扱われます。

(1.3.0以降)

default = false


compiler.sizeof()

指定された型(例:'int')のサイズを返します。型が不明な場合は-1を返します。Cライクな言語の場合、ネイティブコンパイルではヘッダーstddef.hstdio.hが暗黙的にインクルードされ、クロスコンパイルの場合のみstddef.hがインクルードされます。

シグネチャ

# returns the size of the given type (e
int sizeof(
  str typename,     # The type to compute

  # Keyword arguments:
  args                : list[str]        # Used to pass a list of compiler arguments
  dependencies        : dep | list[dep]  # Additionally dependencies required for compiling and / or linking
  include_directories : inc | list[inc]  # Extra directories for header searches
  no_builtin_args     : bool             # When set to `true`, the compiler arguments controlled by built-in configuration options are not added
  prefix              : str | list[str]  # Used to add `#include`s and other things that are required
)

引数

compiler.sizeof() メソッドは、以下の位置引数を受け入れます。

名前 説明 タグ
typename str

計算する型。

最後に、compiler.sizeof() は以下のキーワード引数を受け入れます。

名前 説明 タグ
args list[str]

コンパイラ引数のリストを渡すために使用します。デフォルトのインクルードパスにないヘッダーのインクルードパスを-Isome/path/to/headerで定義することは一般的にサポートされていますが、通常は推奨されません。

これは、インクルードディレクトリもinclude_directoriesまたはdependency kwarg(存在する場合)で指定できるためです。リンクするライブラリを-lfooで渡す場合も同様です。

dependencies dep | list[dep]

コンパイルおよび/またはリンクに必要な追加の依存関係。

include_directories inc | list[inc]

ヘッダー検索用の追加ディレクトリ。

(0.38.0以降)

no_builtin_args bool

trueに設定すると、組み込み構成オプションによって制御されるコンパイラ引数が追加されません。

default = false

prefix str | list[str]

#includeや、シンボルを宣言するために必要なその他のものを追加するために使用します。1.0.0以降、配列も受け入れられるようになりました。配列が渡された場合、アイテムは改行で区切られて連結されます。システム定義は、コンパイラ引数(例:_GNU_SOURCEは、Linuxで一部のシンボルを公開するためによく必要とされ、argsキーワード引数で渡されるべきです)を介して渡される必要があります。


compiler.symbols_have_underscore_prefix()

Cシンボルのマングリングがシンボルに1つのアンダースコア(_)をプレフィックスとして付加する場合、trueを返します。

シグネチャ

(since 0.37.0)

bool symbols_have_underscore_prefix()


compiler.version()

コンパイラのバージョン番号を文字列として返します。

シグネチャ

str version()


検索結果は次のとおりです