「Meson パッケージガイドライン」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
47行目: 47行目:
 
}
 
}
   
  +
==== ソフトウェア固有のビルドオプションを設定する ====
==== Setting software-specific build options ====
 
   
While Meson has some [https://mesonbuild.com/Builtin-options.html built-in build options] (e.g. {{ic|--prefix}}), the software being packaged could have other [https://mesonbuild.com/Build-options.html build options] which the packager should consider. Valid software-specific build options are normally found in a file named {{ic|meson_options.txt}} (if present) and in {{ic|meson.build}}. Look for {{ic|option(''settings'')}} in these files, then read the {{ic|''settings''}}.
+
Meson にはいくつかの [https://mesonbuild.com/Builtin-options.html 組み込みビルドオプション] (たとえば {{ic|--prefix}}) がありますが、パッケージ化されるソフトウェアには、パッケージャーが考慮すべき、他の [https://mesonbuild.com/Build-options.html ビルドオプション] があるかもしれません。有効なソフトウェア固有のビルドオプションは、通常 {{ic|meson_options.txt}} という名前のファイルに書かれています。(存在する場合) {{ic|meson.build}} にあります。これらのファイルで {{ic|option(''settings'')}} を探し、{{ic|''settings''}} を読みます。
   
To use a software-specific build option, use the notation {{ic|1=-D ''key''=''value''}}, where {{ic|''key''}} is the build option name set in the project and {{ic|''value''}} is a valid value, like e.g. {{ic|true}}.
+
ソフトウェア固有のビルドオプションを使用するには、{{ic|1=-D ''key''=''value''}} という記法を使います。ここで {{ic|''key''}} はプロジェクトで設定したビルドオプション名、 {{ic|''value''}} は例えば {{ic|true}} などの有効な値です。
   
  +
例えば、{{Pkg|gtranslator}} は以下のようなビルドオプションを持っています。
For instance, {{Pkg|gtranslator}} has the following build options:
 
   
 
{{hc|meson_options.txt|
 
{{hc|meson_options.txt|
59行目: 59行目:
 
}}
 
}}
   
  +
したがって、そのドキュメントを構築するためには、Meson を実行する必要があります。 {{ic|1=-D gtk_doc=true}} build オプションを指定すると、コマンドラインは次のようになります。
So, to build its documentation, one must run Meson appending {{ic|1=-D gtk_doc=true}} build option, resulting in a command line like e.g.
 
   
 
arch-meson $pkgname-$pkgver build -Dgtk_doc=true
 
arch-meson $pkgname-$pkgver build -Dgtk_doc=true

2022年2月17日 (木) 18:27時点における版

Meson 公式サイトより。

Meson はオープンソースのビルドシステムで、非常に高速で、さらに重要なことに、可能な限りユーザーフレンドリーであることを意図しています。

Python で書かれた Meson は、マルチプラットフォームのサポート、複数のプログラミング言語のサポート、クロスコンパイルなどを特徴としています。

Meson はソフトウェアを直接ビルドするのではなく、バックエンドのビルドシステムをセットアップします。一般的には ninja と共に使われますが、他のビルドシステムを使うこともできます。一般的には、GNU ビルドシステム を置き換えるために使われます。

このドキュメントは Meson を使うソフトウェアのための PKGBUILD を書くための標準ガイドラインを扱っています。

Usage

必要条件

mesonPKGBUILDmakedepends の配列に含まれなければなりません。

build()

設定とビルドは通常 meson バイナリを使う ですが、Arch Linux arch-meson ラッパースクリプトを使う ことによっても行うことができます。

mesonarch-meson コマンドはどちらも optionssource directorybuild directory を使用法のシンタックスに含んでいます。

  • オプション:少なくとも --prefix /usr を含める必要がありますが、その他のオプションは meson configure --help で確認してください。また ソフトウェア固有の構築オプション も確認してください。
  • ソースディレクトリ (または "sourcedir"): ソフトウェアのソースコードが格納されている場所です。例えば ., $pkgname または $pkgname-$pkgver などです。
  • 一般的には build または _build という名前ですが、任意で指定できます。
ノート: ソースディレクトリがビルドディレクトリの前に meson に渡される場合と、その逆の場合がありますが、Meson はどちらがどちらかを知っていて適切に環境をセットアップするので問題ありません。

meson バイナリを直接使用する場合

Arch Linux のパッケージはファイルを /usr/local にインストールしてはいけないため、--prefix=/usr は常に meson のバイナリに渡す必要があります、これは Arch パッケージガイドライン#パッケージエチケット に従っています。--buildtype=plain 組み込みのオプションは、あなたが何をしているかを知っていれば、他の値を設定することができます。

arch-meson ラッパースクリプトの使用

arch-mesonmeson パッケージに含まれるラッパースクリプトで、Arch パッケージで使われるであろう Meson 組み込みのオプションのいくつかを設定し、パッケージ製作者の時間と PKGBUILD のコードを節約する利点があります。arch-meson に書かれている説明を引用すると、Highly opinionated wrapper for Arch Linux packaging(Arch Linux のパッケージングのための高度なラッパー)です。

例:

build() {
  arch-meson source build
  meson compile -C build
}

ソフトウェア固有のビルドオプションを設定する

Meson にはいくつかの 組み込みビルドオプション (たとえば --prefix) がありますが、パッケージ化されるソフトウェアには、パッケージャーが考慮すべき、他の ビルドオプション があるかもしれません。有効なソフトウェア固有のビルドオプションは、通常 meson_options.txt という名前のファイルに書かれています。(存在する場合) と meson.build にあります。これらのファイルで option(settings) を探し、settings を読みます。

ソフトウェア固有のビルドオプションを使用するには、-D key=value という記法を使います。ここで key はプロジェクトで設定したビルドオプション名、 value は例えば true などの有効な値です。

例えば、gtranslator は以下のようなビルドオプションを持っています。

meson_options.txt
option('gtk_doc', type: 'boolean', value: false, description: 'use gtk-doc to build documentation')

したがって、そのドキュメントを構築するためには、Meson を実行する必要があります。 -D gtk_doc=true build オプションを指定すると、コマンドラインは次のようになります。

arch-meson $pkgname-$pkgver build -Dgtk_doc=true

check()

If the software being packaged provides test suite, consider running it in the PKGBUILD's check() function. This can be accomplished with meson test command.

Example:

check() {
  meson test -C build
}

where build is the same build directory name used in the above #build() step.

ヒント:
  • ninja test -C build could be directly used instead.
  • The --print-errorlogs parameter can be added to meson test in order to report the output produced by the failing tests along with other useful information as the environmental variables.

See meson test --help and Unit tests in Meson docs for more info.

package()

Packaging normally requires running only meson install, but check if another installation command is required (e.g. an uncommon license). Use the same build directory as above and set the --destdir flag:

package() {
  meson install -C build --destdir "$pkgdir"
}
ノート: Appending DESTDIR="$pkgdir" is also a valid alternative to --destdir.[1]
ヒント: ninja install -C build could be directly used instead.

Template

To sum up the above instructions and to provide a single copy-and-paste point, see the template below:

makedepends=(meson)

build() {
  arch-meson $pkgname-$pkgver build
  meson compile -C build
}

check() {
  meson test -C build
}

package() {
  meson install -C build --destdir "$pkgdir"
}

Example packages

This is a small list of packages that use Meson. See other packages in the list "Required by" in meson.

See also