src_suffix = '.pb',
emitter = nanopb_targets)
env.Append(BUILDERS = {'Nanopb': nanopb_file_builder})
- env.SetDefault(NANOPB_GENERATOR = 'python ' + env.GetBuildPath("#../generator/nanopb_generator.py"))
+ gen_path = env['ESCAPE'](env.GetBuildPath("#../generator/nanopb_generator.py"))
+ env.SetDefault(NANOPB_GENERATOR = 'python ' + gen_path)
env.SetDefault(NANOPB_FLAGS = '-q')
# Combined method to run both protoc and nanopb generator
else:
infile = None
- pipe = subprocess.Popen(str(source[0]),
+ args = [str(source[0])]
+ if env.has_key('ARGS'):
+ args.extend(env['ARGS'])
+
+ pipe = subprocess.Popen(args,
stdin = infile,
stdout = open(str(target[0]), 'w'),
stderr = sys.stderr)
# Build command that decodes a message using protoc
def decode_actions(source, target, env, for_signature):
- dirs = ' '.join(['-I' + env.GetBuildPath(d) for d in env['PROTOCPATH']])
- return '$PROTOC $PROTOCFLAGS %s --decode=%s %s <%s >%s' % (dirs, env['MESSAGE'], source[1], source[0], target[0])
+ esc = env['ESCAPE']
+ dirs = ' '.join(['-I' + esc(env.GetBuildPath(d)) for d in env['PROTOCPATH']])
+ return '$PROTOC $PROTOCFLAGS %s --decode=%s %s <%s >%s' % (
+ dirs, env['MESSAGE'], esc(str(source[1])), esc(str(source[0])), esc(str(target[0])))
decode_builder = Builder(generator = decode_actions,
suffix = '.decoded')
env.Append(BUILDERS = {'Decode': decode_builder})
+ # Build command that encodes a message using protoc
+ def encode_actions(source, target, env, for_signature):
+ esc = env['ESCAPE']
+ dirs = ' '.join(['-I' + esc(env.GetBuildPath(d)) for d in env['PROTOCPATH']])
+ return '$PROTOC $PROTOCFLAGS %s --encode=%s %s <%s >%s' % (
+ dirs, env['MESSAGE'], esc(str(source[1])), esc(str(source[0])), esc(str(target[0])))
+
+ encode_builder = Builder(generator = encode_actions,
+ suffix = '.encoded')
+ env.Append(BUILDERS = {'Encode': encode_builder})
+
# Build command that asserts that two files be equal
def compare_files(target, source, env):
data1 = open(str(source[0]), 'rb').read()