前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >使用meson编译postgresql的方法

使用meson编译postgresql的方法

作者头像
mingjie
发布2023-02-28 15:59:59
1.3K0
发布2023-02-28 15:59:59
举报
文章被收录于专栏:Postgresql源码分析

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

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

1 编译过程

工具与编译目录结构

代码语言:javascript
复制
yum install -y ninja-build meson

# 源码目录
pgroot99/pgsrc

# 新建构建目录
pgroot99/pgbuild

第一步

进入构建目录pgroot99/pgbuild

代码语言:javascript
复制
cd pgroot99/pgbuild

meson setup . ../pgsrc/

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

代码语言:javascript
复制
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中,如果有新加参数名称不对可以到这个文件中查询。

代码语言:javascript
复制
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

代码语言:javascript
复制
-- 编译
ninja
-- 安装
ninja install

-- 如需清理
ninja clean	

2 测试

查看用例

代码语言:javascript
复制
meson test --list

make check

代码语言:javascript
复制
meson test --suite setup --suite regress	

meson test --suite setup --suite plpgsql	

make installcheck

代码语言:javascript
复制
meson test --setup running regress-running/regress

3 命令对照表

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

option=

value`enable cassert--enable-cassert-Dcassert=trueenable 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

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2023-02-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1 编译过程
    • 第一步
      • 第二步:配置intro-buildoptions.json
        • 第三步:编译、安装(默认会使用CPU核数编译)
        • 2 测试
        • 3 命令对照表
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档