Skip to content

Commit

Permalink
meson: Add initial version of meson based build system
Browse files Browse the repository at this point in the history
Autoconf is showing its age, fewer and fewer contributors know how to wrangle
it. Recursive make has a lot of hard to resolve dependency issues and slow
incremental rebuilds. Our home-grown MSVC build system is hard to maintain for
developers not using Windows and runs tests serially. While these and other
issues could individually be addressed with incremental improvements, together
they seem best addressed by moving to a more modern build system.

After evaluating different build system choices, we chose to use meson, to a
good degree based on the adoption by other open source projects.

We decided that it's more realistic to commit a relatively early version of
the new build system and mature it in tree.

This commit adds an initial version of a meson based build system. It supports
building postgres on at least AIX, FreeBSD, Linux, macOS, NetBSD, OpenBSD,
Solaris and Windows (however only gcc is supported on aix, solaris). For
Windows/MSVC postgres can now be built with ninja (faster, particularly for
incremental builds) and msbuild (supporting the visual studio GUI, but
building slower).

Several aspects (e.g. Windows rc file generation, PGXS compatibility, LLVM
bitcode generation, documentation adjustments) are done in subsequent commits
requiring further review. Other aspects (e.g. not installing test-only
extensions) are not yet addressed.

When building on Windows with msbuild, builds are slower when using a visual
studio version older than 2019, because those versions do not support
MultiToolTask, required by meson for intra-target parallelism.

The plan is to remove the MSVC specific build system in src/tools/msvc soon
after reaching feature parity. However, we're not planning to remove the
autoconf/make build system in the near future. Likely we're going to keep at
least the parts required for PGXS to keep working around until all supported
versions build with meson.

Some initial help for postgres developers is at
https://wiki.postgresql.org/wiki/Meson

With contributions from Thomas Munro, John Naylor, Stone Tickle and others.

Author: Andres Freund <andres@anarazel.de>
Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Author: Peter Eisentraut <peter@eisentraut.org>
Reviewed-By: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Discussion: https://postgr.es/m/20211012083721.hvixq4pnh2pixr3j@alap3.anarazel.de
  • Loading branch information
anarazel committed Sep 22, 2022
1 parent fbb5f54 commit e692727
Show file tree
Hide file tree
Showing 265 changed files with 10,962 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
install_data(
'install-sh', 'missing',
install_dir: dir_pgxs / 'config'
)
6 changes: 6 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -20658,3 +20658,9 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi


# Ensure that any meson build directories would reconfigure and see that
# there's a conflicting in-tree build and can error out.
if test "$vpath_build"="no"; then
touch meson.build
fi
6 changes: 6 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2472,3 +2472,9 @@ AC_CONFIG_HEADERS([src/interfaces/ecpg/include/ecpg_config.h],
[echo >src/interfaces/ecpg/include/stamp-h])

AC_OUTPUT

# Ensure that any meson build directories would reconfigure and see that
# there's a conflicting in-tree build and can error out.
if test "$vpath_build"="no"; then
touch meson.build
fi
23 changes: 23 additions & 0 deletions contrib/adminpack/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
adminpack = shared_module('adminpack',
['adminpack.c'],
kwargs: contrib_mod_args,
)
contrib_targets += adminpack

install_data(
'adminpack.control',
'adminpack--1.0.sql',
'adminpack--1.0--1.1.sql',
'adminpack--1.1--2.0.sql',
'adminpack--2.0--2.1.sql',
kwargs: contrib_data_args,
)

tests += {
'name': 'adminpack',
'sd': meson.current_source_dir(),
'bd': meson.current_build_dir(),
'regress': {
'sql': ['adminpack'],
},
}
37 changes: 37 additions & 0 deletions contrib/amcheck/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
amcheck = shared_module('amcheck', [
'verify_heapam.c',
'verify_nbtree.c',
],
kwargs: contrib_mod_args,
)
contrib_targets += amcheck

install_data(
'amcheck.control',
'amcheck--1.0.sql',
'amcheck--1.0--1.1.sql',
'amcheck--1.1--1.2.sql',
'amcheck--1.2--1.3.sql',
kwargs: contrib_data_args,
)

tests += {
'name': 'amcheck',
'sd': meson.current_source_dir(),
'bd': meson.current_build_dir(),
'regress': {
'sql': [
'check',
'check_btree',
'check_heap',
],
},
'tap': {
'tests': [
't/001_verify_heapam.pl',
't/002_cic.pl',
't/003_cic_2pc.pl',
],
},
}

5 changes: 5 additions & 0 deletions contrib/auth_delay/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
autoinc = shared_module('auth_delay',
['auth_delay.c'],
kwargs: contrib_mod_args,
)
contrib_targets += autoinc
16 changes: 16 additions & 0 deletions contrib/auto_explain/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
auto_explain = shared_module('auto_explain',
files('auto_explain.c'),
kwargs: contrib_mod_args,
)
contrib_targets += auto_explain

tests += {
'name': 'auto_explain',
'sd': meson.current_source_dir(),
'bd': meson.current_build_dir(),
'tap': {
'tests': [
't/001_auto_explain.pl',
],
},
}
22 changes: 22 additions & 0 deletions contrib/basebackup_to_shell/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
basebackup_to_shell_sources = files(
'basebackup_to_shell.c',
)

basebackup_to_shell = shared_module('basebackup_to_shell',
basebackup_to_shell_sources,
kwargs: contrib_mod_args,
)
contrib_targets += basebackup_to_shell

