blob: ee6dc4f0ceccf0d591bacd5df4c1f581980debe8 [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",
76 defaults: ["bsdiff_defaults"],
77
Alex Deymoa28e0192017-09-08 14:21:05 +020078 srcs: [
Tianjie Xu1c26e2e2017-10-26 17:19:41 -070079 "brotli_compressor.cc",
Alex Deymoa28e0192017-09-08 14:21:05 +020080 "bsdiff.cc",
81 "bz2_compressor.cc",
Tianjie Xu1c26e2e2017-10-26 17:19:41 -070082 "compressor_buffer.cc",
Alex Deymo68c0e7f2017-10-02 20:38:12 +020083 "diff_encoder.cc",
Alex Deymo710b3da2017-10-26 13:13:28 +020084 "endsley_patch_writer.cc",
Tianjie Xu18480eb2017-11-29 16:21:43 -080085 "logging.cc",
Alex Deymoa28e0192017-09-08 14:21:05 +020086 "patch_writer.cc",
Alex Deymo8a179e52017-10-26 17:10:20 +020087 "patch_writer_factory.cc",
Alex Deymoe1140a22017-10-02 21:01:15 +020088 "split_patch_writer.cc",
Alex Deymo48ad5ab2017-09-13 22:17:57 +020089 "suffix_array_index.cc",
Alex Deymoa28e0192017-09-08 14:21:05 +020090 ],
Alex Deymo831dc452017-09-07 21:09:58 +020091 static_libs: [
92 "libdivsufsort64",
93 "libdivsufsort",
Tianjie Xu1c26e2e2017-10-26 17:19:41 -070094 "libbrotli",
Alex Deymo831dc452017-09-07 21:09:58 +020095 ],
96}
97
Tao Bao1c1bce92019-01-10 11:28:53 -080098// Host executables: bsdiff and bspatch are only built for the host.
99cc_binary_host {
Alex Deymo831dc452017-09-07 21:09:58 +0200100 name: "bspatch",
101 defaults: ["bsdiff_defaults"],
102
103 srcs: ["bspatch_main.cc"],
104 static_libs: [
105 "libbspatch",
106 "libbz",
Tianjie Xu1c26e2e2017-10-26 17:19:41 -0700107 "libbrotli",
Alex Deymo831dc452017-09-07 21:09:58 +0200108 ],
109}
110
Alex Deymo831dc452017-09-07 21:09:58 +0200111cc_binary_host {
112 name: "bsdiff",
113 defaults: ["bsdiff_defaults"],
114
Tianjie Xu1f1cdb22017-11-20 11:05:55 -0800115 srcs: [
116 "bsdiff_arguments.cc",
117 "bsdiff_main.cc",
118 ],
Alex Deymo831dc452017-09-07 21:09:58 +0200119 static_libs: [
120 "libbsdiff",
121 "libdivsufsort64",
122 "libdivsufsort",
123 "libbz",
Tianjie Xu1c26e2e2017-10-26 17:19:41 -0700124 "libbrotli",
Alex Deymo831dc452017-09-07 21:09:58 +0200125 ],
126}
127
128// Unit tests.
129cc_test {
130 name: "bsdiff_unittest",
131 defaults: ["bsdiff_defaults"],
132 test_suites: ["device-tests"],
133 srcs: [
Tianjie Xu1c26e2e2017-10-26 17:19:41 -0700134 "brotli_compressor_unittest.cc",
Alex Deymo338f3402018-03-23 13:40:17 +0100135 "brotli_decompressor_unittest.cc",
Tianjie Xu1f1cdb22017-11-20 11:05:55 -0800136 "bsdiff_arguments.cc",
137 "bsdiff_arguments_unittest.cc",
Alex Deymo831dc452017-09-07 21:09:58 +0200138 "bsdiff_unittest.cc",
139 "bspatch_unittest.cc",
Alex Deymo64d5cd82018-03-12 20:00:04 +0100140 "bz2_decompressor_unittest.cc",
Alex Deymo68c0e7f2017-10-02 20:38:12 +0200141 "diff_encoder_unittest.cc",
Alex Deymo710b3da2017-10-26 13:13:28 +0200142 "endsley_patch_writer_unittest.cc",
Alex Deymo831dc452017-09-07 21:09:58 +0200143 "extents_file_unittest.cc",
144 "extents_unittest.cc",
Tianjie Xu65288122017-10-13 15:10:58 -0700145 "patch_reader_unittest.cc",
Alex Deymofb3b6322017-09-27 14:28:54 +0200146 "patch_writer_unittest.cc",
Alex Deymoe1140a22017-10-02 21:01:15 +0200147 "split_patch_writer_unittest.cc",
Alex Deymo48ad5ab2017-09-13 22:17:57 +0200148 "suffix_array_index_unittest.cc",
Alex Deymo831dc452017-09-07 21:09:58 +0200149 "test_utils.cc",
150 "testrunner.cc",
151 ],
Alex Deymo831dc452017-09-07 21:09:58 +0200152 static_libs: [
153 "libbsdiff",
154 "libbspatch",
155 "libgmock",
156 "libdivsufsort64",
157 "libdivsufsort",
158 "libbz",
Tianjie Xu1c26e2e2017-10-26 17:19:41 -0700159 "libbrotli",
Alex Deymo831dc452017-09-07 21:09:58 +0200160 ],
Alex Deymofb3b6322017-09-27 14:28:54 +0200161 target: {
162 android: {
163 cflags: ["-DBSDIFF_TARGET_UNITTEST"],
164 },
165 },
Julien Desprezf57f6932021-02-07 21:32:05 +0000166 test_options: {
167 unit_test: true,
168 },
Alex Deymo831dc452017-09-07 21:09:58 +0200169}