source: rtems-central/rtems_spec_to_x.py @ 9dad293

Last change on this file since 9dad293 was 99da835, checked in by Sebastian Huber <sebastian.huber@…>, on 04/17/20 at 12:47:55

Run doxygen in pre-qualified workspace

  • Property mode set to 100755
File size: 4.0 KB
Line 
1#!/usr/bin/env python
2# SPDX-License-Identifier: BSD-2-Clause
3""" This script generates glossaries of terms from the specification. """
4
5# Copyright (C) 2019, 2020 embedded brains GmbH (http://www.embedded-brains.de)
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
10# 1. Redistributions of source code must retain the above copyright
11#    notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright
13#    notice, this list of conditions and the following disclaimer in the
14#    documentation and/or other materials provided with the distribution.
15#
16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26# POSSIBILITY OF SUCH DAMAGE.
27
28import os
29import string
30import subprocess
31from typing import List
32
33import rtemsqual.applconfig
34import rtemsqual.build
35from rtemsqual.items import ItemCache
36import rtemsqual.glossary
37import rtemsqual.util
38import rtemsqual.validation
39
40
41def _run_command(args: List[str], cwd: str) -> int:
42    task = subprocess.Popen(args,
43                            stdout=subprocess.PIPE,
44                            stderr=subprocess.STDOUT,
45                            cwd=cwd)
46    while True:
47        line = task.stdout.readline()
48        if line:
49            print(line.decode("utf-8").strip())
50        elif task.poll() is not None:
51            break
52    return task.wait()
53
54
55def _run_pre_qualified_only_build(config: dict, item_cache: ItemCache) -> None:
56    files = rtemsqual.build.gather_files(config, item_cache)
57    source_dir = config["source-directory"]
58    workspace_dir = config["workspace-directory"]
59    rtemsqual.util.copy_files(source_dir, workspace_dir, files)
60    with open(os.path.join(workspace_dir, "config.ini"), "w") as config_ini:
61        content = string.Template(config["config-ini"]).substitute(config)
62        config_ini.write(content)
63    specs = os.path.relpath(os.path.join(source_dir, "spec"), workspace_dir)
64    _run_command([
65        "./waf", "configure", "--rtems-specs", specs, "--rtems-top-group",
66        "/build/grp"
67    ], workspace_dir)
68    _run_command(["./waf"], workspace_dir)
69
70
71def _run_pre_qualified_doxygen(config: dict) -> None:
72    workspace_dir = config["workspace-directory"]
73    with open(config["doxyfile-template"], "r") as doxyfile_template:
74
75        class Template(string.Template):
76            """ Template class with custom delimiter. """
77            delimiter = "%"
78
79        doxyfile_vars = {}
80        doxyfile_vars["project_name"] = "RTEMS"
81        doxyfile_vars["output_directory"] = "doc"
82        content = Template(doxyfile_template.read()).substitute(doxyfile_vars)
83        with open(os.path.join(workspace_dir, "Doxyfile"), "w") as doxyfile:
84            doxyfile.write(content)
85    _run_command(["doxygen"], workspace_dir)
86
87
88def main() -> None:
89    """ Generates glossaries of terms according to the configuration. """
90    config = rtemsqual.util.load_config("config.yml")
91    item_cache = ItemCache(config["spec"])
92    rtemsqual.glossary.generate(config["glossary"], item_cache)
93    rtemsqual.applconfig.generate(config["appl-config"], item_cache)
94    rtemsqual.validation.generate(config["validation"], item_cache)
95    _run_pre_qualified_only_build(config["build"], item_cache)
96    _run_pre_qualified_doxygen(config["build"])
97
98
99if __name__ == "__main__":
100    main()
Note: See TracBrowser for help on using the repository browser.