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 += [ ":puffin_fuzzer" ] 20 } 21} 22 23pkg_config("target_defaults") { 24 pkg_deps = [ 25 "libchrome-${libbase_ver}", 26 "protobuf-lite", 27 ] 28 cflags = [ "-Wextra" ] 29 cflags_cc = [ "-Wnon-virtual-dtor" ] 30 include_dirs = [ "src/include" ] 31 defines = [ 32 "USE_BRILLO", 33 "_FILE_OFFSET_BITS=64", 34 ] 35} 36 37proto_library("libpuffin-proto") { 38 proto_in_dir = "src" 39 proto_out_dir = "include/puffin/src" 40 sources = [ 41 "src/puffin.proto", 42 ] 43} 44 45pkg_config("libpuffpatch_config") { 46 pkg_deps = [ 47 "libbspatch", 48 ] 49} 50 51static_library("libpuffpatch") { 52 configs += [ 53 "//common-mk:nouse_thin_archive", 54 ":target_defaults", 55 ":libpuffpatch_config", 56 ] 57 configs -= [ "//common-mk:use_thin_archive" ] 58 complete_static_lib = true 59 deps = [ ":libpuffin-proto" ] 60 sources = [ 61 "src/bit_reader.cc", 62 "src/bit_writer.cc", 63 "src/huffer.cc", 64 "src/huffman_table.cc", 65 "src/puff_reader.cc", 66 "src/puff_writer.cc", 67 "src/puffer.cc", 68 "src/puffin_stream.cc", 69 "src/puffpatch.cc", 70 ] 71} 72 73pkg_config("libpuffdiff_config") { 74 pkg_deps = [ 75 "libbsdiff", 76 ] 77} 78static_library("libpuffdiff") { 79 configs += [ 80 "//common-mk:nouse_thin_archive", 81 ":target_defaults", 82 ":libpuffdiff_config", 83 ] 84 configs -= [ "//common-mk:use_thin_archive" ] 85 deps = [ 86 ":libpuffpatch", 87 ] 88 sources = [ 89 "src/file_stream.cc", 90 "src/memory_stream.cc", 91 "src/puffdiff.cc", 92 "src/utils.cc", 93 ] 94} 95 96pkg_config("libbrillo") { 97 pkg_deps = [ 98 "libbrillo-${libbase_ver}", 99 ] 100} 101 102executable("puffin") { 103 configs += [ 104 ":libbrillo", 105 ":target_defaults", 106 ] 107 deps = [ 108 ":libpuffdiff", 109 ] 110 sources = [ 111 "src/extent_stream.cc", 112 "src/main.cc", 113 ] 114} 115 116if (use.test) { 117 executable("puffin_test") { 118 configs += [ 119 "//common-mk:test", 120 ":libbrillo", 121 ":target_defaults", 122 ] 123 sources = [ 124 "src/bit_io_unittest.cc", 125 "src/extent_stream.cc", 126 "src/patching_unittest.cc", 127 "src/puff_io_unittest.cc", 128 "src/puffin_unittest.cc", 129 "src/stream_unittest.cc", 130 "src/unittest_common.cc", 131 "src/utils_unittest.cc", 132 ] 133 deps = [ 134 "//common-mk/testrunner", 135 ":libpuffdiff", 136 ] 137 } 138} 139 140if (use.fuzzer) { 141 executable("puffin_fuzzer") { 142 configs += [ 143 "//common-mk/common_fuzzer", 144 ":libbrillo", 145 ":target_defaults", 146 ] 147 deps = [ 148 ":libpuffdiff", 149 ] 150 sources = [ 151 "src/fuzzer.cc", 152 ] 153 } 154} 155