1# Copyright 2018 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import("//common-mk/pkg_config.gni") 6import("//common-mk/proto_library.gni") 7 8group("all") { 9 deps = [ 10 ":libpuffin-proto", 11 ":libpuffdiff", 12 ":libpuffpatch", 13 ":puffin", 14 ] 15 if (use.test) { 16 deps += [ ":puffin_test" ] 17 } 18 if (use.fuzzer) { 19 deps += [ 20 ":puffin_huff_fuzzer", 21 ":puffin_puff_fuzzer", 22 ":puffin_puffpatch_fuzzer", 23 ] 24 } 25} 26 27pkg_config("target_defaults") { 28 pkg_deps = [ 29 "libchrome", 30 ] 31 if (use.fuzzer) { 32 # Link against protobuf for fuzzers so we can use libprotobuf-mutator. 33 pkg_deps += [ "protobuf" ] 34 } else { 35 pkg_deps += [ "protobuf-lite" ] 36 } 37 cflags = [ "-Wextra" ] 38 cflags_cc = [ "-Wnon-virtual-dtor" ] 39 include_dirs = [ "src/include" ] 40 defines = [ 41 "USE_BRILLO", 42 "_FILE_OFFSET_BITS=64", 43 ] 44} 45 46proto_library("libpuffin-proto") { 47 proto_in_dir = "src" 48 proto_out_dir = "include/puffin/src" 49 sources = [ 50 "src/puffin.proto", 51 ] 52} 53 54pkg_config("libpuffpatch_config") { 55 pkg_deps = [ 56 "libbspatch", 57 ] 58} 59 60static_library("libpuffpatch") { 61 configs += [ 62 "//common-mk:nouse_thin_archive", 63 ":target_defaults", 64 ":libpuffpatch_config", 65 ] 66 configs -= [ "//common-mk:use_thin_archive" ] 67 complete_static_lib = true 68 deps = [ ":libpuffin-proto" ] 69 sources = [ 70 "src/bit_reader.cc", 71 "src/bit_writer.cc", 72 "src/huffer.cc", 73 "src/huffman_table.cc", 74 "src/puff_reader.cc", 75 "src/puff_writer.cc", 76 "src/puffer.cc", 77 "src/puffin_stream.cc", 78 "src/puffpatch.cc", 79 ] 80} 81 82pkg_config("libpuffdiff_config") { 83 pkg_deps = [ 84 "libbsdiff", 85 ] 86} 87static_library("libpuffdiff") { 88 configs += [ 89 "//common-mk:nouse_thin_archive", 90 ":target_defaults", 91 ":libpuffdiff_config", 92 ] 93 configs -= [ "//common-mk:use_thin_archive" ] 94 deps = [ 95 ":libpuffpatch", 96 ] 97 sources = [ 98 "src/file_stream.cc", 99 "src/memory_stream.cc", 100 "src/puffdiff.cc", 101 "src/utils.cc", 102 ] 103} 104 105pkg_config("libbrillo") { 106 pkg_deps = [ 107 "libbrillo", 108 ] 109} 110 111executable("puffin") { 112 configs += [ 113 ":libbrillo", 114 ":target_defaults", 115 ] 116 deps = [ 117 ":libpuffdiff", 118 ] 119 sources = [ 120 "src/extent_stream.cc", 121 "src/main.cc", 122 ] 123} 124 125if (use.test) { 126 executable("puffin_test") { 127 configs += [ 128 "//common-mk:test", 129 ":libbrillo", 130 ":target_defaults", 131 ] 132 sources = [ 133 "src/bit_io_unittest.cc", 134 "src/extent_stream.cc", 135 "src/patching_unittest.cc", 136 "src/puff_io_unittest.cc", 137 "src/puffin_unittest.cc", 138 "src/stream_unittest.cc", 139 "src/unittest_common.cc", 140 "src/utils_unittest.cc", 141 ] 142 deps = [ 143 "//common-mk/testrunner", 144 ":libpuffdiff", 145 ] 146 } 147} 148 149if (use.fuzzer) { 150 executable("puffin_huff_fuzzer") { 151 configs += [ 152 "//common-mk/common_fuzzer", 153 ":libbrillo", 154 ":target_defaults", 155 ] 156 deps = [ 157 ":libpuffpatch", 158 ] 159 sources = [ 160 "src/fuzzer_huff.cc", 161 ] 162 } 163 executable("puffin_puff_fuzzer") { 164 configs += [ 165 "//common-mk/common_fuzzer", 166 ":libbrillo", 167 ":target_defaults", 168 ] 169 deps = [ 170 ":libpuffpatch", 171 ] 172 sources = [ 173 "src/fuzzer_puff.cc", 174 ] 175 } 176 executable("puffin_puffpatch_fuzzer") { 177 configs += [ 178 "//common-mk/common_fuzzer", 179 ":libbrillo", 180 ":target_defaults", 181 ] 182 deps = [ 183 ":libpuffdiff", 184 ] 185 sources = [ 186 "src/fuzzer_puffpatch.cc", 187 ] 188 } 189} 190