[rtems-central commit] spec2modules.py: Add target files option

Sebastian Huber sebh at rtems.org
Tue Aug 17 07:36:33 UTC 2021


Module:    rtems-central
Branch:    master
Commit:    41ca85ee6b6cfdc9a6a088f2cfb762e42d962e36
Changeset: http://git.rtems.org/rtems-central/commit/?id=41ca85ee6b6cfdc9a6a088f2cfb762e42d962e36

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Aug 17 09:35:27 2021 +0200

spec2modules.py: Add target files option

---

 rtemsspec/tests/test_validation.py |  1 +
 rtemsspec/validation.py            | 13 ++++++++++---
 spec2modules.py                    | 26 +++++++++++++++++++-------
 3 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/rtemsspec/tests/test_validation.py b/rtemsspec/tests/test_validation.py
index 5314050..e1b1157 100644
--- a/rtemsspec/tests/test_validation.py
+++ b/rtemsspec/tests/test_validation.py
@@ -60,6 +60,7 @@ def test_validation(tmpdir):
     assert len(list(transition_map.get_post_conditions(["RTEMS_SMP"]))) == 9
 
     generate(validation_config, item_cache)
+    generate(validation_config, item_cache, ["ts.c"])
 
     with open(os.path.join(base_directory, "ts.c"), "r") as src:
         content = """/* SPDX-License-Identifier: BSD-2-Clause */
diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py
index 306a0d9..5c3f932 100644
--- a/rtemsspec/validation.py
+++ b/rtemsspec/validation.py
@@ -1053,7 +1053,9 @@ _GATHER = {
 }
 
 
-def generate(config: dict, item_cache: ItemCache) -> None:
+def generate(config: dict,
+             item_cache: ItemCache,
+             targets: Optional[List[str]] = None) -> None:
     """
     Generates source files and build specification items for validation test
     suites and test cases according to the configuration.
@@ -1079,5 +1081,10 @@ def generate(config: dict, item_cache: ItemCache) -> None:
                 test_case_to_suites.setdefault(test_case.uid,
                                                []).extend(test_suites)
 
-    for src in source_files.values():
-        src.generate(config["base-directory"], test_case_to_suites)
+    if not targets:
+        for src in source_files.values():
+            src.generate(config["base-directory"], test_case_to_suites)
+    else:
+        for target in targets:
+            source_files[target].generate(config["base-directory"],
+                                          test_case_to_suites)
diff --git a/spec2modules.py b/spec2modules.py
index d652dc3..a848bae 100755
--- a/spec2modules.py
+++ b/spec2modules.py
@@ -25,20 +25,32 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
+import argparse
+import sys
+
 import rtemsspec
 
 
 def main() -> None:
     """ Generates files of the modules from the specification. """
+    parser = argparse.ArgumentParser()
+    parser.add_argument("targets",
+                        metavar="TARGET",
+                        nargs="*",
+                        help="a target file of a specification item")
+    args = parser.parse_args(sys.argv[1:])
     config = rtemsspec.util.load_config("config.yml")
     item_cache = rtemsspec.items.ItemCache(config["spec"])
-    rtemsspec.interface.generate(config["interface"], item_cache)
-    rtemsspec.validation.generate(config["validation"], item_cache)
-    rtemsspec.applconfig.generate(config["appl-config"], item_cache)
-    rtemsspec.specdoc.document(config["spec-documentation"], item_cache)
-    rtemsspec.glossary.generate(config["glossary"], item_cache)
-    rtemsspec.interfacedoc.generate(config["interface-documentation"],
-                                    item_cache)
+    rtemsspec.validation.generate(config["validation"], item_cache,
+                                  args.targets)
+
+    if not args.targets:
+        rtemsspec.interface.generate(config["interface"], item_cache)
+        rtemsspec.applconfig.generate(config["appl-config"], item_cache)
+        rtemsspec.specdoc.document(config["spec-documentation"], item_cache)
+        rtemsspec.glossary.generate(config["glossary"], item_cache)
+        rtemsspec.interfacedoc.generate(config["interface-documentation"],
+                                        item_cache)
 
 
 if __name__ == "__main__":



More information about the vc mailing list