Compare commits
7 Commits
nanopb-0.2
...
dev_no_pb_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17c10119dd | ||
|
|
97210c91a9 | ||
|
|
cace53dfbd | ||
|
|
eff9e11150 | ||
|
|
5813144246 | ||
|
|
171d64734a | ||
|
|
321ca6c1d5 |
19
.gitignore
vendored
19
.gitignore
vendored
@@ -5,17 +5,22 @@
|
|||||||
*.pb.c
|
*.pb.c
|
||||||
*.pb.h
|
*.pb.h
|
||||||
*.pb
|
*.pb
|
||||||
|
*.pyc
|
||||||
*~
|
*~
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
.sconsign.dblite
|
.sconsign.dblite
|
||||||
|
config.log
|
||||||
|
.sconf_temp
|
||||||
|
tests/build
|
||||||
julkaisu.txt
|
julkaisu.txt
|
||||||
docs/*.html
|
docs/*.html
|
||||||
docs/generator_flow.png
|
docs/generator_flow.png
|
||||||
example/client
|
examples/simple/simple
|
||||||
example/server
|
examples/network_server/client
|
||||||
example_avr_double/decode_double
|
examples/network_server/server
|
||||||
example_avr_double/encode_double
|
examples/using_double_on_avr/decode_double
|
||||||
example_avr_double/test_conversions
|
examples/using_double_on_avr/encode_double
|
||||||
example_unions/decode
|
examples/using_double_on_avr/test_conversions
|
||||||
example_unions/encode
|
examples/using_union_messages/decode
|
||||||
|
examples/using_union_messages/encode
|
||||||
generator/nanopb_pb2.pyc
|
generator/nanopb_pb2.pyc
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ function(NANOPB_GENERATE_CPP SRCS HDRS)
|
|||||||
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
|
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
|
||||||
COMMAND python
|
COMMAND python
|
||||||
ARGS ${NANOPB_GENERATOR_EXECUTABLE} ${FIL_WE}.pb
|
ARGS ${NANOPB_GENERATOR_EXECUTABLE} ${FIL_WE}.pb
|
||||||
DEPENDS ${FIL_WE}.pb
|
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb"
|
||||||
COMMENT "Running nanopb generator on ${FIL_WE}.pb"
|
COMMENT "Running nanopb generator on ${FIL_WE}.pb"
|
||||||
VERBATIM )
|
VERBATIM )
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
'''Generate header file for nanopb from a ProtoBuf FileDescriptorSet.'''
|
'''Generate header file for nanopb from a ProtoBuf FileDescriptorSet.'''
|
||||||
nanopb_version = "nanopb-0.2.4"
|
nanopb_version = "nanopb-0.2.5-dev"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import google.protobuf.descriptor_pb2 as descriptor
|
import google.protobuf.descriptor_pb2 as descriptor
|
||||||
|
|||||||
2
pb.h
2
pb.h
@@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
/* Version of the nanopb library. Just in case you want to check it in
|
/* Version of the nanopb library. Just in case you want to check it in
|
||||||
* your own program. */
|
* your own program. */
|
||||||
#define NANOPB_VERSION nanopb-0.2.4
|
#define NANOPB_VERSION nanopb-0.2.5-dev
|
||||||
|
|
||||||
/* Include all the system headers needed by nanopb. You will need the
|
/* Include all the system headers needed by nanopb. You will need the
|
||||||
* definitions of the following:
|
* definitions of the following:
|
||||||
|
|||||||
134
pb_decode.c
134
pb_decode.c
@@ -32,7 +32,6 @@ typedef struct {
|
|||||||
void *pSize; /* Pointer where to store the size of current array field */
|
void *pSize; /* Pointer where to store the size of current array field */
|
||||||
} pb_field_iterator_t;
|
} pb_field_iterator_t;
|
||||||
|
|
||||||
typedef bool (*pb_decoder_t)(pb_istream_t *stream, const pb_field_t *field, void *dest) checkreturn;
|
|
||||||
|
|
||||||
static bool checkreturn buf_read(pb_istream_t *stream, uint8_t *buf, size_t count);
|
static bool checkreturn buf_read(pb_istream_t *stream, uint8_t *buf, size_t count);
|
||||||
static bool checkreturn pb_decode_varint32(pb_istream_t *stream, uint32_t *dest);
|
static bool checkreturn pb_decode_varint32(pb_istream_t *stream, uint32_t *dest);
|
||||||
@@ -40,6 +39,7 @@ static bool checkreturn read_raw_value(pb_istream_t *stream, pb_wire_type_t wire
|
|||||||
static void pb_field_init(pb_field_iterator_t *iter, const pb_field_t *fields, void *dest_struct);
|
static void pb_field_init(pb_field_iterator_t *iter, const pb_field_t *fields, void *dest_struct);
|
||||||
static bool pb_field_next(pb_field_iterator_t *iter);
|
static bool pb_field_next(pb_field_iterator_t *iter);
|
||||||
static bool checkreturn pb_field_find(pb_field_iterator_t *iter, uint32_t tag);
|
static bool checkreturn pb_field_find(pb_field_iterator_t *iter, uint32_t tag);
|
||||||
|
static bool checkreturn decode_ltype(pb_istream_t *stream, const pb_field_t *field, void *dest, pb_type_t type);
|
||||||
static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter);
|
static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter);
|
||||||
static bool checkreturn decode_callback_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter);
|
static bool checkreturn decode_callback_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter);
|
||||||
static bool checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter);
|
static bool checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter);
|
||||||
@@ -57,21 +57,6 @@ static bool checkreturn pb_dec_submessage(pb_istream_t *stream, const pb_field_t
|
|||||||
static bool checkreturn pb_skip_varint(pb_istream_t *stream);
|
static bool checkreturn pb_skip_varint(pb_istream_t *stream);
|
||||||
static bool checkreturn pb_skip_string(pb_istream_t *stream);
|
static bool checkreturn pb_skip_string(pb_istream_t *stream);
|
||||||
|
|
||||||
/* --- Function pointers to field decoders ---
|
|
||||||
* Order in the array must match pb_action_t LTYPE numbering.
|
|
||||||
*/
|
|
||||||
static const pb_decoder_t PB_DECODERS[PB_LTYPES_COUNT] = {
|
|
||||||
&pb_dec_varint,
|
|
||||||
&pb_dec_svarint,
|
|
||||||
&pb_dec_fixed32,
|
|
||||||
&pb_dec_fixed64,
|
|
||||||
|
|
||||||
&pb_dec_bytes,
|
|
||||||
&pb_dec_string,
|
|
||||||
&pb_dec_submessage,
|
|
||||||
NULL /* extensions */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*******************************
|
/*******************************
|
||||||
* pb_istream_t implementation *
|
* pb_istream_t implementation *
|
||||||
*******************************/
|
*******************************/
|
||||||
@@ -124,6 +109,26 @@ bool checkreturn pb_read(pb_istream_t *stream, uint8_t *buf, size_t count)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Read a single byte from input stream. buf may not be NULL.
|
||||||
|
* This is an optimization for the varint decoding. */
|
||||||
|
static bool checkreturn pb_readbyte(pb_istream_t *stream, uint8_t *buf)
|
||||||
|
{
|
||||||
|
if (!stream->bytes_left)
|
||||||
|
PB_RETURN_ERROR(stream, "end-of-stream");
|
||||||
|
|
||||||
|
#ifndef PB_BUFFER_ONLY
|
||||||
|
if (!stream->callback(stream, buf, 1))
|
||||||
|
PB_RETURN_ERROR(stream, "io error");
|
||||||
|
#else
|
||||||
|
*buf = *(uint8_t*)stream->state;
|
||||||
|
stream->state = (uint8_t*)stream->state + 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
stream->bytes_left--;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
pb_istream_t pb_istream_from_buffer(uint8_t *buf, size_t bufsize)
|
pb_istream_t pb_istream_from_buffer(uint8_t *buf, size_t bufsize)
|
||||||
{
|
{
|
||||||
pb_istream_t stream;
|
pb_istream_t stream;
|
||||||
@@ -149,7 +154,7 @@ static bool checkreturn pb_decode_varint32(pb_istream_t *stream, uint32_t *dest)
|
|||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
uint32_t result;
|
uint32_t result;
|
||||||
|
|
||||||
if (!pb_read(stream, &byte, 1))
|
if (!pb_readbyte(stream, &byte))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!(byte & 0x80))
|
if (!(byte & 0x80))
|
||||||
@@ -168,7 +173,7 @@ static bool checkreturn pb_decode_varint32(pb_istream_t *stream, uint32_t *dest)
|
|||||||
if (bitpos >= 32)
|
if (bitpos >= 32)
|
||||||
PB_RETURN_ERROR(stream, "varint overflow");
|
PB_RETURN_ERROR(stream, "varint overflow");
|
||||||
|
|
||||||
if (!pb_read(stream, &byte, 1))
|
if (!pb_readbyte(stream, &byte))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
result |= (uint32_t)(byte & 0x7F) << bitpos;
|
result |= (uint32_t)(byte & 0x7F) << bitpos;
|
||||||
@@ -191,7 +196,7 @@ bool checkreturn pb_decode_varint(pb_istream_t *stream, uint64_t *dest)
|
|||||||
if (bitpos >= 64)
|
if (bitpos >= 64)
|
||||||
PB_RETURN_ERROR(stream, "varint overflow");
|
PB_RETURN_ERROR(stream, "varint overflow");
|
||||||
|
|
||||||
if (!pb_read(stream, &byte, 1))
|
if (!pb_readbyte(stream, &byte))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
result |= (uint64_t)(byte & 0x7F) << bitpos;
|
result |= (uint64_t)(byte & 0x7F) << bitpos;
|
||||||
@@ -293,28 +298,23 @@ static bool checkreturn read_raw_value(pb_istream_t *stream, pb_wire_type_t wire
|
|||||||
/* Decode string length from stream and return a substream with limited length.
|
/* Decode string length from stream and return a substream with limited length.
|
||||||
* Remember to close the substream using pb_close_string_substream().
|
* Remember to close the substream using pb_close_string_substream().
|
||||||
*/
|
*/
|
||||||
bool checkreturn pb_make_string_substream(pb_istream_t *stream, pb_istream_t *substream)
|
bool checkreturn pb_make_string_substream(pb_istream_t *stream, size_t *remaining_length)
|
||||||
{
|
{
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
if (!pb_decode_varint32(stream, &size))
|
if (!pb_decode_varint32(stream, &size))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
*substream = *stream;
|
if (stream->bytes_left < size)
|
||||||
if (substream->bytes_left < size)
|
|
||||||
PB_RETURN_ERROR(stream, "parent stream too short");
|
PB_RETURN_ERROR(stream, "parent stream too short");
|
||||||
|
|
||||||
substream->bytes_left = size;
|
*remaining_length = stream->bytes_left - size;
|
||||||
stream->bytes_left -= size;
|
stream->bytes_left = size;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pb_close_string_substream(pb_istream_t *stream, pb_istream_t *substream)
|
void pb_close_string_substream(pb_istream_t *stream, size_t remaining_length)
|
||||||
{
|
{
|
||||||
stream->state = substream->state;
|
stream->bytes_left += remaining_length;
|
||||||
|
|
||||||
#ifndef PB_NO_ERRMSG
|
|
||||||
stream->errmsg = substream->errmsg;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pb_field_init(pb_field_iterator_t *iter, const pb_field_t *fields, void *dest_struct)
|
static void pb_field_init(pb_field_iterator_t *iter, const pb_field_t *fields, void *dest_struct)
|
||||||
@@ -381,22 +381,37 @@ static bool checkreturn pb_field_find(pb_field_iterator_t *iter, uint32_t tag)
|
|||||||
* Decode a single field *
|
* Decode a single field *
|
||||||
*************************/
|
*************************/
|
||||||
|
|
||||||
|
/* Invoke a decoder function based on the ltype of a field. */
|
||||||
|
static bool checkreturn decode_ltype(pb_istream_t *stream,
|
||||||
|
const pb_field_t *field, void *dest, pb_type_t type)
|
||||||
|
{
|
||||||
|
switch (PB_LTYPE(type))
|
||||||
|
{
|
||||||
|
case PB_LTYPE_VARINT: return pb_dec_varint(stream, field, dest);
|
||||||
|
case PB_LTYPE_SVARINT: return pb_dec_svarint(stream, field, dest);
|
||||||
|
case PB_LTYPE_FIXED32: return pb_dec_fixed32(stream, field, dest);
|
||||||
|
case PB_LTYPE_FIXED64: return pb_dec_fixed64(stream, field, dest);
|
||||||
|
case PB_LTYPE_BYTES: return pb_dec_bytes(stream, field, dest);
|
||||||
|
case PB_LTYPE_STRING: return pb_dec_string(stream, field, dest);
|
||||||
|
case PB_LTYPE_SUBMESSAGE: return pb_dec_submessage(stream, field, dest);
|
||||||
|
|
||||||
|
default: PB_RETURN_ERROR(stream, "invalid field type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter)
|
static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter)
|
||||||
{
|
{
|
||||||
pb_type_t type;
|
pb_type_t type;
|
||||||
pb_decoder_t func;
|
|
||||||
|
|
||||||
type = iter->pos->type;
|
type = iter->pos->type;
|
||||||
func = PB_DECODERS[PB_LTYPE(type)];
|
|
||||||
|
|
||||||
switch (PB_HTYPE(type))
|
switch (PB_HTYPE(type))
|
||||||
{
|
{
|
||||||
case PB_HTYPE_REQUIRED:
|
case PB_HTYPE_REQUIRED:
|
||||||
return func(stream, iter->pos, iter->pData);
|
return decode_ltype(stream, iter->pos, iter->pData, type);
|
||||||
|
|
||||||
case PB_HTYPE_OPTIONAL:
|
case PB_HTYPE_OPTIONAL:
|
||||||
*(bool*)iter->pSize = true;
|
*(bool*)iter->pSize = true;
|
||||||
return func(stream, iter->pos, iter->pData);
|
return decode_ltype(stream, iter->pos, iter->pData, type);
|
||||||
|
|
||||||
case PB_HTYPE_REPEATED:
|
case PB_HTYPE_REPEATED:
|
||||||
if (wire_type == PB_WT_STRING
|
if (wire_type == PB_WT_STRING
|
||||||
@@ -405,24 +420,25 @@ static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t
|
|||||||
/* Packed array */
|
/* Packed array */
|
||||||
bool status = true;
|
bool status = true;
|
||||||
size_t *size = (size_t*)iter->pSize;
|
size_t *size = (size_t*)iter->pSize;
|
||||||
pb_istream_t substream;
|
size_t remaining_length;
|
||||||
if (!pb_make_string_substream(stream, &substream))
|
if (!pb_make_string_substream(stream, &remaining_length))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while (substream.bytes_left && *size < iter->pos->array_size)
|
while (stream->bytes_left)
|
||||||
{
|
{
|
||||||
void *pItem = (uint8_t*)iter->pData + iter->pos->data_size * (*size);
|
void *pItem = (uint8_t*)iter->pData + iter->pos->data_size * (*size);
|
||||||
if (!func(&substream, iter->pos, pItem))
|
|
||||||
|
if (*size >= iter->pos->array_size)
|
||||||
|
PB_RETURN_ERROR(stream, "array overflow");
|
||||||
|
|
||||||
|
if (!decode_ltype(stream, iter->pos, pItem, type))
|
||||||
{
|
{
|
||||||
status = false;
|
status = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
(*size)++;
|
(*size)++;
|
||||||
}
|
}
|
||||||
pb_close_string_substream(stream, &substream);
|
pb_close_string_substream(stream, remaining_length);
|
||||||
|
|
||||||
if (substream.bytes_left != 0)
|
|
||||||
PB_RETURN_ERROR(stream, "array overflow");
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -435,7 +451,7 @@ static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t
|
|||||||
PB_RETURN_ERROR(stream, "array overflow");
|
PB_RETURN_ERROR(stream, "array overflow");
|
||||||
|
|
||||||
(*size)++;
|
(*size)++;
|
||||||
return func(stream, iter->pos, pItem);
|
return decode_ltype(stream, iter->pos, pItem, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -458,18 +474,18 @@ static bool checkreturn decode_callback_field(pb_istream_t *stream, pb_wire_type
|
|||||||
|
|
||||||
if (wire_type == PB_WT_STRING)
|
if (wire_type == PB_WT_STRING)
|
||||||
{
|
{
|
||||||
pb_istream_t substream;
|
size_t remaining_length;
|
||||||
|
|
||||||
if (!pb_make_string_substream(stream, &substream))
|
if (!pb_make_string_substream(stream, &remaining_length))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (!pCallback->funcs.decode(&substream, iter->pos, arg))
|
if (!pCallback->funcs.decode(stream, iter->pos, arg))
|
||||||
PB_RETURN_ERROR(stream, "callback failed");
|
PB_RETURN_ERROR(stream, "callback failed");
|
||||||
} while (substream.bytes_left);
|
} while (stream->bytes_left);
|
||||||
|
|
||||||
pb_close_string_substream(stream, &substream);
|
pb_close_string_substream(stream, remaining_length);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -726,14 +742,14 @@ bool checkreturn pb_decode(pb_istream_t *stream, const pb_field_t fields[], void
|
|||||||
|
|
||||||
bool pb_decode_delimited(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct)
|
bool pb_decode_delimited(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct)
|
||||||
{
|
{
|
||||||
pb_istream_t substream;
|
size_t remaining_length;
|
||||||
bool status;
|
bool status;
|
||||||
|
|
||||||
if (!pb_make_string_substream(stream, &substream))
|
if (!pb_make_string_substream(stream, &remaining_length))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
status = pb_decode(&substream, fields, dest_struct);
|
status = pb_decode(stream, fields, dest_struct);
|
||||||
pb_close_string_substream(stream, &substream);
|
pb_close_string_substream(stream, remaining_length);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -876,10 +892,10 @@ bool checkreturn pb_dec_string(pb_istream_t *stream, const pb_field_t *field, vo
|
|||||||
bool checkreturn pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field, void *dest)
|
bool checkreturn pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field, void *dest)
|
||||||
{
|
{
|
||||||
bool status;
|
bool status;
|
||||||
pb_istream_t substream;
|
size_t remaining_length;
|
||||||
const pb_field_t* submsg_fields = (const pb_field_t*)field->ptr;
|
const pb_field_t* submsg_fields = (const pb_field_t*)field->ptr;
|
||||||
|
|
||||||
if (!pb_make_string_substream(stream, &substream))
|
if (!pb_make_string_substream(stream, &remaining_length))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (field->ptr == NULL)
|
if (field->ptr == NULL)
|
||||||
@@ -888,10 +904,10 @@ bool checkreturn pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field
|
|||||||
/* New array entries need to be initialized, while required and optional
|
/* New array entries need to be initialized, while required and optional
|
||||||
* submessages have already been initialized in the top-level pb_decode. */
|
* submessages have already been initialized in the top-level pb_decode. */
|
||||||
if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
|
if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
|
||||||
status = pb_decode(&substream, submsg_fields, dest);
|
status = pb_decode(stream, submsg_fields, dest);
|
||||||
else
|
else
|
||||||
status = pb_decode_noinit(&substream, submsg_fields, dest);
|
status = pb_decode_noinit(stream, submsg_fields, dest);
|
||||||
|
|
||||||
pb_close_string_substream(stream, &substream);
|
pb_close_string_substream(stream, remaining_length);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,8 +128,8 @@ bool pb_decode_fixed32(pb_istream_t *stream, void *dest);
|
|||||||
bool pb_decode_fixed64(pb_istream_t *stream, void *dest);
|
bool pb_decode_fixed64(pb_istream_t *stream, void *dest);
|
||||||
|
|
||||||
/* Make a limited-length substream for reading a PB_WT_STRING field. */
|
/* Make a limited-length substream for reading a PB_WT_STRING field. */
|
||||||
bool pb_make_string_substream(pb_istream_t *stream, pb_istream_t *substream);
|
bool pb_make_string_substream(pb_istream_t *stream, size_t *remaining_length);
|
||||||
void pb_close_string_substream(pb_istream_t *stream, pb_istream_t *substream);
|
void pb_close_string_substream(pb_istream_t *stream, size_t remaining_length);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|||||||
56
pb_encode.c
56
pb_encode.c
@@ -20,10 +20,9 @@
|
|||||||
/**************************************
|
/**************************************
|
||||||
* Declarations internal to this file *
|
* Declarations internal to this file *
|
||||||
**************************************/
|
**************************************/
|
||||||
typedef bool (*pb_encoder_t)(pb_ostream_t *stream, const pb_field_t *field, const void *src) checkreturn;
|
|
||||||
|
|
||||||
static bool checkreturn buf_write(pb_ostream_t *stream, const uint8_t *buf, size_t count);
|
static bool checkreturn buf_write(pb_ostream_t *stream, const uint8_t *buf, size_t count);
|
||||||
static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *field, const void *pData, size_t count, pb_encoder_t func);
|
static bool checkreturn encode_ltype(pb_ostream_t *stream, const pb_field_t *field, const void *src, pb_type_t type);
|
||||||
|
static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *field, const void *pData, size_t count);
|
||||||
static bool checkreturn encode_field(pb_ostream_t *stream, const pb_field_t *field, const void *pData);
|
static bool checkreturn encode_field(pb_ostream_t *stream, const pb_field_t *field, const void *pData);
|
||||||
static bool checkreturn default_extension_encoder(pb_ostream_t *stream, const pb_extension_t *extension);
|
static bool checkreturn default_extension_encoder(pb_ostream_t *stream, const pb_extension_t *extension);
|
||||||
static bool checkreturn encode_extension_field(pb_ostream_t *stream, const pb_field_t *field, const void *pData);
|
static bool checkreturn encode_extension_field(pb_ostream_t *stream, const pb_field_t *field, const void *pData);
|
||||||
@@ -35,21 +34,6 @@ static bool checkreturn pb_enc_bytes(pb_ostream_t *stream, const pb_field_t *fie
|
|||||||
static bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_t *field, const void *src);
|
static bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_t *field, const void *src);
|
||||||
static bool checkreturn pb_enc_submessage(pb_ostream_t *stream, const pb_field_t *field, const void *src);
|
static bool checkreturn pb_enc_submessage(pb_ostream_t *stream, const pb_field_t *field, const void *src);
|
||||||
|
|
||||||
/* --- Function pointers to field encoders ---
|
|
||||||
* Order in the array must match pb_action_t LTYPE numbering.
|
|
||||||
*/
|
|
||||||
static const pb_encoder_t PB_ENCODERS[PB_LTYPES_COUNT] = {
|
|
||||||
&pb_enc_varint,
|
|
||||||
&pb_enc_svarint,
|
|
||||||
&pb_enc_fixed32,
|
|
||||||
&pb_enc_fixed64,
|
|
||||||
|
|
||||||
&pb_enc_bytes,
|
|
||||||
&pb_enc_string,
|
|
||||||
&pb_enc_submessage,
|
|
||||||
NULL /* extensions */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*******************************
|
/*******************************
|
||||||
* pb_ostream_t implementation *
|
* pb_ostream_t implementation *
|
||||||
*******************************/
|
*******************************/
|
||||||
@@ -106,9 +90,28 @@ bool checkreturn pb_write(pb_ostream_t *stream, const uint8_t *buf, size_t count
|
|||||||
* Encode a single field *
|
* Encode a single field *
|
||||||
*************************/
|
*************************/
|
||||||
|
|
||||||
|
/* Invoke an encoder function based on the ltype of a field. */
|
||||||
|
static bool checkreturn encode_ltype(pb_ostream_t *stream,
|
||||||
|
const pb_field_t *field, const void *src, pb_type_t type)
|
||||||
|
{
|
||||||
|
switch (PB_LTYPE(type))
|
||||||
|
{
|
||||||
|
case PB_LTYPE_VARINT: return pb_enc_varint(stream, field, src);
|
||||||
|
case PB_LTYPE_SVARINT: return pb_enc_svarint(stream, field, src);
|
||||||
|
case PB_LTYPE_FIXED32: return pb_enc_fixed32(stream, field, src);
|
||||||
|
case PB_LTYPE_FIXED64: return pb_enc_fixed64(stream, field, src);
|
||||||
|
case PB_LTYPE_BYTES: return pb_enc_bytes(stream, field, src);
|
||||||
|
case PB_LTYPE_STRING: return pb_enc_string(stream, field, src);
|
||||||
|
case PB_LTYPE_SUBMESSAGE: return pb_enc_submessage(stream, field, src);
|
||||||
|
|
||||||
|
default: PB_RETURN_ERROR(stream, "invalid field type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Encode a static array. Handles the size calculations and possible packing. */
|
/* Encode a static array. Handles the size calculations and possible packing. */
|
||||||
static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *field,
|
static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *field,
|
||||||
const void *pData, size_t count, pb_encoder_t func)
|
const void *pData, size_t count)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
const void *p;
|
const void *p;
|
||||||
@@ -141,7 +144,7 @@ static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *fie
|
|||||||
p = pData;
|
p = pData;
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (!func(&sizestream, field, p))
|
if (!encode_ltype(&sizestream, field, p, field->type))
|
||||||
return false;
|
return false;
|
||||||
p = (const char*)p + field->data_size;
|
p = (const char*)p + field->data_size;
|
||||||
}
|
}
|
||||||
@@ -158,7 +161,7 @@ static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *fie
|
|||||||
p = pData;
|
p = pData;
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (!func(stream, field, p))
|
if (!encode_ltype(stream, field, p, field->type))
|
||||||
return false;
|
return false;
|
||||||
p = (const char*)p + field->data_size;
|
p = (const char*)p + field->data_size;
|
||||||
}
|
}
|
||||||
@@ -170,7 +173,7 @@ static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *fie
|
|||||||
{
|
{
|
||||||
if (!pb_encode_tag_for_field(stream, field))
|
if (!pb_encode_tag_for_field(stream, field))
|
||||||
return false;
|
return false;
|
||||||
if (!func(stream, field, p))
|
if (!encode_ltype(stream, field, p, field->type))
|
||||||
return false;
|
return false;
|
||||||
p = (const char*)p + field->data_size;
|
p = (const char*)p + field->data_size;
|
||||||
}
|
}
|
||||||
@@ -184,12 +187,9 @@ static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *fie
|
|||||||
static bool checkreturn encode_static_field(pb_ostream_t *stream,
|
static bool checkreturn encode_static_field(pb_ostream_t *stream,
|
||||||
const pb_field_t *field, const void *pData)
|
const pb_field_t *field, const void *pData)
|
||||||
{
|
{
|
||||||
pb_encoder_t func;
|
|
||||||
const void *pSize;
|
const void *pSize;
|
||||||
bool dummy = true;
|
bool dummy = true;
|
||||||
|
|
||||||
func = PB_ENCODERS[PB_LTYPE(field->type)];
|
|
||||||
|
|
||||||
if (field->size_offset)
|
if (field->size_offset)
|
||||||
pSize = (const char*)pData + field->size_offset;
|
pSize = (const char*)pData + field->size_offset;
|
||||||
else
|
else
|
||||||
@@ -200,7 +200,7 @@ static bool checkreturn encode_static_field(pb_ostream_t *stream,
|
|||||||
case PB_HTYPE_REQUIRED:
|
case PB_HTYPE_REQUIRED:
|
||||||
if (!pb_encode_tag_for_field(stream, field))
|
if (!pb_encode_tag_for_field(stream, field))
|
||||||
return false;
|
return false;
|
||||||
if (!func(stream, field, pData))
|
if (!encode_ltype(stream, field, pData, field->type))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -210,13 +210,13 @@ static bool checkreturn encode_static_field(pb_ostream_t *stream,
|
|||||||
if (!pb_encode_tag_for_field(stream, field))
|
if (!pb_encode_tag_for_field(stream, field))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!func(stream, field, pData))
|
if (!encode_ltype(stream, field, pData, field->type))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PB_HTYPE_REPEATED:
|
case PB_HTYPE_REPEATED:
|
||||||
if (!encode_array(stream, field, pData, *(const size_t*)pSize, func))
|
if (!encode_array(stream, field, pData, *(const size_t*)pSize))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ if 'CXXFLAGS' in ARGUMENTS: env.Append(CCFLAGS = ARGUMENTS['CXXFLAGS'])
|
|||||||
add_nanopb_builders(env)
|
add_nanopb_builders(env)
|
||||||
|
|
||||||
# Path to the files shared by tests, and to the nanopb core.
|
# Path to the files shared by tests, and to the nanopb core.
|
||||||
env.Append(CPPPATH = ["#../", "#common"])
|
env.Append(CPPPATH = ["#../", "$COMMON"])
|
||||||
|
|
||||||
# Path for finding nanopb.proto
|
# Path for finding nanopb.proto
|
||||||
env.Append(PROTOCPATH = '#../generator')
|
env.Append(PROTOCPATH = '#../generator')
|
||||||
@@ -110,5 +110,10 @@ elif 'cl' in env['CXX']:
|
|||||||
env.Append(CXXFLAGS = '/Zi /W2 /WX')
|
env.Append(CXXFLAGS = '/Zi /W2 /WX')
|
||||||
|
|
||||||
# Now include the SConscript files from all subdirectories
|
# Now include the SConscript files from all subdirectories
|
||||||
SConscript(Glob('*/SConscript'), exports = 'env')
|
import os.path
|
||||||
|
env['VARIANT_DIR'] = 'build'
|
||||||
|
env['BUILD'] = '#' + env['VARIANT_DIR']
|
||||||
|
env['COMMON'] = '#' + env['VARIANT_DIR'] + '/common'
|
||||||
|
for subdir in Glob('*/SConscript'):
|
||||||
|
SConscript(subdir, exports = 'env', variant_dir = env['VARIANT_DIR'] + '/' + os.path.dirname(str(subdir)))
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
env.NanopbProto("alltypes")
|
env.NanopbProto(["alltypes", "alltypes.options"])
|
||||||
enc = env.Program(["encode_alltypes.c", "alltypes.pb.c", "#common/pb_encode.o"])
|
enc = env.Program(["encode_alltypes.c", "alltypes.pb.c", "$COMMON/pb_encode.o"])
|
||||||
dec = env.Program(["decode_alltypes.c", "alltypes.pb.c", "#common/pb_decode.o"])
|
dec = env.Program(["decode_alltypes.c", "alltypes.pb.c", "$COMMON/pb_decode.o"])
|
||||||
|
|
||||||
env.RunTest(enc)
|
env.RunTest(enc)
|
||||||
env.RunTest([dec, "encode_alltypes.output"])
|
env.RunTest([dec, "encode_alltypes.output"])
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
enc = env.Program(["encode_legacy.c", "alltypes_legacy.c", "#common/pb_encode.o"])
|
enc = env.Program(["encode_legacy.c", "alltypes_legacy.c", "$COMMON/pb_encode.o"])
|
||||||
dec = env.Program(["decode_legacy.c", "alltypes_legacy.c", "#common/pb_decode.o"])
|
dec = env.Program(["decode_legacy.c", "alltypes_legacy.c", "$COMMON/pb_decode.o"])
|
||||||
|
|
||||||
env.RunTest(enc)
|
env.RunTest(enc)
|
||||||
env.RunTest([dec, "encode_legacy.output"])
|
env.RunTest([dec, "encode_legacy.output"])
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
enc = env.Program(["encode_buffer.c", "#common/person.pb.c", "#common/pb_encode.o"])
|
enc = env.Program(["encode_buffer.c", "$COMMON/person.pb.c", "$COMMON/pb_encode.o"])
|
||||||
dec = env.Program(["decode_buffer.c", "#common/person.pb.c", "#common/pb_decode.o"])
|
dec = env.Program(["decode_buffer.c", "$COMMON/person.pb.c", "$COMMON/pb_decode.o"])
|
||||||
|
|
||||||
env.RunTest(enc)
|
env.RunTest(enc)
|
||||||
env.RunTest([dec, "encode_buffer.output"])
|
env.RunTest([dec, "encode_buffer.output"])
|
||||||
env.Decode(["encode_buffer.output", "#common/person.proto"], MESSAGE = "Person")
|
env.Decode(["encode_buffer.output", "$COMMON/person.proto"], MESSAGE = "Person")
|
||||||
env.Compare(["decode_buffer.output", "encode_buffer.decoded"])
|
env.Compare(["decode_buffer.output", "encode_buffer.decoded"])
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
enc = env.Program(["encode_stream.c", "#common/person.pb.c", "#common/pb_encode.o"])
|
enc = env.Program(["encode_stream.c", "$COMMON/person.pb.c", "$COMMON/pb_encode.o"])
|
||||||
dec = env.Program(["decode_stream.c", "#common/person.pb.c", "#common/pb_decode.o"])
|
dec = env.Program(["decode_stream.c", "$COMMON/person.pb.c", "$COMMON/pb_decode.o"])
|
||||||
|
|
||||||
env.RunTest(enc)
|
env.RunTest(enc)
|
||||||
env.RunTest([dec, "encode_stream.output"])
|
env.RunTest([dec, "encode_stream.output"])
|
||||||
env.Decode(["encode_stream.output", "#common/person.proto"], MESSAGE = "Person")
|
env.Decode(["encode_stream.output", "$COMMON/person.proto"], MESSAGE = "Person")
|
||||||
env.Compare(["decode_stream.output", "encode_stream.decoded"])
|
env.Compare(["decode_stream.output", "encode_stream.decoded"])
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ Import("env")
|
|||||||
c = Copy("$TARGET", "$SOURCE")
|
c = Copy("$TARGET", "$SOURCE")
|
||||||
env.Command("pb_encode.c", "#../pb_encode.c", c)
|
env.Command("pb_encode.c", "#../pb_encode.c", c)
|
||||||
env.Command("pb_decode.c", "#../pb_decode.c", c)
|
env.Command("pb_decode.c", "#../pb_decode.c", c)
|
||||||
env.Command("alltypes.pb.h", "#alltypes/alltypes.pb.h", c)
|
env.Command("alltypes.pb.h", "$BUILD/alltypes/alltypes.pb.h", c)
|
||||||
env.Command("alltypes.pb.c", "#alltypes/alltypes.pb.c", c)
|
env.Command("alltypes.pb.c", "$BUILD/alltypes/alltypes.pb.c", c)
|
||||||
env.Command("encode_alltypes.c", "#alltypes/encode_alltypes.c", c)
|
env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c)
|
||||||
env.Command("decode_alltypes.c", "#alltypes/decode_alltypes.c", c)
|
env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c)
|
||||||
|
|
||||||
# Define the compilation options
|
# Define the compilation options
|
||||||
opts = env.Clone()
|
opts = env.Clone()
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
env.NanopbProto("callbacks")
|
env.NanopbProto("callbacks")
|
||||||
enc = env.Program(["encode_callbacks.c", "callbacks.pb.c", "#common/pb_encode.o"])
|
enc = env.Program(["encode_callbacks.c", "callbacks.pb.c", "$COMMON/pb_encode.o"])
|
||||||
dec = env.Program(["decode_callbacks.c", "callbacks.pb.c", "#common/pb_decode.o"])
|
dec = env.Program(["decode_callbacks.c", "callbacks.pb.c", "$COMMON/pb_decode.o"])
|
||||||
|
|
||||||
env.RunTest(enc)
|
env.RunTest(enc)
|
||||||
env.RunTest([dec, "encode_callbacks.output"])
|
env.RunTest([dec, "encode_callbacks.output"])
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ Import("env")
|
|||||||
c = Copy("$TARGET", "$SOURCE")
|
c = Copy("$TARGET", "$SOURCE")
|
||||||
env.Command("pb_encode.cxx", "#../pb_encode.c", c)
|
env.Command("pb_encode.cxx", "#../pb_encode.c", c)
|
||||||
env.Command("pb_decode.cxx", "#../pb_decode.c", c)
|
env.Command("pb_decode.cxx", "#../pb_decode.c", c)
|
||||||
env.Command("alltypes.pb.h", "#alltypes/alltypes.pb.h", c)
|
env.Command("alltypes.pb.h", "$BUILD/alltypes/alltypes.pb.h", c)
|
||||||
env.Command("alltypes.pb.cxx", "#alltypes/alltypes.pb.c", c)
|
env.Command("alltypes.pb.cxx", "$BUILD/alltypes/alltypes.pb.c", c)
|
||||||
env.Command("encode_alltypes.cxx", "#alltypes/encode_alltypes.c", c)
|
env.Command("encode_alltypes.cxx", "$BUILD/alltypes/encode_alltypes.c", c)
|
||||||
env.Command("decode_alltypes.cxx", "#alltypes/decode_alltypes.c", c)
|
env.Command("decode_alltypes.cxx", "$BUILD/alltypes/decode_alltypes.c", c)
|
||||||
|
|
||||||
# Now build and run the test normally.
|
# Now build and run the test normally.
|
||||||
enc = env.Program(["encode_alltypes.cxx", "alltypes.pb.cxx", "pb_encode.cxx"])
|
enc = env.Program(["encode_alltypes.cxx", "alltypes.pb.cxx", "pb_encode.cxx"])
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Import('env')
|
Import('env')
|
||||||
p = env.Program(["decode_unittests.c", "#common/unittestproto.pb.c"])
|
p = env.Program(["decode_unittests.c", "$COMMON/unittestproto.pb.c"])
|
||||||
env.RunTest(p)
|
env.RunTest(p)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Build and run the stand-alone unit tests for the nanopb encoder part.
|
# Build and run the stand-alone unit tests for the nanopb encoder part.
|
||||||
|
|
||||||
Import('env')
|
Import('env')
|
||||||
p = env.Program(["encode_unittests.c", "#common/unittestproto.pb.c"])
|
p = env.Program(["encode_unittests.c", "$COMMON/unittestproto.pb.c"])
|
||||||
env.RunTest(p)
|
env.RunTest(p)
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ Import("env")
|
|||||||
|
|
||||||
# We use the files from the alltypes test case
|
# We use the files from the alltypes test case
|
||||||
incpath = env.Clone()
|
incpath = env.Clone()
|
||||||
incpath.Append(PROTOCPATH = '#alltypes')
|
incpath.Append(PROTOCPATH = '$BUILD/alltypes')
|
||||||
incpath.Append(CPPPATH = '#alltypes')
|
incpath.Append(CPPPATH = '$BUILD/alltypes')
|
||||||
|
|
||||||
incpath.NanopbProto("extensions")
|
incpath.NanopbProto(["extensions", "extensions.options"])
|
||||||
enc = incpath.Program(["encode_extensions.c", "extensions.pb.c", "#alltypes/alltypes.pb$OBJSUFFIX", "#common/pb_encode.o"])
|
enc = incpath.Program(["encode_extensions.c", "extensions.pb.c", "$BUILD/alltypes/alltypes.pb$OBJSUFFIX", "$COMMON/pb_encode.o"])
|
||||||
dec = incpath.Program(["decode_extensions.c", "extensions.pb.c", "#alltypes/alltypes.pb$OBJSUFFIX", "#common/pb_decode.o"])
|
dec = incpath.Program(["decode_extensions.c", "extensions.pb.c", "$BUILD/alltypes/alltypes.pb$OBJSUFFIX", "$COMMON/pb_decode.o"])
|
||||||
|
|
||||||
env.RunTest(enc)
|
env.RunTest(enc)
|
||||||
env.RunTest([dec, "encode_extensions.output"])
|
env.RunTest([dec, "encode_extensions.output"])
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
dec = env.GetBuildPath('#basic_buffer/${PROGPREFIX}decode_buffer${PROGSUFFIX}')
|
dec = env.GetBuildPath('$BUILD/basic_buffer/${PROGPREFIX}decode_buffer${PROGSUFFIX}')
|
||||||
env.RunTest('person_with_extra_field.output', [dec, "person_with_extra_field.pb"])
|
env.RunTest('person_with_extra_field.output', [dec, "person_with_extra_field.pb"])
|
||||||
env.Compare(["person_with_extra_field.output", "person_with_extra_field.expected"])
|
env.Compare(["person_with_extra_field.output", "person_with_extra_field.expected"])
|
||||||
|
|
||||||
dec = env.GetBuildPath('#basic_stream/${PROGPREFIX}decode_stream${PROGSUFFIX}')
|
dec = env.GetBuildPath('$BUILD/basic_stream/${PROGPREFIX}decode_stream${PROGSUFFIX}')
|
||||||
env.RunTest('person_with_extra_field_stream.output', [dec, "person_with_extra_field.pb"])
|
env.RunTest('person_with_extra_field_stream.output', [dec, "person_with_extra_field.pb"])
|
||||||
env.Compare(["person_with_extra_field_stream.output", "person_with_extra_field.expected"])
|
env.Compare(["person_with_extra_field_stream.output", "person_with_extra_field.expected"])
|
||||||
|
|
||||||
dec2 = env.GetBuildPath('#alltypes/${PROGPREFIX}decode_alltypes${PROGSUFFIX}')
|
dec2 = env.GetBuildPath('$BUILD/alltypes/${PROGPREFIX}decode_alltypes${PROGSUFFIX}')
|
||||||
env.RunTest('alltypes_with_extra_fields.output', [dec2, 'alltypes_with_extra_fields.pb'])
|
env.RunTest('alltypes_with_extra_fields.output', [dec2, 'alltypes_with_extra_fields.pb'])
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ Import("env")
|
|||||||
c = Copy("$TARGET", "$SOURCE")
|
c = Copy("$TARGET", "$SOURCE")
|
||||||
env.Command("pb_encode.c", "#../pb_encode.c", c)
|
env.Command("pb_encode.c", "#../pb_encode.c", c)
|
||||||
env.Command("pb_decode.c", "#../pb_decode.c", c)
|
env.Command("pb_decode.c", "#../pb_decode.c", c)
|
||||||
env.Command("encode_alltypes.c", "#alltypes/encode_alltypes.c", c)
|
env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c)
|
||||||
env.Command("decode_alltypes.c", "#alltypes/decode_alltypes.c", c)
|
env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c)
|
||||||
|
|
||||||
env.NanopbProto("alltypes")
|
env.NanopbProto(["alltypes", "alltypes.options"])
|
||||||
|
|
||||||
# Define the compilation options
|
# Define the compilation options
|
||||||
opts = env.Clone()
|
opts = env.Clone()
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ Import("env")
|
|||||||
c = Copy("$TARGET", "$SOURCE")
|
c = Copy("$TARGET", "$SOURCE")
|
||||||
env.Command("pb_encode.c", "#../pb_encode.c", c)
|
env.Command("pb_encode.c", "#../pb_encode.c", c)
|
||||||
env.Command("pb_decode.c", "#../pb_decode.c", c)
|
env.Command("pb_decode.c", "#../pb_decode.c", c)
|
||||||
env.Command("encode_alltypes.c", "#alltypes/encode_alltypes.c", c)
|
env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c)
|
||||||
env.Command("decode_alltypes.c", "#alltypes/decode_alltypes.c", c)
|
env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c)
|
||||||
|
|
||||||
env.NanopbProto("alltypes")
|
env.NanopbProto(["alltypes", "alltypes.options"])
|
||||||
|
|
||||||
# Define the compilation options
|
# Define the compilation options
|
||||||
opts = env.Clone()
|
opts = env.Clone()
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
env.NanopbProto("missing_fields")
|
env.NanopbProto("missing_fields")
|
||||||
test = env.Program(["missing_fields.c", "missing_fields.pb.c", "#common/pb_encode.o", "#common/pb_decode.o"])
|
test = env.Program(["missing_fields.c", "missing_fields.pb.c", "$COMMON/pb_encode.o", "$COMMON/pb_decode.o"])
|
||||||
env.RunTest(test)
|
env.RunTest(test)
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ Import("env")
|
|||||||
c = Copy("$TARGET", "$SOURCE")
|
c = Copy("$TARGET", "$SOURCE")
|
||||||
env.Command("pb_encode.c", "#../pb_encode.c", c)
|
env.Command("pb_encode.c", "#../pb_encode.c", c)
|
||||||
env.Command("pb_decode.c", "#../pb_decode.c", c)
|
env.Command("pb_decode.c", "#../pb_decode.c", c)
|
||||||
env.Command("alltypes.pb.h", "#alltypes/alltypes.pb.h", c)
|
env.Command("alltypes.pb.h", "$BUILD/alltypes/alltypes.pb.h", c)
|
||||||
env.Command("alltypes.pb.c", "#alltypes/alltypes.pb.c", c)
|
env.Command("alltypes.pb.c", "$BUILD/alltypes/alltypes.pb.c", c)
|
||||||
env.Command("encode_alltypes.c", "#alltypes/encode_alltypes.c", c)
|
env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c)
|
||||||
env.Command("decode_alltypes.c", "#alltypes/decode_alltypes.c", c)
|
env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c)
|
||||||
|
|
||||||
# Define the compilation options
|
# Define the compilation options
|
||||||
opts = env.Clone()
|
opts = env.Clone()
|
||||||
|
|||||||
Reference in New Issue
Block a user