• 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
8if (cpu_arch == "arm") {
9  import("//build/config/arm.gni")
10}
11
12if (cpu_arch == "x86" || cpu_arch == "x64") {
13
14import("//third_party/yasm/yasm_assemble.gni")
15
16yasm_assemble("simd_asm") {
17  defines = []
18
19  if (cpu_arch == "x86") {
20    sources = [
21      "simd/jccolmmx.asm",
22      "simd/jccolss2.asm",
23      "simd/jcgrammx.asm",
24      "simd/jcgrass2.asm",
25      "simd/jcqnt3dn.asm",
26      "simd/jcqntmmx.asm",
27      "simd/jcqnts2f.asm",
28      "simd/jcqnts2i.asm",
29      "simd/jcqntsse.asm",
30      "simd/jcsammmx.asm",
31      "simd/jcsamss2.asm",
32      "simd/jdcolmmx.asm",
33      "simd/jdcolss2.asm",
34      "simd/jdmermmx.asm",
35      "simd/jdmerss2.asm",
36      "simd/jdsammmx.asm",
37      "simd/jdsamss2.asm",
38      "simd/jf3dnflt.asm",
39      "simd/jfmmxfst.asm",
40      "simd/jfmmxint.asm",
41      "simd/jfss2fst.asm",
42      "simd/jfss2int.asm",
43      "simd/jfsseflt.asm",
44      "simd/ji3dnflt.asm",
45      "simd/jimmxfst.asm",
46      "simd/jimmxint.asm",
47      "simd/jimmxred.asm",
48      "simd/jiss2flt.asm",
49      "simd/jiss2fst.asm",
50      "simd/jiss2int.asm",
51      "simd/jiss2red.asm",
52      "simd/jisseflt.asm",
53      "simd/jsimdcpu.asm",
54    ]
55    defines += [
56      "__x86__",
57    ]
58  } else if (cpu_arch == "x64") {
59    sources = [
60      "simd/jccolss2-64.asm",
61      "simd/jcgrass2-64.asm",
62      "simd/jcqnts2f-64.asm",
63      "simd/jcqnts2i-64.asm",
64      "simd/jcsamss2-64.asm",
65      "simd/jdcolss2-64.asm",
66      "simd/jdmerss2-64.asm",
67      "simd/jdsamss2-64.asm",
68      "simd/jfss2fst-64.asm",
69      "simd/jfss2int-64.asm",
70      "simd/jfsseflt-64.asm",
71      "simd/jiss2flt-64.asm",
72      "simd/jiss2fst-64.asm",
73      "simd/jiss2int-64.asm",
74      "simd/jiss2red-64.asm",
75    ]
76    defines += [
77      "__x86_64__",
78    ]
79  }
80
81  if (is_win) {
82    defines += [
83      "MSVC",
84    ]
85    include_dirs = [ "win" ]
86    if (cpu_arch == "x86") {
87      defines += [
88        "WIN32",
89      ]
90    } else {
91      defines += [
92        "WIN64",
93      ]
94    }
95  } else if (is_mac) {
96    defines += [
97      "MACHO",
98    ]
99    include_dirs = [ "mac" ]
100  } else if (is_linux) {
101    defines += [
102      "ELF",
103    ]
104    include_dirs = [ "linux" ]
105  }
106}
107
108}
109
110source_set("simd") {
111  if (cpu_arch == "x86") {
112    deps = [ ":simd_asm" ]
113    sources = [
114      "simd/jsimd_i386.c",
115    ]
116  } else if (cpu_arch == "x64") {
117    deps = [ ":simd_asm" ]
118    sources = [
119      "simd/jsimd_x86_64.c",
120    ]
121  } else if (cpu_arch == "arm" && arm_version >= 7 &&
122             (arm_use_neon || arm_optionally_use_neon)) {
123    sources = [
124      "simd/jsimd_arm.c",
125      "simd/jsimd_arm_neon.S",
126    ]
127  } else {
128    sources = [ "jsimd_none.c" ]
129  }
130}
131
132config("libjpeg_config") {
133  include_dirs = [ "." ]
134}
135
136source_set("libjpeg") {
137  sources = [
138    "jcapimin.c",
139    "jcapistd.c",
140    "jccoefct.c",
141    "jccolor.c",
142    "jcdctmgr.c",
143    "jchuff.c",
144    "jchuff.h",
145    "jcinit.c",
146    "jcmainct.c",
147    "jcmarker.c",
148    "jcmaster.c",
149    "jcomapi.c",
150    "jconfig.h",
151    "jcparam.c",
152    "jcphuff.c",
153    "jcprepct.c",
154    "jcsample.c",
155    "jdapimin.c",
156    "jdapistd.c",
157    "jdatadst.c",
158    "jdatasrc.c",
159    "jdcoefct.c",
160    "jdcolor.c",
161    "jdct.h",
162    "jddctmgr.c",
163    "jdhuff.c",
164    "jdhuff.h",
165    "jdinput.c",
166    "jdmainct.c",
167    "jdmarker.c",
168    "jdmaster.c",
169    "jdmerge.c",
170    "jdphuff.c",
171    "jdpostct.c",
172    "jdsample.c",
173    "jerror.c",
174    "jerror.h",
175    "jfdctflt.c",
176    "jfdctfst.c",
177    "jfdctint.c",
178    "jidctflt.c",
179    "jidctfst.c",
180    "jidctint.c",
181    "jidctred.c",
182    "jinclude.h",
183    "jmemmgr.c",
184    "jmemnobs.c",
185    "jmemsys.h",
186    "jmorecfg.h",
187    "jpegint.h",
188    "jpeglib.h",
189    "jpeglibmangler.h",
190    "jquant1.c",
191    "jquant2.c",
192    "jutils.c",
193    "jversion.h",
194  ]
195
196  defines = [
197    "WITH_SIMD",
198    "MOTION_JPEG_SUPPORTED",
199    "NO_GETENV",
200  ]
201
202  configs += [ ":libjpeg_config" ]
203
204  direct_dependent_configs = [ ":libjpeg_config" ]
205
206  # MemorySanitizer doesn't support assembly code, so keep it disabled in
207  # MSan builds for now.
208  # TODO: Enable on Linux when .asm files are recognized.
209  if (is_msan || is_linux) {
210    sources += [ "jsimd_none.c" ]
211  } else {
212    deps = [ ":simd" ]
213  }
214
215  # TODO(GYP): Compile the .asm files with YASM as GYP does.
216}
217