forked from facebook/litho
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LITHO_DEFS.bzl
383 lines (282 loc) · 12.1 KB
/
LITHO_DEFS.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
LITHO_ROOT = "//"
LITHO_VISIBILITY = [
"PUBLIC",
]
LITHO_STUBS_VISIBILITY = [
"//litho-core/...",
]
LITHO_TESTING_UTIL_VISIBILITY = [
"PUBLIC",
]
LITHO_IS_OSS_BUILD = True
def make_dep_path(pth):
return LITHO_ROOT + pth
LITHO_ROOT_TARGET = make_dep_path(":components")
# Java source
LITHO_JAVA_TARGET = make_dep_path("litho-core/src/main/java/com/facebook/litho:litho")
LITHO_ANNOTATIONS_TARGET = make_dep_path("litho-annotations/src/main/java/com/facebook/litho/annotations:annotations")
LITHO_CONFIG_TARGET = make_dep_path("litho-core/src/main/java/com/facebook/litho/config:config")
LITHO_DISPLAYLISTSTUBS_TARGET = make_dep_path("litho-stubs:stubs")
LITHO_VIEWCOMPAT_TARGET = make_dep_path("litho-core/src/main/java/com/facebook/litho/viewcompat:viewcompat")
LITHO_UTILS_TARGET = make_dep_path("litho-core/src/main/java/com/facebook/litho/utils:utils")
LITHO_WIDGET_ACCESSIBILITIES_TARGET = make_dep_path("litho-widget/src/main/java/com/facebook/litho/widget/accessibility:accessibility")
LITHO_WIDGET_TARGET = make_dep_path("litho-widget/src/main/java/com/facebook/litho/widget:widget")
LITHO_LITHO_FRESCO_TARGET = make_dep_path("litho-fresco/src/main/java/com/facebook/litho/fresco:fresco")
LITHO_TESTING_CORE_TARGET = make_dep_path("litho-testing/src/main/java/com/facebook/litho:litho")
LITHO_TESTING_TARGET = make_dep_path("litho-testing/src/main/java/com/facebook/litho/testing:testing")
LITHO_TESTING_ASSERTJ_TARGET = make_dep_path("litho-testing/src/main/java/com/facebook/litho/testing/assertj:assertj")
LITHO_TESTING_HELPER_TARGET = make_dep_path("litho-testing/src/main/java/com/facebook/litho/testing/helper:helper")
LITHO_TESTING_SUBCOMPONENTS_TARGET = make_dep_path("litho-testing/src/main/java/com/facebook/litho/testing/subcomponents:subcomponents")
LITHO_TESTING_WIDGET_TARGET = make_dep_path("litho-testing/src/main/java/com/facebook/litho/widget:widget")
LITHO_TESTING_ESPRESSO_TARGET = make_dep_path("litho-espresso/src/main/java/com/facebook/litho/testing/espresso:espresso")
LITHO_TEST_RES = make_dep_path("litho-it/src/main:res")
LITHO_SECTIONS_TARGET = make_dep_path("litho-sections-core/src/main/java/com/facebook/litho/sections:sections")
LITHO_SECTIONS_COMMON_TARGET = make_dep_path("litho-sections-core/src/main/java/com/facebook/litho/sections/common:common")
LITHO_SECTIONS_WIDGET_TARGET = make_dep_path("litho-sections-widget/src/main/java/com/facebook/litho/sections/widget:widget")
LITHO_SECTIONS_ANNOTATIONS_TARGET = make_dep_path("litho-sections-annotations/src/main/java/com/facebook/litho/sections/annotations:annotations")
LITHO_SECTIONS_PROCESSOR_TARGET = make_dep_path("litho-sections-processor/src/main/java/com/facebook/litho/sections/specmodels/processor:processor")
LITHO_SECTIONS_CONFIG_TARGET = make_dep_path("litho-sections-core/src/main/java/com/facebook/litho/sections/config:config")
LITHO_FBJNI_JAVA_TARGET = make_dep_path("lib/fbjni/src/main/java/com/facebook/jni:jni")
# Test source
LITHO_TEST_TARGET = make_dep_path("litho-it/src/test/java/com/facebook/litho:litho")
# Java source with local upstream
LITHO_PROGUARDANNOTATIONS_TARGET = make_dep_path("litho-annotations/src/main/java/com/facebook/proguard/annotations:annotations")
# Resources
LITHO_RES_TARGET = make_dep_path("litho-core:res")
# Libraries
LITHO_INFERANNOTATIONS_TARGET = make_dep_path("lib/infer-annotations:infer-annotations")
LITHO_JSR_TARGET = make_dep_path("lib/jsr-305:jsr-305")
LITHO_ANDROIDSUPPORT_TARGET = make_dep_path("lib/android-support:android-support")
LITHO_ANDROIDSUPPORT_RECYCLERVIEW_TARGET = make_dep_path("lib/android-support:android-support-recyclerview")
LITHO_ANDROIDSUPPORT_APPCOMPAT_TARGET = make_dep_path("lib/appcompat:appcompat")
LITHO_ANDROIDSUPPORT_TESTING_TARGET = make_dep_path("lib/android-support:android-support-testing")
LITHO_YOGA_TARGET = make_dep_path("lib/yoga:yoga")
LITHO_YOGAJNI_TARGET = make_dep_path("lib/yogajni:jni")
LITHO_BUILD_CONFIG_TARGET = make_dep_path(":build_config")
LITHO_COMMONS_CLI_TARGET = make_dep_path("lib/commons-cli:commons-cli")
LITHO_TEXTLAYOUTBUILDER_TARGET = make_dep_path("lib/textlayoutbuilder:textlayoutbuilder")
LITHO_JAVAPOET_TARGET = make_dep_path("lib/javapoet:javapoet")
LITHO_FBCORE_TARGET = make_dep_path("lib/fbcore:fbcore")
LITHO_SOLOADER_TARGET = make_dep_path("lib/soloader:soloader")
LITHO_ASSERTJ_TARGET = make_dep_path("lib/assertj:assertj")
LITHO_COMPILE_TESTING_TARGET = make_dep_path("lib/compile-testing:compile-testing")
LITHO_TRUTH_TARGET = make_dep_path("lib/truth:truth")
LITHO_MOCKITO_TARGET = make_dep_path("lib/mockito:mockito")
LITHO_POWERMOCK_REFLECT_TARGET = make_dep_path("lib/powermock:powermock-reflect")
LITHO_POWERMOCK_MOCKITO_TARGET = make_dep_path("lib/powermock:powermock-mockito")
LITHO_JNI_TARGET = make_dep_path("lib/jni-hack:jni-hack")
LITHO_FBJNI_TARGET = make_dep_path("lib/fbjni:jni")
LITHO_GUAVA_TARGET = make_dep_path("lib/guava:guava")
LITHO_DIFFUTILS_TARGET = make_dep_path("lib/diff-utils:diff-utils")
LITHO_ESPRESSO_TARGET = make_dep_path("lib/espresso:espresso")
LITHO_SCREENSHOT_TARGET = make_dep_path("lib/screenshot:screenshot")
LITHO_JAVAC_TOOLS_TARGET = make_dep_path("lib/javac-tools:javac-tools")
# Fresco
LITHO_FRESCO_TARGET = make_dep_path("lib/fresco:fresco")
LITHO_ROBOLECTRIC_TARGET = make_dep_path("lib/robolectric3:robolectric3")
LITHO_JUNIT_TARGET = make_dep_path("lib/junit:junit")
LITHO_HAMCREST_LIBRARY_TARGET = make_dep_path("lib/hamcrest:hamcrest")
LITHO_HAMCREST_CORE_TARGET = make_dep_path("lib/hamcrest:hamcrest")
# Annotation processors
LITHO_PROCESSOR_TARGET = make_dep_path("litho-processor/src/main/java/com/facebook/litho/specmodels/processor:processor")
LITHO_PROCESSOR_LIB_TARGET = make_dep_path("litho-processor/src/main/java/com/facebook/litho/specmodels/processor:processor-lib")
LITHO_SECTIONS_PROCESSOR_LIB_TARGET = make_dep_path("litho-sections-processor/src/main/java/com/facebook/litho/sections/specmodels/processor:processor-lib")
# Sample app
LITHO_SAMPLE_JAVA = make_dep_path("sample/src/main/java/com/facebook/samples/litho:litho")
LITHO_SAMPLE_APP_TARGET = make_dep_path("sample/src/oss-only/java/com/facebook/samples/litho:litho")
LITHO_SAMPLE_APP_EXTRAS = []
LITHO_SAMPLE_BAREBONES_JAVA = make_dep_path("sample-barebones/src/main/java/com/facebook/samples/lithobarebones:lithobarebones")
LITHO_SAMPLE_BAREBONES_RES = make_dep_path("sample-barebones:res")
LITHO_SAMPLE_CODELAB_JAVA = make_dep_path("sample-codelab/src/main/java/com/facebook/samples/lithocodelab:lithocodelab")
LITHO_SAMPLE_CODELAB_RES = make_dep_path("sample-codelab:res")
LITHO_SAMPLE_RES = make_dep_path("sample:res")
# Other targets
LITHO_OSS_TARGET = make_dep_path(":components")
# Targets that sometimes exist and sometimes don't
LITHO_TEXTLAYOUTBUILDER_UTILS_TARGET = []
LITHO_FRESCO_TARGETS = [
make_dep_path("lib/fbcore:fbcore"),
make_dep_path("lib/fresco:fresco-drawee"),
make_dep_path("lib/fresco:fresco"),
]
LITHO_FRESCO_PIPELINE_TARGET = [make_dep_path("lib/fresco:imagepipeline")]
LITHO_FRESCO_CONTROLLER_TARGET = []
LITHO_FRESCO_INTERFACES_TARGET = []
def components_robolectric_test(
name,
*args,
**kwargs):
"""Tests that can successfully run from the library root folder."""
extra_vm_args = [
"-Drobolectric.dependency.dir=lib/android-all",
"-Dcom.facebook.litho.is_oss=true",
]
kwargs["vm_args"] = extra_vm_args
kwargs["use_cxx_libraries"] = True
kwargs["cxx_library_whitelist"] = [
"//lib/yogajni:jni",
"//lib/fbjni:jni",
]
native.robolectric_test(
name = name,
*args,
**kwargs
)
def fb_instrumentation_test(*args, **kwargs):
# Not supported in OSS at the moment.
pass
def fb_java_test(*args, **kwargs):
"""Uses native java_test for OSS project."""
java_test(*args, **kwargs)
def litho_android_library(name, srcs = None, *args, **kwargs):
srcs = srcs or []
# This has no meaning in OSS.
kwargs.pop("fblite", None)
native.android_library(name, srcs = srcs, *args, **kwargs)
components_robolectric_powermock_test = components_robolectric_test
def fb_xplat_cxx_library(*args, **kwargs):
"""Delegates to cxx_library for OSS project."""
native.cxx_library(*args, **kwargs)
def fb_android_resource(**kwargs):
"""Delegates to native android_resource rule."""
android_resource(**kwargs)
def fb_java_library(**kwargs):
"""Delegates to native java_library rule."""
native.java_library(**kwargs)
def fb_android_library(**kwargs):
"""Delegates to native android_library rule."""
native.android_library(**kwargs)
def fb_prebuilt_cxx_library(**kwargs):
"""Delegates to native prebuilt_cxx_library."""
native.prebuilt_cxx_library(**kwargs)
def fb_instrumentation_test(**kwargs):
"""
We don't support this in the OSS build for now.
Please use Gradle instead.
"""
pass
def fb_core_android_library(**kwargs):
native.android_library(**kwargs)
def define_fbjni_targets():
# This target is only used in open source
fb_prebuilt_cxx_library(
name = "ndklog",
exported_platform_linker_flags = [
(
"^android.*",
["-llog"],
),
],
header_only = True,
visibility = LITHO_VISIBILITY,
)
fb_xplat_cxx_library(
name = "jni",
soname = "libfb.$(ext)",
srcs = native.glob(
[
"src/main/cpp/fb/**/*.cpp",
],
),
header_namespace = "",
compiler_flags = [
"-fno-omit-frame-pointer",
"-fexceptions",
"-frtti",
"-Wall",
"-std=c++11",
"-DDISABLE_CPUCAP",
"-DDISABLE_XPLAT",
],
exported_headers = subdir_glob(
[
("src/main/cpp", "fb/**/*.h"),
],
),
exported_platform_headers = [
(
"^(?!android-arm$).*$",
subdir_glob([
("src/main/cpp", "lyra/*.h"),
]),
),
],
platform_srcs = [
(
"^(?!android-arm$).*$",
glob([
"src/main/cpp/lyra/*.cpp",
]),
),
],
deps = [
LITHO_JNI_TARGET,
":ndklog",
],
visibility = LITHO_VISIBILITY,
)
# This target is only used in open source and will break the monobuild
# because we cannot define `soname` multiple times.
def define_yogajni_targets():
fb_prebuilt_cxx_library(
name = "ndklog",
exported_platform_linker_flags = [
(
"^android.*",
["-llog"],
),
],
header_only = True,
visibility = LITHO_VISIBILITY,
)
fb_xplat_cxx_library(
name = "jni",
soname = "libyoga.$(ext)",
srcs = native.glob(["src/main/cpp/jni/*.cpp"]),
header_namespace = "",
compiler_flags = [
"-fno-omit-frame-pointer",
"-fexceptions",
"-Wall",
"-O3",
"-std=c++11",
],
deps = [
make_dep_path("lib/yoga/src/main/cpp:yoga"),
LITHO_FBJNI_TARGET,
":ndklog",
],
visibility = LITHO_VISIBILITY,
)
# This target is only used in open source and will break the monobuild
# because we cannot define `soname` multiple times.
def define_cpp_yoga_targets():
fb_prebuilt_cxx_library(
name = "ndklog",
exported_platform_linker_flags = [
(
"^android.*",
["-llog"],
),
],
header_only = True,
visibility = LITHO_VISIBILITY,
)
fb_xplat_cxx_library(
name = "yoga",
srcs = native.glob(["yoga/*.cpp"]),
deps = [
":ndklog",
],
compiler_flags = [
"-fno-omit-frame-pointer",
"-fexceptions",
"-Wall",
"-std=c++11",
"-O3",
],
exported_headers = native.glob(["yoga/*.h"]),
force_static = True,
header_namespace = "",
visibility = LITHO_VISIBILITY,
)