Allow the user to set the version control key. --- spec/build/cpukit/grp.yml | 2 ++ spec/build/cpukit/optversioncontrolkey.yml | 21 ++++++++++++ wscript | 38 +++++++++++++--------- 3 files changed, 45 insertions(+), 16 deletions(-) create mode 100644 spec/build/cpukit/optversioncontrolkey.yml
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 @@ -18,6 +18,8 @@ links: uid: cpuopts - role: build-dependency uid: cfghdr +- role: build-dependency + uid: optversioncontrolkey - role: build-dependency uid: libdebugger - role: build-dependency 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 diff --git a/wscript b/wscript index 862000513d..e80c3800b6 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_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): -- 2.35.3 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel