From b03be4fa4d863e6beb362cfef6d834d14c96b7e1 Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Sun, 20 Sep 2015 14:12:19 +0300 Subject: Add syntax specification to .proto files (issue #167) Eliminates a warning on protoc 3.0. --- tests/package_name/SConscript | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'tests/package_name/SConscript') 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"]) -- cgit 1.2.3-korg