summaryrefslogtreecommitdiffstats
path: root/generator/nanopb_generator.py
diff options
context:
space:
mode:
Diffstat (limited to 'generator/nanopb_generator.py')
-rw-r--r--generator/nanopb_generator.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index e38d3822..c3b5fbee 100644
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -450,12 +450,14 @@ def generate_header(dependencies, headername, enums, messages, options):
symbol = make_identifier(headername)
yield '#ifndef _PB_%s_\n' % symbol
yield '#define _PB_%s_\n' % symbol
- yield '#include <pb.h>\n\n'
+ yield options.libformat % ('pb.h')
+ yield '\n'
for dependency in dependencies:
noext = os.path.splitext(dependency)[0]
- yield '#include "%s.%s.h"\n' % (noext,options.extension)
-
+ yield options.genformat % (noext + '.' + options.extension + '.h')
+ yield '\n'
+
yield '#ifdef __cplusplus\n'
yield 'extern "C" {\n'
yield '#endif\n\n'
@@ -490,7 +492,8 @@ def generate_source(headername, enums, messages):
yield '/* Automatically generated nanopb constant definitions */\n'
yield '/* Generated by %s at %s. */\n\n' % (nanopb_version, time.asctime())
- yield '#include "%s"\n\n' % headername
+ yield options.genformat % (headername)
+ yield '\n'
for msg in messages:
yield msg.default_decl(False)
@@ -583,7 +586,13 @@ optparser = OptionParser(
optparser.add_option("-x", dest="exclude", metavar="FILE", action="append", default=[],
help="Exclude file from generated #include list.")
optparser.add_option("-e", "--extension", dest="extension", metavar="EXTENSION", default="pb",
- help="use extension instead of 'pb' for generated files.")
+ help="Set extension to use instead of 'pb' for generated files. [default: %default]")
+optparser.add_option("-Q", "--generated-include-format", dest="genformat",
+ metavar="FORMAT", default='#include "%s"\n',
+ help="Set format string to use for including other .pb.h files. [default: %default]")
+optparser.add_option("-L", "--library-include-format", dest="libformat",
+ metavar="FORMAT", default='#include <%s>\n',
+ help="Set format string to use for including the nanopb pb.h header. [default: %default]")
optparser.add_option("-q", "--quiet", dest="quiet", action="store_true", default=False,
help="Don't print anything except errors.")
optparser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False,