Merge branch 'issue530' into 'master'

build: Allow version number to be followed by "-" and a suffix

See merge request dbus/dbus!494
This commit is contained in:
Simon McVittie 2024-12-10 12:30:37 +00:00
commit e3c3cd6889
6 changed files with 31 additions and 8 deletions

View file

@ -20,7 +20,7 @@ else()
set(LANGUAGES C)
endif()
project(dbus
VERSION ${DBUS_VERSION}
VERSION ${DBUS_VERSION_NO_SUFFIX}
LANGUAGES C CXX
)

View file

@ -32,8 +32,9 @@ endmacro()
macro(meson_version prefix)
set(WS "[ \t\r\n]")
string(TOUPPER ${prefix} prefix_upper)
string(REGEX REPLACE ".*${WS}version:${WS}*'([0-9.]+)'.*" "\\1" ${prefix_upper}_VERSION ${_meson_build_raw})
string(REPLACE "." ";" VERSION_LIST ${${prefix_upper}_VERSION})
string(REGEX REPLACE ".*${WS}version:${WS}*'([0-9.]+(-[-a-zA-Z0-9.]+)?)'.*" "\\1" ${prefix_upper}_VERSION ${_meson_build_raw})
string(REGEX REPLACE "-.*" "" ${prefix_upper}_VERSION_NO_SUFFIX ${${prefix_upper}_VERSION})
string(REPLACE "." ";" VERSION_LIST ${${prefix_upper}_VERSION_NO_SUFFIX})
list(GET VERSION_LIST 0 ${prefix_upper}_MAJOR_VERSION)
list(GET VERSION_LIST 1 ${prefix_upper}_MINOR_VERSION)
list(GET VERSION_LIST 2 ${prefix_upper}_MICRO_VERSION)

View file

@ -4,7 +4,7 @@ LIBDBUS_1_@SOVERSION@ {
local:
*;
};
LIBDBUS_PRIVATE_@DBUS_VERSION@ {
LIBDBUS_PRIVATE_@DBUS_VERSION_NO_SUFFIX@ {
global:
_dbus_*;
};

View file

@ -179,6 +179,9 @@ dbus_get_local_machine_id (void)
* least significant byte. This means two DBUS_VERSION can be compared to see
* which is higher.
*
* This does not include any release-status suffix like "-alpha", "-beta",
* "-rc".
*
* Consider carefully whether to use this or the runtime version from
* dbus_get_version().
*/
@ -188,6 +191,10 @@ dbus_get_local_machine_id (void)
*
* The COMPILE TIME version of libdbus, as a string "X.Y.Z".
*
* This might include additional information beyond what appears in
* DBUS_VERSION, for example an "-alpha", "-beta" or "-rc" suffix
* that is not represented elsewhere.
*
* Consider carefully whether to use this or the runtime version from
* dbus_get_version().
*/

View file

@ -21,7 +21,7 @@
project('dbus',
'c',
version: '1.16.99',
version: '1.16.99-alpha',
meson_version: '>=0.56',
)
@ -47,11 +47,13 @@ install_symlinks = []
not_found = dependency('', required: false)
version = meson.project_version()
version_no_suffix = version.split('-')[0]
config.set_quoted('VERSION', version)
data_config.set('VERSION', version)
data_config.set('DBUS_VERSION', version)
data_config.set('DBUS_VERSION_NO_SUFFIX', version_no_suffix)
ver_array = version.split('.')
ver_array = version_no_suffix.split('.')
arch_config.set('DBUS_VERSION', version)
arch_config.set('DBUS_MAJOR_VERSION', ver_array[0])
arch_config.set('DBUS_MINOR_VERSION', ver_array[1])
@ -142,7 +144,7 @@ if platform_windows
).stdout().strip()
data_config.set('BUILD_TIMESTAMP', build_timestamp)
data_config.set('BUILD_FILEVERSION', ','.join(version.split('.')))
data_config.set('BUILD_FILEVERSION', ','.join(version_no_suffix.split('.')))
data_config.set('DBUS_VER_FILE_TYPE', 'VFT_DLL')
data_config.set('DBUS_VER_INTERNAL_NAME', 'libdbus-1-@0@' .format(soversion))

View file

@ -615,8 +615,11 @@ _dbus_list_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
static dbus_bool_t
_dbus_misc_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
{
static const char compiled_version[] = DBUS_VERSION_STRING;
const char *runtime_version;
int major, minor, micro;
DBusString str;
size_t len;
/* make sure we don't crash on NULL */
dbus_get_version (NULL, NULL, NULL);
@ -663,7 +666,17 @@ _dbus_misc_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
if (!_dbus_string_append_printf (&str, "%d.%d.%d", major, minor, micro))
_dbus_test_fatal ("no memory");
_dbus_test_check (_dbus_string_equal_c_str (&str, DBUS_VERSION_STRING));
runtime_version = _dbus_string_get_const_data (&str);
len = _dbus_string_get_length_uint (&str);
/* This is not an API guarantee, but in practice we only plan to
* set the version string to either X.Y.Z (stable branches) or
* X.Y.Z-{alpha,beta,rc} (development branches), so the
* DBUS_VERSION_STRING stored in compiled_version should be
* X.Y.Z followed by either '\0' or "-...". */
_dbus_test_check (strlen (compiled_version) >= len);
_dbus_test_check (strncmp (runtime_version, compiled_version, len) == 0);
_dbus_test_check (compiled_version[len] == '\0' || compiled_version[len] == '-');
_dbus_string_free (&str);