<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 25, 2023 at 10:12 AM Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-brains.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Allow the user to set the version control key.<br>
---<br>
 spec/build/cpukit/grp.yml             |  2 ++<br>
 spec/build/cpukit/optversionvckey.yml | 20 ++++++++++++++<br>
 wscript                               | 38 ++++++++++++++++-----------<br>
 3 files changed, 44 insertions(+), 16 deletions(-)<br>
 create mode 100644 spec/build/cpukit/optversionvckey.yml<br>
<br>
diff --git a/spec/build/cpukit/grp.yml b/spec/build/cpukit/grp.yml<br>
index e07e975d7d..fbeab45b5c 100644<br>
--- a/spec/build/cpukit/grp.yml<br>
+++ b/spec/build/cpukit/grp.yml<br>
@@ -18,6 +18,8 @@ links:<br>
   uid: cpuopts<br>
 - role: build-dependency<br>
   uid: cfghdr<br>
+- role: build-dependency<br>
+  uid: optversionvckey<br>
 - role: build-dependency<br>
   uid: libdebugger<br>
 - role: build-dependency<br>
diff --git a/spec/build/cpukit/optversionvckey.yml b/spec/build/cpukit/optversionvckey.yml<br>
new file mode 100644<br>
index 0000000000..7197381342<br>
--- /dev/null<br>
+++ b/spec/build/cpukit/optversionvckey.yml<br>
@@ -0,0 +1,20 @@<br>
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause<br>
+actions:<br>
+- get-string: null<br>
+- env-assign: null<br>
+build-type: option<br>
+copyrights:<br>
+- Copyright (C) 2022, 2023 embedded brains GmbH & Co. KG<br>
+default:<br>
+- enabled-by: true<br>
+  value: ''<br>
+description: |<br>
+  If defined to a non-empty value, then the value will be used for the version<br>
+  control key returned by rtems_version() and rtems_version_control_key(),<br>
+  otherwise the value will be determined by the Git repository containing the<br>
+  waf top directory.<br></blockquote><div><br></div><div>And would this change for a release tarball?</div><div><br></div><div>I'm reading this as a project specific version string in addition to major and minor.</div><div><br></div><div>And that if used, it would be the responsibility of the user to track that back to revision control hash.</div><div><br></div><div>If so, this likely needs a bit more written. </div><div><br></div><div>Right?</div><div><br></div><div>--joel</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+enabled-by: true<br>
+format: '{}'<br>
+links: []<br>
+name: RTEMS_VERSION_VC_KEY<br>
+type: build<br>
diff --git a/wscript b/wscript<br>
index 862000513d..2026d55070 100755<br>
--- a/wscript<br>
+++ b/wscript<br>
@@ -58,38 +58,44 @@ def no_unicode(value):<br>
<br>
<br>
 class VersionControlKeyHeader:<br>
-    _content = None<br>
+    _git_commit = None<br>
<br>
     @staticmethod<br>
     def write(bld, filename):<br>
-        if VersionControlKeyHeader._content is None:<br>
-            from waflib.Build import Context<br>
-            from waflib.Errors import WafError<br>
-<br>
-            content = """/*<br>
+        content = """/*<br>
  * Automatically generated. Do not edit.<br>
  */<br>
 #if !defined(_RTEMS_VERSION_VC_KEY_H_)<br>
 #define _RTEMS_VERSION_VC_KEY_H_<br>
 """<br>
-            try:<br>
-                rev = bld.cmd_and_log("git rev-parse HEAD",<br>
-                                      quiet=Context.STDOUT).strip()<br>
-                content += """#define RTEMS_VERSION_VC_KEY "{}"<br>
+        rev = bld.env.RTEMS_VERSION_VC_KEY<br>
+        if not rev:<br>
+            rev = VersionControlKeyHeader._git_commit<br>
+            if rev is None:<br>
+                from waflib.Build import Context<br>
+                from waflib.Errors import WafError<br>
+<br>
+                try:<br>
+                    rev = bld.cmd_and_log("git rev-parse HEAD",<br>
+                                          quiet=Context.STDOUT).strip()<br>
+                except WafError:<br>
+                    rev = ""<br>
+                VersionControlKeyHeader._git_commit = rev<br>
+        if rev:<br>
+            content += """#define RTEMS_VERSION_VC_KEY "{}"<br>
 """.format(rev)<br>
-            except WafError:<br>
-                content += """/* No version control key found; release? */<br>
+        else:<br>
+            content += """/* No version control key found; release? */<br>
 """<br>
-            content += """#endif<br>
+        content += """#endif<br>
 """<br>
-            VersionControlKeyHeader._content = content<br>
         f = bld.bldnode.make_node(filename)<br>
         f.parent.mkdir()<br>
         try:<br>
             if content != f.read():<br>
-                f.write(VersionControlKeyHeader._content)<br>
+                f.write(content)<br>
         except:<br>
-            f.write(VersionControlKeyHeader._content)<br>
+            f.write(content)<br>
<br>
<br>
 class EnvWrapper(object):<br>
-- <br>
2.35.3<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div></div>