diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-11-23 11:04:12 +0200 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-12-29 20:26:58 +0200 |
commit | 1fc90ab4c4731ab521ee7f6b4f1f936f76520e2e (patch) | |
tree | 4d710c7fc45c3a7a3c71357491d54fbd8a096690 /tests/site_scons/site_init.py | |
parent | 440a53f85965f35cd7bc401ef7e3fb9c4dfd1390 (diff) |
Add a SCons tool for nanopb protos.
This tool script is useful both for building the tests and also for use in other applications.
Diffstat (limited to 'tests/site_scons/site_init.py')
-rw-r--r-- | tests/site_scons/site_init.py | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/tests/site_scons/site_init.py b/tests/site_scons/site_init.py index 38aa1a44..2226144f 100644 --- a/tests/site_scons/site_init.py +++ b/tests/site_scons/site_init.py @@ -11,42 +11,6 @@ except ImportError: def add_nanopb_builders(env): '''Add the necessary builder commands for nanopb tests.''' - - # Build command for building .pb from .proto using protoc - def proto_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 -o%s %s' % (dirs, esc(str(target[0])), esc(str(source[0]))) - - proto_file_builder = Builder(generator = proto_actions, - suffix = '.pb', - src_suffix = '.proto') - env.Append(BUILDERS = {'Proto': proto_file_builder}) - env.SetDefault(PROTOC = 'protoc') - env.SetDefault(PROTOCPATH = ['.']) - - # Build command for running nanopb generator - import os.path - def nanopb_targets(target, source, env): - basename = os.path.splitext(str(source[0]))[0] - target.append(basename + '.pb.h') - return target, source - - nanopb_file_builder = Builder(action = '$NANOPB_GENERATOR $NANOPB_FLAGS $SOURCE', - suffix = '.pb.c', - src_suffix = '.pb', - emitter = nanopb_targets) - env.Append(BUILDERS = {'Nanopb': nanopb_file_builder}) - 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 - def run_protoc_and_nanopb(env, source): - b1 = env.Proto(source) - b2 = env.Nanopb(source) - return b1 + b2 - env.AddMethod(run_protoc_and_nanopb, "NanopbProto") # Build command that runs a test program and saves the output def run_test(target, source, env): |