diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2017-09-15 21:47:12 +0300 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2017-09-15 21:47:29 +0300 |
commit | 32c7fd5ab68cdac677fe2ec16308d3d4081bc7c8 (patch) | |
tree | 9bf0c3848a06f0d1307128512c4791daa1f5497f | |
parent | 8837b48bebc6ab9cc30d89449efc50e4489754ab (diff) |
Add options to define source and header file extensions (issue #264)
-rwxr-xr-x | generator/nanopb_generator.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py index 20712ff..e51c983 100755 --- a/generator/nanopb_generator.py +++ b/generator/nanopb_generator.py @@ -1151,7 +1151,7 @@ class ProtoFile: for incfile in includes: noext = os.path.splitext(incfile)[0] - yield options.genformat % (noext + options.extension + '.h') + yield options.genformat % (noext + options.extension + options.header_extension) yield '\n' yield '/* @@protoc_insertion_point(includes) */\n' @@ -1464,6 +1464,10 @@ optparser.add_option("-x", dest="exclude", metavar="FILE", action="append", defa help="Exclude file from generated #include list.") optparser.add_option("-e", "--extension", dest="extension", metavar="EXTENSION", default=".pb", help="Set extension to use instead of '.pb' for generated files. [default: %default]") +optparser.add_option("-H", "--header-extension", dest="header_extension", metavar="EXTENSION", default=".h", + help="Set extension to use for generated header files. [default: %default]") +optparser.add_option("-S", "--source-extension", dest="source_extension", metavar="EXTENSION", default=".c", + help="Set extension to use for generated source files. [default: %default]") optparser.add_option("-f", "--options-file", dest="options_file", metavar="FILE", default="%s.options", help="Set name of a separate generator options file.") optparser.add_option("-I", "--options-path", dest="options_path", metavar="DIR", @@ -1553,8 +1557,8 @@ def process_file(filename, fdesc, options, other_files = {}): # Decide the file names noext = os.path.splitext(filename)[0] - headername = noext + options.extension + '.h' - sourcename = noext + options.extension + '.c' + headername = noext + options.extension + options.header_extension + sourcename = noext + options.extension + options.source_extension headerbasename = os.path.basename(headername) # List of .proto files that should not be included in the C header file |