diff --git a/templates/cc/BUILD.bazel b/templates/cc/BUILD.bazel index 9bb4b43f3..cd4b89f52 100644 --- a/templates/cc/BUILD.bazel +++ b/templates/cc/BUILD.bazel @@ -27,6 +27,7 @@ go_library( visibility = ["//visibility:public"], deps = [ "//templates/shared:go_default_library", + "//vendor/github.com/iancoleman/strcase:go_default_library", "//vendor/github.com/lyft/protoc-gen-star:go_default_library", "//vendor/github.com/lyft/protoc-gen-star/lang/go:go_default_library", "@com_github_golang_protobuf//ptypes:go_default_library", diff --git a/templates/cc/file.go b/templates/cc/file.go index c27f2fddf..f821d7bbc 100644 --- a/templates/cc/file.go +++ b/templates/cc/file.go @@ -70,7 +70,7 @@ using std::string; } // namespace {{ end }} -#define X_{{ .Package.ProtoName.ScreamingSnakeCase }}_{{ .File.InputPath.BaseName | upper }}(X) \ +#define X_{{ .Package.ProtoName.ScreamingSnakeCase }}_{{ .File.InputPath.BaseName | screaming_snake_case }}(X) \ {{ range .AllMessages -}} X({{class . }}) \ {{ end }} diff --git a/templates/cc/register.go b/templates/cc/register.go index d9182e2fe..6155bb933 100644 --- a/templates/cc/register.go +++ b/templates/cc/register.go @@ -11,6 +11,7 @@ import ( "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/duration" "github.com/golang/protobuf/ptypes/timestamp" + "github.com/iancoleman/strcase" pgs "github.com/lyft/protoc-gen-star" pgsgo "github.com/lyft/protoc-gen-star/lang/go" ) @@ -95,9 +96,10 @@ func RegisterHeader(tpl *template.Template, params pgs.Parameters) { fns := CCFuncs{pgsgo.InitContext(params)} tpl.Funcs(map[string]interface{}{ - "class": fns.className, - "output": fns.output, - "upper": strings.ToUpper, + "class": fns.className, + "output": fns.output, + "upper": strings.ToUpper, + "screaming_snake_case": strcase.ToScreamingSnake, }) template.Must(tpl.Parse(headerFileTpl)) diff --git a/tests/harness/cases/BUILD b/tests/harness/cases/BUILD index 9a7cf3ac6..0fdfaf734 100644 --- a/tests/harness/cases/BUILD +++ b/tests/harness/cases/BUILD @@ -4,9 +4,9 @@ load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@io_bazel_rules_go//go:def.bzl", "go_library") load( "//bazel:pgv_proto_library.bzl", - "pgv_gogo_proto_library", - "pgv_go_proto_library", "pgv_cc_proto_library", + "pgv_go_proto_library", + "pgv_gogo_proto_library", "pgv_java_proto_library", "pgv_python_proto_library", ) @@ -17,6 +17,7 @@ proto_library( "bool.proto", "bytes.proto", "enums.proto", + "filename-with-dash.proto", "kitchen_sink.proto", "maps.proto", "messages.proto", @@ -31,8 +32,8 @@ proto_library( ], visibility = ["//visibility:public"], deps = [ - "//validate:validate_proto", "//tests/harness/cases/other_package:embed_proto", + "//validate:validate_proto", "@com_google_protobuf//:any_proto", "@com_google_protobuf//:duration_proto", "@com_google_protobuf//:timestamp_proto", @@ -70,34 +71,34 @@ pgv_gogo_proto_library( pgv_cc_proto_library( name = "cc", - deps = [":cases_proto"], cc_deps = [ "//tests/harness/cases/other_package:cc", ], visibility = ["//tests:__subpackages__"], + deps = [":cases_proto"], ) java_proto_library( name = "cases_java_proto", - deps = [":cases_proto"], visibility = ["//visibility:public"], + deps = [":cases_proto"], ) pgv_java_proto_library( name = "java", - deps = [":cases_proto"], - visibility = ["//visibility:public"], java_deps = [ ":cases_java_proto", "//tests/harness/cases/other_package:java", ], + visibility = ["//visibility:public"], + deps = [":cases_proto"], ) pgv_python_proto_library( name = "python", - deps = [":cases_proto"], - visibility = ["//visibility:public"], python_deps = [ "//tests/harness/cases/other_package:python", ], + visibility = ["//visibility:public"], + deps = [":cases_proto"], ) diff --git a/tests/harness/cases/filename-with-dash.proto b/tests/harness/cases/filename-with-dash.proto new file mode 100644 index 000000000..f86cfc22d --- /dev/null +++ b/tests/harness/cases/filename-with-dash.proto @@ -0,0 +1,6 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "cases"; + +import "validate/validate.proto"; diff --git a/tests/harness/cc/harness.cc b/tests/harness/cc/harness.cc index ee2053578..d6be09c4d 100644 --- a/tests/harness/cc/harness.cc +++ b/tests/harness/cc/harness.cc @@ -15,6 +15,8 @@ #include "tests/harness/cases/bytes.pb.validate.h" #include "tests/harness/cases/enums.pb.h" #include "tests/harness/cases/enums.pb.validate.h" +#include "tests/harness/cases/filename-with-dash.pb.h" +#include "tests/harness/cases/filename-with-dash.pb.validate.h" #include "tests/harness/cases/maps.pb.h" #include "tests/harness/cases/maps.pb.validate.h" #include "tests/harness/cases/messages.pb.h"