[libcamera-devel] [PATCH v3 2/5] meson: Shared Object version handling

Kieran Bingham kieran.bingham at ideasonboard.com
Thu Oct 13 10:50:13 CEST 2022


Quoting Laurent Pinchart (2022-10-12 19:09:27)
> Hi Kieran,
> 
> On Wed, Oct 12, 2022 at 08:21:03PM +0300, Laurent Pinchart via libcamera-devel wrote:
> > On Wed, Oct 12, 2022 at 04:45:17PM +0100, Kieran Bingham wrote:
> > > Quoting Laurent Pinchart (2022-10-12 15:51:16)
> > > > On Mon, Oct 10, 2022 at 06:32:11PM +0100, Kieran Bingham via libcamera-devel wrote:
> > > > > The libcamera project is not yet ready to declare ABI nor API stability,
> > > > > but it will benefit the community to be able to provide more regular
> > > > > release cycles to determine 'versioned' points of history.
> > > > > 
> > > > > Ideally, these releases will be made at any ABI breakage, but can be
> > > > > made at arbitary time based points along the way.
> > > > > 
> > > > > To support releases which may not be ABI stable, declare the soversion
> > > > > of both the libcamera and libcamera-base library to be dependant upon
> > > > > both the major and minor component of the project version.
> > > > > 
> > > > > As part of this, introduce a new 'Versions' summary section to highlight
> > > > > the different version components that may become apparent within any
> > > > > given build.
> > > > > 
> > > > > Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>
> > > > > Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> > > > > 
> > > > > ---
> > > > > v3:
> > > > >  - fix typo
> > > > >  - Use libcamera_version directly for SONAME.
> > > > >  - Fix ordering of EXCLUDE_PATTERNS
> > > > >  - Use meson.project_version() in the event the git versions
> > > > >    are incorrect.
> > > > >  - No need to present libcamera_version anymore
> > > > >    - Guaranteed to be the same as 'project_version'
> > > > > 
> > > > > Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> > > > > ---
> > > > >  Documentation/Doxyfile.in      |  4 +++-
> > > > >  meson.build                    | 23 +++++++++++++++++++++++
> > > > >  src/libcamera/base/meson.build |  1 +
> > > > >  src/libcamera/meson.build      |  1 +
> > > > >  4 files changed, 28 insertions(+), 1 deletion(-)
> > > > > 
> > > > > diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in
> > > > > index 88dfcddaebf6..e87bb2b42c5e 100644
> > > > > --- a/Documentation/Doxyfile.in
> > > > > +++ b/Documentation/Doxyfile.in
> > > > > @@ -51,7 +51,9 @@ EXCLUDE_PATTERNS       = @TOP_BUILDDIR@/include/libcamera/ipa/*_serializer.h \
> > > > >                           @TOP_BUILDDIR@/include/libcamera/ipa/ipu3_*.h \
> > > > >                           @TOP_BUILDDIR@/include/libcamera/ipa/raspberrypi_*.h \
> > > > >                           @TOP_BUILDDIR@/include/libcamera/ipa/rkisp1_*.h \
> > > > > -                         @TOP_BUILDDIR@/include/libcamera/ipa/vimc_*.h
> > > > > +                         @TOP_BUILDDIR@/include/libcamera/ipa/vimc_*.h \
> > > > > +                         @TOP_BUILDDIR@/src/libcamera/libcamera.so* \
> > > > > +                         @TOP_BUILDDIR@/src/libcamera/base/libcamera-base.so*
> > > > 
> > > > I'm still getting
> > > > 
> > > > warning: source 'libcamera/build/x86-gcc-10.4.0/src/libcamera/libcamera.so.0' is not a readable file or directory... skipping.
> > > > warning: source 'libcamera/build/x86-gcc-10.4.0/src/libcamera/libcamera.so' is not a readable file or directory... skipping.
> > > > warning: source 'libcamera/build/x86-gcc-10.4.0/src/libcamera/base/libcamera-base.so.0' is not a readable file or directory... skipping.
> > > > 
> > > > despite this.
> > > 
> > > Ah, that's a pain, I thought it had gone - but ... it must have been
> > > because I cleaned my tree or such.
> > >  
> > > > I was hoping that EXCLUDE_SYMLINKS would fix it, but that's not the
> > > > case. Doxygen prints the warning before checking if the file is a
> > > > symlink. It should be easily fixable in Doxygen, I may even send a
> > > > patch. Should we set EXCLUDE_SYMLINKS to prepare for that, and drop the
> > > > EXCLUDE_PATTERNS change ?
> > > 
> > > What is the EXCLUDE_SYMLINKS change?
> > 
> > Setting EXCLUDE_SYMLINKS to YES makes doxygen ignore symlinks. The
> > non-readable files are symlinks, so it would fix our issue. That is, if
> > it worked :-)
> > 
> > > I'm happy to add that, or we can drop this here and fix it later.
> > > 
> > > Certainly no point adding lines that don't affect it though.
> > 
> > We can add it later when doxygen is fixed I suppose.
> 
> https://github.com/doxygen/doxygen/pull/9636
> 
> Successfully tested with EXCLUDE_SYMLINKS = YES.


Ok - that's the following hunk applied to this patch:

diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in
index e87bb2b42c5e..e4f0cd426d39 100644
--- a/Documentation/Doxyfile.in
+++ b/Documentation/Doxyfile.in
@@ -51,9 +51,7 @@ EXCLUDE_PATTERNS       = @TOP_BUILDDIR@/include/libcamera/ipa/*_serializer.h \
                          @TOP_BUILDDIR@/include/libcamera/ipa/ipu3_*.h \
                          @TOP_BUILDDIR@/include/libcamera/ipa/raspberrypi_*.h \
                          @TOP_BUILDDIR@/include/libcamera/ipa/rkisp1_*.h \
-                         @TOP_BUILDDIR@/include/libcamera/ipa/vimc_*.h \
-                         @TOP_BUILDDIR@/src/libcamera/libcamera.so* \
-                         @TOP_BUILDDIR@/src/libcamera/base/libcamera-base.so*
+                         @TOP_BUILDDIR@/include/libcamera/ipa/vimc_*.h

 EXCLUDE_SYMBOLS        = libcamera::BoundMethodArgs \
                          libcamera::BoundMethodBase \
@@ -68,6 +66,8 @@ EXCLUDE_SYMBOLS        = libcamera::BoundMethodArgs \
                          *::details \
                          std::*

+EXCLUDE_SYMLINKS       = YES
+
 HTML_OUTPUT            = api-html

 GENERATE_LATEX         = NO




> 
> > > > >  
> > > > >  EXCLUDE_SYMBOLS        = libcamera::BoundMethodArgs \
> > > > >                           libcamera::BoundMethodBase \
> > > > > diff --git a/meson.build b/meson.build
> > > > > index 2c6173b4f97e..3e2bcc0de2c3 100644
> > > > > --- a/meson.build
> > > > > +++ b/meson.build
> > > > > @@ -26,6 +26,29 @@ endif
> > > > >  
> > > > >  libcamera_version = libcamera_git_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.
> > > > 
> > > > For a moment I wondered what we should do if there's a git tag more
> > > > recent than the meson project version. Then I thought whoever does that
> > > > would probably deserve an Undefined Behaviour (TM) that would have at
> > > > least a 50% change of sudo rm -rf /. As we're nice people, let's just
> > > > ignore this case :-)
> > > > 
> > > > > +if libcamera_version != meson.project_version()
> > > > > +    warning('The sources disagree about the version: '
> > > > > +            + libcamera_version + ' != ' + meson.project_version())
> > > > > +
> > > > > +    libcamera_version = meson.project_version()
> > > > > +    libcamera_git_version = libcamera_version + '+' + libcamera_git_version.split('+')[1]
> > > > > +    summary({'Source version override': true}, section : 'Versions')
> > > > 
> > > > Maybe bool_yn to match the the rest of our summary sections ? It will by
> > > > default (on terminals that support it) print YES in green and NO in red,
> > > > so if we phrased this message the other way around (for instance 'Source
> > > > version match' : false) it would appear more prominantly as something
> > > > bad. Entirely up to you.
> > > 
> > > Source version match : NO
> > > 
> > > sounds reasonable. I'll try it out.

This made me realise that in the event of a mismatch, it also makes
sense to report what git reports.
So that makes this :

diff --git a/meson.build b/meson.build
index 05cdee1edaf6..8b06120f17eb 100644
--- a/meson.build
+++ b/meson.build
@@ -33,9 +33,13 @@ if libcamera_version != meson.project_version()
     warning('The sources disagree about the version: '
             + libcamera_version + ' != ' + meson.project_version())

+    summary({'libcamera git version' : libcamera_git_version,
+             'Source version match' : false,
+            },
+            bool_yn : true, section : 'Versions')
+
     libcamera_version = meson.project_version()
     libcamera_git_version = libcamera_version + '+' + libcamera_git_version.split('+')[1]
-    summary({'Source version override': true}, section : 'Versions')
 endif

 # Until we make ABI compatible releases, the full libcamera version is used as


This gives a final presentation (upon a version mismatch of)

  Versions
    libcamera git version    : 0.0.1+dirty (2022-10-13T09:08:43+01:00)
    Source version match     : NO
    project                  : 0.1.1
    sources                  : 0.1.1+dirty (2022-10-13T09:08:43
    soname                   : 0.1.1

And highlights that I've got the concatenation of the
meson.project_version() and the extra build information wrong. (due to
splitting on +), so I'll fix that.


That's fixable by using .replace() instead of .split()

+    libcamera_git_version = libcamera_git_version.replace(libcamera_version,
+                                                          meson.project_version())
     libcamera_version = meson.project_version()
-    libcamera_git_version = libcamera_version + '+' + libcamera_git_version.split('+')[1]
-    summary({'Source version override': true}, section : 'Versions')

And now we have: (Yes my tree has changed from above)

  Versions
    libcamera git version    : 0.0.1+2-55c615e3-dirty (2022-10-13T09:33:35+01:00)
    Source version match     : NO
    project                  : 0.1.1
    sources                  : 0.1.1+2-55c615e3-dirty (2022-10-13T09:33:35+01:00)
    soname                   : 0.1.1

The only thing to be aware of is that if there is a "Source Version
Match : NO", then the 'patch count' (+2) can't be trusted at all. But I
think that's fine to just be aware of and ignore, and there's sufficient
information around to still tie down what commit / build is in use.

So ... lets add a marker to indicate when we modify the verision string.

     libcamera_git_version = libcamera_git_version.replace(libcamera_version,
                                                           meson.project_version())
     libcamera_version = meson.project_version()
+
+    # Append a marker to show we have modified this version string
+    libcamera_git_version += '-nvm'
 endif
 
 # Until we make ABI compatible releases, the full libcamera version is used as

Which now gives us:


  Versions
    libcamera git version    : 0.0.1+2-55c615e3-dirty (2022-10-13T09:40:50+01:00)
    Source version match     : NO
    project                  : 0.1.1
    sources                  : 0.1.1+2-55c615e3-dirty (2022-10-13T09:40:50+01:00)-nvm
    soname                   : 0.1.1


Finally, the project version is now redundant, as it is 'guaranteed' to
be presented in the 'sources' version string. (And is actually presented
above the summary section anyway).

So that leaves us with:

for a good case:

libcamera 0.0.1

  Versions
    sources                  : 0.0.1+3-9b089899-dirty (2022-10-13T09:48:13+01:00)
    soname                   : 0.0.1

And a mis-match case:

libcamera 0.1.1

  Versions
    libcamera git version    : 0.0.1+3-9b089899-dirty (2022-10-13T09:47:34+01:00)
    Source version match     : NO
    sources                  : 0.1.1+3-9b089899-dirty (2022-10-13T09:47:34+01:00)-nvm
    soname                   : 0.1.1


The soname could also now be dropped as 'we' know it is
'major.minor.patch' now, until we (actually) hit 0.1, where it would be
major.minor, and when we hit a real 1.x, it would become just 'major'.




> > > 
> > > > Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> > > > 
> > > > > +endif
> > > > > +
> > > > > +# Until we make ABI compatible releases, the full libcamera version is used as
> > > > > +# the soname.
> > > > > +libcamera_soversion = libcamera_version
> > > > > +
> > > > > +summary({
> > > > > +            'project': meson.project_version(),
> > > > > +            'sources': libcamera_git_version,
> > > > > +            'soname': libcamera_soversion,
> > > > > +        },
> > > > > +        section : 'Versions')
> > > > > +
> > > > >  # This script generates the .tarball-version file on a 'meson dist' command.
> > > > >  meson.add_dist_script('utils/run-dist.sh')
> > > > >  
> > > > > diff --git a/src/libcamera/base/meson.build b/src/libcamera/base/meson.build
> > > > > index 7a75914ab2a8..7a7fd7e4ca87 100644
> > > > > --- a/src/libcamera/base/meson.build
> > > > > +++ b/src/libcamera/base/meson.build
> > > > > @@ -51,6 +51,7 @@ libcamera_base_args = [ '-DLIBCAMERA_BASE_PRIVATE' ]
> > > > >  libcamera_base_lib = shared_library('libcamera-base',
> > > > >                                      [libcamera_base_sources, libcamera_base_headers],
> > > > >                                      version : libcamera_version,
> > > > > +                                    soversion : libcamera_soversion,
> > > > >                                      name_prefix : '',
> > > > >                                      install : true,
> > > > >                                      cpp_args : libcamera_base_args,
> > > > > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> > > > > index 7fcbb2ddc9e7..5f39d2e2c60a 100644
> > > > > --- a/src/libcamera/meson.build
> > > > > +++ b/src/libcamera/meson.build
> > > > > @@ -161,6 +161,7 @@ libcamera_deps = [
> > > > >  libcamera = shared_library('libcamera',
> > > > >                             libcamera_sources,
> > > > >                             version : libcamera_version,
> > > > > +                           soversion : libcamera_soversion,
> > > > >                             name_prefix : '',
> > > > >                             install : true,
> > > > >                             include_directories : includes,
> 
> -- 
> Regards,
> 
> Laurent Pinchart


More information about the libcamera-devel mailing list