[libcamera-devel] [PATCH v2] meson: Align handling of build metadata
Kieran Bingham
kieran.bingham at ideasonboard.com
Wed Mar 1 13:43:59 CET 2023
On 01/03/2023 11:56, Michael Riesch wrote:
> Hi Kieran,
>
> On 3/1/23 01:24, Kieran Bingham wrote:
>> Quoting Michael Riesch (2023-02-27 21:15:04)
>>> The build metadata is split off correctly from the version string
>>> obtained with utils/gen-version.sh, but for the meson project version
>>> this step is not carried out. However, since libcamera uses Semantic
>>> Versioning, it should be possible to add build metadata to the meson
>>> project version. Align the handling of the build metadata to resolve
>>> this mismatch.
>>>
>>> Signed-off-by: Michael Riesch <michael.riesch at wolfvision.net>
>>> ---
>>> v2 of this series follows a discussion with kbingham in #libcamera
>>>
>>> Changes in v2:
>>> - revise patch message to reflect the current mismatch and the
>>> proposed fix better
>>> - introduce the 'project_version' variable to avoid three .split()
>>> operations
>>>
>>> meson.build | 9 +++++----
>>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/meson.build b/meson.build
>>> index 9eee9d39..c8222338 100644
>>> --- a/meson.build
>>> +++ b/meson.build
>>> @@ -25,13 +25,14 @@ if libcamera_git_version == ''
>>> endif
>>>
>>> libcamera_version = libcamera_git_version.split('+')[0]
>>> +project_version = meson.project_version().split('+')[0]
>>>
>>> # A shallow clone, or a clone without a reachable tag equivalent to the
>>> # meson.project_version() could leave the project in a mis-described state.
>>> # Produce a warning in this event, and fix to a best effort.
>>> -if libcamera_version != meson.project_version()
>>> +if libcamera_version != project_version
>>> warning('The sources disagree about the version: '
>>> - + libcamera_version + ' != ' + meson.project_version())
>>> + + libcamera_version + ' != ' + project_version)
>>>
>>> summary({'libcamera git version' : libcamera_git_version,
>>> 'Source version match' : false,
>>> @@ -40,9 +41,9 @@ if libcamera_version != meson.project_version()
>>>
>>> # Replace the version components reported by git with the release version,
>>> # but keep all trailing information supplied by git.
>>> - libcamera_git_version = (meson.project_version() +
>>> + libcamera_version = project_version
>>
>> I'm not sure this works. I think I assigned libcamera_version 'after'
>> intentionally, as it gets used
>
> TL;DR: I'll revert this swap in v3.
>
> I think the original intention was to save calls to .split(), but the
> different calls are eliminated anyway now with the newly introduced
> variable.
>
>>> + libcamera_git_version = (libcamera_version +
>>> libcamera_git_version.strip(libcamera_version))
>>
>> Here, which isn't going to do the right thing anymore.
>>
>> Before it was handling 'invalid' git versions as follows:
>>
>> meson.project_version() = 0.0.4
>> libcamera_git_version = 0.0.0+1-58e0b6e1 # from utils/gen-version.sh
>> libcamera_version = libcamera_git_version.split('+')[0]
>>
>> if (libcamera_version != project_version)
>> libcamera_git_version = 0.0.4 + "0.0.0+1-58e0b6e1".strip(0.0.0)
>>
>> == 0.0.4+1-58e0b6e1
>>
>> But now you've made this:
>> libcamera_git_version = 0.0.4 + "0.0.0+1-58e0b6e1".strip(0.0.4)
>>
>> == 0.0.40.0.0+1-58e0b6e1
>>
>> Can you test with a shallow clone:
>>
>> git clone https://git.libcamera.org/libcamera/libcamera.git/ --depth 1
>>
>> And applying your patch please?
>
> Haha, it even works, but only by coincidence. I believe .strip('0.0.4')
> effectively strips all '0', '4' and '.' characters, hence '0.0.0' is
> stripped.
>
Yikes - that's not good. That means I've misunderstood the .strip() and
it's not doing what I was anticipating (strip off that exact string only).
--
Kieran
> Will send v3 in the evening or so.
>
> Thanks and best regards,
> Michael
>
>>
>> --
>> Kieran
>>
>>
>>> - libcamera_version = meson.project_version()
>>>
>>> # Append a marker to show we have modified this version string
>>> libcamera_git_version += '-nvm'
>>> --
>>> 2.30.2
>>>
More information about the libcamera-devel
mailing list