blob: 3541d03fcaf9cca5babb979e71ca4a3cd3d97a2a [file] [log] [blame]
Alex Deymo831dc452017-09-07 21:09:58 +02001// Copyright (C) 2008 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
Bob Badour5489e952021-01-21 17:10:33 -080015package {
16 default_applicable_licenses: ["external_bsdiff_license"],
17}
18
19license {
20 name: "external_bsdiff_license",
21 visibility: [":__subpackages__"],
22 license_kinds: ["SPDX-license-identifier-Apache-2.0","SPDX-license-identifier-BSD"],
23 license_text: ["LICENSE"],
24}
25
Alex Deymo831dc452017-09-07 21:09:58 +020026cc_defaults {
27 name: "bsdiff_defaults",
28 host_supported: true,
Tianjie Xu1c26e2e2017-10-26 17:19:41 -070029 static_libs: ["libbz", "libbrotli"],
Alex Deymodcd423b2017-09-13 20:54:24 +020030 // Allow internal includes to be referenced with the "bsdiff/" prefix in the
31 // path.
32 include_dirs: ["external"],
Alex Deymocb620ca2017-10-30 11:51:38 +010033 export_include_dirs: ["include"],
Alex Deymo831dc452017-09-07 21:09:58 +020034 cflags: [
35 "-D_FILE_OFFSET_BITS=64",
36 "-Wall",
37 "-Werror",
38 "-Wextra",
39 "-Wno-unused-parameter",
40 ],
41}
42
43// Host and target static libraries.
44cc_library_static {
45 name: "libbspatch",
46 defaults: ["bsdiff_defaults"],
Bill Peckham64263b72019-09-17 16:48:12 -070047 vendor_available: true,
Dan Willemsen141f70a2018-10-23 13:44:38 -070048 recovery_available: true,
Alex Deymo831dc452017-09-07 21:09:58 +020049
Bill Peckham590b1fa2019-10-17 18:09:55 -070050 visibility: [
51 "//bootable/recovery:__subpackages__",
52 "//external/puffin:__subpackages__",
53 "//system/update_engine:__subpackages__",
David Anderson6caee522020-08-05 17:30:04 -070054 "//system/core/fs_mgr/libsnapshot:__subpackages__",
Bill Peckham590b1fa2019-10-17 18:09:55 -070055 ],
56
Alex Deymo831dc452017-09-07 21:09:58 +020057 srcs: [
Tianjie Xu4d10c3e2017-10-26 14:02:06 -070058 "brotli_decompressor.cc",
Alex Deymo831dc452017-09-07 21:09:58 +020059 "bspatch.cc",
Tianjie Xu65288122017-10-13 15:10:58 -070060 "bz2_decompressor.cc",
Alex Deymo831dc452017-09-07 21:09:58 +020061 "buffer_file.cc",
Tianjie Xu4d10c3e2017-10-26 14:02:06 -070062 "decompressor_interface.cc",
Alex Deymo831dc452017-09-07 21:09:58 +020063 "extents.cc",
64 "extents_file.cc",
65 "file.cc",
Tianjie Xu18480eb2017-11-29 16:21:43 -080066 "logging.cc",
Alex Deymo831dc452017-09-07 21:09:58 +020067 "memory_file.cc",
Tianjie Xu65288122017-10-13 15:10:58 -070068 "patch_reader.cc",
Alex Deymo831dc452017-09-07 21:09:58 +020069 "sink_file.cc",
Tianjie Xu65288122017-10-13 15:10:58 -070070 "utils.cc",
Alex Deymo831dc452017-09-07 21:09:58 +020071 ],
72}
73
74cc_library_static {
75 name: "libbsdiff",
Kelvin Zhang67386a22021-12-20 15:18:02 -080076 recovery_available: true,
Alex Deymo831dc452017-09-07 21:09:58 +020077 defaults: ["bsdiff_defaults"],
78
Alex Deymoa28e0192017-09-08 14:21:05 +020079 srcs: [
Tianjie Xu1c26e2e2017-10-26 17:19:41 -070080 "brotli_compressor.cc",
Alex Deymoa28e0192017-09-08 14:21:05 +020081 "bsdiff.cc",
82 "bz2_compressor.cc",
Tianjie Xu1c26e2e2017-10-26 17:19:41 -070083 "compressor_buffer.cc",
Alex Deymo68c0e7f2017-10-02 20:38:12 +020084 "diff_encoder.cc",
Alex Deymo710b3da2017-10-26 13:13:28 +020085 "endsley_patch_writer.cc",
Tianjie Xu18480eb2017-11-29 16:21:43 -080086 "logging.cc",
Alex Deymoa28e0192017-09-08 14:21:05 +020087 "patch_writer.cc",
Alex Deymo8a179e52017-10-26 17:10:20 +020088 "patch_writer_factory.cc",
Alex Deymoe1140a22017-10-02 21:01:15 +020089 "split_patch_writer.cc",
Alex Deymo48ad5ab2017-09-13 22:17:57 +020090 "suffix_array_index.cc",
Alex Deymoa28e0192017-09-08 14:21:05 +020091 ],
Alex Deymo831dc452017-09-07 21:09:58 +020092 static_libs: [
93 "libdivsufsort64",
94 "libdivsufsort",
Tianjie Xu1c26e2e2017-10-26 17:19:41 -070095 "libbrotli",
Alex Deymo831dc452017-09-07 21:09:58 +020096 ],
97}
98
Tao Bao1c1bce92019-01-10 11:28:53 -080099// Host executables: bsdiff and bspatch are only built for the host.
100cc_binary_host {
Alex Deymo831dc452017-09-07 21:09:58 +0200101 name: "bspatch",
102 defaults: ["bsdiff_defaults"],
103
104 srcs: ["bspatch_main.cc"],
105 static_libs: [
106 "libbspatch",
107 "libbz",
Tianjie Xu1c26e2e2017-10-26 17:19:41 -0700108 "libbrotli",
Alex Deymo831dc452017-09-07 21:09:58 +0200109 ],
110}
111
Alex Deymo831dc452017-09-07 21:09:58 +0200112cc_binary_host {
113 name: "bsdiff",
114 defaults: ["bsdiff_defaults"],
115
Tianjie Xu1f1cdb22017-11-20 11:05:55 -0800116 srcs: [
117 "bsdiff_arguments.cc",
118 "bsdiff_main.cc",
119 ],
Alex Deymo831dc452017-09-07 21:09:58 +0200120 static_libs: [
121 "libbsdiff",
122 "libdivsufsort64",
123 "libdivsufsort",
124 "libbz",
Tianjie Xu1c26e2e2017-10-26 17:19:41 -0700125 "libbrotli",
Alex Deymo831dc452017-09-07 21:09:58 +0200126 ],
127}
128
129// Unit tests.
130cc_test {
131 name: "bsdiff_unittest",
132 defaults: ["bsdiff_defaults"],
133 test_suites: ["device-tests"],
134 srcs: [
Tianjie Xu1c26e2e2017-10-26 17:19:41 -0700135 "brotli_compressor_unittest.cc",
Alex Deymo338f3402018-03-23 13:40:17 +0100136 "brotli_decompressor_unittest.cc",
Tianjie Xu1f1cdb22017-11-20 11:05:55 -0800137 "bsdiff_arguments.cc",
138 "bsdiff_arguments_unittest.cc",
Alex Deymo831dc452017-09-07 21:09:58 +0200139 "bsdiff_unittest.cc",
140 "bspatch_unittest.cc",
Alex Deymo64d5cd82018-03-12 20:00:04 +0100141 "bz2_decompressor_unittest.cc",
Alex Deymo68c0e7f2017-10-02 20:38:12 +0200142 "diff_encoder_unittest.cc",
Alex Deymo710b3da2017-10-26 13:13:28 +0200143 "endsley_patch_writer_unittest.cc",
Alex Deymo831dc452017-09-07 21:09:58 +0200144 "extents_file_unittest.cc",
145 "extents_unittest.cc",
Tianjie Xu65288122017-10-13 15:10:58 -0700146 "patch_reader_unittest.cc",
Alex Deymofb3b6322017-09-27 14:28:54 +0200147 "patch_writer_unittest.cc",
Alex Deymoe1140a22017-10-02 21:01:15 +0200148 "split_patch_writer_unittest.cc",
Alex Deymo48ad5ab2017-09-13 22:17:57 +0200149 "suffix_array_index_unittest.cc",
Alex Deymo831dc452017-09-07 21:09:58 +0200150 "test_utils.cc",
151 "testrunner.cc",
152 ],
Alex Deymo831dc452017-09-07 21:09:58 +0200153 static_libs: [
154 "libbsdiff",
155 "libbspatch",
156 "libgmock",
157 "libdivsufsort64",
158 "libdivsufsort",
159 "libbz",
Tianjie Xu1c26e2e2017-10-26 17:19:41 -0700160 "libbrotli",
Alex Deymo831dc452017-09-07 21:09:58 +0200161 ],
Alex Deymofb3b6322017-09-27 14:28:54 +0200162 target: {
163 android: {
164 cflags: ["-DBSDIFF_TARGET_UNITTEST"],
165 },
166 },
Julien Desprezf57f6932021-02-07 21:32:05 +0000167 test_options: {
168 unit_test: true,
169 },
Alex Deymo831dc452017-09-07 21:09:58 +0200170}