如何使用介子构建 glib
How to use meson to build glib
我需要为特定项目升级 glib。它目前使用 glib 2.28.8。我有三个问题。
- 我以前从未使用过
meson
和ninja
,所以我检查了glib的INSTALL.in
,它只是说运行 meson _build
,然后是ninja -C _build
。所以我 运行 meson _build
得到以下输出:
$ meson _build
The Meson build system
Version: 0.47.2
Source dir: /srv/devel/build/glib-2.65.0
Build dir: /srv/devel/build/glib-2.65.0/_build
Build type: native build
meson.build:227: WARNING: Identifier 'in' will become a reserved keyword in a future release. Please rename it.
meson.build:227:14: ERROR: Expecting eol got id.
if vs_crt_opt in ['mdd', 'mtd']
所以基本构建不起作用。为什么?
- 出于我们的目的,我们使用以下配置命令:
PKG_CONFIG_PATH=$(OUTPUT_DIR)/lib/pkgconfig ./configure --prefix=$(OUTPUT_DIR) --disable-dtrace --disable-selinux ac_cv_path_MSGFMT=/bin/true CPPFLAGS="-fPIC -I$(OUTPUT_DIR)/include" LDFLAGS="-L$(OUTPUT_DIR)/lib" --enable-static --disable-shared
如何在介子中指定它?
- 我还需要在 Windows 中构建。有什么问题吗?
谢谢!
编辑:我尝试了旧版本的 glib,回到 2.62.0,当我 运行 meson _build
我得到错误 meson.build:1:0: ERROR: Meson version is 0.47.2 but project requires >= 0.49.2.
。所以这可能是问题 (1) 的很大一部分。这是 CentOS 6 和 7 上的 运行ning,所以我可能必须获取并安装当前的介子包。
So the basic build doesn't work. Why?
您在编辑中正确地理解了这一点:GLib 2.64 requires Meson 0.49.2,Meson 0.47.2 似乎太旧以至于无法正确解析 GLib 的 meson.build
。
从您的构建输出来看,您正在尝试构建 GLib 2.65.0。请注意,2.65 是一个不稳定的发行版系列。即使是次要版本的 GLib(2.62.x、2.64.x 等)也是稳定的;奇数不稳定。使用不稳定的版本很好,只要您知道您注册的是什么:它可能包含错误,并且该不稳定系列中引入的新 API 可能会在第一个稳定版本(在 2.x 的情况下)之前更改或删除。 65.x,对应的第一个稳定版本为 2.66.0)。
For our purposes, we use the following configure command:
你会想要这样的东西:
meson --prefix "$(OUTPUT_DIR)" -Dselinux=disabled -Ddefault_library=static _build
从b_staticpic
option’s default value可以看出,-fPIC
是静态库的默认值,所以(我相信)不需要明确指定。
不需要禁用 dtrace 支持,因为它是 disabled by default。如果确实需要禁用它,可以使用 -Ddtrace=false
.
自定义 -L
和 -I
参数应该被 --prefix
的使用覆盖。
覆盖 msgfmt
工具以禁用国际化不是构建 GLib 的受支持方式,你只能靠自己了。
Meson 中的内置选项有一些很好的文档 here and here。
I will also need to build in Windows. Any gotchas there?
这个问题太宽泛了,无法在 Whosebug 上回答。
我需要为特定项目升级 glib。它目前使用 glib 2.28.8。我有三个问题。
- 我以前从未使用过
meson
和ninja
,所以我检查了glib的INSTALL.in
,它只是说运行meson _build
,然后是ninja -C _build
。所以我 运行meson _build
得到以下输出:
$ meson _build
The Meson build system
Version: 0.47.2
Source dir: /srv/devel/build/glib-2.65.0
Build dir: /srv/devel/build/glib-2.65.0/_build
Build type: native build
meson.build:227: WARNING: Identifier 'in' will become a reserved keyword in a future release. Please rename it.
meson.build:227:14: ERROR: Expecting eol got id.
if vs_crt_opt in ['mdd', 'mtd']
所以基本构建不起作用。为什么?
- 出于我们的目的,我们使用以下配置命令:
PKG_CONFIG_PATH=$(OUTPUT_DIR)/lib/pkgconfig ./configure --prefix=$(OUTPUT_DIR) --disable-dtrace --disable-selinux ac_cv_path_MSGFMT=/bin/true CPPFLAGS="-fPIC -I$(OUTPUT_DIR)/include" LDFLAGS="-L$(OUTPUT_DIR)/lib" --enable-static --disable-shared
如何在介子中指定它?
- 我还需要在 Windows 中构建。有什么问题吗?
谢谢!
编辑:我尝试了旧版本的 glib,回到 2.62.0,当我 运行 meson _build
我得到错误 meson.build:1:0: ERROR: Meson version is 0.47.2 but project requires >= 0.49.2.
。所以这可能是问题 (1) 的很大一部分。这是 CentOS 6 和 7 上的 运行ning,所以我可能必须获取并安装当前的介子包。
So the basic build doesn't work. Why?
您在编辑中正确地理解了这一点:GLib 2.64 requires Meson 0.49.2,Meson 0.47.2 似乎太旧以至于无法正确解析 GLib 的 meson.build
。
从您的构建输出来看,您正在尝试构建 GLib 2.65.0。请注意,2.65 是一个不稳定的发行版系列。即使是次要版本的 GLib(2.62.x、2.64.x 等)也是稳定的;奇数不稳定。使用不稳定的版本很好,只要您知道您注册的是什么:它可能包含错误,并且该不稳定系列中引入的新 API 可能会在第一个稳定版本(在 2.x 的情况下)之前更改或删除。 65.x,对应的第一个稳定版本为 2.66.0)。
For our purposes, we use the following configure command:
你会想要这样的东西: meson --prefix "$(OUTPUT_DIR)" -Dselinux=disabled -Ddefault_library=static _build
从b_staticpic
option’s default value可以看出,-fPIC
是静态库的默认值,所以(我相信)不需要明确指定。
不需要禁用 dtrace 支持,因为它是 disabled by default。如果确实需要禁用它,可以使用 -Ddtrace=false
.
自定义 -L
和 -I
参数应该被 --prefix
的使用覆盖。
覆盖 msgfmt
工具以禁用国际化不是构建 GLib 的受支持方式,你只能靠自己了。
Meson 中的内置选项有一些很好的文档 here and here。
I will also need to build in Windows. Any gotchas there?
这个问题太宽泛了,无法在 Whosebug 上回答。