Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meson does not allow strings like X.Y.Z+META to be used as the library version #10565

Open
DieTime opened this issue Jul 5, 2022 · 1 comment

Comments

@DieTime
Copy link

DieTime commented Jul 5, 2022

Describe the bug
I am passing the version using the meson options from the rpm spec file.

When using the Sailfish OS build system, the version has metadata at the end, which also gets into the meson build script.

$ meson -Dversion=0.1.0+master.20220705111300.6e4b184 builddir

Previously, I used cmake, which allowed you to specify strings of this format as the version of the library. Meson throws an error that the version must be X.Y.Z. However, Semantic Versioning 2.0 assumes the use of metadata in the version, see this.

This makes it difficult to write meson scripts, as it is very common to write something like this:

version_parts = get_option('version').replace('+', '.').split('.')
assert(version_parts.length() >= 3,
       'The version does not contain major, minor and patch')

major = version_parts[0]
minor = version_parts[1]
patch = version_parts[2]

version = f'@major@.@minor@.@patch@'

To Reproduce

project('libexample', 'c')

version = '0.1.0+master.20220705111300.6e4b184'

# ERROR:
# Invalid Shared library version "0.1.0+master.20220705111300.6e4b184".
# Must be of the form X.Y.Z where all three are numbers.
lib = shared_library('example', 'main.c', version: version)

Expected behavior
Behavior similar to cmake: output library libexample.so.0.1.0+master.20220705111300.6e4b184

system parameters

  • Is this a cross build or just a plain native build (for the same computer)? native build
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.): Ubuntu 20.04
  • what Python version are you using e.g. 3.8.0: 3.8.10
  • what meson --version: 0.62.2
  • what ninja --version if it's a Ninja build: 1.10.0
DieTime added a commit to DieTime/meson that referenced this issue Jul 6, 2022
Some projects use metadata when versioning, such as the OBS build system.
When trying to pass a version from such projects to the meson build
script and use it as a dynamic library version, an error is thrown that
the version should look like X.Y.Z.

However, Semantic Versioning 2.0 assumes the use of metadata in the
version, see: https://semver.org/#spec-item-10

This commit adds support for metadata in dynamic library versions.
Fixes an issue: mesonbuild#10565
@DieTime DieTime changed the title Meson does not allow strings like X.Y.Z+<branch>.<date>.<commit> to be used as the library version Meson does not allow strings like X.Y.Z+META to be used as the library version Jul 6, 2022
@eli-schwartz
Copy link
Member

However, Semantic Versioning 2.0 assumes the use of metadata in the version, see this.

It doesn't assume it, it permits it. :)

And I honestly don't think I've ever seen this in a library version before. :) Considering e.g. the libtool versioning convention, I wouldn't even assume library versions follow a 3-part semver, let alone one with optional metadata, regardless of what project versions do.

This makes it difficult to write meson scripts, as it is very common to write something like this:

I wouldn't say that's difficult. Or common. If someone is replacing a plus with a period, then they are specifically trying to handle this uncommon use case.

It will always trigger the assert and fail, but if the version is used for something other than a library version, you could handle the library version much more simply: use .split('+') instead, and only keep the first half.

DieTime added a commit to DieTime/meson that referenced this issue Jul 7, 2022
Some projects use metadata when versioning, such as the OBS build system.
When trying to pass a version from such projects to the meson build
script and use it as a dynamic library version, an error is thrown that
the version should look like X.Y.Z.

However, Semantic Versioning 2.0 assumes the use of metadata in the
version, see: https://semver.org/#spec-item-10

This commit adds support for metadata in dynamic library versions.
Fixes an issue: mesonbuild#10565
DieTime added a commit to DieTime/meson that referenced this issue Jul 7, 2022
Some projects use metadata when versioning, such as the OBS build system.
When trying to pass a version from such projects to the meson build
script and use it as a dynamic library version, an error is thrown that
the version should look like X.Y.Z.

However, Semantic Versioning 2.0 assumes the use of metadata in the
version, see: https://semver.org/#spec-item-10

This commit adds support for metadata in dynamic library versions.
Fixes an issue: mesonbuild#10565
DieTime added a commit to DieTime/meson that referenced this issue Jul 7, 2022
Some projects use metadata when versioning, such as the OBS build system.
When trying to pass a version from such projects to the meson build
script and use it as a dynamic library version, an error is thrown that
the version should look like X.Y.Z.

However, Semantic Versioning 2.0 permits the use of metadata in the
version, see: https://semver.org/#spec-item-10

This commit adds support for metadata in dynamic library versions.
Fixes an issue: mesonbuild#10565
DieTime added a commit to DieTime/meson that referenced this issue Jul 19, 2022
Some projects use metadata when versioning, such as the Sailfish OS
build system. When trying to pass a version from such projects to the
meson build script and use it as a dynamic library version, an error
is thrown that the version should look like X.Y.Z.

However, Semantic Versioning 2.0 permits the use of metadata in the
version, see: https://semver.org/#spec-item-10

This commit adds support for metadata in dynamic library versions.
Fixes an issue: mesonbuild#10565
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants