-
Notifications
You must be signed in to change notification settings - Fork 1
/
BUILD.gn
1870 lines (1736 loc) · 56.4 KB
/
BUILD.gn
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 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/board.gni")
import("//build/compiled_action.gni")
import("//build/config/build_api_module.gni")
import("//build/config/compiler.gni")
import("//build/drivers/check_included_drivers.gni")
import("//build/drivers/create_all_drivers_doc.gni")
import("//build/images/args.gni")
import("//build/info/info.gni")
import("//build/product.gni")
import("//build/rust/config.gni")
import("//build/security.gni")
import("//build/testing/platforms.gni")
import("//build/testing/validated_test_types_group.gni")
import("//build/toolchain/goma.gni")
import("//build/toolchain/rbe.gni")
import("//build/toolchain/zircon/clang.gni")
import("//build/zbi/zbi.gni")
declare_args() {
## NOTE: The "legacy_*" versions of these args are part of multi-month
# transition to using product assembly and separate the definition of
# the platform from the definition of the product.
#
# These args replace the use of the non-"legacy_" prefixed arg
# throughout the product definition files (//products/**/*.gni).
#
# NOTE: These "legacy_*" args will go away when the long-term transition to
# product assembly is complete, and they should not be relied upon
# within developer's own args.gn files or BUILD.gn files.
# If you add fuchsia_driver_package labels to this variable, any drivers in these packages will
# be visible to Driver Manager. These package labels are also considered to be in the
# 'base' package set (for more info see 'base_package_labels').
base_driver_package_labels = []
# If you add package labels to this variable, the packages will be included in
# the 'base' package set, which represents the set of packages that are part
# of an OTA. These packages are updated as an atomic unit during an OTA
# process and are immutable and are a superset of the TCB (Trusted Computing
# Base) for a product. These packages are never evicted by the system.
base_package_labels = []
legacy_base_package_labels = []
# If you add package labels to this variable, the packages will be included
# in the 'cache' package set, which represents an additional set of software
# that is made available on disk immediately after paving and in factory
# flows. These packages are updated with an OTA, and can also be updated
# ephemerally. This cache of software can be evicted by the system if storage
# pressure arises or other policies indicate.
cache_package_labels = []
legacy_cache_package_labels = []
# If you add package labels to this variable, the packages will be included
# in the 'universe' package set, which represents all software that is
# produced that is to be published to a package repository or to the SDK by
# the build. The build system ensures that the universe package set includes
# the base and cache package sets, which means you do not need to redundantly
# include those labels in this variable.
universe_package_labels = []
# If you add package labels to this variable, the packages will be included in
# the 'discoverable' package set, as defined by RFC-0212 "Package Sets":
# https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/0212_package_sets
#
# They will be compiled, and published, but not added as dependencies of the
# assembled images, and so will not be able to cause the inclusion of
# 'config_data' or 'shell_command' entries.
#
# As these cannot be part of the legacy AIB for a product, there is no
# "legacy" version of this argument.
discoverable_package_labels = []
# These are arguments used by Infra (and 'fx set') to add tests to a build
# configuration without necessarily adding them to the assembled product, and
# validating that they only contain tests of the type in their name.
# Fully hermetic tests (both by packaging and at runtime)
hermetic_test_package_labels = []
# Non-hermetic tests (at runtime). Non-test packages found in this group will
# be flagged as an error by the build.
test_package_labels = []
# Host-driven, "end-to-end" tests that run on a Fuchsia image (either real
# hardware or emulated).
e2e_test_labels = []
# Host-only tests. These cannot have any dependency on an assembled platform
# image, or the compiled OS itself, not even for their host_test_data().
#
# These will be added to the build using the host toolchain.
host_test_labels = []
# A developer-only argument that is used to add tests to the build without
# going through the test-type validate that the above sets of tests are.
# These are always a dependency of the main product assembly.
developer_test_labels = []
# If you add labels to this variable, these will be included in the 'host'
# artifact set, which represents an additional set of host-only software that
# is produced by the build.
#
# These will be added to the build using the host toolchain.
host_labels = []
# A file containing historical test duration data for this build
# configuration, used used by testsharder to evenly split tests across
# shards. It should be set for any builds where testsharder will be run
# afterwards.
test_durations_file = ""
# Extra idk_archive() labels to be uploaded to the artifacts store. This is an
# extension mechanism for IDK bits outside of the main repository.
sdk_archive_labels = []
}
if (host_os == "mac") {
import("//build/config/mac/mac_sdk.gni")
}
assert(
current_toolchain == default_toolchain,
"The root build file (//BUILD.gn) can only be processed in the `default_toolchain`.")
###
### fx integration.
###
# Write a file that can be sourced by `fx`. This file is produced
# by `gn gen` and is not known to Ninja at all, so it has nothing to
# do with the build itself. Its sole purpose is to leave bread
# crumbs about the settings `gn gen` used for `fx` to use later.
_relative_build_dir = rebase_path(root_build_dir, "//", "//")
_host_out_dir = rebase_path(host_out_dir, root_build_dir)
_fx_config_lines = [
"# Generated by `gn gen`.",
"FUCHSIA_BUILD_DIR='${_relative_build_dir}'",
"FUCHSIA_ARCH='${target_cpu}'",
"FUCHSIA_PRODUCT_NAME=${build_info_product}",
"FUCHSIA_BOARD_NAME=${board_name}",
"FUCHSIA_ZBI_COMPRESSION=zstd",
"HOST_OUT_DIR='${_host_out_dir}'",
"USE_GOMA=$use_goma",
]
if (use_goma && goma_dir != prebuilt_goma_dir) {
_fx_config_lines += [ "GOMA_DIR=" + rebase_path(goma_dir) ]
}
write_file("$root_build_dir/fx.config", _fx_config_lines)
generated_file("default_toolchain_name.txt") {
outputs = [ "$root_build_dir/default_toolchain_name.txt" ]
contents = default_toolchain
}
###
### Build API modules.
###
# This is the top-level build API module that just lists all the others.
# Each element of the list is the simple name of the API module; the
# module's contents are found at "$root_build_dir/$target_name.json".
#
# Type: list(string)
#
build_api_module("api") {
testonly = true
data_keys = [ "build_api_modules" ]
deps = [
":all_package_manifest_paths",
":archives",
":args",
":assembly_input_archives",
":assembly_manifests",
":bazel_build_events_logs",
":bazel_sdk_info",
":binaries",
":boards",
":build_info",
":checkout_artifacts",
":cipd_assembly_artifacts",
":clippy_target_mapping",
":detailed_size_checker_data",
":fuzzers",
":generated_sources",
":gerrit_size_report",
":golden_files",
":images",
":licenses",
":package-repositories",
":platforms",
":prebuilt_binaries",
":prebuilt_package_flavors",
":product_bundles",
":product_size_checker_output",
":rbe_config",
":sdk_archives",
":test_components",
":test_durations",
":test_list_location",
":tests",
":tool_paths",
":triage_sources",
":vnames_config",
"//build/images/archive",
"//sdk:sdk_source_set_list",
"//sdk/ctf:ctf_artifacts",
]
}
if (current_toolchain == default_toolchain) {
# This target is used to generate, at `gn gen` time a file
# that is exclusively used by //build/api/client.py.
# NOTE: nothing should depend on this target.
generated_file("build_api_client_info") {
deps = [ "//:api" ]
outputs = [ "$root_build_dir/build_api_client_info" ]
data_keys = [ "build_api_client_info" ]
walk_keys = [ "build_api_client_info_barrier" ]
testonly = true
visibility = [] # Empty on purpose
}
# This target generates a file that contains the path to the build API client
# script, relative to the build directory (e.g. '../../build/api/client').
#
# Many tools that process the build API files only have a path to the build
# directory, and do not know where the Fuchsia source directory itself is
# located. By reading this file, they can retrieve this information easily,
# without relying on fragile heuristics. This file should always be
# generated at `gn gen` time, and nothing should depend on it.
generated_file("build_api_client_path") {
# IMPORTANT: Do not include a newline at the end of "contents"
contents = rebase_path("//build/api/client", root_build_dir)
outputs = [ "$root_build_dir/build_api_client_path" ]
visibility = [] # Empty on purpose.
}
}
# This describes the location of the package repository, in:
# "$root_build_dir/package-repositories.json"
#
# Type: list(scope)
#
# path
# Required: Path to the package repository, relative to $root_build_dir.
# Type: path relative to $root_build_dir
#
# targets
# Required: Path to the targets.json file with the contents in this
# package repository, relative to $root_build_dir.
# Type: path relative to $root_build_dir
#
# blobs
# Required: Path to the blobs directory in this package repository,
# relative to $root_build_dir.
# Type: path relative to $root_build_dir
#
build_api_module("package-repositories") {
testonly = true
data_keys = [ "package_repository" ]
deps = [ "//build/images/updates" ]
}
# This describes all the archives the build can produce, in:
# "$root_build_dir/archives.json"
#
# TODO(https://fxbug.dev/42119886): Delete me ASAP. Archives are targets that necessarily
# depend on 'everything'; targets like this should be migrated away from.
#
# Type: list(scope)
#
# name
# Required: The primary way that this archive is known to consumers.
# The tuple of ($name, $type) should be unique.
# Type: string
#
# path
# Required: Path to where the archive is found, relative to $root_build_dir.
# Type: path relative to $root_build_dir
#
# type
# Required: "zip" or "tgz".
# Type: string
#
build_api_module("archives") {
testonly = true
data_keys = [ "archives" ]
deps = [
"//build/gn:archives",
"//build/images/archive",
]
}
# TODO(crbug.com/gn/132): Remove when GN emits the equivalent information
# itself.
#
# in file: "$root_build_dir/args.json"
#
# This just regurgitates the build arguments specified to `gn gen`. This is
# the exact JSON representation of the settings in "$root_build_dir/args.gn".
# It does not include build arguments left to their default values. So to
# reproduce the settings of this build, one could put in `args.gn`:
# ```
# forward_variables_from(read_file("args.json", "json"), "*")
# ```
# Type: scope
#
build_api_module("args") {
contents = read_file("$root_build_dir/args.gn", "scope")
}
# Describes the location where the Bazel SDK is generated.
#
# See //build/bazel:generate_fuchsia_sdk_repository for more details.
#
#
# Type: list(scope)
#
# location
# Required: Directory where the Bazel SDK is generated
# Type: string
#
#
build_api_module("bazel_sdk_info") {
testonly = true
data_keys = [ "bazel_sdk_info" ]
deps = [ "//build/bazel:generate_fuchsia_sdk_repository" ]
}
# Describes the location of Bazel build events log files
# for all Bazel invocations from Ninja. For context, see
# https://bazel.build/remote/bep
#
# Type: list(scope)
#
# gn_label
# Required: GN label of action invoking a Bazel build command.
# Type: string
#
# build_events_log
# Required: Path to build event log file.
# Type: Path relative to build directory.
#
# format
# Required: Format of log file, can be "binary", "text" or "json"
# Type: string
#
#
build_api_module("bazel_build_events_logs") {
testonly = true
data_keys = [ "bazel_build_events_log" ]
deps = [
":default",
"//build/bazel/bazel_sdk:bazel_sdk_tests",
]
}
# This describes all the binaries linked by the build.
#
# This enumerates each linked binary (executable, shared library, or
# loadable/"plug-in" module) used by the build, or produced by the build.
#
# This includes host tools, kernels, boot loaders, drivers, as well as
# normal executables. This also includes prebuilt toolchain runtime
# libraries that end up in image files. It does not yet include any
# non-native binary formats.
#
# For non-prebuilts, this is meant to reach the entire dependency graph
# of all binaries that the build would ever produce. Not every binary
# described is necessarily actually produced by any given Ninja run. Either
# the $debug or the $dist file for any individual binary can be passed to
# Ninja as a specific target argument to ensure it's built and
# up to date before making use of that binary. Like all build_api_module()
# targets, the top-level "binaries" target serves as a Ninja target to
# request that every binary described be built.
#
# Note that in certain cases, the paths in `debug` and `dist` will
# point out of the build tree, and thus cannot be used as Ninja targets.
# This happens for prebuilts or binaries produced by the Zircon build.
#
# Type: list(scope)
#
# cpu
# Required: CPU architecture the binary is for, e.g. "arm64" or "x64".
# Type: string
#
# os
# Required: OS the binary is for, e.g. "fuchsia", "linux", or "mac".
# Type: string
#
# environment
# Required: The ${toolchain_environment} name of what specific
# execution this was built for, e.g. "user", "host", "guest". The
# tuple of ($cpu, $os, $environment) should indicate what hardware and
# software environment this binary is compatible with.
# Type: string
#
# label
# Required: The GN label of the binary target.
# Type: label_with_toolchain
#
# type
# Required: The type of binary.
# Type: "executable" or "shared_library" or "loadable_module"
#
# debug
# Required: Path to where the unstripped or separate debug file is
# found, relative to $root_build_dir. If $dist is omitted, this
# is also the file that is used at runtime.
# Type: path relative to $root_build_dir
#
# dist
# Optional: Path to where the stripped binary for deployment/execution is
# found, relative to $root_build_dir. This binary may be required for
# some debugging tasks if $debug is a separate debug file rather than
# an unstripped file. It should exactly match the binary that will be
# seen on devices or run directly on hosts.
# Type: path relative to $root_build_dir
#
# elf_build_id
# Optional: Path to a file containing the lowercase ASCII hexadecimal
# representation of the ELF build ID in this binary. This is omitted
# for OS environments that don't use ELF. For an ELF binary that
# doesn't have a build ID note, this key will be present but point to
# an empty file.
# Type: path relative to $root_build_dir
#
# breakpad
# Optional: Path to the breakpad symbol file for the debug binary. This
# will only be present if $output_breakpad_syms was set.
# Type: path relative to $root_build_dir
build_api_module("binaries") {
testonly = true
data_keys = [ "binaries" ]
deps = [ ":default" ]
}
# Lists the board configurations that are defined in this build.
#
# Type: list (scope)
#
# label
# Required: The GN label for the board_configuration target
#
# outdir
# Required: The path (relative to the root out dir) of the directory that
# contains the board configuration.
#
build_api_module("boards") {
testonly = true
data_keys = [ "board_configs" ]
deps = [ "//boards" ]
}
# Lists the board input bundles that are defined in this build.
#
# Type: list (scope)
#
# label
# Required: The GN label for the board_configuration target
#
# outdir
# Required: The path (relative to the root out dir) of the directory that
# contains the board input bundle.
#
build_api_module("board_input_bundles") {
testonly = true
data_keys = [ "board_input_bundles" ]
deps = [ "//boards" ]
}
# Describes the configuration of the build in the file:
# "$root_build_dir/build_info.json"
#
# Type: list(scope)
#
# version
# Optional: The version of the build. Present during official builds.
# Type: string
#
# configurations
# Required: The list of product/board configurations within the build.
# Each `configurations` entry is a scope that contains both a product
# and board specification.
# Type: list(scope)
#
build_api_module("build_info") {
testonly = true
contents = {
version = build_info_version
# A list to accommodate the future of a build that support building multiple
# (board, product) pairs.
configurations = [
{
board = build_info_board
product = build_info_product
},
]
}
}
# Artifacts from the checkout. Though a priori unrelated to the build, they are
# useful to track here.
#
# in file: "$root_build_dir/checkout_artifacts.json"
#
# Type: list(scope)
#
# name
# Required: The primary way that this file is known to consumers.
# The name should be unique among other entries.
# Type: string
#
# path
# Required: Path to where the file is found, relative to $root_build_dir.
# Type: path relative to $root_build_dir
#
# type
# Required: The file format (e.g., "txt" or "xml").
# Type: string
#
build_api_module("checkout_artifacts") {
testonly = true
data_keys = [ "checkout_artifacts" ]
deps = [ ":checkout_artifacts.metadata" ]
}
group("checkout_artifacts.metadata") {
testonly = true
visibility = [ ":checkout_artifacts" ]
metadata = {
checkout_artifacts = [
{
# TODO(https://fxbug.dev/42119886): Remove `archive` field. This is a signal to
# include the this file in the archive.
archive = true
name = "jiri_snapshot"
path = rebase_path("//.jiri_root/update_history/latest", root_build_dir)
type = "xml"
},
{
name = "ssh_authorized_key"
path = rebase_path("//.ssh/authorized_keys", root_build_dir)
type = "txt"
},
{
name = "ssh_private_key"
path = rebase_path("//.ssh/pkey", root_build_dir)
type = "txt"
},
]
}
}
# This describes all the generated source files in the build.
#
# The intent is that telling Ninja to build all these individual files
# will be the minimal work sufficient for source code analysis of all
# the files described in the compilation database to be viable.
#
# Type: list(path relative to $root_build_dir)
#
build_api_module("generated_sources") {
testonly = true
data_keys = [ "generated_sources" ]
deps = [
"//build/images/updates:packages",
"//sdk",
]
}
# This describes all golden files in the build, as defined by `golden_files()`.
#
# Type: list(scope)
#
# * name
# - Required: The name of the target defining the golden files.
# - Type: string
#
# * label
# - Required: The label toolchain of the associated target.
# - Type: label_with_toolchain
#
# * stamp
# - Required: The stamp file of the associated diff check.
# - Type: build directory -relative path
#
# * files
# - Required: The associated golden file comparisons.
# - Type: list(scope)
#
# Each scope contains:
#
# * golden
# - Required: A golden file.
# - Type: source-relative path
#
# * candidate
# - Required: The candidate version of the file, to be compared against the
# golden.
# - Type: build directory -relative path
#
build_api_module("golden_files") {
testonly = true
data_keys = [ "golden_files" ]
deps = [ ":default" ]
}
# Describes the "fuzzers" in the build, in the file:
# "$root_build_dir/fuzzers.json"
#
# See //build/fuzzing/fuzzer.gni for more details.
#
#
# Type: list(scope)
#
# fuzzer_package
# Required: Name of a package containing fuzzers.
# Type: string
#
# fuzzers
# Required: The fuzzer binaries included in the associated package.
# Type: list of labels
#
# fuzz_host
# Required: Indicates whether the associated fuzzer binaries were built for
# the host.
# Type: boolean
#
build_api_module("fuzzers") {
testonly = true
data_keys = [ "fuzz_spec" ]
deps = [ "//build/images/updates:packages" ]
}
# This describes all the "image" files the build can produce, in the file:
# "$root_build_dir/images.json"
#
# An "image file" is a binary file that typically ends up on a device
# partition (e.g. kernel, boot loader, partition image, etc).
#
# Consumers of the build should look here for the images to be built.
# The $cpu, $name, and $type fields identify the purpose of each image.
# Consumers are expected to ignore extra images they have no use for or
# whose fields they don't understand.
#
# The $path field indicates where the file is found in the build
# directory. The presence of an image in the list means that the build
# *can* produce it, not that the build *will* produce it. Hence,
# consumers should use $path as an explicit argument to Ninja to ensure
# that each needed image gets built.
#
# Type: list(scope)
#
# cpu
# Required: CPU architecture the image is for, e.g. "arm64" or "x64".
# Type: string
#
# name
# Required: The primary way that this image is known to consumers.
# Note that the name need not be unique within the images list.
# The tuple of ($name, $type, $cpu) should be unique.
# Type: string
#
# fastboot_flash
# Optional: the partition(s) to fastboot flash this image to. As a special
# case, this can be an empty list to indicate a file that may be needed for
# flashing but doesn't necessarily get flashed to a partition, for example
# bootloader unlock credentials.
# Type: list(string)
#
# label
# Required: The GN label of the image target.
# Type: label_with_toolchain
#
# path
# Required: Path to where the file is found, relative to $root_build_dir.
# This is also the argument to Ninja that ensures this image will be built.
# Type: path relative to $root_build_dir
#
# testonly
# Optional: This image includes test code/data not meant for production.
# Type: bool
# Default: false
#
# tags
# Optional: Tags associated with the image. Certain tags may indicate
# to the build API consumer what should be done with the image.
# Type: list(string)
#
# type
# Required: Type of file, e.g. "zbi". This often corresponds to the
# extension used on the image file name, but not always. For many
# miscellaneous formats, this is just "bin" and the consumer is
# expected to understand what the particular format is for particular
# $name, $cpu combinations. Other types include:
# * "zbi": the ZBI (<lib/zbi-format/zbi.h>) format
# * "efi": an EFI executable that an EFI boot loader can load
# * "kernel": some other format loaded by a boot loader or emulator
# * "blk": contents to be written to a storage device or partition
# Type: string
#
# bootserver_pave, bootserver_pave_zedboot, bootserver_netboot
# Optional: flag names under which the associated image should be passed to
# the bootserver when paving, paving zedboot, or netbooting, respectively.
# Type: list(string)
#
# archive
# Optional: Set to true to indicate this image should be part of
# the build archives generated by //build/images/archive.
# Type: bool
# Default: false
#
build_api_module("images") {
testonly = true
walk_keys = [ "images_barrier" ]
data_keys = [ "images" ]
deps = [
# XXX(46415): as the build is specialized by board (bootfs_only)
# for bringup, it is not possible for this to be complete. As this
# is used in the formation of the build API with infrastructure,
# and infrastructure assumes that the board configuration modulates
# the definition of `zircon-a` between bringup/non-bringup, we can
# not in fact have a complete description. See the associated
# conditional at this group also.
"build/images",
# Images who are pulled as part of host interaction tests.
":host",
# There are standalone images outside of the main assembly dependency graph
# which may be specified as data dependencies of select tests.
":tests",
]
}
# Describes the SDK archives that can be built, in the file:
# "$root_build_dir/sdk_archives.json"
#
# * name
# - Required: Name of the SDK.
# - Type: string
#
# * label
# - Required: GN label of the associated `sdk` target.
# - Type: label_with_toolchain
#
# * path
# - Required: Path to the built archive.
# - Type: path relative to $root_build_dir
#
# * os
# - Required: OS is the operating system which the SDK is built for. A value
# of "fuchsia" indicates the SDK is host OS agnostic.
# - Type: string
#
# * cpu
# - Required: CPU architecture which the SDK is built for.
# - Type: string
#
build_api_module("sdk_archives") {
testonly = true
data_keys = [ "sdk_archives" ]
deps = [
# WARNING (https://fxbug.dev/42067830): the driver SDK will soon be removed.
"//sdk:driver_archive",
"//sdk:final_fuchsia_idk",
] + sdk_archive_labels
}
# Describes the platforms available for testing, in the file:
# "$root_build_dir/platforms.json"
#
# TODO(https://fxbug.dev/42055429): the fuchsia platform should not know about such things.
#
# Type: list(scope)
#
build_api_module("platforms") {
testonly = true
contents = []
foreach(platform, test_platforms) {
if (!defined(platform.cpu) || platform.cpu == current_cpu) {
contents += [ platform ]
}
}
}
# This describes where to find all prebuilt binaries, in the file:
# "$root_build_dir/prebuilt_binaries.json"
#
# The `manifest` field will point to another JSON file that is almost a subset
# of the :binaries build API module: the only fields present are `cpu`,
# `debug`, `os`, and `elf_build_id`, which in this case is not a file pointer
# but instead the actual build ID.
#
#
# Type: list(scope)
#
# name
# Required: The name of the collection of prebuilt binaries.
# Type: string
#
# manifest
# Required: The path to the manifest of prebuilt binaires. See note above
# for its schema.
# Type: string
#
build_api_module("prebuilt_binaries") {
testonly = true
data_keys = [ "prebuilt_binaries" ]
deps = [
"//build/images/updates:packages",
"//build/prebuilt",
"//sdk",
]
}
# This describes which flavor was used for each of the prebuilt packages
# which provide multiple flavors to choose from.
#
# in file:
# "$root_build_dir/images.json"
#
# For more information, see: //build/packages/prebuilt_package_with_flavors.gni
#
# Type: list(scope)
#
# package
# Required: The name of the package.
#
# name
# Required: The name of the flavor that is being used.
#
# archive
# Required: The path to the archive that was used.
#
# production_safe
# Required: if 'true' then this flavor is valid for use in production
# contexts.
#
build_api_module("prebuilt_package_flavors") {
testonly = true
data_keys = [ "prebuilt_package_with_flavors" ]
deps = [ "//build/images/updates:packages" ]
}
# Tests in the build.
#
# Below, the "testing root" refers to $root_build_dir on host, and the full
# filesystem path from the root on device.
#
# This rule outputs the tests.json file in the build directory,
# which is aggregated at test time.
#
# The format is documented at
# https://fuchsia.dev/fuchsia-src/reference/testing/tests-json-format
#
# Type: list(scope)
#
# * name
# - Required: Name of test.
# - Type: string
#
# * label
# - Required: GN label associated with the test
# - Type: label_with_toolchain
#
# * path
# - Required: Path to the test's executable.
# - Type: path relative to the testing root.
#
# * cpu, os
# - Required: cpu and os values, respectively, for which this test is
# intended. Defaults to $current_cpu and $current_os if not manually
# specified.
# - Type: string
#
# * disabled
# - Optional: a free-form string indicating a reason for the test being
# disabled.
# - Type: string
#
# * runtime_deps
# - Optional: a JSON file containing a list of root_build_dir-relative
# paths defining ascribed runtime dependencies of the test. These
# dependencies are aggregated via the metadata graph of the associated
# test target under a data key of "test_runtime_deps.
# - Type: path relative to root_build_dir
#
# * isolated
# - Optional: whether the test needs to be run in isolation to other tests.
# - Type: bool
#
# * timeout_secs
# - Optional: the timeout in seconds for the test.
# - Type: int
#
build_api_module("tests") {
testonly = true
data_keys = [ "tests" ]
walk_keys = [ "tests_barrier" ]
deps = [
# Pull in tests from host_labels. This is deprecated, and tests should be
# in //:host_tests instead.
"//:host",
# Pull in tests present in the assembled product image. This is deprecated,
# and tests should be in the various type-specific test groups below.
"//build/images:main_assembly",
# Pull in tests from the various type-specific on-device test groups
"//:e2e_tests",
"//:hermetic_test_packages",
# Pull in tests from the non-device type-specific test groups.
"//:host_tests",
"//:test_packages",
# Pull in tests from the developer
"//:developer_specified_tests",
# While these should be redundant with the above, they way in which they are
# redundant (included via the main assembly) is quite opaque, and so they
# are listed here for developers to be able to see (and to ensure that all
# developer-chosen tests are in the build api, catching any failures to
# include those tests in the assembly.
#
# This is deprecated, and the above type-specific groups should be used
# instead.
":developer_base_packages",
":developer_cache_packages",
":developer_universe_packages",
]
}
# Test components in the build.
#
# Creates list of test components and the realm to run them in if not running
# in the default hermetic realm.
#
# Type: list(scope)
#
# * label
# - Required: GN label associated with the test component
# - Type: label_with_toolchain
#
# * realm
# - Optional: Moniker of the realm to run the test in.
# - Type: Moniker inside the system topology.
#
build_api_module("test_components") {
testonly = true
data_keys = [ "test_components" ]
walk_keys = [ "test_components_barrier" ]
deps = [
# Pull in tests present in the assembled product image. This is deprecated,
# and tests should be in the various type-specific test groups below.
"//build/images:main_assembly",
# Pull in tests from the various type-specific on-device test groups
"//:hermetic_test_packages",
"//:test_packages",
# Pull in tests from the developer
"//:developer_specified_tests",
# While these should be redundant with the above, they way in which they are
# redundant (included via the main assembly) is quite opaque, and so they
# are listed here for developers to be able to see (and to ensure that all
# developer-chosen tests are in the build api, catching any failures to
# include those tests in the assembly.
#
# This is deprecated, and the above type-specific groups should be used
# instead.
":developer_base_packages",
":developer_cache_packages",
":developer_universe_packages",
]
}
# The output location of test-list.json.
#
# Creates a stable build API that users can use to programmatically retrieve
# test-list.json without having to hardcode the location of the file.
#
# Type: list(string): Each entry will be the location of a test-list.json file.
build_api_module("test_list_location") {
testonly = true
data_keys = [ "test_list" ]
deps = [
# Pull in the actual test-list target.
"//:test-list",
]
}
# test-list.json contains the set of tests in the build along with arbitrary