1# Copyright 2017 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 5{ 6 'target_defaults': { 7 'variables': { 8 'deps': [ 9 'libbrillo-<(libbase_ver)', 10 'libchrome-<(libbase_ver)', 11 ], 12 }, 13 'cflags': [ 14 '-Wextra', 15 ], 16 'cflags_cc': [ 17 '-Wnon-virtual-dtor', 18 ], 19 'include_dirs': [ 20 'src/include', 21 ], 22 'defines': [ 23 'USE_BRILLO=1', 24 '_FILE_OFFSET_BITS=64', 25 'ZLIB_CONST', 26 ], 27 }, 28 'targets': [ 29 # libpuffin-proto library 30 { 31 'target_name': 'libpuffin-proto', 32 'type': 'static_library', 33 'variables': { 34 'proto_in_dir': 'src', 35 'proto_out_dir': 'include/puffin/src', 36 }, 37 'cflags!': ['-fPIE'], 38 'cflags': ['-fPIC'], 39 'all_dependent_settings': { 40 'variables': { 41 'deps': [ 42 'protobuf-lite', 43 ], 44 }, 45 }, 46 'sources': [ 47 '<(proto_in_dir)/puffin.proto', 48 ], 49 'includes': ['../../platform2/common-mk/protoc.gypi'], 50 }, 51 # puffpatch static library. The reason to do one static and one shared is to 52 # be able to run the unittest. 53 { 54 'target_name': 'libpuffpatch-static', 55 'type': 'static_library', 56 'cflags!': ['-fPIE'], 57 'cflags': ['-fPIC'], 58 'sources': [ 59 'src/bit_reader.cc', 60 'src/bit_writer.cc', 61 'src/huffer.cc', 62 'src/huffman_table.cc', 63 'src/puff_reader.cc', 64 'src/puff_writer.cc', 65 'src/puffer.cc', 66 'src/puffin_stream.cc', 67 'src/puffpatch.cc', 68 ], 69 'dependencies': [ 70 'libpuffin-proto', 71 ], 72 'all_dependent_settings': { 73 'link_settings': { 74 'libraries': [ 75 '-lbspatch', 76 ], 77 }, 78 }, 79 }, 80 # puffdiff static library. 81 { 82 'target_name': 'libpuffdiff-static', 83 'type': 'static_library', 84 'cflags!': ['-fPIE'], 85 'cflags': ['-fPIC'], 86 'sources': [ 87 'src/file_stream.cc', 88 'src/memory_stream.cc', 89 'src/puffdiff.cc', 90 'src/utils.cc', 91 ], 92 'dependencies': [ 93 'libpuffpatch-static', 94 ], 95 'all_dependent_settings': { 96 'variables': { 97 'deps': [ 98 'zlib', 99 ], 100 }, 101 'link_settings': { 102 'libraries': [ 103 '-lbsdiff', 104 ], 105 }, 106 }, 107 }, 108 # puffpatch shared library. 109 { 110 'target_name': 'libpuffpatch', 111 'type': 'shared_library', 112 'dependencies': [ 113 'libpuffpatch-static', 114 ], 115 }, 116 # puffdiff shared library. 117 { 118 'target_name': 'libpuffdiff', 119 'type': 'shared_library', 120 'dependencies': [ 121 'libpuffdiff-static', 122 ], 123 }, 124 # Puffin executable. We don't use the shared libraries because then we have 125 # to export symbols that shouldn't be exported otherwise. 126 { 127 'target_name': 'puffin', 128 'type': 'executable', 129 'dependencies': [ 130 'libpuffdiff-static', 131 ], 132 'sources': [ 133 'src/extent_stream.cc', 134 'src/main.cc', 135 ], 136 }, 137 ], 138 # unit tests. 139 'conditions': [ 140 ['USE_test == 1', { 141 'targets': [ 142 # Samples generator. 143 { 144 'target_name': 'libsample_generator', 145 'type': 'static_library', 146 'sources': [ 147 'src/sample_generator.cc', 148 ], 149 'all_dependent_settings': { 150 'variables': { 151 'deps': [ 152 'zlib', 153 ], 154 }, 155 }, 156 }, 157 # Unit tests. 158 { 159 'target_name': 'puffin_unittest', 160 'type': 'executable', 161 'dependencies': [ 162 'libpuffdiff-static', 163 'libsample_generator', 164 '../../platform2/common-mk/testrunner.gyp:testrunner', 165 ], 166 'includes': ['../../platform2/common-mk/common_test.gypi'], 167 'sources': [ 168 'src/bit_io_unittest.cc', 169 'src/extent_stream.cc', 170 'src/patching_unittest.cc', 171 'src/puff_io_unittest.cc', 172 'src/puffin_unittest.cc', 173 'src/stream_unittest.cc', 174 'src/unittest_common.cc', 175 'src/utils_unittest.cc', 176 ], 177 }, 178 ], 179 }], 180 # fuzzer target 181 ['USE_fuzzer == 1', { 182 'targets': [ 183 { 184 'target_name': 'puffin_fuzzer', 185 'type': 'executable', 186 'dependencies': [ 187 'libpuffin-proto', 188 'libpuffdiff-static', 189 'libpuffpatch-static', 190 ], 191 'includes': ['../../platform2/common-mk/common_fuzzer.gypi'], 192 'sources': [ 193 'src/fuzzer.cc', 194 ], 195 }, 196 ], 197 }], 198 ], 199} 200