aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcsharptest <roger@csharptest.net>2012-10-10 16:44:31 -0500
committerrogerk <devnull@localhost>2012-10-10 16:44:31 -0500
commit6bea9e25b1a3a362c0f5f09f5b64af0365604400 (patch)
tree15fdf595785d47f904c3b40844472756085736fa
parentbf2a92c524086890be7ebfe6645dd9b55e274f56 (diff)
downloadprotobuf-6bea9e25b1a3a362c0f5f09f5b64af0365604400.tar.gz
protobuf-6bea9e25b1a3a362c0f5f09f5b64af0365604400.tar.bz2
protobuf-6bea9e25b1a3a362c0f5f09f5b64af0365604400.zip
Issue 40: import doesn't work / proto_path does not work for command-line file names
-rw-r--r--src/ProtoGen.Test/TestPreprocessing.cs2
-rw-r--r--src/ProtoGen/ProgramPreprocess.cs19
2 files changed, 18 insertions, 3 deletions
diff --git a/src/ProtoGen.Test/TestPreprocessing.cs b/src/ProtoGen.Test/TestPreprocessing.cs
index 81b88a3a..188f26dd 100644
--- a/src/ProtoGen.Test/TestPreprocessing.cs
+++ b/src/ProtoGen.Test/TestPreprocessing.cs
@@ -567,7 +567,7 @@ message MyMessage {
}
//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()
{
string test = new StackFrame(false).GetMethod().Name;
diff --git a/src/ProtoGen/ProgramPreprocess.cs b/src/ProtoGen/ProgramPreprocess.cs
index 011035eb..110bdff0 100644
--- a/src/ProtoGen/ProgramPreprocess.cs
+++ b/src/ProtoGen/ProgramPreprocess.cs
@@ -84,6 +84,15 @@ namespace Google.ProtocolBuffers.ProtoGen
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)
{
if (arg.StartsWith(ProtocDirectoryArg))
@@ -95,7 +104,7 @@ namespace Google.ProtocolBuffers.ProtoGen
{
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)))
{
if (tempFile == null)
@@ -105,7 +114,13 @@ namespace Google.ProtocolBuffers.ProtoGen
protocArgs.Add(String.Format("--descriptor_set_out={0}", tempFile));
protoGenArgs.Add(tempFile);
}
- protocArgs.Add(arg);
+ string patharg = arg;
+ if (!File.Exists(patharg))
+ {
+ patharg = Path.Combine(pathRoot, arg);
+ }
+
+ protocArgs.Add(patharg);
}
else
{