diff mbox series

spirv-tools: Fix git-describe related reproducibility

Message ID 20240802233553.2385836-1-yoann.congal@smile.fr
State Accepted, archived
Commit fa7ab8f9afaeeba9e2b2806f28e7e9cbd2595353
Headers show
Series spirv-tools: Fix git-describe related reproducibility | expand

Commit Message

Yoann Congal Aug. 2, 2024, 11:35 p.m. UTC
From: Yoann Congal <yoann.congal@smile.fr>

This reproducibility problem comes down to git-describe output. Fixes
this by using an environment variable to force the description and use
it to set this description to ${PV}

Fixes [YOCTO #15567].

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
 ...sion.py-support-an-envvar-to-force-t.patch | 43 +++++++++++++++++++
 .../spir/spirv-tools_1.3.283.0.bb             |  9 +++-
 2 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-graphics/spir/spirv-tools/0001-update_build_version.py-support-an-envvar-to-force-t.patch
diff mbox series

Patch

diff --git a/meta/recipes-graphics/spir/spirv-tools/0001-update_build_version.py-support-an-envvar-to-force-t.patch b/meta/recipes-graphics/spir/spirv-tools/0001-update_build_version.py-support-an-envvar-to-force-t.patch
new file mode 100644
index 0000000000..edcbf506b9
--- /dev/null
+++ b/meta/recipes-graphics/spir/spirv-tools/0001-update_build_version.py-support-an-envvar-to-force-t.patch
@@ -0,0 +1,43 @@ 
+From 39b6385454d705128e684ed779ba9620e2ead1e2 Mon Sep 17 00:00:00 2001
+From: Yoann Congal <yoann.congal@smile.fr>
+Date: Thu, 1 Aug 2024 18:58:04 +0200
+Subject: [PATCH] update_build_version.py: support an envvar to force the
+ description
+
+FORCED_BUILD_VERSION_DESCRIPTION envvar can be used to force a version
+description instead of resorting to git describe which can change for a
+given commit if multiple lightweight commits point ot it.
+
+Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
+Upstream-Status: Submitted [https://github.com/KhronosGroup/SPIRV-Tools/pull/5758]
+---
+ utils/update_build_version.py | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/utils/update_build_version.py b/utils/update_build_version.py
+index bb66e18a..9115cab1 100755
+--- a/utils/update_build_version.py
++++ b/utils/update_build_version.py
+@@ -24,9 +24,10 @@
+ #  - The software version deduced from the given CHANGES file.
+ #  - A longer string with the project name, the software version number, and
+ #    git commit information for the CHANGES file's directory.  The commit
+-#    information is the output of "git describe" if that succeeds, or "git
+-#    rev-parse HEAD" if that succeeds, or otherwise a message containing the
+-#    phrase "unknown hash".
++#    information is the content of the FORCED_BUILD_VERSION_DESCRIPTION
++#    environement variable is it exists, else the output of "git describe" if
++#    that succeeds, or "git rev-parse HEAD" if that succeeds, or otherwise a
++#    message containing the phrase "unknown hash".
+ # The string contents are escaped as necessary.
+ 
+ import datetime
+@@ -150,7 +151,7 @@ def main():
+       sys.exit(1)
+ 
+     repo_path = os.path.dirname(changes_file_path)
+-    description = describe(repo_path)
++    description = os.getenv("FORCED_BUILD_VERSION_DESCRIPTION", describe(repo_path))
+     content = OUTPUT_FORMAT.format(version_tag=version, description=description)
+ 
+     # Escape file content.
diff --git a/meta/recipes-graphics/spir/spirv-tools_1.3.283.0.bb b/meta/recipes-graphics/spir/spirv-tools_1.3.283.0.bb
index 292a17f00d..c54f80c756 100644
--- a/meta/recipes-graphics/spir/spirv-tools_1.3.283.0.bb
+++ b/meta/recipes-graphics/spir/spirv-tools_1.3.283.0.bb
@@ -8,7 +8,9 @@  LICENSE  = "Apache-2.0"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
 
 SRCREV = "dd4b663e13c07fea4fbb3f70c1c91c86731099f7"
-SRC_URI = "git://github.com/KhronosGroup/SPIRV-Tools.git;branch=main;protocol=https"
+SRC_URI = "git://github.com/KhronosGroup/SPIRV-Tools.git;branch=main;protocol=https \
+           file://0001-update_build_version.py-support-an-envvar-to-force-t.patch \
+           "
 PE = "1"
 # These recipes need to be updated in lockstep with each other:
 # glslang, vulkan-headers, vulkan-loader, vulkan-tools, spirv-headers, spirv-tools
@@ -29,6 +31,11 @@  EXTRA_OECMAKE += "\
     -DSPIRV_SKIP_TESTS=ON \
 "
 
+# Force the version description "git describe" related non-reproducibility
+do_compile:prepend() {
+    export FORCED_BUILD_VERSION_DESCRIPTION="${PV}"
+}
+
 do_install:append:class-target() {
     # Properly set _IMPORT_PREFIX in INTERFACE_LINK_LIBRARIES so that dependent
     # tools can find the right library