Add nanopb version number to generated files.
tools/set_version.sh is used to update the values. Update issue 36 Status: FixedInGit
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
'''Generate header file for nanopb from a ProtoBuf FileDescriptorSet.'''
|
'''Generate header file for nanopb from a ProtoBuf FileDescriptorSet.'''
|
||||||
|
nanopb_version = "nanopb-0.1.7-dev"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import google.protobuf.descriptor_pb2 as descriptor
|
import google.protobuf.descriptor_pb2 as descriptor
|
||||||
@@ -31,7 +32,7 @@ except:
|
|||||||
# Generation of single fields
|
# Generation of single fields
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
import time
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
# Values are tuple (c type, pb ltype)
|
# Values are tuple (c type, pb ltype)
|
||||||
@@ -429,6 +430,7 @@ def generate_header(dependencies, headername, enums, messages):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
yield '/* Automatically generated nanopb header */\n'
|
yield '/* Automatically generated nanopb header */\n'
|
||||||
|
yield '/* Generated by %s at %s. */\n\n' % (nanopb_version, time.asctime())
|
||||||
|
|
||||||
symbol = headername.replace('.', '_').upper()
|
symbol = headername.replace('.', '_').upper()
|
||||||
yield '#ifndef _PB_%s_\n' % symbol
|
yield '#ifndef _PB_%s_\n' % symbol
|
||||||
@@ -516,6 +518,7 @@ def generate_source(headername, enums, messages):
|
|||||||
'''Generate content for a source file.'''
|
'''Generate content for a source file.'''
|
||||||
|
|
||||||
yield '/* Automatically generated nanopb constant definitions */\n'
|
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 '#include "%s"\n\n' % headername
|
||||||
|
|
||||||
for msg in messages:
|
for msg in messages:
|
||||||
|
|||||||
2
pb.h
2
pb.h
@@ -6,6 +6,8 @@
|
|||||||
* see pb_encode.h or pb_decode.h
|
* see pb_encode.h or pb_decode.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define NANOPB_VERSION nanopb-0.1.7-dev
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|||||||
10
tools/set_version.sh
Executable file
10
tools/set_version.sh
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Run this from the top directory of nanopb tree.
|
||||||
|
# e.g. user@localhost:~/nanopb$ tools/set_version.sh nanopb-0.1.9-dev
|
||||||
|
# It sets the version number in pb.h and generator/nanopb_generator.py.
|
||||||
|
|
||||||
|
sed -i -e 's/nanopb_version\s*=\s*"[^"]*"/nanopb_version = "'$1'"/' generator/nanopb_generator.py
|
||||||
|
sed -i -e 's/#define\s*NANOPB_VERSION\s*.*/#define NANOPB_VERSION '$1'/' pb.h
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user