[PATCH 01/10] build: Generate build hash
chrisj at rtems.org
Thu Feb 25 04:13:51 UTC 2021
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.
Any chance of a build label set in the config.ini? :)
> + 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.
> + state = hashlib.sha256()
> + state.update(build_hash.encode("utf-8"))
Why the `utf-8` encode and then decode later?
> + conf.define(
> + "RTEMS_BUILD_HASH",
> + base64.urlsafe_b64encode(state.digest()).decode("utf-8"),
Thank you for base64 encoding the result.
More information about the devel