chromecast: meson.build: check both x.y and x.y.z for protoc

Protobuf and protoc version naming changed starting after version
21.7.11.x, at version 22.x.y[^2]. Other versioning changes during the
21.* cycle were made right before[^1].

The new versioning is described on the specific page from protocol
buffers website[^3].

For instance, protoc from archlinux currently outputs version 25.3,
leading to the following message if checking a 3-number version number
like the version in the contribs:

    Program protoc found: NO found 25.3 but need: '25.3.0' (/usr/bin/protoc)

After this patch we have the following with version 25.3:

    Program protoc found: YES 25.3 25.3 (/usr/bin/protoc)

and with version 21.1 from contrib:

    Program protoc found: YES 3.21.1 3.21.1

[^1]: https://protobuf.dev/news/2022-05-06/
[^2]: https://protobuf.dev/news/2022-07-06/
[^3]: https://protobuf.dev/support/version-support/
This commit is contained in:
Alexandre Janniaux 2024-04-10 17:28:41 +02:00 committed by Steve Lhomme
parent e53da4bf08
commit b77311d307
1 changed files with 18 additions and 1 deletions

View File

@ -4,10 +4,27 @@ protoc = disabler()
chromecast_proto = []
if protobuf_dep.found()
# Protoc can output either a 2-number version or a 3-number version...
# Protobuf switched from version naming 3.20.12.z to version 21.7.z, and
# protoc provide compatibility with version x.y now. But version 21.y.z
# still outputs the previous kind of version naming up until 3.21.12.z
# included, so the first version with the x.y format is 22.0.
protobuf_version_list = protobuf_dep.version().split('.')
if protobuf_dep.version().version_compare('< 3.22.0.0')
protoc_version = '@0@.@1@.@2@'.format(
protobuf_version_list[0],
protobuf_version_list[1],
protobuf_version_list[2])
else
# Protobuf version is x.y.z and protoc version is x.y
protoc_version = '@0@.@1@'.format(protobuf_version_list[0], protobuf_version_list[1])
endif
protoc = find_program('protoc',
version: '@0@.@1@'.format(protobuf_version_list[0], protobuf_version_list[1]),
version: protoc_version,
required: get_option('chromecast'))
endif
if protoc.found()
protobuf_gen = generator(protoc,
output: [
'@BASENAME@.pb.cc'.format(protobuf_dep.version()),