• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
5# Do not use the targets in this file unless you need a certain libjpeg
6# implementation. Use the meta target //third_party:jpeg instead.
7
8import("//build/config/sanitizers/sanitizers.gni")
9if (current_cpu == "arm") {
10  import("//build/config/arm.gni")
11}
12
13if (current_cpu == "x86" || current_cpu == "x64") {
14  import("//third_party/yasm/yasm_assemble.gni")
15
16  yasm_assemble("simd_asm") {
17    defines = []
18
19    if (current_cpu == "x86") {
20      sources = [
21        "simd/jccolor-mmx.asm",
22        "simd/jccolor-sse2.asm",
23        "simd/jcgray-mmx.asm",
24        "simd/jcgray-sse2.asm",
25        "simd/jchuff-sse2.asm",
26        "simd/jcsample-mmx.asm",
27        "simd/jcsample-sse2.asm",
28        "simd/jdcolor-mmx.asm",
29        "simd/jdcolor-sse2.asm",
30        "simd/jdmerge-mmx.asm",
31        "simd/jdmerge-sse2.asm",
32        "simd/jdsample-mmx.asm",
33        "simd/jdsample-sse2.asm",
34        "simd/jfdctflt-3dn.asm",
35        "simd/jfdctflt-sse.asm",
36        "simd/jfdctfst-mmx.asm",
37        "simd/jfdctfst-sse2.asm",
38        "simd/jfdctint-mmx.asm",
39        "simd/jfdctint-sse2.asm",
40        "simd/jidctflt-3dn.asm",
41        "simd/jidctflt-sse.asm",
42        "simd/jidctflt-sse2.asm",
43        "simd/jidctfst-mmx.asm",
44        "simd/jidctfst-sse2.asm",
45        "simd/jidctint-mmx.asm",
46        "simd/jidctint-sse2.asm",
47        "simd/jidctred-mmx.asm",
48        "simd/jidctred-sse2.asm",
49        "simd/jquant-3dn.asm",
50        "simd/jquant-mmx.asm",
51        "simd/jquant-sse.asm",
52        "simd/jquantf-sse2.asm",
53        "simd/jquanti-sse2.asm",
54        "simd/jsimdcpu.asm",
55      ]
56      defines += [
57        "__x86__",
58        "PIC",
59      ]
60    } else if (current_cpu == "x64") {
61      sources = [
62        "simd/jccolor-sse2-64.asm",
63        "simd/jcgray-sse2-64.asm",
64        "simd/jchuff-sse2-64.asm",
65        "simd/jcsample-sse2-64.asm",
66        "simd/jdcolor-sse2-64.asm",
67        "simd/jdmerge-sse2-64.asm",
68        "simd/jdsample-sse2-64.asm",
69        "simd/jfdctflt-sse-64.asm",
70        "simd/jfdctfst-sse2-64.asm",
71        "simd/jfdctint-sse2-64.asm",
72        "simd/jidctflt-sse2-64.asm",
73        "simd/jidctfst-sse2-64.asm",
74        "simd/jidctint-sse2-64.asm",
75        "simd/jidctred-sse2-64.asm",
76        "simd/jquantf-sse2-64.asm",
77        "simd/jquanti-sse2-64.asm",
78      ]
79      defines += [
80        "__x86_64__",
81        "PIC",
82      ]
83    }
84
85    if (is_win) {
86      defines += [ "MSVC" ]
87      include_dirs = [ "win" ]
88      if (current_cpu == "x86") {
89        defines += [ "WIN32" ]
90      } else {
91        defines += [ "WIN64" ]
92      }
93    } else if (is_mac || is_ios) {
94      defines += [ "MACHO" ]
95      include_dirs = [ "mac" ]
96    } else if (is_linux || is_android) {
97      defines += [ "ELF" ]
98      include_dirs = [ "linux" ]
99    }
100  }
101}
102
103source_set("simd") {
104  if (current_cpu == "x86") {
105    deps = [
106      ":simd_asm",
107    ]
108    sources = [
109      "simd/jsimd_i386.c",
110    ]
111  } else if (current_cpu == "x64") {
112    deps = [
113      ":simd_asm",
114    ]
115    sources = [
116      "simd/jsimd_x86_64.c",
117    ]
118  } else if (current_cpu == "arm" && arm_version >= 7 &&
119             (arm_use_neon || arm_optionally_use_neon)) {
120    sources = [
121      "simd/jsimd_arm.c",
122      "simd/jsimd_arm_neon.S",
123    ]
124  } else if (current_cpu == "arm64") {
125    sources = [
126      "simd/jsimd_arm64.c",
127      "simd/jsimd_arm64_neon.S",
128    ]
129  } else {
130    sources = [
131      "jsimd_none.c",
132    ]
133  }
134
135  if (is_win) {
136    cflags = [ "/wd4245" ]
137  }
138}
139
140config("libjpeg_config") {
141  include_dirs = [ "." ]
142}
143
144source_set("libjpeg") {
145  sources = [
146    "jcapimin.c",
147    "jcapistd.c",
148    "jccoefct.c",
149    "jccolor.c",
150    "jcdctmgr.c",
151    "jchuff.c",
152    "jchuff.h",
153    "jcinit.c",
154    "jcmainct.c",
155    "jcmarker.c",
156    "jcmaster.c",
157    "jcomapi.c",
158    "jconfig.h",
159    "jcparam.c",
160    "jcphuff.c",
161    "jcprepct.c",
162    "jcsample.c",
163    "jdapimin.c",
164    "jdapistd.c",
165    "jdatadst.c",
166    "jdatasrc.c",
167    "jdcoefct.c",
168    "jdcolor.c",
169    "jdct.h",
170    "jddctmgr.c",
171    "jdhuff.c",
172    "jdhuff.h",
173    "jdinput.c",
174    "jdmainct.c",
175    "jdmarker.c",
176    "jdmaster.c",
177    "jdmerge.c",
178    "jdphuff.c",
179    "jdpostct.c",
180    "jdsample.c",
181    "jerror.c",
182    "jerror.h",
183    "jfdctflt.c",
184    "jfdctfst.c",
185    "jfdctint.c",
186    "jidctflt.c",
187    "jidctfst.c",
188    "jidctint.c",
189    "jidctred.c",
190    "jinclude.h",
191    "jmemmgr.c",
192    "jmemnobs.c",
193    "jmemsys.h",
194    "jmorecfg.h",
195    "jpegint.h",
196    "jpeglib.h",
197    "jpeglibmangler.h",
198    "jquant1.c",
199    "jquant2.c",
200    "jutils.c",
201    "jversion.h",
202  ]
203
204  defines = [
205    "WITH_SIMD",
206    "NO_GETENV",
207  ]
208
209  configs += [ ":libjpeg_config" ]
210
211  public_configs = [ ":libjpeg_config" ]
212
213  # MemorySanitizer doesn't support assembly code, so keep it disabled in
214  # MSan builds for now.
215  if (is_msan) {
216    sources += [ "jsimd_none.c" ]
217  } else {
218    deps = [
219      ":simd",
220    ]
221  }
222}
223