1// 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
15package {
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
26cc_defaults {
27    name: "bsdiff_defaults",
28    host_supported: true,
29    static_libs: ["libbz", "libbrotli"],
30    // Allow internal includes to be referenced with the "bsdiff/" prefix in the
31    // path.
32    include_dirs: ["external"],
33    export_include_dirs: ["include"],
34    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"],
47    vendor_available: true,
48    recovery_available: true,
49
50    visibility: [
51        "//bootable/recovery:__subpackages__",
52        "//external/puffin:__subpackages__",
53        "//system/update_engine:__subpackages__",
54        "//system/core/fs_mgr/libsnapshot:__subpackages__",
55    ],
56
57    srcs: [
58        "brotli_decompressor.cc",
59        "bspatch.cc",
60        "bz2_decompressor.cc",
61        "buffer_file.cc",
62        "decompressor_interface.cc",
63        "extents.cc",
64        "extents_file.cc",
65        "file.cc",
66        "logging.cc",
67        "memory_file.cc",
68        "patch_reader.cc",
69        "sink_file.cc",
70        "utils.cc",
71    ],
72}
73
74cc_library_static {
75    name: "libbsdiff",
76    defaults: ["bsdiff_defaults"],
77
78    srcs: [
79        "brotli_compressor.cc",
80        "bsdiff.cc",
81        "bz2_compressor.cc",
82        "compressor_buffer.cc",
83        "diff_encoder.cc",
84        "endsley_patch_writer.cc",
85        "logging.cc",
86        "patch_writer.cc",
87        "patch_writer_factory.cc",
88        "split_patch_writer.cc",
89        "suffix_array_index.cc",
90    ],
91    static_libs: [
92        "libdivsufsort64",
93        "libdivsufsort",
94        "libbrotli",
95    ],
96}
97
98// Host executables: bsdiff and bspatch are only built for the host.
99cc_binary_host {
100    name: "bspatch",
101    defaults: ["bsdiff_defaults"],
102
103    srcs: ["bspatch_main.cc"],
104    static_libs: [
105        "libbspatch",
106        "libbz",
107        "libbrotli",
108    ],
109}
110
111cc_binary_host {
112    name: "bsdiff",
113    defaults: ["bsdiff_defaults"],
114
115    srcs: [
116        "bsdiff_arguments.cc",
117        "bsdiff_main.cc",
118    ],
119    static_libs: [
120        "libbsdiff",
121        "libdivsufsort64",
122        "libdivsufsort",
123        "libbz",
124        "libbrotli",
125    ],
126}
127
128// Unit tests.
129cc_test {
130    name: "bsdiff_unittest",
131    defaults: ["bsdiff_defaults"],
132    test_suites: ["device-tests"],
133    srcs: [
134        "brotli_compressor_unittest.cc",
135        "brotli_decompressor_unittest.cc",
136        "bsdiff_arguments.cc",
137        "bsdiff_arguments_unittest.cc",
138        "bsdiff_unittest.cc",
139        "bspatch_unittest.cc",
140        "bz2_decompressor_unittest.cc",
141        "diff_encoder_unittest.cc",
142        "endsley_patch_writer_unittest.cc",
143        "extents_file_unittest.cc",
144        "extents_unittest.cc",
145        "patch_reader_unittest.cc",
146        "patch_writer_unittest.cc",
147        "split_patch_writer_unittest.cc",
148        "suffix_array_index_unittest.cc",
149        "test_utils.cc",
150        "testrunner.cc",
151    ],
152    static_libs: [
153        "libbsdiff",
154        "libbspatch",
155        "libgmock",
156        "libdivsufsort64",
157        "libdivsufsort",
158        "libbz",
159        "libbrotli",
160    ],
161    target: {
162        android: {
163            cflags: ["-DBSDIFF_TARGET_UNITTEST"],
164        },
165    },
166    test_options: {
167        unit_test: true,
168    },
169}
170