diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2016-04-20 18:22:41 -0400 |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2016-04-20 18:22:41 -0400 |
commit | 462e7fab9831c026acbb38778f4506fcfdb2d945 (patch) | |
tree | fbdba99b300cf4968536527a00689466ed4aac38 /src | |
parent | 3af705452787a06c9c14a0df440750e45b7d81f1 (diff) | |
download | protobuf-462e7fab9831c026acbb38778f4506fcfdb2d945.tar.gz protobuf-462e7fab9831c026acbb38778f4506fcfdb2d945.tar.bz2 protobuf-462e7fab9831c026acbb38778f4506fcfdb2d945.zip |
protoc: support '=' in --proto_path arguments
Diffstat (limited to 'src')
-rw-r--r-- | src/google/protobuf/compiler/command_line_interface.cc | 9 | ||||
-rw-r--r-- | src/google/protobuf/compiler/command_line_interface_unittest.cc | 15 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 26a4f0b0..37f4e63b 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -1106,8 +1106,13 @@ CommandLineInterface::InterpretArgument(const string& name, // Make sure disk path exists, warn otherwise. if (access(disk_path.c_str(), F_OK) < 0) { - std::cerr << disk_path << ": warning: directory does not exist." - << std::endl; + // Try the original path; it may have just happed to have a '=' in it. + if (access(parts[i].c_str(), F_OK) < 0) { + cerr << disk_path << ": warning: directory does not exist." << endl; + } else { + virtual_path = ""; + disk_path = parts[i]; + } } // Don't use make_pair as the old/default standard library on Solaris diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index 46ea5c4e..adeb4cd5 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -780,6 +780,21 @@ TEST_F(CommandLineInterfaceTest, NonRootMapping) { ExpectGenerated("test_generator", "", "bar/foo.proto", "Foo"); } +TEST_F(CommandLineInterfaceTest, PathWithEqualsSign) { + // Test setting up a search path which happens to have '=' in it. + + CreateTempDir("with=sign"); + CreateTempFile("with=sign/foo.proto", + "syntax = \"proto2\";\n" + "message Foo {}\n"); + + Run("protocol_compiler --test_out=$tmpdir " + "--proto_path=$tmpdir/with=sign foo.proto"); + + ExpectNoErrors(); + ExpectGenerated("test_generator", "", "foo.proto", "Foo"); +} + TEST_F(CommandLineInterfaceTest, MultipleGenerators) { // Test that we can have multiple generators and use both in one invocation, // each with a different output directory. |