[PATCH] build: Add optional RTEMS_VERSION_VC_KEY

Joel Sherrill joel at rtems.org
Tue Jul 25 17:09:49 UTC 2023


On Tue, Jul 25, 2023 at 10:12 AM Sebastian Huber <
sebastian.huber at embedded-brains.de> wrote:

> Allow the user to set the version control key.
> ---
>  spec/build/cpukit/grp.yml             |  2 ++
>  spec/build/cpukit/optversionvckey.yml | 20 ++++++++++++++
>  wscript                               | 38 ++++++++++++++++-----------
>  3 files changed, 44 insertions(+), 16 deletions(-)
>  create mode 100644 spec/build/cpukit/optversionvckey.yml
>
> diff --git a/spec/build/cpukit/grp.yml b/spec/build/cpukit/grp.yml
> index e07e975d7d..fbeab45b5c 100644
> --- a/spec/build/cpukit/grp.yml
> +++ b/spec/build/cpukit/grp.yml
> @@ -18,6 +18,8 @@ links:
>    uid: cpuopts
>  - role: build-dependency
>    uid: cfghdr
> +- role: build-dependency
> +  uid: optversionvckey
>  - role: build-dependency
>    uid: libdebugger
>  - role: build-dependency
> diff --git a/spec/build/cpukit/optversionvckey.yml
> b/spec/build/cpukit/optversionvckey.yml
> new file mode 100644
> index 0000000000..7197381342
> --- /dev/null
> +++ b/spec/build/cpukit/optversionvckey.yml
> @@ -0,0 +1,20 @@
> +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
> +actions:
> +- get-string: null
> +- env-assign: null
> +build-type: option
> +copyrights:
> +- Copyright (C) 2022, 2023 embedded brains GmbH & Co. KG
> +default:
> +- enabled-by: true
> +  value: ''
> +description: |
> +  If defined to a non-empty value, then the value will be used for the
> version
> +  control key returned by rtems_version() and rtems_version_control_key(),
> +  otherwise the value will be determined by the Git repository containing
> the
> +  waf top directory.
>

And would this change for a release tarball?

I'm reading this as a project specific version string in addition to major
and minor.

And that if used, it would be the responsibility of the user to track that
back to revision control hash.

If so, this likely needs a bit more written.

Right?

--joel


> +enabled-by: true
> +format: '{}'
> +links: []
> +name: RTEMS_VERSION_VC_KEY
> +type: build
> diff --git a/wscript b/wscript
> index 862000513d..2026d55070 100755
> --- a/wscript
> +++ b/wscript
> @@ -58,38 +58,44 @@ def no_unicode(value):
>
>
>  class VersionControlKeyHeader:
> -    _content = None
> +    _git_commit = None
>
>      @staticmethod
>      def write(bld, filename):
> -        if VersionControlKeyHeader._content is None:
> -            from waflib.Build import Context
> -            from waflib.Errors import WafError
> -
> -            content = """/*
> +        content = """/*
>   * Automatically generated. Do not edit.
>   */
>  #if !defined(_RTEMS_VERSION_VC_KEY_H_)
>  #define _RTEMS_VERSION_VC_KEY_H_
>  """
> -            try:
> -                rev = bld.cmd_and_log("git rev-parse HEAD",
> -                                      quiet=Context.STDOUT).strip()
> -                content += """#define RTEMS_VERSION_VC_KEY "{}"
> +        rev = bld.env.RTEMS_VERSION_VC_KEY
> +        if not rev:
> +            rev = VersionControlKeyHeader._git_commit
> +            if rev is None:
> +                from waflib.Build import Context
> +                from waflib.Errors import WafError
> +
> +                try:
> +                    rev = bld.cmd_and_log("git rev-parse HEAD",
> +                                          quiet=Context.STDOUT).strip()
> +                except WafError:
> +                    rev = ""
> +                VersionControlKeyHeader._git_commit = rev
> +        if rev:
> +            content += """#define RTEMS_VERSION_VC_KEY "{}"
>  """.format(rev)
> -            except WafError:
> -                content += """/* No version control key found; release? */
> +        else:
> +            content += """/* No version control key found; release? */
>  """
> -            content += """#endif
> +        content += """#endif
>  """
> -            VersionControlKeyHeader._content = content
>          f = bld.bldnode.make_node(filename)
>          f.parent.mkdir()
>          try:
>              if content != f.read():
> -                f.write(VersionControlKeyHeader._content)
> +                f.write(content)
>          except:
> -            f.write(VersionControlKeyHeader._content)
> +            f.write(content)
>
>
>  class EnvWrapper(object):
> --
> 2.35.3
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20230725/3bcd4971/attachment.htm>


More information about the devel mailing list