nscn.polaris2.protoc.bridge

Members list

Type members

Classlikes

final case class Artifact(groupId: String, artifactId: String, version: String, crossVersion: Boolean = ..., configuration: Option[String] = ..., extraAttributes: Map[String, String] = ...)

Maven coordinates of an artifact a generator wants on the consumer's classpath.

Maven coordinates of an artifact a generator wants on the consumer's classpath.

crossVersion = true means the build tool should append its Scala binary version suffix to artifactId (foo -> foo_3).

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class BuiltinGenerator(name: String, suggestedDependencies: Seq[Artifact] = ...) extends Generator

A generator compiled into protoc itself (--java_out, --cpp_out, ...).

A generator compiled into protoc itself (--java_out, --cpp_out, ...).

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Generator
class Object
trait Matchable
class Any
Show all
case object DescriptorSetGenerator extends Generator

protoc's --descriptor_set_out, which writes a single file rather than a directory.

protoc's --descriptor_set_out, which writes a single file rather than a directory.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Generator
class Object
trait Matchable
class Any
Show all
Self type
final class ExtraEnv(val secondaryOutputDir: String)

Extra environment the bridge hands to in-JVM generators, on top of what protoc sends.

Extra environment the bridge hands to in-JVM generators, on top of what protoc sends.

protoc's plugin protocol has no room for this, so the bridge appends it as an unknown field on the serialized CodeGeneratorRequest and mirrors it in the child process environment. No Java or Scala class is generated for the message: the writer side must work without a protobuf-java of its own version on the classpath, so it serializes by hand (see ProtoUtils) and the reader side uses DynamicMessage.

Field number and variable name are deliberately kept byte-identical to protoc-bridge's (1020 is protobuf's globally reserved extension number for ScalaPB) so a third-party protoc plugin that already speaks this protocol keeps working.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object ExtraEnv

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
ExtraEnv.type

Reader half of ExtraEnv, split out because it needs protobuf-java and only runs inside the generator, where a compatible protobuf-java is guaranteed.

Reader half of ExtraEnv, split out because it needs protobuf-java and only runs inside the generator, where a compatible protobuf-java is guaranteed.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
sealed trait Generator

One code generator invocation protoc should perform.

One code generator invocation protoc should perform.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
final case class JvmGenerator(name: String, gen: ProtocCodeGenerator) extends Generator

A generator running inside this JVM, reached through a frontend.PluginFrontend.

A generator running inside this JVM, reached through a frontend.PluginFrontend.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Generator
class Object
trait Matchable
class Any
Show all
final case class PluginGenerator(name: String, suggestedDependencies: Seq[Artifact], path: Option[String]) extends Generator

An external protoc-gen-<name> executable, optionally at an explicit path.

An external protoc-gen-<name> executable, optionally at an explicit path.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Generator
class Object
trait Matchable
class Any
Show all
object ProtoUtils

The few protobuf wire-format primitives the bridge needs on its own.

The few protobuf wire-format primitives the bridge needs on its own.

ExtraEnv is appended to an already-serialized CodeGeneratorRequest without ever parsing it, so the bridge cannot go through protobuf-java's generated code here - it would need a compiled message type for a message that deliberately has none.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
ProtoUtils.type
object ProtocBridge

Entry point: turns a list of Targets into a single protoc invocation.

Entry point: turns a list of Targets into a single protoc invocation.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

The raw interface a protoc code generator implements: bytes of a CodeGeneratorRequest in, bytes of a CodeGeneratorResponse out.

The raw interface a protoc code generator implements: bytes of a CodeGeneratorRequest in, bytes of a CodeGeneratorResponse out.

Generator authors normally implement nscn.polaris2.protoc.bridge.codegen.CodeGenApp instead, which decodes the request into resolved FileDescriptors.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait CodeGenApp

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
abstract class ProtocRunner[ExitCode]

How the bridge actually launches protoc.

How the bridge actually launches protoc.

Abstract rather than a plain function because the build tool may want to intercept the invocation, and because the extra environment carrying the secondary-output directory has to reach the child process.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Self type
ProtocRunner[ExitCode]
object ProtocRunner

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
final case class SandboxedJvmGenerator extends Generator

A JvmGenerator loaded from its own artifact into its own ClassLoader.

A JvmGenerator loaded from its own artifact into its own ClassLoader.

The point is dependency isolation: the build tool, and any other generator in the same protoc run, may hold an incompatible protobuf-java. Resolving the generator's artifact separately and loading it in a child loader keeps those apart.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Generator
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

Normalizes os.name / os.arch into the classifiers protobuf publishes its protoc executables under (osx-aarch_64, linux-x86_64, ...).

Normalizes os.name / os.arch into the classifiers protobuf publishes its protoc executables under (osx-aarch_64, linux-x86_64, ...).

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
final case class Target(generator: Generator, outputPath: File, options: Seq[String] = ...)

A generator plus where its output goes and which options it receives.

A generator plus where its output goes and which options it receives.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Target

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Target.type
object gens

Ready-made Generator values for the generators protoc ships with.

Ready-made Generator values for the generators protoc ships with.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
gens.type