aboutsummaryrefslogtreecommitdiffhomepage
path: root/gyp/libjpeg-turbo.gyp
blob: 4dcea626ded2f5d75d5101cd95353fe8b2ce3ed9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

{
  'xcode_settings': {
    'SYMROOT': '<(DEPTH)/xcodebuild',
  },
  'variables': {
    'shared_generated_dir': '<(SHARED_INTERMEDIATE_DIR)/third_party/externals/libjpeg-turbo',
    'conditions': [
      [ 'skia_os == "win"', {
        'object_suffix': 'obj',
      }, {
        'object_suffix': 'o',
      }],
    ],
  },
  'targets': [
    {
      'target_name': 'yasm-win',
      'type': 'executable',
      'sources': [
        '../third_party/externals/yasm/binaries/win/yasm.exe',
      ],
      'copies' : [{
        'destination': '<(PRODUCT_DIR)',
        'files': [ '../third_party/externals/yasm/binaries/win/yasm.exe' ],
      }],
    },
    {
      'target_name': 'libjpeg-turbo',
      'type': 'static_library',
      'include_dirs': [
        '../third_party/externals/libjpeg-turbo/',
      ],
      'defines': [
        'WITH_SIMD',
        'MOTION_JPEG_SUPPORTED',
        'NO_GETENV',
      ],
      'cflags': [
        '-w', # supresses warnings
      ],
      'msvs_settings': {
        'VCCLCompilerTool': {
          'WarningLevel': '0',
        },
      },
      'xcode_settings': {
        'WARNING_CFLAGS': [
          '-w',
        ],
      },
      'sources': [
        '../third_party/externals/libjpeg-turbo/jaricom.c',
        '../third_party/externals/libjpeg-turbo/jcapimin.c',
        '../third_party/externals/libjpeg-turbo/jcapistd.c',
        '../third_party/externals/libjpeg-turbo/jcarith.c',
        '../third_party/externals/libjpeg-turbo/jccoefct.c',
        '../third_party/externals/libjpeg-turbo/jccolor.c',
        '../third_party/externals/libjpeg-turbo/jcdctmgr.c',
        '../third_party/externals/libjpeg-turbo/jchuff.c',
        '../third_party/externals/libjpeg-turbo/jchuff.h',
        '../third_party/externals/libjpeg-turbo/jcinit.c',
        '../third_party/externals/libjpeg-turbo/jcmainct.c',
        '../third_party/externals/libjpeg-turbo/jcmarker.c',
        '../third_party/externals/libjpeg-turbo/jcmaster.c',
        '../third_party/externals/libjpeg-turbo/jcomapi.c',
        '../third_party/externals/libjpeg-turbo/jconfig.h',
        '../third_party/externals/libjpeg-turbo/jconfigint.h',
        '../third_party/externals/libjpeg-turbo/jcparam.c',
        '../third_party/externals/libjpeg-turbo/jcphuff.c',
        '../third_party/externals/libjpeg-turbo/jcprepct.c',
        '../third_party/externals/libjpeg-turbo/jcsample.c',
        '../third_party/externals/libjpeg-turbo/jdapimin.c',
        '../third_party/externals/libjpeg-turbo/jdapistd.c',
        '../third_party/externals/libjpeg-turbo/jdarith.c',
        '../third_party/externals/libjpeg-turbo/jdcoefct.c',
        '../third_party/externals/libjpeg-turbo/jdcolor.c',
        '../third_party/externals/libjpeg-turbo/jdct.h',
        '../third_party/externals/libjpeg-turbo/jddctmgr.c',
        '../third_party/externals/libjpeg-turbo/jdhuff.c',
        '../third_party/externals/libjpeg-turbo/jdhuff.h',
        '../third_party/externals/libjpeg-turbo/jdinput.c',
        '../third_party/externals/libjpeg-turbo/jdmainct.c',
        '../third_party/externals/libjpeg-turbo/jdmarker.c',
        '../third_party/externals/libjpeg-turbo/jdmaster.c',
        '../third_party/externals/libjpeg-turbo/jdmerge.c',
        '../third_party/externals/libjpeg-turbo/jdphuff.c',
        '../third_party/externals/libjpeg-turbo/jdpostct.c',
        '../third_party/externals/libjpeg-turbo/jdsample.c',
        '../third_party/externals/libjpeg-turbo/jerror.c',
        '../third_party/externals/libjpeg-turbo/jerror.h',
        '../third_party/externals/libjpeg-turbo/jfdctflt.c',
        '../third_party/externals/libjpeg-turbo/jfdctfst.c',
        '../third_party/externals/libjpeg-turbo/jfdctint.c',
        '../third_party/externals/libjpeg-turbo/jidctflt.c',
        '../third_party/externals/libjpeg-turbo/jidctfst.c',
        '../third_party/externals/libjpeg-turbo/jidctint.c',
        '../third_party/externals/libjpeg-turbo/jidctred.c',
        '../third_party/externals/libjpeg-turbo/jinclude.h',
        '../third_party/externals/libjpeg-turbo/jmemmgr.c',
        '../third_party/externals/libjpeg-turbo/jmemnobs.c',
        '../third_party/externals/libjpeg-turbo/jmemsys.h',
        '../third_party/externals/libjpeg-turbo/jmorecfg.h',
        '../third_party/externals/libjpeg-turbo/jpegint.h',
        '../third_party/externals/libjpeg-turbo/jpeglib.h',
        '../third_party/externals/libjpeg-turbo/jpeglibmangler.h',
        '../third_party/externals/libjpeg-turbo/jquant1.c',
        '../third_party/externals/libjpeg-turbo/jquant2.c',
        '../third_party/externals/libjpeg-turbo/jutils.c',
        '../third_party/externals/libjpeg-turbo/jversion.h',
      ],
      'direct_dependent_settings': {
        'include_dirs': [
          '../third_party/externals/libjpeg-turbo/',
        ],
      },
      'msvs_disabled_warnings': [4018, 4101],
      # VS2010 does not correctly incrementally link obj files generated
      # from asm files. This flag disables UseLibraryDependencyInputs to
      # avoid this problem.
      'msvs_2010_disable_uldi_when_referenced': 1,

      # Add target-specific source files.
      'conditions': [
        # TODO (msarett): Is it possible to enable cross compiling for Android on other platforms?
        [ 'skia_os == "android" and host_os != "linux" and "x86" in skia_arch_type', {
           'sources': [
             '../third_party/externals/libjpeg-turbo/jsimd_none.c',
           ],
        }],
        [ 'skia_arch_type == "x86" and (skia_os != "android" or host_os == "linux")', {
          'sources': [
            '../third_party/externals/libjpeg-turbo/simd/jsimd_i386.c',
            '../third_party/externals/libjpeg-turbo/simd/jccolor-mmx.asm',
            '../third_party/externals/libjpeg-turbo/simd/jccolor-sse2.asm',
            '../third_party/externals/libjpeg-turbo/simd/jcgray-mmx.asm',
            '../third_party/externals/libjpeg-turbo/simd/jcgray-sse2.asm',
            '../third_party/externals/libjpeg-turbo/simd/jcsample-mmx.asm',
            '../third_party/externals/libjpeg-turbo/simd/jcsample-sse2.asm',
            '../third_party/externals/libjpeg-turbo/simd/jdcolor-mmx.asm',
            '../third_party/externals/libjpeg-turbo/simd/jdcolor-sse2.asm',
            '../third_party/externals/libjpeg-turbo/simd/jdmerge-mmx.asm',
            '../third_party/externals/libjpeg-turbo/simd/jdmerge-sse2.asm',
            '../third_party/externals/libjpeg-turbo/simd/jdsample-mmx.asm',
            '../third_party/externals/libjpeg-turbo/simd/jdsample-sse2.asm',
            '../third_party/externals/libjpeg-turbo/simd/jfdctflt-3dn.asm',
            '../third_party/externals/libjpeg-turbo/simd/jfdctflt-sse.asm',
            '../third_party/externals/libjpeg-turbo/simd/jfdctfst-mmx.asm',
            '../third_party/externals/libjpeg-turbo/simd/jfdctfst-sse2.asm',
            '../third_party/externals/libjpeg-turbo/simd/jfdctint-mmx.asm',
            '../third_party/externals/libjpeg-turbo/simd/jfdctint-sse2.asm',
            '../third_party/externals/libjpeg-turbo/simd/jidctflt-3dn.asm',
            '../third_party/externals/libjpeg-turbo/simd/jidctflt-sse2.asm',
            '../third_party/externals/libjpeg-turbo/simd/jidctflt-sse.asm',
            '../third_party/externals/libjpeg-turbo/simd/jidctfst-mmx.asm',
            '../third_party/externals/libjpeg-turbo/simd/jidctfst-sse2.asm',
            '../third_party/externals/libjpeg-turbo/simd/jidctint-mmx.asm',
            '../third_party/externals/libjpeg-turbo/simd/jidctint-sse2.asm',
            '../third_party/externals/libjpeg-turbo/simd/jidctred-mmx.asm',
            '../third_party/externals/libjpeg-turbo/simd/jidctred-sse2.asm',
            '../third_party/externals/libjpeg-turbo/simd/jquant-3dn.asm',
            '../third_party/externals/libjpeg-turbo/simd/jquantf-sse2.asm',
            '../third_party/externals/libjpeg-turbo/simd/jquanti-sse2.asm',
            '../third_party/externals/libjpeg-turbo/simd/jquant-mmx.asm',
            '../third_party/externals/libjpeg-turbo/simd/jquant-sse.asm',
            '../third_party/externals/libjpeg-turbo/simd/jsimdcpu.asm',
          ],
        }],
        [ 'skia_arch_type == "x86_64" and (skia_os != "android" or host_os == "linux")', {
          'sources': [
            '../third_party/externals/libjpeg-turbo/simd/jsimd_x86_64.c',
            '../third_party/externals/libjpeg-turbo/simd/jccolor-sse2-64.asm',
            '../third_party/externals/libjpeg-turbo/simd/jcgray-sse2-64.asm',
            '../third_party/externals/libjpeg-turbo/simd/jcsample-sse2-64.asm',
            '../third_party/externals/libjpeg-turbo/simd/jdcolor-sse2-64.asm',
            '../third_party/externals/libjpeg-turbo/simd/jdmerge-sse2-64.asm',
            '../third_party/externals/libjpeg-turbo/simd/jdsample-sse2-64.asm',
            '../third_party/externals/libjpeg-turbo/simd/jfdctflt-sse-64.asm',
            '../third_party/externals/libjpeg-turbo/simd/jfdctfst-sse2-64.asm',
            '../third_party/externals/libjpeg-turbo/simd/jfdctint-sse2-64.asm',
            '../third_party/externals/libjpeg-turbo/simd/jidctflt-sse2-64.asm',
            '../third_party/externals/libjpeg-turbo/simd/jidctfst-sse2-64.asm',
            '../third_party/externals/libjpeg-turbo/simd/jidctint-sse2-64.asm',
            '../third_party/externals/libjpeg-turbo/simd/jidctred-sse2-64.asm',
            '../third_party/externals/libjpeg-turbo/simd/jquantf-sse2-64.asm',
            '../third_party/externals/libjpeg-turbo/simd/jquanti-sse2-64.asm',
          ],
        }],
        [ 'skia_arch_type == "arm64"', {
          'sources': [
            '../third_party/externals/libjpeg-turbo/simd/jsimd_arm64.c',
            '../third_party/externals/libjpeg-turbo/simd/jsimd_arm64_neon.S',
          ],
        }],
        [ 'skia_arch_type == "arm"', {
          'conditions': [
            [ 'arm_version >= 7 and (arm_neon == 1 or arm_neon_optional == 1)', {
              'sources': [
                '../third_party/externals/libjpeg-turbo/simd/jsimd_arm.c',
                '../third_party/externals/libjpeg-turbo/simd/jsimd_arm_neon.S',
              ],
            }, {
              'sources': [
                '../third_party/externals/libjpeg-turbo/jsimd_none.c',
              ],
            }],
          ],
        }],
        [ 'skia_arch_type == "mips"', {
          'conditions': [
            [ 'skia_arch_width == 64', {
              'sources': [
                '../third_party/externals/libjpeg-turbo/simd/jsimd_mips.c',
                '../third_party/externals/libjpeg-turbo/simd/jsimd_mips_dspr2_asm.h',
                '../third_party/externals/libjpeg-turbo/simd/jsimd_mips_dspr2.S',
              ],
            }, {
              'sources': [
                '../third_party/externals/libjpeg-turbo/jsimd_none.c',
              ],
            }],
          ],
        }],
      
        # Build rules for an asm file.
        # On Windows, we use the precompiled yasm binary.
        # On Linux, we build our patched yasm and use it.
        # On Mac, we always build our patched yasm and use it.
        [ 'skia_os == "win"', {
          'dependencies': [
            'yasm-win',
          ],
          'variables': {
            'yasm_path': '<(PRODUCT_DIR)/yasm.exe',
            'conditions': [
              [ 'skia_arch_type == "x86"', {
                'yasm_format': '-fwin32',
                'yasm_flags': [
                  '-D__x86__',
                  '-DWIN32',
                  '-DMSVC',
                  '-Iwin/'
                ],
              }, {
                'yasm_format': '-fwin64',
                'yasm_flags': [
                  '-D__x86_64__',
                  '-DWIN64',
                  '-DMSVC',
                  '-Iwin/'
                ],
              }],
            ],
          },
        }],
        [ 'skia_os == "android" and host_os == "linux" and \
          (skia_arch_type == "x86" or skia_arch_type == "x86_64")', {
          'dependencies': [
            'yasm.gyp:yasm#host',
          ],
          'variables': {
            'yasm_path': '<(PRODUCT_DIR)/yasm',
            'conditions': [
              [ 'skia_arch_type == "x86"', {
                'yasm_format': '-felf',
                'yasm_flags': [
                  '-D__x86__',
                  '-DELF',
                  '-Ilinux/'
                ],
              }, {
                'yasm_format': '-felf64',
                'yasm_flags': [
                  '-D__x86_64__',
                  '-DELF',
                  '-Ilinux/'
                ],
              }],
            ],
          },
        }],
        [ '(skia_os == "mac" or skia_os == "ios") and \
           (skia_arch_type == "x86" or skia_arch_type == "x86_64")', {
          'dependencies': [
            'yasm.gyp:yasm#host',
          ],
          'variables': {
            'yasm_path': '<(PRODUCT_DIR)/yasm',
            'conditions': [
              [ 'skia_arch_type == "x86"', {
                'yasm_format': '-fmacho',
                'yasm_flags': [
                  '-D__x86__',
                  '-DMACHO',
                  '-Imac/'
                ],
              }, {
                'yasm_format': '-fmacho64',
                'yasm_flags': [
                  '-D__x86_64__',
                  '-DMACHO',
                  '-Imac/'
                ],
              }],
            ],
          },
        }],
        [ '(skia_os == "linux" or skia_os == "freebsd" or skia_os == "openbsd" or \
            skia_os == "solaris" or skia_os == "chromeos")', {
          'dependencies': [
            'yasm.gyp:yasm#host',
          ],
          'variables': {
            'yasm_path': '<(PRODUCT_DIR)/yasm',
            'conditions': [
              [ 'skia_arch_type == "x86"', {
                'yasm_format': '-felf',
                'yasm_flags': [
                  '-D__x86__',
                  '-DELF',
                  '-Ilinux/'
                ],
              }, {
                'yasm_format': '-felf64',
                'yasm_flags': [
                  '-D__x86_64__',
                  '-DELF',
                  '-Ilinux/'
                ],
              }],
            ],
          },
        }],
      ],
      'rules': [
        {
          'rule_name': 'assemble',
          'extension': 'asm',
          'conditions': [
            [ '(skia_arch_type == "x86" or skia_arch_type == "x86_64") and \
               (skia_os != "android" or host_os == "linux")', {
              'inputs': [],
              'outputs': [
                '<(shared_generated_dir)/<(RULE_INPUT_ROOT).<(object_suffix)',
              ],
              'action': [
                '<(yasm_path)',
                '<(yasm_format)',
                '<@(yasm_flags)',
                '-DRGBX_FILLER_0XFF',
                '-DSTRICT_MEMORY_ACCESS',
                '-Isimd/',
                '-o', '<(shared_generated_dir)/<(RULE_INPUT_ROOT).<(object_suffix)',
                '<(RULE_INPUT_PATH)',
              ],
              'process_outputs_as_sources': 1,
              'message': 'Building <(RULE_INPUT_ROOT).<(object_suffix)',
            }],
          ]
        },
      ],
    },
  ],
}