v1-0001-meson-Make-auto-the-default-of-the-uuid-option.patch
text/x-diff
Filename: v1-0001-meson-Make-auto-the-default-of-the-uuid-option.patch
Type: text/x-diff
Part: 0
Patch
Format: format-patch
Series: patch v1-0001
Subject: meson: Make auto the default of the uuid option
| File | + | − |
|---|---|---|
| .cirrus.yml | 2 | 3 |
| meson.build | 54 | 26 |
| meson_options.txt | 2 | 2 |
| src/makefiles/meson.build | 1 | 1 |
From 0e92050c15ca6e9ebeddaafad229eee53fc9e7b0 Mon Sep 17 00:00:00 2001
From: Nazir Bilal Yavuz <byavuz81@gmail.com>
Date: Tue, 14 Mar 2023 16:38:02 +0300
Subject: [PATCH v1] meson: Make auto the default of the uuid option
---
.cirrus.yml | 5 +--
meson.build | 80 ++++++++++++++++++++++++++-------------
meson_options.txt | 4 +-
src/makefiles/meson.build | 2 +-
4 files changed, 59 insertions(+), 32 deletions(-)
diff --git a/.cirrus.yml b/.cirrus.yml
index 505c50f3285..1ccb14c6340 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -181,7 +181,7 @@ task:
su postgres <<-EOF
meson setup \
--buildtype=debug \
- -Dcassert=true -Duuid=bsd -Dtcl_version=tcl86 -Ddtrace=auto \
+ -Dcassert=true -Dtcl_version=tcl86 -Ddtrace=auto \
-DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
-Dextra_lib_dirs=/usr/local/lib -Dextra_include_dirs=/usr/local/include/ \
build
@@ -243,7 +243,6 @@ LINUX_CONFIGURE_FEATURES: &LINUX_CONFIGURE_FEATURES >-
LINUX_MESON_FEATURES: &LINUX_MESON_FEATURES >-
-Dllvm=enabled
- -Duuid=e2fs
task:
@@ -496,7 +495,7 @@ task:
-Dextra_include_dirs=${brewpath}/include \
-Dextra_lib_dirs=${brewpath}/lib \
-Dcassert=true \
- -Duuid=e2fs -Ddtrace=auto \
+ -Ddtrace=auto \
-Dsegsize_blocks=6 \
-DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
build
diff --git a/meson.build b/meson.build
index 2ebdf914c1b..7955ae42d03 100644
--- a/meson.build
+++ b/meson.build
@@ -1282,34 +1282,61 @@ endif
###############################################################
uuidopt = get_option('uuid')
+uuid_library = 'none'
+uuid = not_found_dep
+if uuidopt == 'auto' and auto_features.disabled()
+ uuidopt = 'none'
+endif
+
if uuidopt != 'none'
- uuidname = uuidopt.to_upper()
- if uuidopt == 'e2fs'
- uuid = dependency('uuid', required: true)
- uuidfunc = 'uuid_generate'
- uuidheader = 'uuid/uuid.h'
- elif uuidopt == 'bsd'
- # libc should have uuid function
- uuid = declare_dependency()
- uuidfunc = 'uuid_to_string'
- uuidheader = 'uuid.h'
- elif uuidopt == 'ossp'
- uuid = dependency('ossp-uuid', required: true)
- uuidfunc = 'uuid_export'
- uuidheader = 'uuid.h'
- else
- error('huh')
- endif
- if not cc.has_header_symbol(uuidheader, uuidfunc, args: test_c_args, dependencies: uuid)
- error('uuid library @0@ missing required function @1@'.format(uuidopt, uuidfunc))
- endif
- cdata.set('HAVE_@0@'.format(uuidheader.underscorify().to_upper()), 1)
+ uuids = {
+ 'e2fs': {
+ 'uuiddep': 'uuid',
+ 'uuidfunc': 'uuid_generate',
+ 'uuidheader': 'uuid/uuid.h',
+ },
+ 'bsd': {
+ 'uuiddep': '',
+ 'uuidfunc': 'uuid_to_string',
+ 'uuidheader': 'uuid.h',
+ },
+ 'ossp': {
+ 'uuiddep': 'ossp-uuid',
+ 'uuidfunc': 'uuid_export',
+ 'uuidheader': 'uuid.h',
+ }
+ }
- cdata.set('HAVE_UUID_@0@'.format(uuidname), 1,
- description: 'Define to 1 if you have @0@ UUID support.'.format(uuidname))
-else
- uuid = not_found_dep
+ foreach uuidname, uuid_values : uuids
+ if uuidopt != 'auto' and uuidname != uuidopt
+ continue
+ endif
+ uuid_required = (uuidname == uuidopt)
+ uuiddep = uuid_values['uuiddep']
+ uuidheader = uuid_values['uuidheader']
+ uuidfunc = uuid_values['uuidfunc']
+
+ # libc should have uuid function
+ uuid = uuiddep != '' ? dependency(uuiddep, required: uuid_required) : \
+ declare_dependency()
+
+ if uuid.found() and cc.has_header_symbol(uuidheader, uuidfunc, args: test_c_args,
+ dependencies: uuid, required: uuid_required)
+ uuidname_upper = uuidname.to_upper()
+ uuid_library = uuidname
+ cdata.set('HAVE_@0@'.format(uuidheader.underscorify().to_upper()), 1)
+ cdata.set('HAVE_UUID_@0@'.format(uuidname_upper), 1,
+ description: 'Define to 1 if you have @0@ UUID support.'.format(uuidname_upper))
+ break
+ else
+ uuid = not_found_dep
+ endif
+ endforeach
+endif
+
+if uuidopt == 'auto' and auto_features.enabled() and not uuid.found()
+ error('no UUID library found')
endif
@@ -3302,11 +3329,12 @@ if meson.version().version_compare('>=0.57')
'readline': readline,
'selinux': selinux,
'systemd': systemd,
- 'uuid': uuid,
+ 'uuid': uuid.found() ? [uuid, '(@0@)'.format(uuid_library)] : uuid,
'zlib': zlib,
'zstd': zstd,
},
section: 'External libraries',
+ list_sep: ', ',
)
endif
diff --git a/meson_options.txt b/meson_options.txt
index 4402dd4299d..3ffe6fb758d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -137,8 +137,8 @@ option('ssl', type : 'combo', choices : ['auto', 'none', 'openssl'],
option('systemd', type : 'feature', value: 'auto',
description: 'build with systemd support')
-option('uuid', type : 'combo', choices : ['none', 'bsd', 'e2fs', 'ossp'],
- value : 'none',
+option('uuid', type : 'combo', choices : ['auto', 'none', 'bsd', 'e2fs', 'ossp'],
+ value : 'auto',
description: 'build contrib/uuid-ossp using LIB')
option('zlib', type : 'feature', value: 'auto',
diff --git a/src/makefiles/meson.build b/src/makefiles/meson.build
index 7635771c5ae..25e2a54a6bb 100644
--- a/src/makefiles/meson.build
+++ b/src/makefiles/meson.build
@@ -67,7 +67,7 @@ pgxs_kv = {
# want the chosen option, rather than the library
'with_ssl' : ssl_library,
- 'with_uuid': uuidopt,
+ 'with_uuid': uuid_library,
'default_port': get_option('pgport'),
'with_system_tzdata': get_option('system_tzdata'),
--
2.39.2