On 25/02/2021 05:13, Chris Johns wrote:

On 25/2/21 12:57 am, Sebastian Huber wrote:
Update #4265.
---
  wscript | 27 ++++++++++++++++++++++++++-
  1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/wscript b/wscript
index 6626fafb74..83c7c446bb 100755
--- a/wscript
+++ b/wscript
@@ -1359,6 +1359,30 @@ def get_compiler(conf, cp, variant):
      return value
+def _generate_build_hash(conf):
+    import hashlib
+    import base64
+
+    build_hash = ""
+    for key in sorted(conf.env):
+        build_hash = build_hash + key + str(conf.env[key])
I am pleased to see the environment is being addressed but on some modern
operating systems the environment has become a bit of a beast. This means
comparable values will be near impossible if the whole environment is included
in the build hash.

Should we look to use a list that is contained? A list that effects the code on
the target? In a purest sense a hash created from the CU pieces in all target
libraries would be ideal however this is recursive.
This is a good idea. Maybe we should iterate over all start files and libraries generated by the build and then create a hash of all executable sections. Then we recompile one object with a command line define with the build hash and replace this object in librtemscpu.a.

Any chance of a build label set in the config.ini? :)
You want something like a rtems_get_build_label() which returns the value of RTEMS_BUILD_LABEL set in a config.ini (or a default, e.g. "arch/bsp")?

+    for discard in [
+        conf.env.PREFIX,
+        conf.bldnode.make_node(conf.env.VARIANT).abspath(),
+        conf.path.abspath(),
+    ]:
+        build_hash = build_hash.replace(discard, "")
I do not follow this piece of logic.
It removes prefix, source and build paths.

+    state = hashlib.sha256()
+    state.update(build_hash.encode("utf-8"))
Why the `utf-8` encode and then decode later?
The hash update needs a byte stream not a string. The define needs a string and not a byte stream.

+    conf.define(
+        "RTEMS_BUILD_HASH",
+        base64.urlsafe_b64encode(state.digest()).decode("utf-8"),
Thank you for base64 encoding the result.

Chris

--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to