Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
75 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
compiler-plugin/src/main/scala/com/trueaccord/scalapb/compiler/Main.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
compiler-plugin/src/main/scala/scalapb/ScalaPbCodeGenerator.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package scalapb | ||
|
||
import com.google.protobuf.ExtensionRegistry | ||
import com.google.protobuf.compiler.PluginProtos.{CodeGeneratorRequest, CodeGeneratorResponse} | ||
import com.trueaccord.scalapb.Scalapb | ||
import com.trueaccord.scalapb.compiler.ProtobufGenerator | ||
import protocbridge.{ProtocCodeGenerator, Artifact} | ||
|
||
|
||
object ScalaPbCodeGenerator extends ProtocCodeGenerator { | ||
override def name: String = "scala" | ||
|
||
override def run(req: CodeGeneratorRequest): CodeGeneratorResponse = { | ||
ProtobufGenerator.handleCodeGeneratorRequest(req) | ||
} | ||
|
||
override def registerExtensions(registry: ExtensionRegistry): Unit = { | ||
Scalapb.registerAllExtensions(registry) | ||
} | ||
|
||
override def suggestedDependencies: Seq[Artifact] = Seq( | ||
Artifact("com.google.protobuf", "protobuf-java", "3.0.0-beta-2"), | ||
Artifact("com.trueaccord.scalapb", "scalapb-runtime", | ||
com.trueaccord.scalapb.compiler.Version.scalapbVersion, crossVersion = true) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package object scalapb { | ||
def generator: protocbridge.Generator = generator() | ||
|
||
def generator(flatPackage: Boolean = false, | ||
javaConversions: Boolean = false, | ||
grpc: Boolean = false): protocbridge.Generator = { | ||
scalapb.ScalaPbCodeGenerator.toGenerator( | ||
Seq( | ||
javaConversions -> "java_conversions", | ||
flatPackage -> "flat_package", | ||
grpc -> "grpc").filter(_._1).map(_._2)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 8 additions & 4 deletions
12
scalapbc/src/main/scala/com/trueaccord/scalapb/ScalaPBC.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
package com.trueaccord.scalapb | ||
|
||
import com.trueaccord.scalapb.compiler.ProtocDriverFactory | ||
import protocbridge.ProtocBridge | ||
|
||
import scalapb.ScalaPbCodeGenerator | ||
|
||
object ScalaPBC extends App { | ||
val code = ProtocDriverFactory.create().buildRunner({ | ||
val code = ProtocBridge.runWithGenerators( | ||
args => | ||
com.github.os72.protocjar.Protoc.runProtoc("-v300" +: args.toArray) | ||
})(args) | ||
com.github.os72.protocjar.Protoc.runProtoc("-v300" +: args.toArray), | ||
args, | ||
Seq("scala" -> ScalaPbCodeGenerator)) | ||
|
||
sys.exit(code) | ||
} |