[RFC,2/2] build: Add a "version_sha" meson build option
diff mbox series

Message ID 20211012152410.978077-3-naush@raspberrypi.com
State Superseded
Headers show
Series
  • Add new build option to override generate SHA
Related show

Commit Message

Naushir Patuck Oct. 12, 2021, 3:24 p.m. UTC
This build option can be used to override the SHA value in the version string
generated by utils/gen-version.sh.

An override is needed if distributions make libcamera builds outside of the
upstream git tree. In these cases, the user can then use the correct SHA value
of the upstream tree instead of the local downstream build tree.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
 meson.build               | 4 +++-
 meson_options.txt         | 5 +++++
 src/libcamera/meson.build | 3 ++-
 3 files changed, 10 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/meson.build b/meson.build
index a49c484fe64e..cea6ca78cfa0 100644
--- a/meson.build
+++ b/meson.build
@@ -16,8 +16,10 @@  project('libcamera', 'c', 'cpp',
 # only. If the source tree isn't under git control, or if it matches the last
 # git version tag, the build metadata (e.g. +211-c94a24f4) is omitted from
 # libcamera_git_version.
+version_sha_override = get_option('version_sha')
 libcamera_git_version = run_command('utils/gen-version.sh',
-                                    meson.build_root()).stdout().strip()
+                                    meson.build_root(),
+                                    version_sha_override).stdout().strip()
 if libcamera_git_version == ''
     libcamera_git_version = meson.project_version()
 endif
diff --git a/meson_options.txt b/meson_options.txt
index 2c80ad8b5e0b..96db8de4cdeb 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -58,3 +58,8 @@  option('v4l2',
         type : 'boolean',
         value : false,
         description : 'Compile the V4L2 compatibility layer')
+
+option('version_sha',
+        type : 'string',
+        value : '',
+        description : 'Custom version sha string to use')
diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
index 243dd3c180eb..94cded2ce6c3 100644
--- a/src/libcamera/meson.build
+++ b/src/libcamera/meson.build
@@ -93,9 +93,10 @@  endforeach
 
 libcamera_sources += control_sources
 
+version_sha_override = get_option('version_sha')
 gen_version = meson.source_root() / 'utils' / 'gen-version.sh'
 
-version_cpp = vcs_tag(command : [gen_version, meson.build_root()],
+version_cpp = vcs_tag(command : [gen_version, meson.build_root(), version_sha_override],
                       input : 'version.cpp.in',
                       output : 'version.cpp',
                       fallback : meson.project_version())