diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2015-03-22 11:17:57 +0200 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2015-03-22 11:17:57 +0200 |
commit | 8c14e736034b82d65b43db529161dd281a37816a (patch) | |
tree | 1c52a323f65419620475ccaef75d1ebb81b2a3de /generator | |
parent | 942e82a82b88a073ad9654f54c11497e48b8fe09 (diff) |
Use make_identifier() to create the name for FOO_MESSAGES define.
This handles special charaters like in "my-file.proto" properly.
Also use headerbasename instead of full path, so that compiling files
with relative path doesn't create symbols like FOO/BAR/BAZ_MESSAGES.
Diffstat (limited to 'generator')
-rwxr-xr-x | generator/nanopb_generator.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py index d316fad2..4673ac67 100755 --- a/generator/nanopb_generator.py +++ b/generator/nanopb_generator.py @@ -920,7 +920,7 @@ def make_identifier(headername): result += '_' return result -def generate_header(noext, dependencies, headername, enums, messages, extensions, options): +def generate_header(dependencies, headername, enums, messages, extensions, options): '''Generate content for a header file. Generates strings, which should be concatenated and stored to file. ''' @@ -1014,7 +1014,8 @@ def generate_header(noext, dependencies, headername, enums, messages, extensions yield '#define PB_MSG_%d %s\n' % (msg.msgid, msg.name) yield '\n' - yield '#define %s_MESSAGES \\\n' % (noext.upper()) + symbol = make_identifier(headername.split('.')[0]) + yield '#define %s_MESSAGES \\\n' % symbol for msg in messages: m = "-1" @@ -1313,7 +1314,7 @@ def process_file(filename, fdesc, options): excludes = ['nanopb.proto', 'google/protobuf/descriptor.proto'] + options.exclude dependencies = [d for d in fdesc.dependency if d not in excludes] - headerdata = ''.join(generate_header(noext,dependencies, headerbasename, enums, + headerdata = ''.join(generate_header(dependencies, headerbasename, enums, messages, extensions, options)) sourcedata = ''.join(generate_source(headerbasename, enums, |