aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-07-20 14:25:11 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-07-20 14:25:11 +0300
commit3cf9668c755560a69e4858dea4f3c415bf807441 (patch)
treee2746338dabd9ee34e23bc3b35da0760a8d56976
parent7f97ad549e8ef2050c662b8160745402e84e8006 (diff)
Do not automatically add a dot with generator -e option.
Now -e option in generator is more versatile. Especially it avoids double-dot problem with some build systems. Given foobar.proto, we now get: -e .pb => foobar.pb.c (default) -e _pb => foobar_pb.c -e '' => foobar.c Note that if you have used -e option previously, you will have to prepend . to the argument to get the same filenames as before. Update issue 122 Status: FixedInGit
-rwxr-xr-xgenerator/nanopb_generator.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index c7371887..8ef4f187 100755
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -724,7 +724,7 @@ def generate_header(dependencies, headername, enums, messages, extensions, optio
for dependency in dependencies:
noext = os.path.splitext(dependency)[0]
- yield options.genformat % (noext + '.' + options.extension + '.h')
+ yield options.genformat % (noext + options.extension + '.h')
yield '\n'
yield '#ifdef __cplusplus\n'
@@ -959,8 +959,8 @@ optparser = OptionParser(
"Output will be written to file.pb.h and file.pb.c.")
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="Set extension to use instead of 'pb' for generated files. [default: %default]")
+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("-f", "--options-file", dest="options_file", metavar="FILE", default="%s.options",
help="Set name of a separate generator options file.")
optparser.add_option("-Q", "--generated-include-format", dest="genformat",
@@ -1027,11 +1027,11 @@ def process_file(filename, fdesc, options):
# Parse the file
file_options = get_nanopb_suboptions(fdesc, toplevel_options, Names([filename]))
enums, messages, extensions = parse_file(fdesc, file_options)
-
+
# Decide the file names
noext = os.path.splitext(filename)[0]
- headername = noext + '.' + options.extension + '.h'
- sourcename = noext + '.' + options.extension + '.c'
+ headername = noext + options.extension + '.h'
+ sourcename = noext + options.extension + '.c'
headerbasename = os.path.basename(headername)
# List of .proto files that should not be included in the C header file