Skip to content

Commit

Permalink
Meson builds work on version 0.45.
Browse files Browse the repository at this point in the history
v0.45 ships with Ubuntu 18.04, which is currently the oldest distro we support. We may never do a Meson release on Ubuntu 18.04 but this allows us to start running unit tests with Meson in the meantime.

Some more granular options are not available so we use buildtype in more places.

The check for a in-tree autoconf/make build had to be removed since the filesystem APIs are not available.

Finally, alias_target was removed. This means that full paths must be used for build targets, which does not seem too bad. For instance, test/src/test-pgbackrest must now be used as a build target instead of simple test-pgbackrest.
  • Loading branch information
dwsteele committed Jul 6, 2022
1 parent 72960bb commit 0eccbc8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 44 deletions.
15 changes: 8 additions & 7 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ project(
['c'],
version: '2.40dev',
license: 'MIT',
meson_version: '>=0.53.2',
meson_version: '>=0.45',
default_options: [
# Core options
'buildtype=release',
Expand All @@ -26,7 +26,7 @@ cc = meson.get_compiler('c')
####################################################################################################################################
# Error on release builds since we do not want anyone using meson for production yet
####################################################################################################################################
if get_option('buildtype') != 'debug'
if get_option('buildtype') != 'debug' and get_option('buildtype') != 'debugoptimized'
error('meson is currently not supported for release builds')
endif

Expand Down Expand Up @@ -91,9 +91,10 @@ warning_disable = [
add_project_arguments(cc.get_supported_arguments(warning_enable, warning_disable), language: 'c')

####################################################################################################################################
# Enable additional optimizations if the level is high enough
# Enable additional optimizations for release builds. We would prefer to use `get_option('optimization') in ['2', '3']` when our
# minimum version is high enough to allow it.
####################################################################################################################################
if get_option('optimization') in ['2', '3']
if get_option('buildtype') == 'release'
optimization_enable = [
# Unroll loops whose number of iterations can be determined at compile time or upon entry to the loop
'-funroll-loops',
Expand Down Expand Up @@ -125,7 +126,7 @@ file_prefix = run_command(
meson.current_source_dir(),
meson.current_build_dir(),
],
check: true,
# check: true, # This should be set when the minimum supported meson version is >= 0.47
).stdout().strip()

add_project_arguments(cc.get_supported_arguments('-fmacro-prefix-map=@0@/src/=' . format(file_prefix)), language: 'c')
Expand Down Expand Up @@ -173,8 +174,8 @@ if cc.compiles('''int main(int arg, char **argv) {({ _Static_assert(1, "foo");})
configuration.set('HAVE_STATIC_ASSERT', true, description: 'Does the compiler provide _Static_assert()?')
endif

# Enable debug code
if get_option('debug')
# Enable debug code. We would prefer to use `get_option('debug')` when our minimum version is high enough to allow it.
if get_option('buildtype') == 'debug' or get_option('buildtype') == 'debugoptimized'
configuration.set('DEBUG', true, description: 'Enable debug code')
endif

Expand Down
29 changes: 1 addition & 28 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
####################################################################################################################################
# It is very easy to get into confusing states when the source directory contains an in-place build, e.g. the wrong build.auto.h
# will be used. So just refuse to build in this case.
####################################################################################################################################
if import('fs').exists(meson.current_source_dir() / 'build.auto.h')
error('''
Non-clean source code directory detected.
To build with meson the source tree may not have an in-place, ./configure
style, build configured. Use a separate check out for meson based builds, or
run 'make clean-all' in the source tree.
You can have both meson and ./configure style builds for the same source tree
by building out-of-source / VPATH with configure as well.''')
endif

####################################################################################################################################
# Write configuration
####################################################################################################################################
Expand Down Expand Up @@ -85,8 +68,6 @@ build_config = executable(
build_by_default: false,
)

alias_target('build-config', build_config)

####################################################################################################################################
# Build error target
####################################################################################################################################
Expand All @@ -108,8 +89,6 @@ build_error = executable(
build_by_default: false,
)

alias_target('build-error', build_error)

####################################################################################################################################
# Build help target
####################################################################################################################################
Expand Down Expand Up @@ -139,8 +118,6 @@ build_help = executable(
# build help.auto.c.inc
subdir('command/help')

alias_target('build-help', help_auto_c_inc)

####################################################################################################################################
# Build postgres target
####################################################################################################################################
Expand All @@ -164,8 +141,6 @@ build_postgres = executable(
# build interface.auto.c.inc
subdir('postgres')

alias_target('build-postgres', build_postgres)

####################################################################################################################################
# pgBackRest target
####################################################################################################################################
Expand Down Expand Up @@ -302,7 +277,7 @@ src_pgbackrest = [
'main.c',
]

pgbackrest = executable(
executable(
'pgbackrest',
src_common,
src_pgbackrest,
Expand All @@ -318,5 +293,3 @@ pgbackrest = executable(
lib_zstd,
]
)

alias_target('pgbackrest', pgbackrest)
2 changes: 1 addition & 1 deletion test/src/command/help/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Generate help
####################################################################################################################################
test_help_auto_c_inc = custom_target(
'help.auto.c.inc',
'test_help.auto.c.inc',
output: 'help.auto.c.inc',
depend_files: [
'../../build/config/config.yaml',
Expand Down
8 changes: 1 addition & 7 deletions test/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@ configure_file(output: 'build.auto.h', configuration: configuration)
# build parse.auto.c.inc
subdir('config')

alias_target('test-build-config', test_parse_auto_c_inc)

####################################################################################################################################
# Build help target
####################################################################################################################################
# build help.auto.c.inc
subdir('command/help')

alias_target('test-build-help', test_help_auto_c_inc)

####################################################################################################################################
# test target
####################################################################################################################################
Expand Down Expand Up @@ -46,7 +42,7 @@ src_test = [
'main.c',
]

test_pgbackrest = executable(
executable(
'test-pgbackrest',
src_common,
src_test,
Expand All @@ -59,5 +55,3 @@ test_pgbackrest = executable(
],
build_by_default: false,
)

alias_target('test-pgbackrest', test_pgbackrest)
2 changes: 1 addition & 1 deletion test/test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ =head1 SYNOPSIS

# Build code
executeTest(
"ninja -C ${strBuildPath}" . ($bMinGen ? '' : ' build-config build-error') . ' build-postgres' .
"ninja -C ${strBuildPath}" . ($bMinGen ? '' : ' src/build-config src/build-error') . ' src/build-postgres' .
($bMinGen ? '' : " && ${strBuildPath}/src/build-config ${strBackRestBase}/src") .
($bMinGen ? '' : " && ${strBuildPath}/src/build-error ${strBackRestBase}/src") .
" && cd $strRepoCachePath/src && ${strBuildPath}/src/build-postgres");
Expand Down

0 comments on commit 0eccbc8

Please sign in to comment.