mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 21:23:34 +08:00
param gen reorganize and fix DISABLE_PARAMS_MODULE_SCOPING
This commit is contained in:
@@ -14,13 +14,19 @@ class SourceScanner(object):
|
||||
Scans provided path and passes all found contents to the parser using
|
||||
parser.Parse method.
|
||||
"""
|
||||
extensions1 = tuple([".c"])
|
||||
extensions1 = tuple([".h"])
|
||||
extensions2 = tuple([".c"])
|
||||
for srcdir in srcdirs:
|
||||
for filename in os.listdir(srcdir):
|
||||
if filename.endswith(extensions1):
|
||||
path = os.path.join(srcdir, filename)
|
||||
if not self.ScanFile(path, parser):
|
||||
return False
|
||||
for filename in os.listdir(srcdir):
|
||||
if filename.endswith(extensions2):
|
||||
path = os.path.join(srcdir, filename)
|
||||
if not self.ScanFile(path, parser):
|
||||
return False
|
||||
return True
|
||||
|
||||
def ScanFile(self, path, parser):
|
||||
|
||||
@@ -9,13 +9,12 @@ import argparse
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
import os
|
||||
|
||||
def generate(xml_file, dest='.', modules=None):
|
||||
def generate(xml_file, dest='.'):
|
||||
"""
|
||||
Generate px4 param source from xml.
|
||||
|
||||
@param xml_file: input parameter xml file
|
||||
@param dest: Destination directory for generated files
|
||||
@param modules: The list of px4 modules to search for params.
|
||||
None means to scan everything.
|
||||
"""
|
||||
# pylint: disable=broad-except
|
||||
@@ -26,9 +25,6 @@ def generate(xml_file, dest='.', modules=None):
|
||||
for group in root:
|
||||
if group.tag == "group" and "no_code_generation" not in group.attrib:
|
||||
for param in group:
|
||||
scope_ = param.find('scope').text
|
||||
if (modules is not None) and (not scope_ in modules):
|
||||
continue
|
||||
params.append(param)
|
||||
|
||||
params = sorted(params, key=lambda name: name.attrib["name"])
|
||||
@@ -55,9 +51,8 @@ def generate(xml_file, dest='.', modules=None):
|
||||
if __name__ == "__main__":
|
||||
arg_parser = argparse.ArgumentParser()
|
||||
arg_parser.add_argument("--xml", help="parameter xml file")
|
||||
arg_parser.add_argument("--modules", help="px4 module list", default=None)
|
||||
arg_parser.add_argument("--dest", help="destination path", default=os.path.curdir)
|
||||
args = arg_parser.parse_args()
|
||||
generate(xml_file=args.xml, modules=args.modules, dest=args.dest)
|
||||
generate(xml_file=args.xml, dest=args.dest)
|
||||
|
||||
# vim: set et fenc=utf-8 ff=unix sts=4 sw=4 ts=4 :
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
python px_process_params.py --xml
|
||||
@@ -77,10 +77,10 @@ def main():
|
||||
help="Inject additional param XML file"
|
||||
" (default FILENAME: ../Tools/parameters_injected.xml)")
|
||||
parser.add_argument("-b", "--board",
|
||||
nargs='?',
|
||||
const="",
|
||||
metavar="BOARD",
|
||||
help="Board to create xml parameter xml for")
|
||||
nargs='?',
|
||||
const="",
|
||||
metavar="BOARD",
|
||||
help="Board to create xml parameter xml for")
|
||||
parser.add_argument("-m", "--markdown",
|
||||
nargs='?',
|
||||
const="parameters.md",
|
||||
@@ -118,13 +118,14 @@ def main():
|
||||
metavar="SUMMARY",
|
||||
default="Automagically updated parameter documentation from code.",
|
||||
help="DokuWiki page edit summary")
|
||||
parser.add_argument('-v', '--verbose', action='store_true', help="verbose output")
|
||||
parser.add_argument('-v', '--verbose',
|
||||
action='store_true',
|
||||
help="verbose output")
|
||||
parser.add_argument("-o", "--overrides",
|
||||
default="{}",
|
||||
metavar="OVERRIDES",
|
||||
help="a dict of overrides in the form of a json string")
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Check for valid command
|
||||
@@ -138,8 +139,9 @@ def main():
|
||||
parser = srcparser.SourceParser()
|
||||
|
||||
# Scan directories, and parse the files
|
||||
if (args.verbose): print("Scanning source path " + str(args.src_path))
|
||||
|
||||
if (args.verbose):
|
||||
print("Scanning source path " + str(args.src_path))
|
||||
|
||||
if not scanner.ScanDir(args.src_path, parser):
|
||||
sys.exit(1)
|
||||
|
||||
@@ -162,7 +164,8 @@ def main():
|
||||
|
||||
# Output to XML file
|
||||
if args.xml:
|
||||
if args.verbose: print("Creating XML file " + args.xml)
|
||||
if args.verbose:
|
||||
print("Creating XML file " + args.xml)
|
||||
cur_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
out = xmlout.XMLOutput(param_groups, args.board,
|
||||
os.path.join(cur_dir, args.inject_xml))
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Remember to set the XMLRPCUSER and XMLRPCPASS environment variables
|
||||
python px_process_params.py --wiki-update
|
||||
Reference in New Issue
Block a user