-
Notifications
You must be signed in to change notification settings - Fork 237
/
Copy pathcore_rules.bzl
1488 lines (1183 loc) · 47.4 KB
/
core_rules.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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under both the MIT license found in the
# LICENSE-MIT file in the root directory of this source tree and the Apache
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree.
# TODO(cjhopman): This was generated by scripts/hacks/rules_shim_with_docs.py,
# but should be manually edited going forward. There may be some errors in
# the generated docs, and so those should be verified to be accurate and
# well-formatted (and then delete this TODO)
load(":common.bzl", "OnDuplicateEntry", "buck", "prelude_rule", "validate_uri")
load(":genrule_common.bzl", "genrule_common")
load(":remote_common.bzl", "remote_common")
ExportFileDescriptionMode = ["reference", "copy"]
Platform = ["linux", "macos", "windows", "freebsd", "unknown"]
RemoteFileType = ["data", "executable", "exploded_zip"]
TargetCpuType = ["arm", "armv7", "arm64", "x86", "x86_64", "mips"]
alias = prelude_rule(
name = "alias",
docs = "",
examples = None,
further = None,
attrs = (
# @unsorted-dict-items
{
"actual": attrs.dep(pulls_and_pushes_plugins = plugins.All),
"contacts": attrs.list(attrs.string(), default = []),
"default_host_platform": attrs.option(attrs.configuration_label(), default = None),
"labels": attrs.list(attrs.string(), default = []),
"licenses": attrs.list(attrs.source(), default = []),
}
),
)
command_alias = prelude_rule(
name = "command_alias",
docs = """
The `command_alias` rule enables you to wrap build
rules that create binaries and to pre-apply command-line
arguments and environment variables.
Example uses include running a command written in a scripting
language with a specific interpreter, and transparently wrapping
sub-commands of a binary.
You can reference a `command_alias` target in
the `cmd` parameter of a `genrule()` by
using the `exe` macro:
```
$(exe //path/to:target)
```
""",
examples = """
```
# Combining an interpreter and a script
cxx_binary(
name = "node-js",
srcs = [
# ...
],
headers = [
# ...
],
)
export_file(
name = "scripts"
)
command_alias(
name = "server",
exe = ":node-js",
args = [
"$(location :scripts)/start-server.js",
],
)
```
```
# Exposing sub commands
export_file(
name = "yarn",
src = "yarn.sh",
)
command_alias(
name = "add",
exe = ":yarn",
args = ["add"],
)
command_alias(
name = "install",
exe = ":yarn",
args = ["install"],
)
command_alias(
name = "run",
exe = ":yarn",
args = ["run"],
)
```
```
# Platform specific commands
export_file(
name = "node-windows",
src = "windows/node.exe",
)
export_file(
name = "node-linux",
src = "linux/node",
)
export_file(
name = "node-macos",
src = "macos/node",
)
command_alias(
name = "node",
platform_exe = {
"windows": ":node-windows",
"linux": ":node-linux",
"macos": ":node-macos",
},
)
```
""",
further = None,
attrs = (
# @unsorted-dict-items
{
# Match `dep` before `source` so that we can support extracting the
# `RunInfo` provider of it, if one exists.
"exe": attrs.option(attrs.one_of(attrs.dep(), attrs.source()), default = None, doc = """
A `build target` for a rule that outputs
an executable, such as an `sh_binary()`,
or an executable source file.
"""),
"platform_exe": attrs.dict(key = attrs.enum(Platform), value = attrs.dep(), sorted = False, default = {}, doc = """
A mapping from platforms to `build target`.
enables you to override `exe` per host platform.
If present, `exe` will be used as a fallback on host platforms that are not
specified in `platform_exe`.
It is possible to omit `exe` when providing `platform_exe`.
In that case, the build will fail if the command is invoked on a platform not specified in
the mapping.
Valid platforms are all values of the [`Platform` enum](https://dev.buck.build/javadoc/com/facebook/buck/util/environment/Platform.html) :
* `FREEBSD`
* `LINUX`
* `MACOS`
* `WINDOWS`
"""),
"args": attrs.list(attrs.arg(), default = [], doc = """
A string of arguments that is passed to the executable specified by
`exe` at startup. These arguments support a subset of
Buck's `string parameter macros`
. Only the
`$(location ...)` and `$(exe ...)` macros are supported currently.
"""),
"env": attrs.dict(key = attrs.string(), value = attrs.arg(), sorted = False, default = {}, doc = """
A map of environment variables that will be passed to the executable represented
by `exe` on startup. Environment variables support the same macros as arguments.
"""),
"contacts": attrs.list(attrs.string(), default = []),
"default_host_platform": attrs.option(attrs.configuration_label(), default = None),
"labels": attrs.list(attrs.string(), default = []),
"licenses": attrs.list(attrs.source(), default = []),
"resources": attrs.list(attrs.source(), default = []),
"_exec_os_type": buck.exec_os_type_arg(),
"_target_os_type": buck.target_os_type_arg(),
}
),
)
config_setting = prelude_rule(
name = "config_setting",
docs = "",
examples = None,
further = None,
attrs = (
# @unsorted-dict-items
{
"constraint_values": attrs.list(attrs.configuration_label(), default = []),
"values": attrs.dict(key = attrs.string(), value = attrs.string(), sorted = False, default = {}),
}
),
)
configuration_alias = prelude_rule(
name = "configuration_alias",
docs = "",
examples = None,
further = None,
attrs = (
# @unsorted-dict-items
{
# configuration_alias acts like alias but for configuration rules.
# The configuration_alias itself is a configuration rule and the `actual` argument is
# expected to be a configuration rule as well.
"actual": attrs.dep(pulls_and_pushes_plugins = plugins.All),
}
),
)
configured_alias = prelude_rule(
name = "configured_alias",
docs = "",
examples = None,
further = None,
attrs = (
# @unsorted-dict-items
{
# The 'actual' attribute of configured_alias is a configured_label, which is
# currently unimplemented. Map it to dep so we can simply forward the providers.
# TODO(nga): "actual" attribute exists here only to display it in query,
# actual `actual` attribute used in rule implementation is named `configured_actual`.
# Logically this should be `attrs.configuration_label`, but `configuration_label`
# is currently an alias for `attrs.dep`, which makes non-transitioned dependency
# also a dependency along with transitioned dependency. (See D40255132).
"actual": attrs.label(),
"configured_actual": attrs.option(attrs.configured_dep(), default = None),
"fallback_actual": attrs.option(attrs.dep(), default = None),
"contacts": attrs.list(attrs.string(), default = []),
"default_host_platform": attrs.option(attrs.configuration_label(), default = None),
"labels": attrs.list(attrs.string(), default = []),
"licenses": attrs.list(attrs.source(), default = []),
# We use a separate field instead of re-purposing `actual`, as we want
# to keep output format compatibility with v1.
# If `configured_actual` is `None`, fallback to this unconfigured dep.
"platform": attrs.option(attrs.configuration_label(), default = None),
"propagate_flavors": attrs.bool(default = False),
}
),
)
constraint_setting = prelude_rule(
name = "constraint_setting",
docs = "",
examples = None,
further = None,
attrs = (
{
}
),
)
constraint_value = prelude_rule(
name = "constraint_value",
docs = "",
examples = None,
further = None,
attrs = (
# @unsorted-dict-items
{
"constraint_setting": attrs.configuration_label(),
}
),
)
export_file = prelude_rule(
name = "export_file",
docs = """
An `export_file()` takes a single file or folder and exposes it so other rules can
use it.
""",
examples = """
The best way to see how the `export_file()` rule works is with some examples. The
common case is:
```
export_file(
name = 'example.html',
)
# This is equivalent to
export_file(
name = 'example.html',
src = 'example.html',
out = 'example.html',
)
```
It is sometimes useful to refer to the file not by its path, but by a more logical name:
```
export_file(
name = 'example',
src = 'example.html',
)
# This is equivalent to
export_file(
name = 'example',
src = 'example.html',
out = 'example.html',
)
```
Finally, there are occasions where you want to export a file more than once but want to copy it to
a different name for each output:
```
export_file(
name = 'runner',
src = 'RemoteRunner.html',
)
export_file(
name = 'runner_hta',
src = 'RemoteRunner.html',
out = 'RemoteRunner.hta',
)
```
Using the `export_file()` rule is also simple:
```
export_file(
name = 'example',
src = 'example.html',
)
genrule(
name = 'demo',
out = 'result.html',
cmd = 'cp $(location :example) $OUT',
)
```
""",
further = None,
attrs = (
# @unsorted-dict-items
{
"src": attrs.option(attrs.source(allow_directory = True), default = None, doc = """
The path to the file that should be exported.
"""),
"out": attrs.option(attrs.string(), default = None, doc = """
The name which the file will be called if another rule depends on it instead of the name it
already has.
"""),
"mode": attrs.option(attrs.enum(ExportFileDescriptionMode), default = None, doc = """
How files are referenced internally in buck.
If set to 'copy', then a full copy will be made into the new location in buck-out.
If set to 'reference', the original file will be used by internal build rules in-place.
However, this mode does not work across repositories or if the 'out' property is set.
For read-only operations, 'reference' can be more performant.
"""),
"contacts": attrs.list(attrs.string(), default = []),
"default_host_platform": attrs.option(attrs.configuration_label(), default = None),
"labels": attrs.list(attrs.string(), default = []),
"licenses": attrs.list(attrs.source(), default = []),
}
),
)
external_test_runner = prelude_rule(
name = "external_test_runner",
docs = "",
examples = None,
further = None,
attrs = (
# @unsorted-dict-items
{
"binary": attrs.dep(),
"contacts": attrs.list(attrs.string(), default = []),
"default_host_platform": attrs.option(attrs.configuration_label(), default = None),
"labels": attrs.list(attrs.string(), default = []),
"licenses": attrs.list(attrs.source(), default = []),
}
),
)
filegroup = prelude_rule(
name = "filegroup",
docs = """
This rule provides access to a set of files.
Files are accessible to `genrule()`s by using their relative path
after a `$(location)` string parameter macro.
Other rules may handle `filegroup()` rules natively for attributes
such as resources.
""",
examples = """
In this example a target exports `.xml` files from all subdirectories
in `resources`.
```
filegroup(
name = 'example',
srcs = glob(['resources/**/*.xml']),
)
genrule(
name = 'process_xml',
out = 'processed.xml',
cmd = '$(exe //example:tool) -in $(location :example)/resources/file.xml > $OUT',
)
```
""",
further = None,
attrs = (
# @unsorted-dict-items
{
"srcs": attrs.named_set(attrs.source(allow_directory = True), sorted = False, default = [], doc = """
The set of files to include in this rule.
"""),
"copy": attrs.bool(default = True),
"contacts": attrs.list(attrs.string(), default = []),
"default_host_platform": attrs.option(attrs.configuration_label(), default = None),
"labels": attrs.list(attrs.string(), default = []),
"licenses": attrs.list(attrs.source(), default = []),
"out": attrs.option(attrs.string(), default = None, doc = """
The name of the output directory. Defaults to the rule's name.
"""),
}
),
)
genrule = prelude_rule(
name = "genrule",
docs = """
A `genrule()` is used to generate files from a shell
command. It must produce a single output file or folder.
""",
examples = """
This genrule() uses a Python script to derive a new
`AndroidManifest.xml` from an
`AndroidManifest.xml` in the source tree.
Note you don't need to prepend execution commands with
`python`: Buck knows how to execute different
kinds of binaries using `$(exe)` command.
```
genrule(
name = 'generate_manifest',
srcs = [
'AndroidManifest.xml',
],
bash = '$(exe //python/android:basic_to_full) ' \
'$SRCDIR/AndroidManifest.xml > $OUT',
cmd_exe = '$(exe //python/android:basic_to_full) ' \
'%SRCDIR%\\AndroidManifest.xml > %OUT%',
out = 'AndroidManifest.xml',
)
```
```
genrule(
name = 'generate_manifest_with_named_outputs',
srcs = [
'AndroidManifest.xml',
],
bash = '$(exe //python/android:basic_to_full) ' \
'$SRCDIR/AndroidManifest.xml > $OUT/AndroidManifest.xml',
cmd_exe = '$(exe //python/android:basic_to_full) ' \
'%SRCDIR%\\AndroidManifest.xml > %OUT%\\AndroidManifest.xml',
outs = {
"manifest": [ "AndroidManifest.xml" ],
},
default_outs = [ "AndroidManifest.xml" ],
)
```
For named outputs, build with any of the following:
```
buck build //:generate_manifest_with_named_outputs
```
```
buck build //:generate_manifest_with_named_outputs[manifest]
```
Consume in `srcs` with:
```
export_file(
name = "magic1",
src = ":generate_manifest_with_named_outputs",
out = "some_dir_to_copy_to/AndroidManifest.xml",
)
```
```
export_file(
name = "magic2",
src = ":generate_manifest_with_named_outputs[manifest]",
out = "some_dir_to_copy_to/AndroidManifest.xml",
)
```
Note that `magic1` consumes `generate_manifest_with_named_outputs`'s default
output. `magic2` consumes `generate_manifest_with_named_outputs`'s named
output "manifest," which happen to be pointing to the same output as the default output in this
case, but they do not have to point to the same output.
""",
further = None,
attrs = (
# @unsorted-dict-items
genrule_common.srcs_arg() |
genrule_common.cmd_arg() |
genrule_common.bash_arg() |
genrule_common.cmd_exe_arg() |
genrule_common.type_arg() |
genrule_common.weight_arg() |
{
"out": attrs.option(attrs.string(), default = None, doc = """
The name of the output file or directory. The complete path to this
argument is provided to the shell command through
the `OUT` environment variable. Only one of `out`
or `outs` may be present.
"""),
"outs": attrs.option(attrs.dict(key = attrs.string(), value = attrs.set(attrs.string(), sorted = False), sorted = False), default = None, doc = """
Mapping defining `named outputs`
to output paths relative to the rule's output directory. Only one of
`out` or `outs` may be present.
Example:
```
genrule(
name = "named_outputs",
outs = {
"output1": [
"out1.txt",
],
"output2": [
"out2.txt",
],
},
default_outs = [ "out1.txt" ],
cmd = "echo something> $OUT/out1.txt && echo another> $OUT/out2.txt",
)
```
Note that a maximum of one value may be present in the list in this map. For example:
```
outs = {
"output1": [
"out1.txt",
],
},
```
is valid, whereas
```
outs = {
"output1": [
"out1.txt",
"out2.txt",
],
},
```
is not.
"""),
"default_outs": attrs.option(attrs.set(attrs.string(), sorted = False), default = None, doc = """
Default output which must be present if the `outs` arg is present. Otherwise does not apply.
If a rule with `outs` is consumed without an output label, the default output is returned. The
default output does not need to be present in any of the named outputs defined in `outs`.
Note that a maximum of one value may be present in this list. For example:
```
default_outs = [ "output_one", ]
```
is valid, whereas
```
default_outs = [ "output_one", "output_two", ]
```
is not.
"""),
"executable_outs": attrs.option(attrs.set(attrs.string(), sorted = False), default = None, doc = """
Only valid if the `outs` arg is present. Dictates which of those named outputs are marked as
executable.
"""),
} |
genrule_common.env_arg() |
genrule_common.environment_expansion_separator() |
{
"enable_sandbox": attrs.option(attrs.bool(), default = None, doc = """
Whether this target should be executed in a sandbox or not.
"""),
"executable": attrs.option(attrs.bool(), default = None, doc = """
Whether the output of the genrule is itself executable. Marking an output as
executable makes `buck run` and `$(exe ...)` macro
expansion work with this target.
"""),
"remote": attrs.option(attrs.bool(), default = None, doc = """
Opts this genrule in to remote execution. Note that it is only safe to
execute a genrule remotely if it is completely hermetic and completely
and correctly describes its dependencies. Defaults to false. This parameter
is unstable. It is subject to removal, default reversal, and other arbitrary
changes in the future.
"""),
"cacheable": attrs.option(attrs.bool(), default = None),
"contacts": attrs.list(attrs.string(), default = []),
"default_host_platform": attrs.option(attrs.configuration_label(), default = None),
"labels": attrs.list(attrs.string(), default = []),
"licenses": attrs.list(attrs.source(), default = []),
"need_android_tools": attrs.bool(default = False),
"_exec_os_type": buck.exec_os_type_arg(),
}
),
)
http_archive = prelude_rule(
name = "http_archive",
docs = """
An `http_archive()` rule is used to download and extract archives
from the Internet to be used as dependencies for other rules. These rules are
downloaded by running `fetch`, or can be downloaded as part of
`build` by setting `.buckconfig`
""",
examples = """
Using `http_archive()`, third party packages can be downloaded from
an `https` URL and used in other library types.
```
http_archive(
name = 'thrift-archive',
urls = [
'https://internal-mirror.example.com/bin/thrift-compiler-0.1.tar.gz.badextension',
],
sha256 = '7baa80df284117e5b945b19b98d367a85ea7b7801bd358ff657946c3bd1b6596',
type='tar.gz',
strip_prefix='thrift-compiler-0.1'
)
genrule(
name = 'thrift-compiler-bin',
out = 'thrift',
cmd = 'cp $(location :thrift-archive)/bin/thrift $OUT',
executable = True,
)
genrule(
name="my-thrift-lib-cpp2",
cmd="$(exe :thrift-compiler-bin) --gen cpp2 -o $OUT $(location //:thrift-file)",
out="gen-cpp2",
)
```
""",
further = None,
attrs = (
# @unsorted-dict-items
remote_common.urls_arg() |
remote_common.sha256_arg() |
remote_common.unarchive_args() |
{
"contacts": attrs.list(attrs.string(), default = []),
"default_host_platform": attrs.option(attrs.configuration_label(), default = None),
"labels": attrs.list(attrs.string(), default = []),
"licenses": attrs.list(attrs.source(), default = []),
"sha1": attrs.option(attrs.string(), default = None),
}
),
)
http_file = prelude_rule(
name = "http_file",
docs = """
An `http_file()` rule is used to download files from the Internet to be used as
dependencies for other rules. This rule only downloads single files, and can
optionally make them executable (see `http_file()executable`)
These rules are downloaded by running `fetch`, or can
be downloaded as part of `build` by setting `.buckconfig`
""",
examples = """
Using `http_file()`, third party packages can be downloaded from
an `https` URL and used in java libraries.
```
http_file(
name = 'guava-23-bin',
urls = [
'http://search.maven.org/remotecontent?filepath=com/google/guava/guava/23.0/guava-23.0.jar',
],
sha256 = '7baa80df284117e5b945b19b98d367a85ea7b7801bd358ff657946c3bd1b6596',
)
http_file(
name = 'guava-23-sources',
urls = [
'http://search.maven.org/remotecontent?filepath=com/google/guava/guava/23.0/guava-23.0-sources.jar',
],
sha256 = '37fe8ba804fb3898c3c8f0cbac319cc9daa58400e5f0226a380ac94fb2c3ca14',
)
prebuilt_java_library(
name = 'guava-23',
binary_jar = ':guava-23-bin',
source_jar = ':guava-23-source',
)
```
Tooling can also be fetched with `http_file()` and used by a `genrule()`.
```
genrule(
name="my-thrift-lib-cpp2",
cmd="$(exe :thrift-compiler-bin) --gen cpp2 -o $OUT $(location //:thrift-file)",
out="gen-cpp2",
)
http_file(
name = 'thrift-compiler-bin',
url = 'https://internal-mirror.example.com/bin/thrift-compiler',
sha256 = 'c24932ccabb66fffb2d7122298f7f1f91e0b1f14e05168e3036333f84bdf58dc',
executable = True,
)
```
Here's an example of a `http_file()` using a mvn URI which uses a Maven classifier.
```
http_file(
name = 'guava-23-bin',
urls = [
'mvn:com.google.guava:guava:jar:23.0',
],
sha256 = '7baa80df284117e5b945b19b98d367a85ea7b7801bd358ff657946c3bd1b6596',
)
```
""",
further = None,
attrs = (
# @unsorted-dict-items
remote_common.urls_arg() |
remote_common.sha256_arg() |
{
"out": attrs.option(attrs.string(), default = None, doc = """
An optional name to call the downloaded artifact. Buck will generate a default name if one is not
provided that uses the `name` of the rule.
"""),
"executable": attrs.option(attrs.bool(), default = None, doc = """
Whether or not the file should be made executable after downloading. If true,
this can also be used via `run` and the
`$(exe )` `string parameter macros`
"""),
"contacts": attrs.list(attrs.string(), default = []),
"default_host_platform": attrs.option(attrs.configuration_label(), default = None),
"labels": attrs.list(attrs.string(), default = []),
"licenses": attrs.list(attrs.source(), default = []),
"sha1": attrs.option(attrs.string(), default = None),
}
),
)
platform = prelude_rule(
name = "platform",
docs = "",
examples = None,
further = None,
attrs = (
# @unsorted-dict-items
{
"constraint_values": attrs.list(attrs.configuration_label(), default = []),
"deps": attrs.list(attrs.configuration_label(), default = []),
}
),
)
remote_file = prelude_rule(
name = "remote_file",
docs = """
A `remote_file()` rule is used to download files from the Internet to be used as
dependencies for other rules. These rules are downloaded by running `fetch`, or can
be downloaded as part of `build`. See the note there about the
`.buckconfig` setting to configure that.
""",
examples = """
Here's an example of a `remote_file()` using an `https` URL.
```
remote_file(
name = 'android-ndk-r10e-darwin-x86_64',
url = 'https://dl.google.com/android/ndk/android-ndk-r10e-darwin-x86_64.bin',
sha1 = 'b57c2b9213251180dcab794352bfc9a241bf2557',
)
```
Here's an example of a `remote_file()` using a `mvn` URL being referenced
by a `prebuilt_jar()`.
```
prebuilt_jar(
name = 'jetty-all',
binary_jar = 'jetty-all-9.2.10.v20150310.jar',
source_jar = ':jetty-source',
)
remote_file(
name = 'jetty-source',
out = 'jetty-all-9.2.10.v20150310-sources.jar',
url = 'mvn:org.eclipse.jetty.aggregate:jetty-all:src:9.2.10.v20150310',
sha1 = '311da310416d2feb3de227081d7c3f48742d7075',
)
```
Here's an example of a `remote_file()` using a `mvn` URI which uses a
non-default maven repository host.
```
remote_file(
name = 'jetty-source',
out = 'jetty-all-9.2.10.v20150310-sources.jar',
url = 'mvn:https://maven-repo.com:org.eclipse.jetty.aggregate:jetty-all:src:9.2.10.v20150310',
sha1 = '311da310416d2feb3de227081d7c3f48742d7075',
)
```
Here's an example of a `remote_file()` using a `mvn` URI which uses a
Maven classifier.
```
remote_file(
name = 'groovy-groovysh-indy',
out = 'jetty-all-9.2.10.v20150310-sources.jar',
url = 'mvn:org.codehaus.groovy:groovy-groovysh:jar:indy:2.4.1',
sha1 = '1600fde728c885cc9506cb102deb1b494bd7c130',
)
```
""",
further = None,
attrs = (
# @unsorted-dict-items
{
"url": attrs.string(validate = validate_uri, doc = """
You can specify an `http`, `https`, or a `mvn` URL. If you
specify a `mvn` URL, it will be decoded as described in the
javadocs for MavenUrlDecoder See the example section below.
"""),
"vpnless_url": attrs.option(attrs.string(), default = None, doc = """
An optional additional URL from which this resource can be downloaded when
off VPN. Meta-internal only.
"""),
"sha1": attrs.string(default = "", doc = """
The [`SHA-1`](//wikipedia.org/wiki/SHA-1) hash of the downloaded artifact.
Buck verifies this is correct and fails the fetch command if it doesn't match in order to
guarantee repeatable builds.
"""),
"out": attrs.option(attrs.string(), default = None, doc = """
An optional name to call the downloaded artifact. Buck will generate a default name if one is not
provided that uses the `name` of the rule.
"""),
"type": attrs.option(attrs.enum(RemoteFileType), default = None, doc = """
An optional type of the downloaded file.
`data`
Regular data file.
`executable`
Executable file. Buck will ensure that output has appropriate permissions if applicable.
`exploded_zip`
Zip archive which will be automatically unzipped into an output directory.
"""),
"contacts": attrs.list(attrs.string(), default = []),
"default_host_platform": attrs.option(attrs.configuration_label(), default = None),
"labels": attrs.list(attrs.string(), default = []),
"licenses": attrs.list(attrs.source(), default = []),
"sha256": attrs.option(attrs.string(), default = None),
}
),
)
test_suite = prelude_rule(
name = "test_suite",
docs = """
A `test_suite()` is used to create a grouping of tests that should all be run by just testing this rule.
This rule can then be given to `buck test`, and all tests that it depends on will be invoked.
Note that the test\\_suite() target is not tested itself, it just tells buck to run other
tests. It will not show up in calls to the external runner nor in the normal test output.
""",
examples = """
This test\\_suite() sets up two different sets of tests to run, 'all' tests and 'slow' tests. Note that `all_tests` can depend on `slow_tests`, and all three tests are run.
```
# instrumentation_tests/BUCK: