On 1/8/2023 5:11 pm, Sebastian Huber wrote: > Define the RTEMS version in the wscript. Optionally use a VERSION file > to change the default values of the wscript.
Thanks, this is welcome. I will update the release scripts when merged. > Allow the command line > option --rtems-version to override __RTEMS_MAJOR__. Remove support for > command line configurable options. I do not understand this last bit. It says allow --rtems-version and then the command line configuration options are removed? And my reading of the change the command line support has been removed? > Rename internal define RTEMS_VERSION_VC_KEY to > RTEMS_VERSION_CONTROL_KEY. OK. Thanks Chris > --- > cpukit/sapi/src/version.c | 8 +-- > spec/build/cpukit/cpuopts.yml | 6 -- > spec/build/cpukit/optvermaj.yml | 13 ---- > spec/build/cpukit/optvermin.yml | 13 ---- > spec/build/cpukit/optverrev.yml | 13 ---- > wscript | 108 +++++++++++++++----------------- > 6 files changed, 55 insertions(+), 106 deletions(-) > delete mode 100644 spec/build/cpukit/optvermaj.yml > delete mode 100644 spec/build/cpukit/optvermin.yml > delete mode 100644 spec/build/cpukit/optverrev.yml > > diff --git a/cpukit/sapi/src/version.c b/cpukit/sapi/src/version.c > index ea07683876..7197ddd153 100644 > --- a/cpukit/sapi/src/version.c > +++ b/cpukit/sapi/src/version.c > @@ -54,8 +54,8 @@ > > const char *rtems_version( void ) > { > -#ifdef RTEMS_VERSION_VC_KEY > - return RTEMS_VERSION "." RTEMS_VERSION_VC_KEY; > +#ifdef RTEMS_VERSION_CONTROL_KEY > + return RTEMS_VERSION "." RTEMS_VERSION_CONTROL_KEY; > #else > return RTEMS_VERSION; > #endif > @@ -78,8 +78,8 @@ int rtems_version_revision( void ) > > const char *rtems_version_control_key( void ) > { > -#ifdef RTEMS_VERSION_VC_KEY > - return RTEMS_VERSION_VC_KEY; > +#ifdef RTEMS_VERSION_CONTROL_KEY > + return RTEMS_VERSION_CONTROL_KEY; > #else > return ""; > #endif > diff --git a/spec/build/cpukit/cpuopts.yml b/spec/build/cpukit/cpuopts.yml > index 49dfc26e4b..f1b30eec55 100644 > --- a/spec/build/cpukit/cpuopts.yml > +++ b/spec/build/cpukit/cpuopts.yml > @@ -7,12 +7,6 @@ guard: _RTEMS_SCORE_CPUOPTS_H > include-headers: [] > install-path: ${BSP_INCLUDEDIR}/rtems/score > links: > -- role: build-dependency > - uid: optvermaj > -- role: build-dependency > - uid: optvermin > -- role: build-dependency > - uid: optverrev > - role: build-dependency > uid: optgcc > - role: build-dependency > diff --git a/spec/build/cpukit/optvermaj.yml b/spec/build/cpukit/optvermaj.yml > deleted file mode 100644 > index e194930b47..0000000000 > --- a/spec/build/cpukit/optvermaj.yml > +++ /dev/null > @@ -1,13 +0,0 @@ > -SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause > -actions: > -- get-string-command-line: '6' > -- env-assign: null > -build-type: option > -copyrights: > -- Copyright (C) 2020 embedded brains GmbH & Co. KG > -default: [] > -description: '' > -enabled-by: true > -links: [] > -name: __RTEMS_MAJOR__ > -type: build > diff --git a/spec/build/cpukit/optvermin.yml b/spec/build/cpukit/optvermin.yml > deleted file mode 100644 > index 8a58959394..0000000000 > --- a/spec/build/cpukit/optvermin.yml > +++ /dev/null > @@ -1,13 +0,0 @@ > -SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause > -actions: > -- set-value: '0' > -- env-assign: null > -build-type: option > -copyrights: > -- Copyright (C) 2020 embedded brains GmbH & Co. KG > -default: [] > -description: '' > -enabled-by: true > -links: [] > -name: __RTEMS_MINOR__ > -type: build > diff --git a/spec/build/cpukit/optverrev.yml b/spec/build/cpukit/optverrev.yml > deleted file mode 100644 > index 618c936e86..0000000000 > --- a/spec/build/cpukit/optverrev.yml > +++ /dev/null > @@ -1,13 +0,0 @@ > -SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause > -actions: > -- set-value: '0' > -- env-assign: null > -build-type: option > -copyrights: > -- Copyright (C) 2020 embedded brains GmbH & Co. KG > -default: [] > -description: '' > -enabled-by: true > -links: [] > -name: __RTEMS_REVISION__ > -type: build > diff --git a/wscript b/wscript > index 862000513d..13c1d1d4d9 100755 > --- a/wscript > +++ b/wscript > @@ -43,7 +43,13 @@ except: > from waflib.TaskGen import after, before_method, feature > > is_windows_host = os.name == "nt" or sys.platform in ["msys", "cygwin"] > -default_prefix = "/opt/rtems/6" > +version = { > + "__RTEMS_MAJOR__": "6", > + "__RTEMS_MINOR__": "0", > + "__RTEMS_REVISION__": "0", > + "RTEMS_VERSION_CONTROL_KEY": "git" > +} > +default_prefix = "/opt/rtems/" + version["__RTEMS_MAJOR__"] > compilers = ["gcc", "clang"] > items = {} > bsps = {} > @@ -62,22 +68,28 @@ class VersionControlKeyHeader: > > @staticmethod > def write(bld, filename): > - if VersionControlKeyHeader._content is None: > - from waflib.Build import Context > - from waflib.Errors import WafError > - > + content = VersionControlKeyHeader._content > + if content is None: > 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 "{}" > -""".format(rev) > - except WafError: > + key = bld.env.RTEMS_VERSION_CONTROL_KEY > + if key == "git": > + from waflib.Build import Context > + from waflib.Errors import WafError > + > + try: > + key = bld.cmd_and_log("git rev-parse HEAD", > + quiet=Context.STDOUT).strip() > + except WafError: > + key = "" > + if key: > + content += """#define RTEMS_VERSION_CONTROL_KEY "{}" > +""".format(key) > + else: > content += """/* No version control key found; release? */ > """ > content += """#endif > @@ -87,9 +99,9 @@ class VersionControlKeyHeader: > 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): > @@ -992,15 +1004,6 @@ class OptionItem(Item): > value = self.default_value(conf.env.ENABLE) > return value > > - def _get_string_command_line(self, conf, cic, value, arg): > - name = self.data["name"] > - try: > - value = conf.rtems_options[name] > - del conf.rtems_options[name] > - except KeyError: > - value = arg[0] > - return value > - > def _script(self, conf, cic, value, arg): > exec(arg) > return value > @@ -1081,7 +1084,6 @@ class OptionItem(Item): > "get-env": self._get_env, > "get-integer": self._get_integer, > "get-string": self._get_string, > - "get-string-command-line": self._get_string_command_line, > "script": self._script, > "set-test-state": self._set_test_state, > "set-value": self._set_value, > @@ -1310,15 +1312,6 @@ def options(ctx): > help= > "sets the RTEMS major version number; it is intended for RTEMS > maintainers and may be used in the bspdefaults and configure commands", > ) > - rg.add_option( > - "--rtems-option", > - metavar="KEY=VALUE", > - action="append", > - dest="rtems_options", > - default=[], > - help= > - "sets the option identified by KEY to the VALUE in the build > specification; it is intended for RTEMS maintainers and may be used in the > bspdefaults and configure commands", > - ) > > > def check_environment(conf): > @@ -1345,6 +1338,27 @@ def check_environment(conf): > conf.msg("Environment variable set", ev, color="RED") > > > +def configure_version(conf): > + cp = configparser.ConfigParser() > + version_file = "VERSION" > + if cp.read([version_file]): > + conf.msg("Configure RTEMS version from file", > + version_file, > + color="YELLOW") > + for key in version: > + try: > + value = cp.get("RTEMS_VERSION", key) > + version[key] = no_unicode(value) > + except configparser.NoOptionError: > + pass > + major = conf.options.rtems_version > + if major is not None: > + conf.msg("Set __RTEMS_MAJOR__ via command line to:", > + major, > + color="YELLOW") > + version["__RTEMS_MAJOR__"] = major > + > + > def load_config_files(ctx): > cp = configparser.ConfigParser() > files = ctx.options.rtems_config > @@ -1441,6 +1455,9 @@ def configure_variant(conf, cp, bsp_map, path_list, > top_group, variant): > arch_bsp = arch + "/" + bsp_base > arch_family = arch + "/" + family > > + for key, value in version.items(): > + conf.env[key] = value > + > conf.env["ARCH"] = arch > conf.env["ARCH_BSP"] = arch_bsp > conf.env["ARCH_FAMILY"] = arch_family > @@ -1462,7 +1479,6 @@ def configure_variant(conf, cp, bsp_map, path_list, > top_group, variant): > conf.env["TOPGROUP"] = top_group > conf.env["VARIANT"] = variant > > - prepare_rtems_options(conf) > cic = ConfigItemContext(cp, path_list) > items[conf.env.TOPGROUP].configure(conf, cic) > bsp_item.configure(conf, cic) > @@ -1470,8 +1486,6 @@ def configure_variant(conf, cp, bsp_map, path_list, > top_group, variant): > options = set([o[0].upper() for o in cp.items(variant)]) > for o in options.difference(cic.options): > conf.msg("Unknown configuration option", o.upper(), color="RED") > - for key in conf.rtems_options: > - conf.msg("Unknown command line RTEMS option", key, color="RED") > > > def check_forbidden_options(ctx, opts): > @@ -1504,28 +1518,10 @@ def get_top_group(ctx): > return top_group > > > -def prepare_rtems_options(conf): > - conf.rtems_options = {} > - for x in conf.options.rtems_options: > - try: > - k, v = x.split("=", 1) > - conf.rtems_options[k] = v > - except: > - conf.fatal( > - "The RTEMS option '{}' is not in KEY=VALUE format".format(x)) > - version = conf.options.rtems_version > - if version is not None: > - key = "__RTEMS_MAJOR__" > - if conf.rtems_options.get(key, version) != version: > - conf.fatal( > - "Conflicting RTEMS major versions specified at the command > line" > - ) > - conf.rtems_options[key] = version > - > - > def configure(conf): > check_forbidden_options(conf, ["compiler"]) > check_environment(conf) > + configure_version(conf) > conf.env["SPECS"] = load_items_from_options(conf) > top_group = get_top_group(conf) > cp = load_config_files(conf) > @@ -1573,7 +1569,6 @@ def build(bld): > [ > "compiler", > "config", > - "options", > "specs", > "tools", > "top_group", > @@ -1668,8 +1663,7 @@ COMPILER = {}""".format(variant, compiler)) > def bsplist(ctx): > """lists base BSP variants""" > check_forbidden_options( > - ctx, > - ["compiler", "config", "options", "tools", "top_group", "version"]) > + ctx, ["compiler", "config", "tools", "top_group", "version"]) > add_log_filter(ctx.cmd) > load_items_from_options(ctx) > white_list = get_white_list(ctx) _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel