summaryrefslogtreecommitdiff
path: root/build/standalone.gypi
blob: 7dbbe1100ef0121f38cf637f46347ddb75814aeb (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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
# Copyright 2014 PDFium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Definitions to be used when building stand-alone PDFium binaries.

{
  'variables': {
    'component%': 'static_library',
    'clang%': 0,
    'asan%': 0,
    'sanitizer_coverage%': 0,
    'use_goma%': 0,
    'gomadir%': '',
    'msvs_multi_core_compile%': '1',
    'variables': {
      'variables': {
        'variables': {
          'conditions': [
            ['OS=="linux" or OS=="mac"', {
              # This handles the Unix platforms we generally deal with.
              # Anything else gets passed through, which probably won't work
              # very well; such hosts should pass an explicit target_arch
              # to gyp.
              'host_arch%':
                '<!(uname -m | sed -e "s/i.86/ia32/;\
                                       s/x86_64/x64/;\
                                       s/amd64/x64/;\
                                       s/arm.*/arm/;\
                                       s/aarch64/arm64/;\
                                       s/mips.*/mipsel/")',
            }, {
              # OS!="linux" and OS!="mac"
              'host_arch%': 'ia32',
            }],
          ],
        },
        'host_arch%': '<(host_arch)',
        'target_arch%': '<(host_arch)',
      },
      'host_arch%': '<(host_arch)',
      'target_arch%': '<(target_arch)',
    },
    'clang_dir%': 'third_party/llvm-build/Release+Asserts',
    # These two are needed by V8.
    'host_arch%': '<(host_arch)',
    'target_arch%': '<(target_arch)',
    'werror%': '-Werror',
    'v8_optimized_debug%': 0,
    'v8_use_external_startup_data%': 0,
    'icu_gyp_path': '../v8/third_party/icu/icu.gyp',
    'libjpeg_gyp_path': '../third_party/third_party.gyp',
    'conditions': [
      ['OS == "win"', {
        'os_posix%': 0,
      }, {
        'os_posix%': 1,
      }],
      ['OS=="linux" or OS=="mac"', {
        'clang%': 1,
        'host_clang%': 1,
      }, {
        'clang%': 0,
        'host_clang%': 0,
      }],
      # Set default gomadir.
      ['OS=="win"', {
        'gomadir%': 'c:\\goma\\goma-win',
      }, {
        'gomadir%': '<!(/bin/echo -n ${HOME}/goma)',
      }],
    ],
  },
  'target_defaults': {
    'default_configuration': 'Debug',
    'configurations': {
      'Debug': {
        'cflags': [
          '-g',
          '-O0',
          '-fdata-sections',
          '-ffunction-sections',
        ],
        'msvs_settings': {
          'VCCLCompilerTool': {
            'Optimization': '0',
            'conditions': [
              ['component=="shared_library"', {
                'RuntimeLibrary': '3',  # /MDd
              }, {
                'RuntimeLibrary': '1',  # /MTd
              }],
            ],
          },
          'VCLinkerTool': {
            'LinkIncremental': '2',
          },
        },
        'xcode_settings': {
          'GCC_OPTIMIZATION_LEVEL': '0',  # -O0
        },
      },
      'Release': {
        'cflags': [
          '-fno-strict-aliasing',
        ],
        'xcode_settings': {
          'GCC_OPTIMIZATION_LEVEL': '3',  # -O3
          'GCC_STRICT_ALIASING': 'NO',
        },
        'msvs_settings': {
          'VCCLCompilerTool': {
            'Optimization': '2',
            'InlineFunctionExpansion': '2',
            'EnableIntrinsicFunctions': 'true',
            'FavorSizeOrSpeed': '0',
            'StringPooling': 'true',
            'conditions': [
              ['component=="shared_library"', {
                'RuntimeLibrary': '2',  #/MD
              }, {
                'RuntimeLibrary': '0',  #/MT
              }],
            ],
          },
          'VCLinkerTool': {
            'LinkIncremental': '1',
            'OptimizeReferences': '2',
            'EnableCOMDATFolding': '2',
          },
        },
        'conditions': [
          ['OS=="linux"', {
            'cflags': [
              '-fdata-sections',
              '-ffunction-sections',
              '-O3',
              '-O2',
            ],
          }],
          ['OS=="android"', {
            'cflags!': [
              '-O3',
              '-Os',
            ],
            'cflags': [
              '-fdata-sections',
              '-ffunction-sections',
              '-O2',
            ],
          }],
        ],  # conditions
      },
      'Debug_x64': {
        'inherit_from': ['Debug'],
        'msvs_configuration_platform': 'x64',
      },
      'Release_x64': {
        'inherit_from': ['Release'],
        'msvs_configuration_platform': 'x64',
      },
    },
    'cflags': [
      '-Wall',
      '-W',
      '-Wno-missing-field-initializers',
      # Code might someday be made clean for -Wsign-compare, but for now
      # this produces too much noise to be useful.
      '-Wno-sign-compare',
      '-Wno-unused-parameter',
      '-pthread',
      '-fno-exceptions',
      '-fvisibility=hidden',
    ],
    'cflags_cc': [
      '-std=gnu++0x',
      '-Wnon-virtual-dtor',
      '-fno-rtti',
    ],
    'ldflags': [
      '-pthread',
    ],
    'defines': [
      # Don't use deprecated V8 APIs anywhere.
      'V8_DEPRECATION_WARNINGS',
    ],
    'msvs_cygwin_dirs': ['<(DEPTH)/v8/third_party/cygwin'],
    'msvs_configuration_attributes': {
      'OutputDirectory': '<(DEPTH)\\build\\$(ConfigurationName)',
      'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)',
      'CharacterSet': '1',
    },
    'msvs_disabled_warnings': [
      # ####
      # This section is PDFium specific.
      # ####

      # C4800: forcing value to bool 'true' or 'false' (performance warning)
      4800,

      # ####
      # This section should match Chromium's build/common.gypi.
      # ####

      # C4091: 'typedef ': ignored on left of 'X' when no variable is
      #                    declared.
      # This happens in a number of Windows headers. Dumb.
      4091,

      # C4127: conditional expression is constant
      # This warning can in theory catch dead code and other problems, but
      # triggers in far too many desirable cases where the conditional
      # expression is either set by macros or corresponds some legitimate
      # compile-time constant expression (due to constant template args,
      # conditionals comparing the sizes of different types, etc.).  Some of
      # these can be worked around, but it's not worth it.
      4127,

      # C4351: new behavior: elements of array 'array' will be default
      #        initialized
      # This is a silly "warning" that basically just alerts you that the
      # compiler is going to actually follow the language spec like it's
      # supposed to, instead of not following it like old buggy versions
      # did.  There's absolutely no reason to turn this on.
      4351,

      # C4355: 'this': used in base member initializer list
      # It's commonly useful to pass |this| to objects in a class'
      # initializer list.  While this warning can catch real bugs, most of
      # the time the constructors in question don't attempt to call methods
      # on the passed-in pointer (until later), and annotating every legit
      # usage of this is simply more hassle than the warning is worth.
      4355,

      # C4503: 'identifier': decorated name length exceeded, name was
      #        truncated
      # This only means that some long error messages might have truncated
      # identifiers in the presence of lots of templates.  It has no effect
      # on program correctness and there's no real reason to waste time
      # trying to prevent it.
      4503,

      # Warning C4589 says: "Constructor of abstract class ignores
      # initializer for virtual base class." Disable this warning because it
      # is flaky in VS 2015 RTM. It triggers on compiler generated
      # copy-constructors in some cases.
      4589,

      # C4611: interaction between 'function' and C++ object destruction is
      #        non-portable
      # This warning is unavoidable when using e.g. setjmp/longjmp.  MSDN
      # suggests using exceptions instead of setjmp/longjmp for C++, but
      # Chromium code compiles without exception support.  We therefore have
      # to use setjmp/longjmp for e.g. JPEG decode error handling, which
      # means we have to turn off this warning (and be careful about how
      # object destruction happens in such cases).
      4611,

      # TODO(thestig): These warnings are level 4. They will be slowly
      # removed as code is fixed.
      4100, # Unreferenced formal parameter
      4121, # Alignment of a member was sensitive to packing
      4244, # Conversion from 'type1' to 'type2', possible loss of data
      4505, # Unreferenced local function has been removed
      4510, # Default constructor could not be generated
      4512, # Assignment operator could not be generated
      4610, # Object can never be instantiated
      4838, # Narrowing conversion. Doesn't seem to be very useful.
      4995, # 'X': name was marked as #pragma deprecated
      4996, # 'X': was declared deprecated (for GetVersionEx).

      # These are variable shadowing warnings that are new in VS2015. We
      # should work through these at some point -- they may be removed from
      # the RTM release in the /W4 set.
      4456, 4457, 4458, 4459,

      # TODO(brucedawson): http://crbug.com/554200 4312 is a VS
      # 2015 64-bit warning for integer to larger pointer
      4312,

      # ####
      # Do not add PDFium specific entries here. Add them to the top.
      # ####
    ],
    'msvs_settings': {
      'VCCLCompilerTool': {
        'MinimalRebuild': 'false',
        'BufferSecurityCheck': 'true',
        'EnableFunctionLevelLinking': 'true',
        'RuntimeTypeInfo': 'false',
        'WarningLevel': '3',
        'DebugInformationFormat': '3',
        'Detect64BitPortabilityProblems': 'false',
        'conditions': [
          [ 'msvs_multi_core_compile', {
            'AdditionalOptions': ['/MP'],
          }],
          ['component=="shared_library"', {
            'ExceptionHandling': '1',  # /EHsc
          }, {
            'ExceptionHandling': '0',
          }],
          ['target_arch=="x64"', {
            # 64-bit warnings need to be resolved.
            # https://code.google.com/p/pdfium/issues/detail?id=101
            'WarnAsError': 'false',
          }, {
            'WarnAsError': 'true',
          }],
        ],
      },
      'VCLibrarianTool': {
        'AdditionalOptions': ['/ignore:4221'],
      },
      'VCLinkerTool': {
        'GenerateDebugInformation': 'true',
        'LinkIncremental': '1',
        # SubSystem values:
        #   0 == not set
        #   1 == /SUBSYSTEM:CONSOLE
        #   2 == /SUBSYSTEM:WINDOWS
        'SubSystem': '1',
      },
    },
    'xcode_settings': {
      'ALWAYS_SEARCH_USER_PATHS': 'NO',
      'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++11',
      'GCC_CW_ASM_SYNTAX': 'NO',                # No -fasm-blocks
      'GCC_DYNAMIC_NO_PIC': 'NO',               # No -mdynamic-no-pic
                                                # (Equivalent to -fPIC)
      'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',        # -fno-exceptions
      'GCC_ENABLE_CPP_RTTI': 'NO',              # -fno-rtti
      'GCC_ENABLE_PASCAL_STRINGS': 'NO',        # No -mpascal-strings
      # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden
      'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
      'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES',      # -fvisibility=hidden
      'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO',     # -Werror
      'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor
      'SYMROOT': '<(DEPTH)/xcodebuild',
      'USE_HEADERMAP': 'NO',
      'OTHER_CFLAGS': [
        '-fno-strict-aliasing',
      ],
      'WARNING_CFLAGS': [
        '-Wall',
        '-Wendif-labels',
        '-W',
        '-Wno-unused-parameter',
      ],
    },
    'variables': {
      'clang_warning_flags': [],
    },
    'includes': [ 'set_clang_warning_flags.gypi', ],
    'conditions': [
      ['component=="shared_library"', {
        'cflags': [
          '-fPIC',
        ],
      }],
      ['asan==1', {
        'defines': [
          'ADDRESS_SANITIZER',
          'LEAK_SANITIZER',
        ],
        'cflags': [
          '-fsanitize=address',
          '-gline-tables-only',
        ],
        'ldflags': [
          '-fsanitize=address',
        ],
      }],
      ['sanitizer_coverage!=0', {
        'cflags': [
          '-fsanitize-coverage=<(sanitizer_coverage)',
        ],
      }],
      ['OS=="win"', {
        'defines': [
          'NOMINMAX',
          '_CRT_SECURE_NO_DEPRECATE',
          '_CRT_NONSTDC_NO_DEPRECATE',
        ],
        'conditions': [
          ['component=="static_library"', {
            'defines': [
              '_HAS_EXCEPTIONS=0',
            ],
          }],
          ['use_goma==1', {
            # goma doesn't support PDB yet.
            'msvs_settings': {
              'VCLinkerTool': {
                'GenerateDebugInformation': 'true',
              },
              'VCCLCompilerTool': {
                'DebugInformationFormat': '1',
              },
            },
          }],
        ],
      }],  # OS=="win"
      ['OS=="mac"', {
        'target_conditions': [
          ['_type!="static_library"', {
            'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
          }],
        ],  # target_conditions
      }],  # OS=="mac"
      ['v8_use_external_startup_data==1', {
        'defines': [
          'V8_USE_EXTERNAL_STARTUP_DATA',
        ],
      }],  # v8_use_external_startup_data==1
      ['clang==1 or host_clang==1', {
        # This is here so that all files get recompiled after a clang roll and
        # when turning clang on or off.
        # (defines are passed via the command line, and build systems rebuild
        # things when their commandline changes). Nothing should ever read this
        # define.
        'defines': ['CR_CLANG_REVISION=<!(python <(DEPTH)/tools/clang/scripts/update.py --print-revision)'],
      }],
    ],
  },
  'xcode_settings': {
    # See comment in Chromium's common.gypi for why this is needed.
    'SYMROOT': '<(DEPTH)/xcodebuild',
  },
  'conditions': [
    ['OS=="linux" or OS=="mac"', {
      'conditions': [
        ['clang==1', {
          'make_global_settings': [
            ['CC', '<(clang_dir)/bin/clang'],
            ['CXX', '<(clang_dir)/bin/clang++'],
          ],
        }],
      ],
    }],  # OS=="linux" or OS=="mac"
    ["use_goma==1", {
      'make_global_settings': [
        ['CC_wrapper', '<(gomadir)/gomacc'],
        ['CXX_wrapper', '<(gomadir)/gomacc'],
      ],
    }],  # use_goma==1
  ],
}