mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 13:13:34 +08:00
libuavcan_dsdlc docstrings
This commit is contained in:
@@ -4,9 +4,16 @@
|
|||||||
# Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
|
# Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
|
'''
|
||||||
|
This module implements the core functionality of the UAVCAN DSDL compiler for libuavcan.
|
||||||
|
Supported Python versions: 3.2+, 2.7.
|
||||||
|
It accepts a list of root namespaces and produces the set of C++ header files for libuavcan.
|
||||||
|
It is based on the DSDL parsing package from pyuavcan.
|
||||||
|
'''
|
||||||
|
|
||||||
from __future__ import division, absolute_import, print_function, unicode_literals
|
from __future__ import division, absolute_import, print_function, unicode_literals
|
||||||
import sys, os, logging, errno
|
import sys, os, logging, errno
|
||||||
from mako.template import Template
|
from mako.template import Template # TODO: get rid of the mako dependency
|
||||||
from pyuavcan import dsdl
|
from pyuavcan import dsdl
|
||||||
|
|
||||||
# Python 2.7 compatibility
|
# Python 2.7 compatibility
|
||||||
@@ -27,6 +34,22 @@ class DsdlCompilerException(Exception):
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
def run(source_dirs, include_dirs, output_dir):
|
def run(source_dirs, include_dirs, output_dir):
|
||||||
|
'''
|
||||||
|
This function takes a list of root namespace directories (containing DSDL definition files to parse), a
|
||||||
|
possibly empty list of search directories (containing DSDL definition files that can be referenced from the types
|
||||||
|
that are going to be parsed), and the output directory path (possibly nonexistent) where the generated C++
|
||||||
|
header files will be stored.
|
||||||
|
|
||||||
|
Note that this module features lazy write, i.e. if an output file does already exist and its content is not going
|
||||||
|
to change, it will not be overwritten. This feature allows to avoid unnecessary recompilation of dependent object
|
||||||
|
files.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
source_dirs List of root namespace directories to parse.
|
||||||
|
include_dirs List of root namespace directories with referenced types (possibly empty). This list is
|
||||||
|
automaitcally extended with source_dirs.
|
||||||
|
output_dir Output directory path. Will be created if doesn't exist.
|
||||||
|
'''
|
||||||
assert isinstance(source_dirs, list)
|
assert isinstance(source_dirs, list)
|
||||||
assert isinstance(include_dirs, list)
|
assert isinstance(include_dirs, list)
|
||||||
output_dir = str(output_dir)
|
output_dir = str(output_dir)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
#
|
#
|
||||||
# UAVCAN DSDL compiler for libuavcan
|
# UAVCAN DSDL compiler for libuavcan
|
||||||
# Written in Python 3, compatible with Python 2.7
|
# Supported Python versions: 3.2+, 2.7.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
|
# Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
|
||||||
#
|
#
|
||||||
@@ -27,8 +27,12 @@ def die(text):
|
|||||||
|
|
||||||
DEFAULT_OUTDIR = './dsdlc_generated'
|
DEFAULT_OUTDIR = './dsdlc_generated'
|
||||||
|
|
||||||
DESCRIPTION = '''UAVCAN DSDL compiler. Takes an input directory that contains an hierarchy of DSDL
|
DESCRIPTION = '''UAVCAN DSDL compiler for libuavcan.
|
||||||
definitions and converts it into compatible hierarchy of C++ types for libuavcan.'''
|
Takes an input directory that contains an hierarchy of DSDL
|
||||||
|
definitions and converts it into compatible hierarchy of C++ types for libuavcan.
|
||||||
|
This script can be used directly from the source directory, no installation required!
|
||||||
|
Supported Python versions: 3.2+, 2.7.
|
||||||
|
'''
|
||||||
|
|
||||||
argparser = argparse.ArgumentParser(description=DESCRIPTION)
|
argparser = argparse.ArgumentParser(description=DESCRIPTION)
|
||||||
argparser.add_argument('source_dir', nargs='+', help='source directory with DSDL definitions')
|
argparser.add_argument('source_dir', nargs='+', help='source directory with DSDL definitions')
|
||||||
|
|||||||
Reference in New Issue
Block a user