forked from material-components/material-components-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaterial_components_ios.bzl
230 lines (206 loc) · 6.87 KB
/
material_components_ios.bzl
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
"""Bazel macros for building MDC component libraries."""
load("@bazel_ios_warnings//:strict_warnings_objc_library.bzl", "strict_warnings_objc_library")
load("@build_bazel_rules_apple//apple/testing/default_runner:ios_test_runner.bzl", "ios_test_runner")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test", "ios_unit_test_suite")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
IOS_MINIMUM_OS = "9.0"
SNAPSHOT_IOS_MINIMUM_OS = "10.0"
DEFAULT_IOS_RUNNER_TARGETS = [
"//components/testing/runners:IPAD_PRO_12_9_IN_9_3",
"//components/testing/runners:IPHONE_7_PLUS_IN_10_3",
"//components/testing/runners:IPHONE_X_IN_11_0",
]
SNAPSHOT_IOS_RUNNER_TARGET = "//components/testing/runners:IPHONE_7_IN_11_2"
def mdc_objc_library(
name,
copts = [],
**kwargs):
"""Declare an Objective-C library with strict_warnings_objc_library."""
strict_warnings_objc_library(
name = name,
copts = copts,
**kwargs)
def mdc_public_objc_library(
name,
deps = [],
extra_srcs = [],
sdk_frameworks = [],
visibility = ["//visibility:public"],
**kwargs):
"""Declare a public MDC component as a Objective-C library according to MDC's conventions.
The conventions for an MDC component are:
- The public implementation lives inside of src.
- The private implementation lives inside of src/private.
The default visibility of "//visibility:public" can be overridden, for
example, "//some/package:__subpackages__".
Args:
name: The name of the library.
deps: The dependencies of the library.
extra_srcs: Extra sources to add to the standard ones.
sdk_frameworks: The SDK frameworks needed, e.g. "CoreGraphics".
visibility: The visibility of the package.
**kwargs: Any arguments accepted by _mdc_objc_library().
"""
mdc_objc_library(
name = name,
deps = deps,
sdk_frameworks = sdk_frameworks,
visibility = visibility,
srcs = native.glob(["src/*.m", "src/private/*.h", "src/private/*.m"]) + extra_srcs,
hdrs = native.glob(["src/*.h"]),
includes = ["src"],
enable_modules = 1,
**kwargs)
def mdc_extension_objc_library(
name,
deps = [],
sdk_frameworks = [],
visibility = ["//visibility:public"],
**kwargs):
"""Declare a public MDC component extension as an Objective-C library according to MDC's
conventions.
The conventions for an MDC component extension are:
- The public implementation lives in `src/$name/`.
- The private implementation lives in `src/$name/private`.
The default visibility can be overridden.
Args:
name: The name of the extension. It must match the folder it resides in.
deps: The dependencies of the extension.
sdk_frameworks: Extra SDK frameworks (e.g., CoreGraphics) required by the extension.
visibility: The visibility of the extension.
**kwarrgs: Any arguments accepted by _mdc_objc_library().
"""
mdc_objc_library(
name = name,
deps = deps,
sdk_frameworks = sdk_frameworks,
visibility = visibility,
srcs = native.glob([
"src/" + name + "/*.m",
"src/" + name + "/private/*.m",
"src/" + name + "/private/*.h",
]),
hdrs = native.glob(["src/" + name + "/*.h"]),
includes = ["src/" + name],
enable_modules = 1,
**kwargs)
def mdc_examples_objc_library(
name,
deps = [],
sdk_frameworks = [],
visibility = ["//visibility:public"],
**kwargs):
"""Declare an MDC component examples target as an Objective-C library according to MDC's
conventions.
The conventions for MDC component examples are:
- The source lives in `examples/` and `examples/supplemental/`.
The default visibility can be overridden.
Args:
name: The name of the examples target.
deps: The examples dependencies.
sdk_frameworks: Extra SDK frameworks (e.g., CoreGraphics) required by the examples.
visibility: The visibility of the examples.
**kwarrgs: Any arguments accepted by _mdc_objc_library().
"""
mdc_objc_library(
name = name,
deps = deps,
sdk_frameworks = sdk_frameworks,
visibility = visibility,
srcs = native.glob([
"examples/*.m",
"examples/*.h",
"examples/supplemental/*.m",
"examples/supplemental/*.h",
]),
enable_modules = 1,
**kwargs)
def mdc_examples_swift_library(
name,
deps = [],
visibility = ["//visibility:public"],
**kwargs):
"""Declare an MDC component examples target as a Swift library according to MDC's
conventions.
The conventions for MDC component examples are:
- The source lives in `examples/` and `examples/supplemental/`.
The default visibility can be overridden.
Args:
name: The name of the examples target.
deps: The examples dependencies.
visibility: The visibility of the examples.
**kwarrgs: Any arguments accepted by _mdc_objc_library().
"""
swift_library(
name = name,
deps = deps,
visibility = visibility,
copts = [
"-swift-version",
"4.2",
],
srcs = native.glob([
"examples/*.swift",
"examples/supplemental/*.swift",
]),
**kwargs)
def mdc_snapshot_objc_library(
name,
extra_srcs = [],
deps = [],
sdk_frameworks = [],
visibility = ["//visibility:private"],
testonly = 1,
**kwargs):
"""Declare an mdc_objc_library for snapshot test source."""
mdc_objc_library(
name = name,
srcs = native.glob([
"tests/snapshot/*.m",
"tests/snapshot/*.h",
"tests/snapshot/supplemental/*.m",
"tests/snapshot/supplemental/*.h",
]) + extra_srcs,
deps = ["//components/private/Snapshot"] + deps,
sdk_frameworks = ["XCTest"] + sdk_frameworks,
visibility = visibility,
testonly = testonly,
**kwargs)
def mdc_snapshot_test(
name,
deps = [],
minimum_os_version = SNAPSHOT_IOS_MINIMUM_OS,
visibility = ["//visibility:private"],
size = "medium",
tags = ["exclusive"],
**kwargs):
"""Declare an MDC ios_unit_test for snapshot tests."""
ios_unit_test(
name = name,
deps = deps,
minimum_os_version = minimum_os_version,
runner = SNAPSHOT_IOS_RUNNER_TARGET,
tags = tags,
test_host = "//components/private/Snapshot/TestHost",
visibility = visibility,
# TODO(https://github.com/material-components/material-components-ios/issues/6335)
flaky = 1,
size = size,
**kwargs)
def mdc_unit_test_suite(
name,
deps = [],
minimum_os_version = IOS_MINIMUM_OS,
visibility = ["//visibility:private"],
size = "medium",
**kwargs):
"""Declare a MDC unit_test_suite using the ios_runners matrix."""
ios_unit_test_suite(
name = name,
deps = deps,
minimum_os_version = minimum_os_version,
runners = DEFAULT_IOS_RUNNER_TARGETS,
visibility = visibility,
size = size,
**kwargs
)