Commit 6bea9e25 authored by csharptest's avatar csharptest Committed by rogerk

Issue 40: import doesn't work / proto_path does not work for command-line file names

parent bf2a92c5
...@@ -567,7 +567,7 @@ message MyMessage { ...@@ -567,7 +567,7 @@ message MyMessage {
} }
//Seems the --proto_path or -I option is non-functional for me. Maybe others have luck? //Seems the --proto_path or -I option is non-functional for me. Maybe others have luck?
[Test, Ignore("http://code.google.com/p/protobuf/issues/detail?id=40")] [Test]
public void TestProtoFileInDifferentDirectory() public void TestProtoFileInDifferentDirectory()
{ {
string test = new StackFrame(false).GetMethod().Name; string test = new StackFrame(false).GetMethod().Name;
......
...@@ -84,6 +84,15 @@ namespace Google.ProtocolBuffers.ProtoGen ...@@ -84,6 +84,15 @@ namespace Google.ProtocolBuffers.ProtoGen
return 0; return 0;
} }
string pathRoot = Environment.CurrentDirectory;
foreach(string arg in args)
{
if (arg.StartsWith("--proto_path=", StringComparison.InvariantCultureIgnoreCase))
{
pathRoot = arg.Substring(13);
}
}
foreach (string arg in args) foreach (string arg in args)
{ {
if (arg.StartsWith(ProtocDirectoryArg)) if (arg.StartsWith(ProtocDirectoryArg))
...@@ -95,7 +104,7 @@ namespace Google.ProtocolBuffers.ProtoGen ...@@ -95,7 +104,7 @@ namespace Google.ProtocolBuffers.ProtoGen
{ {
protocArgs.Add(arg); protocArgs.Add(arg);
} }
else if (File.Exists(arg) && else if ((File.Exists(arg) || File.Exists(Path.Combine(pathRoot, arg))) &&
StringComparer.OrdinalIgnoreCase.Equals(".proto", Path.GetExtension(arg))) StringComparer.OrdinalIgnoreCase.Equals(".proto", Path.GetExtension(arg)))
{ {
if (tempFile == null) if (tempFile == null)
...@@ -105,7 +114,13 @@ namespace Google.ProtocolBuffers.ProtoGen ...@@ -105,7 +114,13 @@ namespace Google.ProtocolBuffers.ProtoGen
protocArgs.Add(String.Format("--descriptor_set_out={0}", tempFile)); protocArgs.Add(String.Format("--descriptor_set_out={0}", tempFile));
protoGenArgs.Add(tempFile); protoGenArgs.Add(tempFile);
} }
protocArgs.Add(arg); string patharg = arg;
if (!File.Exists(patharg))
{
patharg = Path.Combine(pathRoot, arg);
}
protocArgs.Add(patharg);
} }
else else
{ {
......
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