tests += {
'name': 'basebackup_to_shell',
'sd': meson.current_source_dir(),
'bd': meson.current_build_dir(),
'tap': {
'tests': [
't/001_basic.pl',
],
'env': {'GZIP_PROGRAM': gzip.path(),
'TAR': tar.path()},
},
}
23 changes: 23 additions & 0 deletions contrib/basic_archive/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
basic_archive_sources = files(
'basic_archive.c',
)

basic_archive = shared_module('basic_archive',
basic_archive_sources,
kwargs: contrib_mod_args,
)
contrib_targets += basic_archive

tests += {
'name': 'basic_archive',
'sd': meson.current_source_dir(),
'bd': meson.current_build_dir(),
'regress': {
'sql': [
'basic_archive',
],
'regress_args': [
'--temp-config', files('basic_archive.conf'),
],
},
}
36 changes: 36 additions & 0 deletions contrib/bloom/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
bloom_sources = files(
'blcost.c',
'blinsert.c',
'blscan.c',
'blutils.c',
'blvacuum.c',
'blvalidate.c',
)

bloom = shared_module('bloom',
bloom_sources,
kwargs: contrib_mod_args,
)
contrib_targets += bloom

install_data(
'bloom.control',
'bloom--1.0.sql',
kwargs: contrib_data_args,
)

tests += {
'name': 'bloom',
'sd': meson.current_source_dir(),
'bd': meson.current_build_dir(),
'regress': {
'sql': [
'bloom',
],
},
'tap': {
'tests': [
't/001_wal.pl',
],
},
}
42 changes: 42 additions & 0 deletions contrib/bool_plperl/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
if not perl_dep.found()
subdir_done()
endif

bool_plperl_sources = files(
'bool_plperl.c',
)

bool_plperl = shared_module('bool_plperl',
bool_plperl_sources,
include_directories: [plperl_inc, include_directories('.')],
kwargs: contrib_mod_args + {
'dependencies': [perl_dep, contrib_mod_args['dependencies']],
'install_rpath': ':'.join(mod_install_rpaths + ['@0@/CORE'.format(archlibexp)]),
'build_rpath': '@0@/CORE'.format(archlibexp),
},
)
contrib_targets += bool_plperl

install_data(
'bool_plperl.control',
'bool_plperl--1.0.sql',
kwargs: contrib_data_args,
)

install_data(
'bool_plperlu.control',
'bool_plperlu--1.0.sql',
kwargs: contrib_data_args,
)

tests += {
'name': 'bool_plperl',
'sd': meson.current_source_dir(),
'bd': meson.current_build_dir(),
'regress': {
'sql': [
'bool_plperl',
'bool_plperlu',
],
},
}
54 changes: 54 additions & 0 deletions contrib/btree_gin/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
btree_gin = shared_module('btree_gin',
files('btree_gin.c'),
kwargs: contrib_mod_args,
)
contrib_targets += btree_gin

install_data(
'btree_gin.control',
'btree_gin--1.0.sql',
'btree_gin--1.0--1.1.sql',
'btree_gin--1.1--1.2.sql',
'btree_gin--1.2--1.3.sql',
kwargs: contrib_data_args,
)

tests += {
'name': 'btree_gin',
'sd': meson.current_source_dir(),
'bd': meson.current_build_dir(),
'regress': {
'sql': [
'install_btree_gin',
'int2',
'int4',
'int8',
'float4',
'float8',
'money',
'oid',
'timestamp',
'timestamptz',
'time',
'timetz',
'date',
'interval',
'macaddr',
'macaddr8',
'inet',
'cidr',
'text',
'varchar',
'char',
'bytea',
'bit',
'varbit',
'numeric',
'enum',
'uuid',
'name',
'bool',
'bpchar',
],
},
}
84 changes: 84 additions & 0 deletions contrib/btree_gist/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
btree_gist_sources = files(
'btree_bit.c',
'btree_bool.c',
'btree_bytea.c',
'btree_cash.c',
'btree_date.c',
'btree_enum.c',
'btree_float4.c',
'btree_float8.c',
'btree_gist.c',
'btree_inet.c',
'btree_int2.c',
'btree_int4.c',
'btree_int8.c',
'btree_interval.c',
'btree_macaddr.c',
'btree_macaddr8.c',
'btree_numeric.c',
'btree_oid.c',
'btree_text.c',
'btree_time.c',
'btree_ts.c',
'btree_utils_num.c',
'btree_utils_var.c',
'btree_uuid.c',
)

btree_gist = shared_module('btree_gist',
btree_gist_sources,
kwargs: contrib_mod_args,
)
contrib_targets += btree_gist

install_data(
'btree_gist.control',
'btree_gist--1.0--1.1.sql',
'btree_gist--1.1--1.2.sql',
'btree_gist--1.2.sql',
'btree_gist--1.2--1.3.sql',
'btree_gist--1.3--1.4.sql',
'btree_gist--1.4--1.5.sql',
'btree_gist--1.5--1.6.sql',
'btree_gist--1.6--1.7.sql',
kwargs: contrib_data_args,
)

tests += {
'name': 'btree_gist',
'sd': meson.current_source_dir(),
'bd': meson.current_build_dir(),
'regress': {
'sql': [
'init',
'int2',
'int4',
'int8',
'float4',
'float8',
'cash',
'oid',
'timestamp',
'timestamptz',
'time',
'timetz',
'date',
'interval',
'macaddr',
'macaddr8',
'inet',
'cidr',
'text',
'varchar',
'char',
'bytea',
'bit',
'varbit',
'numeric',
'uuid',
'not_equal',
'enum',
'bool',
],
},
}

0 comments on commit e692727

Please sign in to comment.