Home | History | Annotate | Download | only in puffin
      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 
      5 import("//common-mk/pkg_config.gni")
      6 import("//common-mk/proto_library.gni")
      7 
      8 group("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 
     23 pkg_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 
     37 proto_library("libpuffin-proto") {
     38   proto_in_dir = "src"
     39   proto_out_dir = "include/puffin/src"
     40   sources = [
     41     "src/puffin.proto",
     42   ]
     43 }
     44 
     45 pkg_config("libpuffpatch_config") {
     46   pkg_deps = [
     47     "libbspatch",
     48   ]
     49 }
     50 
     51 static_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 
     73 pkg_config("libpuffdiff_config") {
     74   pkg_deps = [
     75     "libbsdiff",
     76   ]
     77 }
     78 static_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 
     96 pkg_config("libbrillo") {
     97   pkg_deps = [
     98     "libbrillo-${libbase_ver}",
     99   ]
    100 }
    101 
    102 executable("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 
    116 if (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 
    140 if (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