使用meson编译postgresql的方法

meson 是一个相对较新的构建系统,力求快速且易于使用。现在postgresql已经支持meson编译,这篇博文会介绍如何使用meson编译新版postgresql。

请确认postgresql源码目录中存在meson.build,如果没有请升级源码版本。

1 编译过程

工具与编译目录结构

yum install -y ninja-build meson

# 源码目录
pgroot99/pgsrc

# 新建构建目录
pgroot99/pgbuild

第一步

进入构建目录pgroot99/pgbuild

cd pgroot99/pgbuild

meson setup . ../pgsrc/

如果出现The conflicting files need to be removed提示,请到源码目录执行maintainer-clean,彻底清理源码目录:

export PGHOME=xxx

./configure --prefix=$PGHOME --enable-tap-tests --with-tcl --enable-depend --enable-cassert --enable-debug --with-perl --with-openssl --with-libxml CFLAGS="-ggdb -O0 -g3 -gdwarf-2"

make maintainer-clean

第二步:配置intro-buildoptions.json

进入构建目录pgroot99/pgbuild

所有可选参数名称与值都在文件meson-info/intro-buildoptions.json中,如果有新加参数名称不对可以到这个文件中查询。

meson configure \
-Dprefix=${PGHOME} \
-Dtap_tests=enabled \
-Dcassert=true \
-Dbuildtype=debug \
-Ddebug=true \
-Doptimization=0 \
-Dlibxml=enabled \
-Dc_args="-ggdb -O0 -g3 -gdwarf-2" 

第三步:编译、安装(默认会使用CPU核数编译)

进入构建目录pgroot99/pgbuild

-- 编译
ninja
-- 安装
ninja install

-- 如需清理
ninja clean	

2 测试

查看用例

meson test --list

make check

meson test --suite setup --suite regress	

meson test --suite setup --suite plpgsql	

make installcheck

meson test --setup running regress-running/regress

3 命令对照表

descriptionold commandnew commandcomment
set up build tree./configure [<options>]meson setup [<options>] [<build dir>] <source-dir>meson only supports building out of tree
set up build tree for visual studioperl src/tools/msvc/mkvcbuild.plmeson setup --backend vs [<options>] [<build dir>] <source-dir>configures build tree for one build type (debug or release or …)
show configure options./configure --helpmeson configureshows options built into meson and PostgreSQL specific options
set configure options./configure --prefix=DIR, --$somedir=DIR, --with-$option, --enable-$feature`meson setupconfigure -D o p t i o n = option= option=value`
enable cassert--enable-cassert-Dcassert=true
enable debug symbols./configure --enable-debug`meson configuresetup -Ddebug=true`
specify compilerCC=compiler ./configureCC=compiler meson setupCC is only checked during meson setup, not with meson configure
set CFLAGSCFLAGS=options ./configuremeson configure|setup -Dc_args=optionsCFLAGS is also checked, but only for meson setup
buildmake -sninjaninja uses parallelism by default, launch from the root of the build tree.
build, showing compiler commandsmakeninja -vninja uses parallelism by default, launch from the root of the build tree.
install all the binaries and librariesmake installninja installuse meson install --quiet for a less verbose experience
clean buildmake cleanninja cleanninja uses parallelism by default, launch from the root of the build tree.
run all testsmake check-worldmeson testruns all test, using parallelism by default
run all tests against existing servermake installcheck-worldmeson test --setup runningLimited to tests that support running against existing server
build documentationcd doc/ && make html && make manninja docsBuilds html documentation and man pages
run main regression testsmake checkmeson test --suite setup --suite regress
run main regression tests against existing servermake installcheckmeson test --setup running regress-running/regress
list testsmeson test --list
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

高铭杰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值