-
Notifications
You must be signed in to change notification settings - Fork 15.6k
/
BUILD.bazel
149 lines (135 loc) · 4.83 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Protobuf C# runtime
#
# See also code generation logic under /src/google/protobuf/compiler/csharp.
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("//build_defs:internal_shell.bzl", "inline_sh_test")
load("//conformance:defs.bzl", "conformance_test")
load("//editions:defaults.bzl", "compile_edition_defaults", "embed_edition_defaults")
load("//upb/cmake:build_defs.bzl", "staleness_test")
################################################################################
# Tests
################################################################################
conformance_test(
name = "conformance_test",
failure_list = "//conformance:failure_list_csharp.txt",
maximum_edition = "2023",
testee = "//conformance:conformance_csharp",
)
################################################################################
# CSharp Runtime
################################################################################
filegroup(
name = "srcs",
srcs = glob(
[
"keys/*",
"protos/*",
"src/**/*.cs*", # .cs and .csproj
],
exclude = [
# Exclude generated files.
"src/*/obj/**/*",
],
) + [
"src/Directory.Build.props",
"src/Google.Protobuf.Test/testprotos.pb",
"src/Google.Protobuf.sln",
],
visibility = [
"//conformance:__subpackages__",
"//csharp:__subpackages__",
],
)
filegroup(
name = "wkt_cs_srcs",
srcs = [
"src/Google.Protobuf/Reflection/Descriptor.pb.cs",
"src/Google.Protobuf/WellKnownTypes/Any.pb.cs",
"src/Google.Protobuf/WellKnownTypes/Api.pb.cs",
"src/Google.Protobuf/WellKnownTypes/Duration.pb.cs",
"src/Google.Protobuf/WellKnownTypes/Empty.pb.cs",
"src/Google.Protobuf/WellKnownTypes/FieldMask.pb.cs",
"src/Google.Protobuf/WellKnownTypes/SourceContext.pb.cs",
"src/Google.Protobuf/WellKnownTypes/Struct.pb.cs",
"src/Google.Protobuf/WellKnownTypes/Timestamp.pb.cs",
"src/Google.Protobuf/WellKnownTypes/Type.pb.cs",
"src/Google.Protobuf/WellKnownTypes/Wrappers.pb.cs",
],
visibility = ["//src/google/protobuf/compiler/csharp:__pkg__"],
)
inline_sh_test(
name = "tests",
srcs = [
"src/Google.Protobuf.sln",
":srcs",
"//conformance:conformance_csharp_proto",
"//csharp/src/Google.Protobuf.Conformance:srcs",
],
cmd = """
cp $(rootpath //conformance:conformance_csharp_proto) `dirname $(location src/Google.Protobuf.sln)`/Google.Protobuf.Conformance/
pushd `dirname $(location src/Google.Protobuf.sln)`/..
dotnet restore src/Google.Protobuf.sln
dotnet build -c Release src/Google.Protobuf.sln
dotnet test -c Release -f net6.0 src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
popd
""",
)
################################################################################
# Distribution files
################################################################################
pkg_files(
name = "dist_files",
srcs = [
".editorconfig",
".gitignore",
"BUILD.bazel",
"CHANGES.txt",
"Google.Protobuf.Tools.nuspec",
"Google.Protobuf.Tools.targets",
"NuGet.Config",
"README.md",
"build_packages.bat",
"build_release.sh",
"build_tools.sh",
"buildall.bat",
"buildall.sh",
"generate_protos.sh",
"install_dotnet_sdk.ps1",
":srcs",
"//csharp/src/Google.Protobuf.Conformance:dist_files",
],
strip_prefix = strip_prefix.from_root(""),
visibility = ["//pkg:__pkg__"],
)
sh_binary(
name = "release",
srcs = ["build_release.sh"],
args = ["$(location build_release.sh)"],
)
################################################################################
# Generated edition defaults (and staleness test)
################################################################################
compile_edition_defaults(
name = "csharp_edition_defaults",
srcs = [
"//:descriptor_proto",
],
maximum_edition = "2023",
minimum_edition = "PROTO2",
)
# TODO Make bazel tests use this output instead of the checked-in one
embed_edition_defaults(
name = "embedded_csharp_edition_defaults_generate",
defaults = "csharp_edition_defaults",
encoding = "base64",
output = "generated/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs",
placeholder = "DEFAULTS_VALUE",
template = "src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs.template",
)
staleness_test(
name = "generated_csharp_defaults_staleness_test",
outs = ["src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs"],
generated_pattern = "generated/%s",
tags = ["manual"],
target_files = ["src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs"],
)