[PATCH] waf: Add --rtems-version as a configure option

chrisj at rtems.org chrisj at rtems.org
Sun Nov 14 03:07:23 UTC 2021


From: Chris Johns <chrisj at rtems.org>

- Provide the option `--rtems-version` to set the major version
  number

- Add a method to handle setting action values

- Return the spec YAML file back to it's original values
  as it does not allow a user to change the version.

Closes #4548
---
 spec/build/cpukit/optvermaj.yml |  6 +++---
 wscript                         | 22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/spec/build/cpukit/optvermaj.yml b/spec/build/cpukit/optvermaj.yml
index e1a5eae5b3..8cb87c29f3 100644
--- a/spec/build/cpukit/optvermaj.yml
+++ b/spec/build/cpukit/optvermaj.yml
@@ -1,16 +1,16 @@
 SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
 actions:
-- get-string: null
+- set-value: '6'
 - env-assign: null
 build-type: option
 copyrights:
 - Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
-default: 6
+default: null
 default-by-variant: []
 description: |
   Major Component of the RTEMS Version Number
 enabled-by: true
-format: '{}' 
+format: '{}'
 links: []
 name: __RTEMS_MAJOR__
 type: build
diff --git a/wscript b/wscript
index 8903f1f97a..225cf671dc 100755
--- a/wscript
+++ b/wscript
@@ -1250,6 +1250,11 @@ def options(ctx):
         metavar="UID",
         help="the UID of the top-level group [default: '/grp']; it may be used in the bsp_defaults and configure commands",
     )
+    rg.add_option(
+        "--rtems-version",
+        metavar="VERSION",
+        help="the versinon of RTEMS to build; this is a developer option to test newer versions",
+    )
 
 
 def check_environment(conf):
@@ -1276,6 +1281,21 @@ def check_environment(conf):
             conf.msg("Environment variable set", ev, color="RED")
 
 
+def item_set_action_value(ctx, path, value):
+    item_path = os.path.dirname(path)
+    if item_path not in items:
+        ctx.fatal("Item '{}' was not found".format(item_path))
+    item = items[item_path]
+    if 'actions' not in item.data:
+        ctx.fatal("Item '{}' does not contain 'actions'".format(item_path))
+    action_name = os.path.basename(path)
+    for action in item.data['actions']:
+        if action_name in action:
+            action[action_name] = value
+            return
+    ctx.fatal("Item '{}' does not contain action '{}'".format(item_path, action_name))
+
+
 def load_config_files(ctx):
     cp = configparser.ConfigParser()
     files = ctx.options.rtems_config
@@ -1454,6 +1474,8 @@ def configure(conf):
     bsp_map = resolve_option_inheritance(conf, cp)
     path_list = get_path_list(conf)
     variant_list = []
+    if conf.options.rtems_version is not None:
+        item_set_action_value(conf, '/cpukit/optvermaj/set-value', conf.options.rtems_version)
     for variant in cp.sections():
         variant = no_unicode(variant)
         variant_list.append(variant)
-- 
2.24.1



More information about the devel mailing list