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

提供: ArchWiki
ナビゲーションに移動 検索に移動
(英語版から転載)
 
(前文を翻訳)
4行目: 4行目:
 
{{Package Guidelines}}
 
{{Package Guidelines}}
   
From [https://mesonbuild.com/ Meson's official website]:
+
[https://mesonbuild.com/ Meson 公式サイトより。]
   
  +
:Meson はオープンソースのビルドシステムで、非常に高速で、さらに重要なことに、可能な限りユーザーフレンドリーであることを意図しています。
:Meson is an open source build system meant to be both extremely fast, and, even more importantly, as user friendly as possible.
 
   
  +
Python で書かれた Meson は、マルチプラットフォームのサポート、複数のプログラミング言語のサポート、クロスコンパイルなどを特徴としています。
Written in Python, Meson features multi-platform support, support several programming languages, cross compilation, and more.
 
   
  +
Meson はソフトウェアを直接ビルドするのではなく、バックエンドのビルドシステムをセットアップします。一般的には {{Pkg|ninja}} と共に使われますが、他のビルドシステムを使うこともできます。一般的には、[[GNU#開発ツール|GNU ビルドシステム]] を置き換えるために使われます。
Meson does not build software directly, but rather sets up a back-end build system. While it is commonly used with {{Pkg|ninja}}, other build systems can be used. It is commonly used to replace [[GNU Build System]].
 
   
  +
このドキュメントは [https://mesonbuild.com/ Meson] を使うソフトウェアのための [[PKGBUILD]] を書くための標準ガイドラインを扱っています。
This document covers standards and guidelines on writing [[PKGBUILD]]s for software that uses [https://mesonbuild.com/ Meson].
 
   
 
== Usage ==
 
== Usage ==

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

Meson 公式サイトより。

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

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

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

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

Usage

Requirements

meson has to be included to the PKGBUILD's makedepends array.

build()

Configuring and building is normally done using meson binary, but it can also be done by using Arch Linux's arch-meson wrapper script.

Both meson and arch-meson commands include in the usage syntax options, source directory and build directory:

  • options: must include at least --prefix /usr, but make sure to check other options with meson configure --help; also check software-specific build options.
  • source directory (or "sourcedir"): where the software's source code is stored, e.g. ., $pkgname or $pkgname-$pkgver.
  • build directory (or "builddir"): where the build files will stored by Meson; commonly named build or _build, but it is discretionary.
ノート: 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.

Using meson binary directly

Notice --prefix=/usr always needs to be passed to meson binary because Arch Linux packages must not install files to /usr/local, according Arch package guidelines#Package etiquette. The --buildtype=plain built-in option can be set to another value, if you know what you are doing.

Example:

build() {
  meson --prefix=/usr --buildtype=plain source build
  meson compile -C build
}

meson compile is a wrapper for supported back-end build systems, which currently defaults to ninja[1]

ヒント: ninja -C build could be directly used instead.

Using arch-meson wrapper script

arch-meson is a wrapper script included in 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".

Example:

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

Setting software-specific build options

While Meson has some built-in build options (e.g. --prefix), the software being packaged could have other build options which the packager should consider. Valid software-specific build options are normally found in a file named meson_options.txt (if present) and in meson.build. Look for option(settings) in these files, then read the settings.

To use a software-specific build option, use the notation -D key=value, where key is the build option name set in the project and value is a valid value, like e.g. true.

For instance, gtranslator has the following build options:

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

So, to build its documentation, one must run Meson appending -D gtk_doc=true build option, resulting in a command line like e.g.

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.[2]
ヒント: 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