aboutsummaryrefslogtreecommitdiffstats
path: root/tests/package_name
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-09-20 14:12:19 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-09-20 14:29:39 +0300
commitb03be4fa4d863e6beb362cfef6d834d14c96b7e1 (patch)
tree31bdb84f1be4ce5104d4a67d3e5c321f12639b83 /tests/package_name
parent6e72df4808aa138f1396ad098ce2d06a6feba882 (diff)
Add syntax specification to .proto files (issue #167)
Eliminates a warning on protoc 3.0.
Diffstat (limited to 'tests/package_name')
-rw-r--r--tests/package_name/SConscript16
1 files changed, 9 insertions, 7 deletions
diff --git a/tests/package_name/SConscript b/tests/package_name/SConscript
index 897bc99c..4afc5037 100644
--- a/tests/package_name/SConscript
+++ b/tests/package_name/SConscript
@@ -3,14 +3,16 @@
Import("env")
-# Build a modified alltypes.proto
-def modify_proto(target, source, env):
- '''Add a "package test.package;" directive to the beginning of the .proto file.'''
- data = open(str(source[0]), 'r').read()
- open(str(target[0]), 'w').write("package test.package;\n\n" + data)
- return 0
+def set_pkgname(src, dst, pkgname):
+ data = open(str(src)).read()
+ placeholder = '// package name placeholder'
+ assert placeholder in data
+ data = data.replace(placeholder, 'package %s;' % pkgname)
+ open(str(dst), 'w').write(data)
-env.Command("alltypes.proto", "#alltypes/alltypes.proto", modify_proto)
+# Build a modified alltypes.proto
+env.Command("alltypes.proto", "#alltypes/alltypes.proto",
+ lambda target, source, env: set_pkgname(source[0], target[0], 'test.package'))
env.Command("alltypes.options", "#alltypes/alltypes.options", Copy("$TARGET", "$SOURCE"))
env.NanopbProto(["alltypes", "alltypes.options"])