[libcamera-devel] [RFC PATCH] libcamera: Disable automatic vcs versioning

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Aug 22 16:39:48 CEST 2022


On Mon, Aug 22, 2022 at 05:17:05PM +0300, Laurent Pinchart via libcamera-devel wrote:
> On Sat, Aug 20, 2022 at 03:29:48PM +0200, Christian Rauch via libcamera-devel wrote:
> > Hi Tomi,
> > 
> > With the recent discussions on "versioning", I would actually argue that
> > this should be removed entirely, and we should only rely on the semver
> > versioning.
> 
> I'd rather not. It has been proven very useful multiple times to have
> the exact git commit ID in bug reports. If we were to drop it, it would
> increase our support burden. I'm fine omitting the commit ID when the
> libcamera version exactly matches a released version, but not otherwise.
> 
> > Am 20.08.22 um 10:07 schrieb Tomi Valkeinen via libcamera-devel:
> > > libcamera builds the git hash version into the libcamera library. This
> > > makes ninja create the generated version.cpp on every build, and if the
> > > git hash has changed, compilation of version.cpp and linking of
> > > libcamera library.
> > >
> > > This patch adds a meson option to disable this behavior and instead use
> > > the meson project-version as the version built into the library, which
> > > is only generated at meson configuration time.
> > >
> > > With this change, ninja will nicely say "no work to do" if there's
> > > nothing to compile, instead of starting the build and generating
> > > version.cpp.
> 
> I'd prefer a way to skip recompilation (and relinking) if the version
> hasn't changed since the last build.

Which of course doesn't work for Tomi's use case.

/me needs to wake up

How can we get the best of both worlds ?

> > > But, more importantly, it often reduces build time. For example, this
> > > takes a particular git range compilation (~20 py bindings patches) from
> > > 43 seconds to 10 seconds. Obviously the improvement depends very much on
> > > the patches in question. If every commit changes libcamera itself, there
> > > is no difference.
> > >
> > > Signed-off-by: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
> > > ---
> > >  meson_options.txt         |  5 +++++
> > >  src/libcamera/meson.build | 29 +++++++++++++++++++++--------
> > >  2 files changed, 26 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/meson_options.txt b/meson_options.txt
> > > index 7a9aecfc..6a0bd0be 100644
> > > --- a/meson_options.txt
> > > +++ b/meson_options.txt
> > > @@ -63,3 +63,8 @@ option('pycamera',
> > >          type : 'feature',
> > >          value : 'disabled',
> > >          description : 'Enable libcamera Python bindings (experimental)')
> > > +
> > > +option('disable-vcs-versioning',
> > > +        type : 'boolean',
> > > +        value : false,
> > > +        description : 'Disable automatic libcamera library versioning with the git hash')
> > > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> > > index ce1f0f2f..6fd6f084 100644
> > > --- a/src/libcamera/meson.build
> > > +++ b/src/libcamera/meson.build
> > > @@ -121,14 +121,27 @@ endforeach
> > >
> > >  libcamera_sources += control_sources
> > >
> > > -gen_version = meson.project_source_root() / 'utils' / 'gen-version.sh'
> > > -
> > > -# Use vcs_tag() and not configure_file() or run_command(), to ensure that the
> > > -# version gets updated with every ninja build and not just at meson setup time.
> > > -version_cpp = vcs_tag(command : [gen_version, meson.project_build_root(), meson.project_source_root()],
> > > -                      input : 'version.cpp.in',
> > > -                      output : 'version.cpp',
> > > -                      fallback : meson.project_version())
> > > +if get_option('disable-vcs-versioning')
> > > +    cdata = configuration_data()
> > > +    cdata.set('VCS_TAG', meson.project_version())
> > > +
> > > +    # For some reason using 'version.cpp' as output file works fine for generation
> > > +    # but causes meson to delete the file before build. Any other file name
> > > +    # seems to work.
> > > +    version_cpp = configure_file(input : 'version.cpp.in',
> > > +                                 output : 'version_static.cpp',
> > > +                                 configuration : cdata)

Do I understand correctly that this will cause a build failure if you
don't first run meson setup with the disable-vcs-versioning option
disabled ?

> > > +
> > > +else
> > > +    gen_version = meson.project_source_root() / 'utils' / 'gen-version.sh'
> > > +
> > > +    # Use vcs_tag() and not configure_file() or run_command(), to ensure that the
> > > +    # version gets updated with every ninja build and not just at meson setup time.
> > > +    version_cpp = vcs_tag(command : [gen_version, meson.project_build_root(), meson.project_source_root()],
> > > +                          input : 'version.cpp.in',
> > > +                          output : 'version.cpp',
> > > +                          fallback : meson.project_version())
> > > +endif
> > >
> > >  libcamera_sources += version_cpp
> > >

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list