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

Christian Rauch Rauch.Christian at gmx.de
Sat Aug 20 15:29:48 CEST 2022


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.

Best,
Christian


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.
>
> 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)
> +
> +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
>


More information about the libcamera-devel mailing list