「Meson パッケージガイドライン」の版間の差分
(前文を翻訳) |
(→テンプレート: 同期) |
||
| (同じ利用者による、間の16版が非表示) | |||
| 14行目: | 14行目: | ||
このドキュメントは [https://mesonbuild.com/ Meson] を使うソフトウェアのための [[PKGBUILD]] を書くための標準ガイドラインを扱っています。 |
このドキュメントは [https://mesonbuild.com/ Meson] を使うソフトウェアのための [[PKGBUILD]] を書くための標準ガイドラインを扱っています。 |
||
| − | == |
+ | == 使い方 == |
| − | === |
+ | === 必要条件 === |
| − | {{Pkg|meson}} |
+ | {{Pkg|meson}} は [[PKGBUILD]] の [[PKGBUILD#makedepends|makedepends]] の配列に含める必要があります。 |
| + | makedepends=(meson ''other_deps'') |
||
| − | === build() === |
||
| + | === prepare() === |
||
| − | Configuring and building is normally done [[#Using meson binary directly|using ''meson'' binary]], but it can also be done by [[#Using arch-meson wrapper script|using Arch Linux's ''arch-meson'' wrapper script]]. |
||
| + | Meson にはサブプロジェクトを管理するためのユーティリティがあり、すべてのサブプロジェクトを事前にダウンロードできます。このコマンドを prepare() ステージで実行することで、build() やその他のステージを完全にオフラインで実行できるようになります。 |
||
| − | Both ''meson'' and ''arch-meson'' commands include in the usage syntax '''options''', '''source directory''' and '''build directory''': |
||
| + | 例: |
||
| − | * '''options''': must include at least {{ic|--prefix /usr}}, but make sure to check other options with {{ic|meson configure --help}}; also check [[#Setting software-specific build options|software-specific build options]]. |
||
| − | * '''source directory''' (or "sourcedir"): where the software's source code is stored, e.g. {{ic|.}}, {{ic|$pkgname}} or {{ic|$pkgname-$pkgver}}. |
||
| − | * '''build directory''' (or "builddir"): where the build files will stored by Meson; commonly named {{ic|build}} or {{ic|_build}}, but it is discretionary. |
||
| + | prepare() { |
||
| − | {{Note|It does not matter if source directory is passed to ''meson'' before the build directory, and vice-versa, as Meson will know which is which and will set up the environment properly.}} |
||
| + | meson subprojects download --sourcedir=''source'' |
||
| + | } |
||
| + | {{Note|この手順は、プロジェクトにダウンロード可能なサブプロジェクトが含まれている場合にのみ必要であり、これらがシステムライブラリのフォールバックとして提供されるだけの場合は不要です。}} |
||
| − | ==== Using meson binary directly ==== |
||
| + | === build() === |
||
| − | Notice {{ic|1=--prefix=/usr}} always needs to be passed to ''meson'' binary because Arch Linux packages must not install files to {{ic|/usr/local}}, according [[Arch package guidelines#Package etiquette]]. The {{ic|1=--buildtype=plain}} built-in option can be set to another value, if you know what you are doing. |
||
| + | 設定とビルドは通常 [[#Meson バイナリを直接使用する|''meson'' バイナリを使い]] ますが、[[#arch-meson ラッパースクリプトの使用|Arch Linux ''arch-meson'' ラッパースクリプトを使う]] ことによっても行うことができます。 |
||
| − | Example: |
||
| + | ''meson'' と ''arch-meson'' コマンドはどちらも '''options''' と '''source directory''' と '''build directory''' を使用法のシンタックスに含んでいます。 |
||
| − | build() { |
||
| − | meson --prefix=/usr --buildtype=plain ''source'' ''build'' |
||
| − | meson compile -C ''build'' |
||
| − | } |
||
| + | * '''オプション''': 少なくとも {{ic|--prefix /usr}} を含める必要がありますが、その他のオプションは {{ic|meson configure --help}} で確認してください。また [[#ソフトウェア固有の構築オプションの設定|ソフトウェア固有の構築オプション]] も確認してください。 |
||
| − | {{ic|meson compile}} is a wrapper for supported back-end build systems, which currently defaults to ''ninja''[https://github.com/mesonbuild/meson/blob/master/mesonbuild/mcompile.py] |
||
| + | * '''ソースディレクトリ''' (または "sourcedir"): ソフトウェアのソースコードが格納されている場所です。例えば {{ic|.}}, {{ic|$pkgname}} または {{ic|$pkgname-$pkgver}} などです。 |
||
| + | * 一般的には {{ic|build}} または {{ic|_build}} という名前ですが、任意で指定できます。 |
||
| + | {{Note|ソースディレクトリがビルドディレクトリの前に ''meson'' に渡される場合と、その逆の場合がありますが、Meson はどちらがどちらかを知っていて適切に環境をセットアップするので問題ありません。}} |
||
| − | {{Tip|{{ic|ninja -C ''build''}} could be directly used instead.}} |
||
| − | ==== |
+ | ==== meson バイナリを直接使用する場合 ==== |
| + | Arch Linux のパッケージはファイルを {{ic|/usr/local}} にインストールしてはいけないため、{{ic|1=--prefix=/usr}} は常に ''meson'' のバイナリに渡す必要があります、これは [[Arch パッケージガイドライン#パッケージエチケット]] に従っています。{{ic|1=--buildtype=plain}} 組み込みのオプションは、あなたが何をしているかを知っていれば、他の値を設定することができます。 |
||
| − | ''arch-meson'' is a wrapper script included in {{Pkg|meson}} package which has the advantage of setting some of Meson built-in options that would probably be used in an Arch package, saving packager's time and code in the PKGBUILD. Quoting the description written in ''arch-meson'', it is a "Highly opinionated wrapper for Arch Linux packaging". |
||
| + | ==== arch-meson ラッパースクリプトの使用 ==== |
||
| − | Example: |
||
| + | |||
| + | ''arch-meson'' は {{Pkg|meson}} パッケージに含まれるラッパースクリプトで、Arch パッケージで使われるであろう Meson 組み込みのオプションのいくつかを設定し、パッケージ製作者の時間と PKGBUILD のコードを節約する利点があります。''arch-meson'' に書かれている説明を引用すると、''Highly opinionated wrapper for Arch Linux packaging'' (Arch Linux のパッケージングのための高度なラッパー) です。 |
||
| + | |||
| + | 例: |
||
build() { |
build() { |
||
| 58行目: | 61行目: | ||
} |
} |
||
| + | ==== ソフトウェア固有のビルドオプションを設定する ==== |
||
| − | ==== Setting software-specific build options ==== |
||
| − | + | 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''}} を読みます。 |
|
| − | + | ソフトウェア固有のビルドオプションを使用するには、{{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| |
||
| 70行目: | 73行目: | ||
}} |
}} |
||
| + | したがって、そのドキュメントを構築するためには、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 |
||
| 76行目: | 79行目: | ||
=== check() === |
=== check() === |
||
| + | パッケージ化されるソフトウェアがテストスイートを提供しているなら、PKGBUILD の [[パッケージの作成#関数 check()|check()]] 関数で実行することを検討してください。これは {{ic|meson test}} コマンドで実行することができます。 |
||
| − | If the software being packaged provides test suite, consider running it in the PKGBUILD's [[Creating packages#check()|check()]] function. This can be accomplished with {{ic|meson test}} command. |
||
| + | 例: |
||
| − | Example: |
||
check() { |
check() { |
||
| 84行目: | 87行目: | ||
} |
} |
||
| + | ここで {{ic|''build''}} は、上記の [[#build()]] ステップで使用したものと同じビルドディレクトリ名です。 |
||
| − | where {{ic|''build''}} is the same build directory name used in the above [[#build()]] step. |
||
| + | {{Tip|{{ic|--print-errorlogs}} パラメーターを {{ic|meson test}} に追加することで、失敗したテストによって生成された出力や環境変数などの有益な情報をレポートできます。}} |
||
| − | {{Tip| |
||
| − | * {{ic|ninja test -C ''build''}} could be directly used instead. |
||
| − | * The {{ic|--print-errorlogs}} parameter can be added to {{ic|meson test}} in order to report the output produced by the failing tests along with other useful information as the environmental variables. |
||
| − | }} |
||
| − | + | 詳細については {{ic|meson test --help}} と [https://mesonbuild.com/Unit-tests.html Unit tests in Meson docs] を参照してください。 |
|
=== package() === |
=== package() === |
||
| + | パッケージングには通常 {{ic|meson install}} のみの実行が必要ですが、他のインストールコマンドが必要な場合は確認してください(例えば [[PKGBUILD#license|uncommon license]] など)上記と同じビルドディレクトリを使い、{{ic|--destdir}} フラグをセットしてください。 |
||
| − | Packaging normally requires running only {{ic|meson install}}, but check if another installation command is required (e.g. an [[PKGBUILD#license|uncommon license]]). Use the same build directory as above and set the {{ic|--destdir}} flag: |
||
package() { |
package() { |
||
| 101行目: | 101行目: | ||
} |
} |
||
| − | {{Note| |
+ | {{Note|{{ic|1=DESTDIR="$pkgdir"}} を追加することも有効です。{{ic|--destdir}} の代わりです [https://mesonbuild.com/Release-notes-for-0-57-0.html#specify-destdir-on-command-line]}} |
| + | |||
| + | == トラブルシューティング == |
||
| + | |||
| + | === ERROR: Function does not take positional arguments === |
||
| + | |||
| + | エラー出力の例: |
||
| + | |||
| + | data/meson.build:21:5: ERROR: Function does not take positional arguments. |
||
| + | |||
| + | Meson 0.60 以降、位置引数の使用が警告からエラーに昇格したエラーが存在します。このエラーのよくある例の 1 つは、無効な引数を i18n.merge_file() に追加することです。たとえば、{{Pkg|aisleriot}} には次のものが含まれていました。 |
||
| + | |||
| + | i18n.merge_file( |
||
| + | 'sol.metainfo.xml', |
||
| + | input: desktop_in, |
||
| + | output: '@BASENAME@', |
||
| + | type: 'desktop', |
||
| + | po_dir: po_dir, |
||
| + | install: true, |
||
| + | install_dir: desktopdatadir, |
||
| + | ) |
||
| + | |||
| + | ここで、{{ic|'sol.metainfo.xml'}} は現在無効な引数であり、削除する必要があります。アップストリームに適用された修正については、[https://gitlab.gnome.org/GNOME/aisleriot/-/commit/4bf6fcf5c8043adfcadd948e678cc68f150cc998 this commit] を参照してください。 |
||
| + | |||
| + | この場合に取るべき措置は次のとおりです。 |
||
| + | # エラーで報告された meson.build にパッチを適用してビルドを修正し、更新された PKGBUILD を公開します。 |
||
| − | {{Tip|{{ic|ninja install -C ''build''}} could be directly used instead.}} |
||
| + | # パッチを使用してアップストリームリポジトリに貢献して、全員が修正できるようにし、次のバージョンでソース配列にパッチが含まれないようにします。 |
||
| − | == |
+ | == テンプレート == |
| + | 上記の手順をまとめ、コピー&ペースト用の一箇所にまとめたテンプレートは以下をご覧ください: |
||
| − | To sum up the above instructions and to provide a single copy-and-paste point, see the template below: |
||
{{bc|1= |
{{bc|1= |
||
| 118行目: | 143行目: | ||
check() { |
check() { |
||
| − | meson test -C build |
+ | meson test -C build --print-errorlogs |
} |
} |
||
| 126行目: | 151行目: | ||
}} |
}} |
||
| + | == サンプルパッケージ == |
||
| − | == Example packages == |
||
| + | これは、Meson を使用するパッケージの小さなリストです。{{Pkg|meson}} の "必要とするパッケージ" のリストにある他のパッケージも参照してください。 |
||
| − | This is a small list of packages that use Meson. See other packages in the list "Required by" in {{Pkg|meson}}. |
||
* {{Pkg|gstreamer}} |
* {{Pkg|gstreamer}} |
||
| 137行目: | 162行目: | ||
* {{Pkg|xorg-server}} |
* {{Pkg|xorg-server}} |
||
| − | == |
+ | == 参照 == |
| − | * [https://mesonbuild.com/ Meson |
+ | * [https://mesonbuild.com/ Meson オフィシャルウェブサイト] |
| − | * [https://mesonbuild.com/Builtin-options.html |
+ | * [https://mesonbuild.com/Builtin-options.html Meson 内蔵オプションの一覧] |
| − | * [https://github.com/mesonbuild/meson Meson |
+ | * [https://github.com/mesonbuild/meson Meson ソースコードリポジトリ GitHub] |
| − | * [[Wikipedia:Meson (software)|Meson |
+ | * [[Wikipedia:Meson (software)|Meson Wikipedia]] |
* {{man|1|meson}} |
* {{man|1|meson}} |
||
2025年2月10日 (月) 01:44時点における最新版
32ビット – CLR – クロス – Eclipse – Electron – Free Pascal – GNOME – Go – Haskell – Java – KDE – カーネル – Lisp – MinGW – Node.js – ノンフリー – OCaml – Perl – PHP – Python – R – Ruby – Rust – VCS – ウェブ – Wine
- Meson はオープンソースのビルドシステムで、非常に高速で、さらに重要なことに、可能な限りユーザーフレンドリーであることを意図しています。
Python で書かれた Meson は、マルチプラットフォームのサポート、複数のプログラミング言語のサポート、クロスコンパイルなどを特徴としています。
Meson はソフトウェアを直接ビルドするのではなく、バックエンドのビルドシステムをセットアップします。一般的には ninja と共に使われますが、他のビルドシステムを使うこともできます。一般的には、GNU ビルドシステム を置き換えるために使われます。
このドキュメントは Meson を使うソフトウェアのための PKGBUILD を書くための標準ガイドラインを扱っています。
目次
使い方
必要条件
meson は PKGBUILD の makedepends の配列に含める必要があります。
makedepends=(meson other_deps)
prepare()
Meson にはサブプロジェクトを管理するためのユーティリティがあり、すべてのサブプロジェクトを事前にダウンロードできます。このコマンドを prepare() ステージで実行することで、build() やその他のステージを完全にオフラインで実行できるようになります。
例:
prepare() {
meson subprojects download --sourcedir=source
}
build()
設定とビルドは通常 meson バイナリを使い ますが、Arch Linux arch-meson ラッパースクリプトを使う ことによっても行うことができます。
meson と arch-meson コマンドはどちらも options と source directory と build directory を使用法のシンタックスに含んでいます。
- オプション: 少なくとも
--prefix /usrを含める必要がありますが、その他のオプションはmeson configure --helpで確認してください。また ソフトウェア固有の構築オプション も確認してください。 - ソースディレクトリ (または "sourcedir"): ソフトウェアのソースコードが格納されている場所です。例えば
.,$pkgnameまたは$pkgname-$pkgverなどです。 - 一般的には
buildまたは_buildという名前ですが、任意で指定できます。
meson バイナリを直接使用する場合
Arch Linux のパッケージはファイルを /usr/local にインストールしてはいけないため、--prefix=/usr は常に meson のバイナリに渡す必要があります、これは Arch パッケージガイドライン#パッケージエチケット に従っています。--buildtype=plain 組み込みのオプションは、あなたが何をしているかを知っていれば、他の値を設定することができます。
arch-meson ラッパースクリプトの使用
arch-meson は meson パッケージに含まれるラッパースクリプトで、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()
パッケージ化されるソフトウェアがテストスイートを提供しているなら、PKGBUILD の check() 関数で実行することを検討してください。これは meson test コマンドで実行することができます。
例:
check() {
meson test -C build
}
ここで build は、上記の #build() ステップで使用したものと同じビルドディレクトリ名です。
詳細については meson test --help と Unit tests in Meson docs を参照してください。
package()
パッケージングには通常 meson install のみの実行が必要ですが、他のインストールコマンドが必要な場合は確認してください(例えば uncommon license など)上記と同じビルドディレクトリを使い、--destdir フラグをセットしてください。
package() {
meson install -C build --destdir "$pkgdir"
}
トラブルシューティング
ERROR: Function does not take positional arguments
エラー出力の例:
data/meson.build:21:5: ERROR: Function does not take positional arguments.
Meson 0.60 以降、位置引数の使用が警告からエラーに昇格したエラーが存在します。このエラーのよくある例の 1 つは、無効な引数を i18n.merge_file() に追加することです。たとえば、aisleriot には次のものが含まれていました。
i18n.merge_file( 'sol.metainfo.xml', input: desktop_in, output: '@BASENAME@', type: 'desktop', po_dir: po_dir, install: true, install_dir: desktopdatadir, )
ここで、'sol.metainfo.xml' は現在無効な引数であり、削除する必要があります。アップストリームに適用された修正については、this commit を参照してください。
この場合に取るべき措置は次のとおりです。
- エラーで報告された meson.build にパッチを適用してビルドを修正し、更新された PKGBUILD を公開します。
- パッチを使用してアップストリームリポジトリに貢献して、全員が修正できるようにし、次のバージョンでソース配列にパッチが含まれないようにします。
テンプレート
上記の手順をまとめ、コピー&ペースト用の一箇所にまとめたテンプレートは以下をご覧ください:
makedepends=(meson)
build() {
arch-meson $pkgname-$pkgver build
meson compile -C build
}
check() {
meson test -C build --print-errorlogs
}
package() {
meson install -C build --destdir "$pkgdir"
}
サンプルパッケージ
これは、Meson を使用するパッケージの小さなリストです。meson の "必要とするパッケージ" のリストにある他のパッケージも参照してください。