-
-
Notifications
You must be signed in to change notification settings - Fork 760
Expand file tree
/
Copy pathBUILD.bazel
More file actions
180 lines (159 loc) · 4.29 KB
/
Copy pathBUILD.bazel
File metadata and controls
180 lines (159 loc) · 4.29 KB
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_cross_binary", "go_library", "go_test")
load("@io_bazel_rules_go//go/tools/bazel_testing:def.bzl", "go_bazel_test")
load("@platforms//host:constraints.bzl", "HOST_CONSTRAINTS")
load(":def.bzl", "no_context_info")
test_suite(
name = "cross",
)
go_binary(
name = "non_pure_cross",
srcs = ["main.go"],
goarch = "amd64",
goos = "darwin",
pure = "off",
deps = [":platform_lib"],
) if "@platforms//os:osx" in HOST_CONSTRAINTS else None
go_binary(
name = "windows_cross",
srcs = ["main.go"],
goarch = "amd64",
goos = "windows",
pure = "on",
deps = [":platform_lib"],
)
go_binary(
name = "linux_cross",
srcs = ["main.go"],
goarch = "amd64",
goos = "linux",
pure = "on",
deps = [":platform_lib"],
)
go_binary(
name = "darwin_cross",
srcs = ["main.go"],
goarch = "amd64",
goos = "darwin",
pure = "on",
deps = [":platform_lib"],
)
go_binary(
name = "asm_cross",
srcs = [
"asm.s",
"main.go",
],
goarch = "386",
goos = "linux",
deps = [":platform_lib"],
)
go_binary(
name = "native_bin",
srcs = ["main.go"],
pure = "on",
deps = [":platform_lib"],
)
go_cross_binary(
name = "windows_go_cross",
platform = "@io_bazel_rules_go//go/toolchain:windows_amd64",
target = ":native_bin",
)
go_cross_binary(
name = "linux_go_cross",
platform = "@io_bazel_rules_go//go/toolchain:linux_amd64",
target = ":native_bin",
)
go_cross_binary(
name = "darwin_go_cross",
platform = "@io_bazel_rules_go//go/toolchain:darwin_amd64",
target = ":native_bin",
)
# Because pure = "on" on the underlying target, this doesn't actually need cgo (and won't try to use it).
# This target ensures that (from Bazel 6) we don't require a C++ toolchain if we're not actually going to use cgo.
go_cross_binary(
name = "windows_go_cross_cgo",
platform = "@io_bazel_rules_go//go/toolchain:windows_amd64_cgo",
target = ":native_bin",
)
# Because pure = "on" on the underlying target, this doesn't actually need cgo (and won't try to use it).
# This target ensures that (from Bazel 6) we don't require a C++ toolchain if we're not actually going to use cgo.
go_cross_binary(
name = "linux_go_cross_cgo",
platform = "@io_bazel_rules_go//go/toolchain:linux_amd64_cgo",
target = ":native_bin",
)
# Because pure = "on" on the underlying target, this doesn't actually need cgo (and won't try to use it).
# This target ensures that (from Bazel 6) we don't require a C++ toolchain if we're not actually going to use cgo.
go_cross_binary(
name = "darwin_go_cross_cgo",
platform = "@io_bazel_rules_go//go/toolchain:darwin_amd64_cgo",
target = ":native_bin",
)
go_library(
name = "platform_lib",
srcs = select({
"//go/platform:darwin": ["lib_darwin.go"],
"//go/platform:linux": ["lib_linux.go"],
"//go/platform:windows": ["lib_windows.go"],
}),
importpath = "github.com/bazelbuild/rules_go/tests/core/cross/platform_lib",
)
go_test(
name = "cross_test",
size = "small",
srcs = ["cross_test.go"],
args = [
"-darwin",
"$(location :darwin_cross)",
"-linux",
"$(location :linux_cross)",
"-windows",
"$(location :windows_cross)",
],
data = [
":darwin_cross",
":linux_cross",
":windows_cross",
],
rundir = ".",
deps = ["//go/tools/bazel:go_default_library"],
)
go_test(
name = "go_cross_binary_test",
size = "small",
srcs = ["cross_test.go"],
args = [
"-darwin",
"$(location :darwin_go_cross)",
"-linux",
"$(location :linux_go_cross)",
"-windows",
"$(location :windows_go_cross)",
],
data = [
":darwin_go_cross",
":linux_go_cross",
":windows_go_cross",
],
rundir = ".",
deps = ["//go/tools/bazel:go_default_library"],
)
go_bazel_test(
name = "ios_select_test",
srcs = ["ios_select_test.go"],
)
go_bazel_test(
name = "proto_test",
srcs = ["proto_test.go"],
)
go_bazel_test(
name = "sdk_version_test",
srcs = ["sdk_version_test.go"],
)
go_bazel_test(
name = "non_executable_test",
srcs = ["non_executable_test.go"],
)
no_context_info(
name = "no_context_info",
)