1# Copyright 2014 The Chromium 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("//build/config/arm.gni")
6
7config("libwebp_config") {
8  include_dirs = [ "." ]
9}
10
11use_dsp_neon = (cpu_arch == "arm64" ||
12            (cpu_arch == "arm" && arm_version >= 7 &&
13                (arm_use_neon || arm_optionally_use_neon)))
14
15source_set("libwebp_dec") {
16  sources = [
17    "dec/alpha.c",
18    "dec/buffer.c",
19    "dec/frame.c",
20    "dec/idec.c",
21    "dec/io.c",
22    "dec/quant.c",
23    "dec/tree.c",
24    "dec/vp8.c",
25    "dec/vp8l.c",
26    "dec/webp.c",
27  ]
28
29  configs -= [ "//build/config/compiler:chromium_code" ]
30  configs += [ "//build/config/compiler:no_chromium_code" ]
31
32  deps = [
33    ":libwebp_dsp",
34    ":libwebp_utils",
35  ]
36  all_dependent_configs = [
37    ":libwebp_config"
38  ]
39  if (use_dsp_neon) {
40    deps += [ ":libwebp_dsp_neon"]
41  }
42}
43
44source_set("libwebp_demux") {
45  sources = [
46    "demux/demux.c",
47  ]
48  all_dependent_configs = [
49    ":libwebp_config"
50  ]
51  configs -= [ "//build/config/compiler:chromium_code" ]
52  configs += [ "//build/config/compiler:no_chromium_code" ]
53}
54
55
56source_set("libwebp_dsp") {
57  sources = [
58    "dsp/alpha_processing.c",
59    "dsp/cpu.c",
60    "dsp/dec.c",
61    "dsp/dec_clip_tables.c",
62    "dsp/dec_mips32.c",
63    "dsp/dec_sse2.c",
64    "dsp/enc.c",
65    "dsp/enc_avx2.c",
66    "dsp/enc_mips32.c",
67    "dsp/enc_sse2.c",
68    "dsp/lossless.c",
69    "dsp/lossless_mips32.c",
70    "dsp/lossless_sse2.c",
71    "dsp/upsampling.c",
72    "dsp/upsampling_sse2.c",
73    "dsp/yuv.c",
74    "dsp/yuv_mips32.c",
75    "dsp/yuv_sse2.c",
76  ]
77  configs -= [ "//build/config/compiler:chromium_code" ]
78  configs += [ "//build/config/compiler:no_chromium_code" ]
79
80  all_dependent_configs = [
81    ":libwebp_config"
82  ]
83  deps = []
84  if (is_android) {
85    deps += [ "//third_party/android_tools:cpu_features" ]
86  }
87# TODO(GYP):
88#      'conditions': [
89#        ['order_profiling != 0', {
90#          'target_conditions' : [
91#            ['_toolset=="target"', {
92#              'cflags!': [ '-finstrument-functions' ],
93#            }],
94#          ],
95#        }],
96#      ],
97}
98
99if (use_dsp_neon) {
100
101source_set("libwebp_dsp_neon") {
102  sources = [
103    "dsp/dec_neon.c",
104    "dsp/enc_neon.c",
105    "dsp/lossless_neon.c",
106    "dsp/upsampling_neon.c",
107  ]
108
109  include_dirs = [ "." ]
110
111  if (cpu_arch == "arm") {
112    # behavior similar to *.c.neon in an Android.mk
113    configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
114    cflags = [ "-mfpu=neon" ]
115  } else if (cpu_arch == "arm64") {
116    # avoid an ICE with gcc-4.9: b/15574841
117    cflags = [ "-frename-registers" ]
118  }
119
120# TODO(GYP):
121#        ['order_profiling != 0', {
122#          'target_conditions' : [
123#            ['_toolset=="target"', {
124#              'cflags!': [ '-finstrument-functions' ],
125#            }],
126#          ],
127#        }],
128#      ],
129#    }
130}
131
132}  # use_dsp_neon
133
134source_set("libwebp_enc") {
135  sources = [
136    "enc/alpha.c",
137    "enc/analysis.c",
138    "enc/backward_references.c",
139    "enc/config.c",
140    "enc/cost.c",
141    "enc/filter.c",
142    "enc/frame.c",
143    "enc/histogram.c",
144    "enc/iterator.c",
145    "enc/picture.c",
146    "enc/picture_csp.c",
147    "enc/picture_psnr.c",
148    "enc/picture_rescale.c",
149    "enc/picture_tools.c",
150    "enc/quant.c",
151    "enc/syntax.c",
152    "enc/token.c",
153    "enc/tree.c",
154    "enc/vp8l.c",
155    "enc/webpenc.c",
156  ]
157  configs -= [ "//build/config/compiler:chromium_code" ]
158  configs += [ "//build/config/compiler:no_chromium_code" ]
159
160  all_dependent_configs = [
161    ":libwebp_config"
162  ]
163}
164
165source_set("libwebp_utils") {
166  sources = [
167    "utils/bit_reader.c",
168    "utils/bit_writer.c",
169    "utils/color_cache.c",
170    "utils/filters.c",
171    "utils/huffman.c",
172    "utils/huffman_encode.c",
173    "utils/quant_levels.c",
174    "utils/quant_levels_dec.c",
175    "utils/random.c",
176    "utils/rescaler.c",
177    "utils/thread.c",
178    "utils/utils.c",
179  ]
180  configs -= [ "//build/config/compiler:chromium_code" ]
181  configs += [ "//build/config/compiler:no_chromium_code" ]
182
183  all_dependent_configs = [
184    ":libwebp_config"
185  ]
186}
187
188group("libwebp") {
189  deps = [
190    ":libwebp_dec",
191    ":libwebp_demux",
192    ":libwebp_dsp",
193    ":libwebp_enc",
194    ":libwebp_utils",
195  ]
196  public_configs = [
197    ":libwebp_config"
198  ]
199  if (use_dsp_neon) {
200    deps += [ ":libwebp_dsp_neon" ]
201  }
202}
203