Skip to content

Commit

Permalink
make the proto-package and scala-package uniform across {node,family,…
Browse files Browse the repository at this point in the history
…std,aux}
  • Loading branch information
pieter-bos committed Jan 25, 2024
1 parent ef82e8f commit 5502336
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 5 deletions.
18 changes: 15 additions & 3 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ object vercors extends Module {
}

def root = T.source(protobufGit.repo())
def jobs = T { 8 }
def jobs = T { 2 }

override def cMakeBuild: T[PathRef] = T {
os.proc("cmake", "-B", T.dest, "-S", root().path).call(cwd = T.dest)
Expand All @@ -643,8 +643,20 @@ object vercors extends Module {
def target = T { "protoc" }
}

def protoPath = T.sources(vercors.col.helpers.megacol().path / os.up, settings.src / "serialize")
def proto = T { vercors.col.helpers.megacol() +: os.walk(settings.src / "serialize").filter(_.ext == "proto").map(PathRef(_)) }
object scalaPBDummy extends ScalaPBModule

def protoPath =
T.sources(
vercors.col.helpers.megacol().path / os.up,
settings.src / "serialize",
scalaPBDummy.scalaPBUnpackProto().path
)

def proto = T {
Seq(vercors.col.helpers.megacol()) ++
os.walk(scalaPBDummy.scalaPBUnpackProto().path).filter(_.ext == "proto").map(PathRef(_)) ++
os.walk(settings.src / "serialize").filter(_.ext == "proto").map(PathRef(_))
}

def generate = T {
os.proc(protoc.executable().path, protoPath().map(p => "-I=" + p.path.toString), "--cpp_out=" + T.dest.toString, proto().map(_.path)).call()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ProtoAuxTypes extends AllNodesGenerator {
Using(Files.newBufferedWriter(dir.resolve(aux.name.last + ".proto"))) { writer =>
Proto.Source(
Seq("scalapb", "scalapb") +: aux.imports,
Proto.renderOptions(Proto.OPAQUE_SUBMESSAGES_OPTIONS),
Proto.renderOptions(Proto.OPAQUE_SUBMESSAGES_OPTIONS.updated("package_name", ProtoNaming.scalaPackageOption(aux.name))),
aux,
).write(writer)
}
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/vct/col/ast/helpers/generator/Serialize.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Serialize extends NodeGenerator {
}

def mk(name: Seq[String], args: Term*): Term =
q"new ${typ(structure.Name(name))}(..${args.toList})"
q"new ${typ(structure.Name(ProtoNaming.scalaPackage(name) :+ name.last))}(..${args.toList})"

def serializeTerm(term: Term, structureType: ST, protoType: Proto.PrimitiveType): Term =
(structureType, protoType) match {
Expand Down
8 changes: 8 additions & 0 deletions src/serialize/vct/col/ast/BigDecimal.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@ syntax = "proto2";

package vct.col.ast;

import "scalapb/scalapb.proto";
import "vct/col/ast/BigInt.proto";

option (scalapb.options) = {
lenses: false
getters: false
no_default_values_in_constructor: true
package_name: "vct.col.ast.serialize"
};

message BigDecimal {
required int32 scale = 1;
required BigInt unscaledValue = 2;
Expand Down
9 changes: 9 additions & 0 deletions src/serialize/vct/col/ast/BigInt.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ syntax = "proto2";

package vct.col.ast;

import "scalapb/scalapb.proto";

option (scalapb.options) = {
lenses: false
getters: false
no_default_values_in_constructor: true
package_name: "vct.col.ast.serialize"
};

/* Big-endian two's complement variable-length integer. If the most
* significant bit of the first byte is 1, you may imagine that this bit is
* "sign-extended" left into infinity.
Expand Down
9 changes: 9 additions & 0 deletions src/serialize/vct/col/ast/BitString.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ syntax = "proto2";

package vct.col.ast;

import "scalapb/scalapb.proto";

option (scalapb.options) = {
lenses: false
getters: false
no_default_values_in_constructor: true
package_name: "vct.col.ast.serialize"
};

message BitString {
required bytes data = 1;
required int32 skipAtLastByte = 2;
Expand Down
9 changes: 9 additions & 0 deletions src/serialize/vct/col/ast/Blame.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ syntax = "proto2";

package vct.col.ast;

import "scalapb/scalapb.proto";

option (scalapb.options) = {
lenses: false
getters: false
no_default_values_in_constructor: true
package_name: "vct.col.ast.serialize"
};

message Blame {
oneof blame {
BlameInput blame_input = 1;
Expand Down
9 changes: 9 additions & 0 deletions src/serialize/vct/col/ast/ExpectedError.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ syntax = "proto2";

package vct.col.ast;

import "scalapb/scalapb.proto";

option (scalapb.options) = {
lenses: false
getters: false
no_default_values_in_constructor: true
package_name: "vct.col.ast.serialize"
};

message ExpectedError {
// this
// message
Expand Down
9 changes: 9 additions & 0 deletions src/serialize/vct/col/ast/Origin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ syntax = "proto2";

package vct.col.ast;

import "scalapb/scalapb.proto";

option (scalapb.options) = {
lenses: false
getters: false
no_default_values_in_constructor: true
package_name: "vct.col.ast.serialize"
};

message Origin {
repeated OriginContent content = 1;
}
Expand Down
9 changes: 9 additions & 0 deletions src/serialize/vct/col/ast/Ref.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ syntax = "proto2";

package vct.col.ast;

import "scalapb/scalapb.proto";

option (scalapb.options) = {
lenses: false
getters: false
no_default_values_in_constructor: true
package_name: "vct.col.ast.serialize"
};

message Ref {
required int64 id = 1;
}

0 comments on commit 5502336

Please sign in to comment.