meson 是一个相对较新的构建系统,力求快速且易于使用。现在postgresql已经支持meson编译,这篇博文会介绍如何使用meson编译新版postgresql。
请确认postgresql源码目录中存在meson.build,如果没有请升级源码版本。
工具与编译目录结构
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
进入构建目录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"
进入构建目录pgroot99/pgbuild
-- 编译
ninja
-- 安装
ninja install
-- 如需清理
ninja clean
查看用例
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
description | old command | new command | comment |
---|---|---|---|
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 studio | perl src/tools/msvc/mkvcbuild.pl | meson setup --backend vs [<options>] [<build dir>] <source-dir> | configures build tree for one build type (debug or release or …) |
show configure options | ./configure --help | meson configure | shows options built into meson and PostgreSQL specific options |
set configure options | ./configure --prefix=DIR, --$somedir=DIR, --with-$option, --enable-$feature | `meson setup | configure -D o p t i o n = option= option=value` |
enable cassert | --enable-cassert | -Dcassert=true | |
enable debug symbols | ./configure --enable-debug | `meson configure | setup -Ddebug=true` |
specify compiler | CC=compiler ./configure | CC=compiler meson setup | CC is only checked during meson setup, not with meson configure |
set CFLAGS | CFLAGS=options ./configure | meson configure|setup -Dc_args=options | CFLAGS is also checked, but only for meson setup |
build | make -s | ninja | ninja uses parallelism by default, launch from the root of the build tree. |
build, showing compiler commands | make | ninja -v | ninja uses parallelism by default, launch from the root of the build tree. |
install all the binaries and libraries | make install | ninja install | use meson install --quiet for a less verbose experience |
clean build | make clean | ninja clean | ninja uses parallelism by default, launch from the root of the build tree. |
run all tests | make check-world | meson test | runs all test, using parallelism by default |
run all tests against existing server | make installcheck-world | meson test --setup running | Limited to tests that support running against existing server |
build documentation | cd doc/ && make html && make man | ninja docs | Builds html documentation and man pages |
run main regression tests | make check | meson test --suite setup --suite regress | |
run main regression tests against existing server | make installcheck | meson test --setup running regress-running/regress | |
list tests | meson test --list |
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 configureset CFLAGSCFLAGS=options ./configuremeson configure|setup -Dc_args=optionsCFLAGS is also checked, but only for meson setupbuildmake -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 experienceclean 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 defaultrun all tests against existing servermake installcheck-worldmeson test --setup runningLimited to tests that support running against existing serverbuild documentationcd doc/ && make html && make manninja docsBuilds html documentation and man pagesrun main regression testsmake checkmeson test --suite setup --suite regressrun main regression tests against existing servermake installcheckmeson test --setup running regress-running/regresslist testsmeson test --list