Browse Source

Fixed plugin for use on Linux.

Tim Burks 9 years ago
parent
commit
cd67135c18
2 changed files with 20 additions and 1 deletions
  1. 11 0
      LINUX.md
  2. 9 1
      Plugin/Sources/main.swift

+ 11 - 0
LINUX.md

@@ -73,3 +73,14 @@ Start a docker instance with the following command:
     .build/debug/Echo collect
     .build/debug/Echo collect
     .build/debug/Echo update
     .build/debug/Echo update
 	
 	
+
+## To test the plugin
+    # build and install protoc
+    cd
+    cd grpc-swift/third_party/grpc/third_party/protobuf 
+    make install
+    # build and test the plugin
+    cd
+    cd grpc-swift/Plugin
+    make test
+

+ 9 - 1
Plugin/Sources/main.swift

@@ -119,10 +119,18 @@ func stripMarkers(_ code:String) -> String {
   return outputLines.joined(separator:"\n")
   return outputLines.joined(separator:"\n")
 }
 }
 
 
+func Log(_ message : String) {
+  FileHandle.standardError.write((message + "\n").data(using:.utf8)!)
+}
+
 func main() throws {
 func main() throws {
 
 
   // we expect our templates to be in the same directory as this executable.
   // we expect our templates to be in the same directory as this executable.
-  let executableURL = URL(fileURLWithPath: Bundle.main.executablePath!)
+  var path = "./protoc-gen-swiftgrpc"
+  if let executablePath = Bundle.main.executablePath {
+    path = executablePath
+  }
+  let executableURL = URL(fileURLWithPath: path)
   let executableDir : String = executableURL.deletingLastPathComponent().path
   let executableDir : String = executableURL.deletingLastPathComponent().path
   let templatePath = Path(executableDir + "/swiftgrpc.templates/")
   let templatePath = Path(executableDir + "/swiftgrpc.templates/")