1# Protobuf C# runtime 2# 3# See also code generation logic under /src/google/protobuf/compiler/csharp. 4 5load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix") 6load("//build_defs:internal_shell.bzl", "inline_sh_test") 7load("//conformance:defs.bzl", "conformance_test") 8 9################################################################################ 10# Tests 11################################################################################ 12 13conformance_test( 14 name = "conformance_test", 15 failure_list = "//conformance:failure_list_csharp.txt", 16 maximum_edition = "2023", 17 testee = "//conformance:conformance_csharp", 18) 19 20################################################################################ 21# CSharp Runtime 22################################################################################ 23 24filegroup( 25 name = "srcs", 26 srcs = glob( 27 [ 28 "keys/*", 29 "protos/*", 30 "src/**/*.cs*", # .cs and .csproj 31 ], 32 exclude = [ 33 # Exclude generated files. 34 "src/*/obj/**/*", 35 ], 36 ) + [ 37 "src/Directory.Build.props", 38 "src/Google.Protobuf.Test/testprotos.pb", 39 "src/Google.Protobuf.sln", 40 ], 41 visibility = [ 42 "//conformance:__subpackages__", 43 "//csharp:__subpackages__", 44 ], 45) 46 47filegroup( 48 name = "wkt_cs_srcs", 49 srcs = [ 50 "src/Google.Protobuf/Reflection/Descriptor.pb.cs", 51 "src/Google.Protobuf/WellKnownTypes/Any.pb.cs", 52 "src/Google.Protobuf/WellKnownTypes/Api.pb.cs", 53 "src/Google.Protobuf/WellKnownTypes/Duration.pb.cs", 54 "src/Google.Protobuf/WellKnownTypes/Empty.pb.cs", 55 "src/Google.Protobuf/WellKnownTypes/FieldMask.pb.cs", 56 "src/Google.Protobuf/WellKnownTypes/SourceContext.pb.cs", 57 "src/Google.Protobuf/WellKnownTypes/Struct.pb.cs", 58 "src/Google.Protobuf/WellKnownTypes/Timestamp.pb.cs", 59 "src/Google.Protobuf/WellKnownTypes/Type.pb.cs", 60 "src/Google.Protobuf/WellKnownTypes/Wrappers.pb.cs", 61 ], 62 visibility = ["//src/google/protobuf/compiler/csharp:__pkg__"], 63) 64 65inline_sh_test( 66 name = "tests", 67 srcs = [ 68 "src/Google.Protobuf.sln", 69 ":srcs", 70 "//conformance:conformance_csharp_proto", 71 "//csharp/src/Google.Protobuf.Conformance:srcs", 72 ], 73 cmd = """ 74 cp $(rootpath //conformance:conformance_csharp_proto) `dirname $(location src/Google.Protobuf.sln)`/Google.Protobuf.Conformance/ 75 pushd `dirname $(location src/Google.Protobuf.sln)`/.. 76 dotnet restore src/Google.Protobuf.sln 77 dotnet build -c Release src/Google.Protobuf.sln 78 dotnet test -c Release -f net6.0 src/Google.Protobuf.Test/Google.Protobuf.Test.csproj 79 popd 80 """, 81) 82 83################################################################################ 84# Distribution files 85################################################################################ 86 87pkg_files( 88 name = "dist_files", 89 srcs = [ 90 ".editorconfig", 91 ".gitignore", 92 "BUILD.bazel", 93 "CHANGES.txt", 94 "Google.Protobuf.Tools.nuspec", 95 "Google.Protobuf.Tools.targets", 96 "NuGet.Config", 97 "README.md", 98 "build_packages.bat", 99 "build_release.sh", 100 "build_tools.sh", 101 "buildall.bat", 102 "buildall.sh", 103 "generate_protos.sh", 104 "install_dotnet_sdk.ps1", 105 ":srcs", 106 "//csharp/src/Google.Protobuf.Conformance:dist_files", 107 ], 108 strip_prefix = strip_prefix.from_root(""), 109 visibility = ["//pkg:__pkg__"], 110) 111 112sh_binary( 113 name = "release", 114 srcs = ["build_release.sh"], 115 args = ["$(location build_release.sh)"], 116) 117