diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2022-10-25 10:38:01 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2023-07-31 09:18:03 +0200 |
commit | ef4ca9361d45098712455e24f8a2fb41b8fb085f (patch) | |
tree | c887d7e31cff1af6c8c970cefab0460ab781b5d1 | |
parent | e26b1a449b48fd70ceb1950103a78ab591ff2e78 (diff) |
build: Add optional RTEMS_VERSION_CONTROL_KEY
Allow the user to set the version control key.
-rw-r--r-- | spec/build/cpukit/grp.yml | 2 | ||||
-rw-r--r-- | spec/build/cpukit/optversioncontrolkey.yml | 21 | ||||
-rwxr-xr-x | wscript | 38 |
3 files changed, 45 insertions, 16 deletions
diff --git a/spec/build/cpukit/grp.yml b/spec/build/cpukit/grp.yml index e07e975d7d..eeaefcba91 100644 --- a/spec/build/cpukit/grp.yml +++ b/spec/build/cpukit/grp.yml @@ -19,6 +19,8 @@ links: - role: build-dependency uid: cfghdr - role: build-dependency + uid: optversioncontrolkey +- role: build-dependency uid: libdebugger - role: build-dependency uid: libftpd diff --git a/spec/build/cpukit/optversioncontrolkey.yml b/spec/build/cpukit/optversioncontrolkey.yml new file mode 100644 index 0000000000..36dfeeb82a --- /dev/null +++ b/spec/build/cpukit/optversioncontrolkey.yml @@ -0,0 +1,21 @@ +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: git +description: | + This option defines what is returned by the directives rtems_version() and + rtems_version_control_key(). If the value is "git", then the version key is + determined by the Git repository containing the waf top directory for each + build process. If the value is the empty string "", then no version key is + used. Otherwise, the value is used as the version key. +enabled-by: true +format: '{}' +links: [] +name: RTEMS_VERSION_CONTROL_KEY +type: build @@ -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_CONTROL_KEY + if rev == "git": + 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): |