diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-03-09 23:03:09 +0200 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-03-09 23:03:09 +0200 |
commit | 6468f23d231343f1e08007621b8f3d566f0ec3ac (patch) | |
tree | 5fc1f5647fd386550b9068f2d0841478566678b0 /generator/nanopb_generator.py | |
parent | 03e53930723dce5793678365f350e94c2bc358dc (diff) |
Make the generator options accept a file name in addition to format string.
Diffstat (limited to 'generator/nanopb_generator.py')
-rw-r--r-- | generator/nanopb_generator.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py index 0e898749..ddfc45b5 100644 --- a/generator/nanopb_generator.py +++ b/generator/nanopb_generator.py @@ -455,7 +455,11 @@ 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 options.libformat % ('pb.h') + try: + yield options.libformat % ('pb.h') + except TypeError: + # no %s specified - use whatever was passed in as options.libformat + yield options.libformat yield '\n' for dependency in dependencies: @@ -688,7 +692,11 @@ def process(filenames, options): fdesc = descriptor.FileDescriptorSet.FromString(data) # Check if any separate options are specified - optfilename = options.options_file % os.path.splitext(filename)[0] + try: + optfilename = options.options_file % os.path.splitext(filename)[0] + except TypeError: + # No %s specified, use the filename as-is + optfilename = options.options_file if options.verbose: print 'Reading options from ' + optfilename |