xref: /aosp_15_r20/build/make/tools/releasetools/Android.bp (revision 9e94795a3d4ef5c1d47486f9a02bb378756cea8a)
1// Copyright (C) 2019 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//
16// Module-specific defaults.
17//
18// For module X, if we need to build it both as a library and an executable:
19//  - A default rule `releasetools_X_defaults` is created, which lists `srcs`, `libs` and
20//    `required` properties.
21//  - `python_library_host` and `python_binary_host` are created by listing
22//    `releasetools_X_defaults` in their defaults.
23//
24
25package {
26    default_applicable_licenses: ["Android-Apache-2.0"],
27}
28
29python_defaults {
30    name: "releasetools_add_img_to_target_files_defaults",
31    srcs: [
32        "add_img_to_target_files.py",
33    ],
34    libs: [
35        "ota_metadata_proto",
36        "releasetools_apex_utils",
37        "releasetools_build_image",
38        "releasetools_build_super_image",
39        "releasetools_common",
40        "libavbtool",
41    ],
42    required: [
43        "care_map_generator",
44    ],
45}
46
47python_defaults {
48    name: "releasetools_build_image_defaults",
49    srcs: [
50        "build_image.py",
51    ],
52    libs: [
53        "releasetools_common",
54        "releasetools_fsverity_metadata_generator",
55        "releasetools_verity_utils",
56    ],
57    required: [
58        "blk_alloc_to_base_fs",
59        "e2fsck",
60        "fsck.erofs",
61        "img2simg",
62        "mkfs.erofs",
63        "mkuserimg_mke2fs",
64        "simg2img",
65        "tune2fs",
66        "mkf2fsuserimg",
67        "fsck.f2fs",
68    ],
69}
70
71python_defaults {
72    name: "releasetools_build_super_image_defaults",
73    srcs: [
74        "build_super_image.py",
75    ],
76    libs: [
77        "releasetools_common",
78    ],
79}
80
81python_defaults {
82    name: "releasetools_img_from_target_files_defaults",
83    srcs: [
84        "img_from_target_files.py",
85    ],
86    libs: [
87        "releasetools_build_super_image",
88        "releasetools_common",
89    ],
90}
91
92python_defaults {
93    name: "releasetools_check_target_files_vintf_defaults",
94    srcs: [
95        "check_target_files_vintf.py",
96    ],
97    libs: [
98        "apex_manifest",
99        "releasetools_apex_utils",
100        "releasetools_common",
101    ],
102    required: [
103        "apexd_host",
104        "checkvintf",
105    ],
106}
107
108python_library_host {
109    name: "ota_metadata_proto",
110    srcs: [
111        "ota_metadata.proto",
112    ],
113    proto: {
114        canonical_path_from_root: false,
115    },
116}
117
118cc_library_static {
119    name: "ota_metadata_proto_cc",
120    srcs: [
121        "ota_metadata.proto",
122    ],
123    host_supported: true,
124    recovery_available: true,
125    proto: {
126        canonical_path_from_root: false,
127        type: "lite",
128        export_proto_headers: true,
129    },
130}
131
132java_library_static {
133    name: "ota_metadata_proto_java",
134    host_supported: true,
135    proto: {
136        type: "nano",
137    },
138    srcs: ["ota_metadata.proto"],
139    sdk_version: "9",
140    target: {
141        android: {
142            jarjar_rules: "jarjar-rules.txt",
143        },
144        host: {
145            static_libs: ["libprotobuf-java-nano"],
146        },
147    },
148    visibility: ["//frameworks/base:__subpackages__"],
149}
150
151python_defaults {
152    name: "releasetools_ota_from_target_files_defaults",
153    srcs: [
154        "edify_generator.py",
155        "non_ab_ota.py",
156        "ota_from_target_files.py",
157        "target_files_diff.py",
158    ],
159    libs: [
160        "ota_metadata_proto",
161        "releasetools_check_target_files_vintf",
162        "releasetools_common",
163        "releasetools_verity_utils",
164        "apex_manifest",
165        "care_map_proto_py",
166        "ota_utils_lib",
167    ],
168    required: [
169        "apexd_host",
170        "brillo_update_payload",
171        "checkvintf",
172        "lz4",
173        "toybox",
174        "unpack_bootimg",
175        "deapexer",
176    ],
177    target: {
178        darwin: {
179            // required module "brillo_update_payload" is disabled on darwin
180            enabled: false,
181        },
182    },
183}
184
185//
186// Host libraries.
187//
188
189python_library_host {
190    name: "releasetools_add_img_to_target_files",
191    defaults: [
192        "releasetools_add_img_to_target_files_defaults",
193    ],
194}
195
196python_library_host {
197    name: "releasetools_apex_utils",
198    srcs: [
199        "apex_utils.py",
200    ],
201    libs: [
202        "apex_manifest",
203        "ota_metadata_proto",
204        "releasetools_common",
205    ],
206}
207
208python_library_host {
209    name: "releasetools_build_image",
210    defaults: [
211        "releasetools_build_image_defaults",
212    ],
213}
214
215python_library_host {
216    name: "releasetools_build_super_image",
217    defaults: [
218        "releasetools_build_super_image_defaults",
219    ],
220}
221
222python_library_host {
223    name: "releasetools_check_target_files_vintf",
224    defaults: [
225        "releasetools_check_target_files_vintf_defaults",
226    ],
227}
228
229python_library_host {
230    name: "releasetools_common",
231    srcs: [
232        "blockimgdiff.py",
233        "common.py",
234        "images.py",
235        "rangelib.py",
236        "sparse_img.py",
237    ],
238    data: [
239        ":zip2zip",
240    ],
241    // Only the tools that are referenced directly are listed as required modules. For example,
242    // `avbtool` is not here, as the script always uses the one from info_dict['avb_avbtool'].
243    required: [
244        "aapt2",
245        "boot_signer",
246        "brotli",
247        "bsdiff",
248        "lz4",
249        "mkbootfs",
250        "signapk",
251        "toybox",
252        "unpack_bootimg",
253    ],
254}
255
256python_library_host {
257    name: "releasetools_img_from_target_files",
258    defaults: [
259        "releasetools_img_from_target_files_defaults",
260    ],
261}
262
263python_library_host {
264    name: "releasetools_ota_from_target_files",
265    defaults: [
266        "releasetools_ota_from_target_files_defaults",
267    ],
268}
269
270python_library_host {
271    name: "releasetools_fsverity_metadata_generator",
272    srcs: [
273        "fsverity_metadata_generator.py",
274    ],
275    libs: [
276        "fsverity_digests_proto_python",
277    ],
278}
279
280python_library_host {
281    name: "releasetools_verity_utils",
282    srcs: [
283        "verity_utils.py",
284    ],
285    required: [
286        "append2simg",
287        "build_verity_metadata",
288        "build_verity_tree",
289        "fec",
290    ],
291}
292
293//
294// Host binaries.
295//
296
297python_defaults {
298    name: "releasetools_binary_defaults",
299    version: {
300        py3: {
301            embedded_launcher: true,
302        },
303    },
304    // TODO (b/140144201) Build imgdiff from releasetools_common
305    required: [
306        "aapt2",
307        "boot_signer",
308        "brotli",
309        "bsdiff",
310        "deapexer",
311        "lz4",
312        "mkbootfs",
313        "signapk",
314        "toybox",
315        "unpack_bootimg",
316    ],
317}
318
319python_binary_host {
320    name: "add_img_to_target_files",
321    defaults: [
322        "releasetools_binary_defaults",
323        "releasetools_add_img_to_target_files_defaults",
324    ],
325}
326
327python_library_host {
328    name: "ota_utils_lib",
329    srcs: [
330        "ota_utils.py",
331        "payload_signer.py",
332        "ota_signing_utils.py",
333    ],
334    libs: [
335        "releasetools_common",
336    ],
337}
338
339python_binary_host {
340    name: "merge_ota",
341    version: {
342        py3: {
343            embedded_launcher: true,
344        },
345    },
346    srcs: [
347        "merge_ota.py",
348    ],
349    libs: [
350        "ota_metadata_proto",
351        "update_payload",
352        "care_map_proto_py",
353        "releasetools_common",
354        "ota_utils_lib",
355    ],
356}
357
358python_binary_host {
359    name: "create_brick_ota",
360    version: {
361        py3: {
362            embedded_launcher: true,
363        },
364    },
365    srcs: [
366        "create_brick_ota.py",
367    ],
368    libs: [
369        "ota_utils_lib",
370    ],
371    required: [
372        "signapk",
373    ],
374}
375
376python_binary_host {
377    name: "build_image",
378    defaults: [
379        "releasetools_binary_defaults",
380        "releasetools_build_image_defaults",
381    ],
382}
383
384python_binary_host {
385    name: "build_super_image",
386    defaults: [
387        "releasetools_binary_defaults",
388        "releasetools_build_super_image_defaults",
389    ],
390}
391
392python_binary_host {
393    name: "check_partition_sizes",
394    srcs: [
395        "check_partition_sizes.py",
396    ],
397    libs: [
398        "releasetools_common",
399    ],
400    defaults: [
401        "releasetools_binary_defaults",
402    ],
403}
404
405python_binary_host {
406    name: "check_ota_package_signature",
407    defaults: ["releasetools_binary_defaults"],
408    srcs: [
409        "check_ota_package_signature.py",
410    ],
411    libs: [
412        "releasetools_common",
413    ],
414    required: [
415        "delta_generator",
416    ],
417    target: {
418        darwin: {
419            // required module "delta_generator" is disabled on darwin
420            enabled: false,
421        },
422    },
423}
424
425python_binary_host {
426    name: "check_target_files_signatures",
427    defaults: ["releasetools_binary_defaults"],
428    srcs: [
429        "check_target_files_signatures.py",
430    ],
431    libs: [
432        "releasetools_common",
433    ],
434    required: [
435        "aapt2",
436    ],
437}
438
439python_binary_host {
440    name: "check_target_files_vintf",
441    defaults: [
442        "releasetools_binary_defaults",
443        "releasetools_check_target_files_vintf_defaults",
444    ],
445}
446
447python_binary_host {
448    name: "img_from_target_files",
449    defaults: [
450        "releasetools_binary_defaults",
451        "releasetools_img_from_target_files_defaults",
452    ],
453}
454
455python_defaults {
456    name: "releasetools_find_shareduid_violation_defaults",
457    srcs: [
458        "find_shareduid_violation.py",
459    ],
460    libs: [
461        "releasetools_common",
462    ],
463}
464
465python_binary_host {
466    name: "find_shareduid_violation",
467    defaults: [
468        "releasetools_binary_defaults",
469        "releasetools_find_shareduid_violation_defaults",
470    ],
471}
472
473python_library_host {
474    name: "releasetools_find_shareduid_violation",
475    defaults: [
476        "releasetools_find_shareduid_violation_defaults",
477    ],
478}
479
480python_binary_host {
481    name: "make_recovery_patch",
482    defaults: ["releasetools_binary_defaults"],
483    srcs: [
484        "make_recovery_patch.py",
485    ],
486    libs: [
487        "releasetools_common",
488    ],
489}
490
491python_binary_host {
492    name: "ota_from_target_files",
493    defaults: [
494        "releasetools_binary_defaults",
495        "releasetools_ota_from_target_files_defaults",
496    ],
497}
498
499python_binary_host {
500    name: "ota_from_raw_img",
501    srcs: [
502        "ota_from_raw_img.py",
503    ],
504    main: "ota_from_raw_img.py",
505    defaults: [
506        "releasetools_binary_defaults",
507    ],
508    required: [
509        "delta_generator",
510    ],
511    libs: [
512        "ota_metadata_proto",
513        "releasetools_common",
514        "ota_utils_lib",
515    ],
516}
517
518python_binary_host {
519    name: "ota_package_parser",
520    defaults: ["releasetools_binary_defaults"],
521    srcs: [
522        "ota_package_parser.py",
523        "rangelib.py",
524    ],
525}
526
527python_binary_host {
528    name: "sparse_img",
529    defaults: ["releasetools_binary_defaults"],
530    srcs: [
531        "rangelib.py",
532        "sparse_img.py",
533    ],
534}
535
536python_binary_host {
537    name: "sign_apex",
538    defaults: ["releasetools_binary_defaults"],
539    srcs: [
540        "sign_apex.py",
541    ],
542    libs: [
543        "releasetools_apex_utils",
544        "releasetools_common",
545    ],
546}
547
548python_binary_host {
549    name: "sign_target_files_apks",
550    defaults: ["releasetools_binary_defaults"],
551    srcs: [
552        "sign_target_files_apks.py",
553        "ota_from_raw_img.py",
554    ],
555    libs: [
556        "releasetools_add_img_to_target_files",
557        "releasetools_apex_utils",
558        "releasetools_common",
559        "ota_metadata_proto",
560        "ota_utils_lib",
561        "update_payload",
562    ],
563}
564
565python_binary_host {
566    name: "validate_target_files",
567    defaults: ["releasetools_binary_defaults"],
568    srcs: [
569        "validate_target_files.py",
570    ],
571    libs: [
572        "releasetools_common",
573    ],
574}
575
576python_binary_host {
577    name: "verity_utils",
578    defaults: ["releasetools_binary_defaults"],
579    srcs: [
580        "verity_utils.py",
581    ],
582    libs: [
583        "releasetools_common",
584    ],
585    required: [
586        "append2simg",
587        "build_verity_metadata",
588        "build_verity_tree",
589        "fec",
590    ],
591}
592
593python_binary_host {
594    name: "fsverity_metadata_generator",
595    defaults: ["releasetools_binary_defaults"],
596    srcs: [
597        "fsverity_metadata_generator.py",
598    ],
599    required: [
600        "fsverity",
601    ],
602}
603
604//
605// Tests.
606//
607
608python_defaults {
609    name: "releasetools_test_defaults",
610    srcs: [
611        "check_ota_package_signature.py",
612        "check_partition_sizes.py",
613        "check_target_files_signatures.py",
614        "make_recovery_patch.py",
615        "ota_package_parser.py",
616        "sign_apex.py",
617        "sign_target_files_apks.py",
618        "validate_target_files.py",
619        "merge_ota.py",
620        ":releasetools_merge_sources",
621        ":releasetools_merge_tests",
622
623        "test_*.py",
624    ],
625    libs: [
626        "releasetools_add_img_to_target_files",
627        "releasetools_apex_utils",
628        "releasetools_build_image",
629        "releasetools_build_super_image",
630        "releasetools_check_target_files_vintf",
631        "releasetools_common",
632        "releasetools_find_shareduid_violation",
633        "releasetools_img_from_target_files",
634        "releasetools_ota_from_target_files",
635        "releasetools_verity_utils",
636        "update_payload",
637    ],
638    data: [
639        "testdata/**/*",
640    ],
641    device_common_data: [
642        ":com.android.apex.compressed.v1",
643        ":com.android.apex.vendor.foo.with_vintf",
644    ],
645    target: {
646        darwin: {
647            // libs dep "releasetools_ota_from_target_files" is disabled on darwin
648            enabled: false,
649        },
650    },
651    required: [
652        "apexd_host",
653        "deapexer",
654    ],
655}
656
657python_test_host {
658    name: "releasetools_test",
659    defaults: ["releasetools_test_defaults"],
660    main: "test_utils.py",
661    // Don't use embedded_launcher, atest will try (but may fail) to load libc++.so from
662    // host, because the test executable won't be able to find the needed libs via its
663    // runpath.
664    test_options: {
665        unit_test: true,
666    },
667}
668