Commit 4e43931e authored by Thomas Van Lenten's avatar Thomas Van Lenten

Add support for a file listing expected package to objc prefixes for validation.

- Add a env var to pass a set of expected prefixes for validation.
- Report warnings/errors based on the expected prefixes vs. the data in the files compiled.
- Use some helpers from common directory.
parent edaefac5
......@@ -11,7 +11,6 @@ set -eu
readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
readonly ProtoRootDir="${ScriptDir}/.."
readonly ProtoC="${ProtoRootDir}/src/protoc"
pushd "${ProtoRootDir}" > /dev/null
......@@ -35,7 +34,7 @@ fi
cd src
make $@ protoc
declare -a RUNTIME_PROTO_FILES=(\
declare -a RUNTIME_PROTO_FILES=( \
google/protobuf/any.proto \
google/protobuf/api.proto \
google/protobuf/descriptor.proto \
......@@ -49,5 +48,3 @@ declare -a RUNTIME_PROTO_FILES=(\
google/protobuf/wrappers.proto)
./protoc --objc_out="${ProtoRootDir}/objectivec" ${RUNTIME_PROTO_FILES[@]}
popd > /dev/null
......@@ -54,9 +54,6 @@ FileGenerator::FileGenerator(const FileDescriptor *file)
: file_(file),
root_class_name_(FileClassName(file)),
is_public_dep_(false) {
// Validate the objc prefix.
ValidateObjCClassPrefix(file_);
for (int i = 0; i < file_->enum_type_count(); i++) {
EnumGenerator *generator = new EnumGenerator(file_->enum_type(i));
enum_generators_.push_back(generator);
......
......@@ -57,8 +57,13 @@ bool ObjectiveCGenerator::Generate(const FileDescriptor* file,
return false;
}
FileGenerator file_generator(file);
// Validate the objc prefix/package pairing.
if (!ValidateObjCClassPrefix(file, error)) {
// *error will have been filled in.
return false;
}
FileGenerator file_generator(file);
string filepath = FilePath(file);
// Generate header.
......
......@@ -53,6 +53,7 @@ class LIBPROTOC_EXPORT ObjectiveCGenerator : public CodeGenerator {
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectiveCGenerator);
};
} // namespace objectivec
} // namespace compiler
} // namespace protobuf
......
......@@ -62,9 +62,6 @@ string FileName(const FileDescriptor* file);
// declared in the proto package.
string FilePath(const FileDescriptor* file);
// Checks the prefix for a given file and outputs any warnings/errors needed.
void ValidateObjCClassPrefix(const FileDescriptor* file);
// Gets the name of the root class we'll generate in the file. This class
// is not meant for external consumption, but instead contains helpers that
// the rest of the the classes need
......@@ -145,6 +142,11 @@ string BuildFlagsString(const vector<string>& strings);
string BuildCommentsString(const SourceLocation& location);
// Checks the prefix for a given file and outputs any warnings needed, if
// there are flat out errors, then out_error is filled in and the result is
// false.
bool ValidateObjCClassPrefix(const FileDescriptor* file, string *out_error);
// Generate decode data needed for ObjC's GPBDecodeTextFormatName() to transform
// the input into the the expected output.
class LIBPROTOC_EXPORT TextFormatDecodeData {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment