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