• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# conditions used in both common.gypi and skia.gyp in chromium
2#
3{
4  'defines': [
5    'SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=<(skia_static_initializers)',
6    'SK_SUPPORT_GPU=<(skia_gpu)',
7    'SK_SUPPORT_OPENCL=<(skia_opencl)',
8    'SK_FORCE_DISTANCEFIELD_FONTS=<(skia_force_distancefield_fonts)',
9    'SK_PICTURE_USE_SK_RECORD',
10    'SK_PICTURE_OPTIMIZE_SK_RECORD',
11  ],
12  'conditions' : [
13    ['skia_pic', {
14     'cflags': [
15       '-fPIC',
16     ],
17     'conditions' : [
18      # FIXME: The reason we don't do this on Android is due to the way
19      # we build the executables/skia_launcher on Android. See
20      # https://codereview.chromium.org/406613003/diff/1/gyp/common_conditions.gypi#newcode455
21      ['skia_os != "android"', {
22       'target_conditions': [
23         [ '_type == "executable"', {
24           'cflags': [ '-fPIE' ],
25           'ldflags': [ '-pie' ],
26         }],
27       ],
28      }],
29     ],
30    }],
31
32    # As of M35, Chrome requires SSE2 on x86 (and SSSE3 on Mac).
33    [ 'skia_arch_type == "x86"', {
34      'cflags': [
35        '-msse2',
36        '-mfpmath=sse',
37      ],
38    }],
39
40    [ 'skia_os == "win"',
41      {
42        'defines': [
43          'SK_BUILD_FOR_WIN32',
44          '_CRT_SECURE_NO_WARNINGS',
45          'GR_GL_FUNCTION_TYPE=__stdcall',
46        ],
47        'msvs_disabled_warnings': [
48            4275,  # An exported class was derived from a class that was not exported
49            4345,  # This is an FYI about a behavior change from long ago. Chrome stifles it too.
50            4355,  # 'this' used in base member initializer list. Off by default in newer compilers.
51        ],
52        'msvs_cygwin_shell': 0,
53        'msvs_settings': {
54          'VCCLCompilerTool': {
55            'WarningLevel': '3',
56            'ProgramDataBaseFileName': '$(OutDir)\\$(ProjectName).pdb',
57            'DebugInformationFormat': '3',
58            'ExceptionHandling': '0',
59            'AdditionalOptions': [ '/MP', ],
60          },
61          'VCLinkerTool': {
62            'LargeAddressAware': 2,  # 2 means "Yes, please let me use more RAM on 32-bit builds."
63            'AdditionalDependencies': [
64              'OpenGL32.lib',
65              'usp10.lib',
66
67              # Prior to gyp r1584, the following were included automatically.
68              'kernel32.lib',
69              'gdi32.lib',
70              'winspool.lib',
71              'comdlg32.lib',
72              'advapi32.lib',
73              'shell32.lib',
74              'ole32.lib',
75              'oleaut32.lib',
76              'user32.lib',
77              'uuid.lib',
78              'odbc32.lib',
79              'odbccp32.lib',
80              'DelayImp.lib',
81            ],
82          },
83        },
84        'configurations': {
85          'Debug': {
86            'msvs_settings': {
87              'VCCLCompilerTool': {
88                'DebugInformationFormat': '4', # editAndContiue (/ZI)
89                'Optimization': '0',           # optimizeDisabled (/Od)
90                'PreprocessorDefinitions': ['_DEBUG'],
91                'RuntimeLibrary': '3',         # rtMultiThreadedDebugDLL (/MDd)
92                'RuntimeTypeInfo': 'false',      # /GR-
93              },
94              'VCLinkerTool': {
95                'GenerateDebugInformation': 'true', # /DEBUG
96                'LinkIncremental': '2',             # /INCREMENTAL
97              },
98            },
99          },
100          'Release': {
101            'msvs_settings': {
102              'VCCLCompilerTool': {
103                'DebugInformationFormat': '3',      # programDatabase (/Zi)
104                'Optimization': '<(skia_release_optimization_level)',
105               # Changing the floating point model requires rebaseling gm images
106               #'FloatingPointModel': '2',          # fast (/fp:fast)
107                'FavorSizeOrSpeed': '1',            # speed (/Ot)
108                'PreprocessorDefinitions': ['NDEBUG'],
109                'RuntimeLibrary': '2',              # rtMultiThreadedDLL (/MD)
110                'EnableEnhancedInstructionSet': '2',# /arch:SSE2
111                'RuntimeTypeInfo': 'false',         # /GR-
112              },
113              'VCLinkerTool': {
114                'GenerateDebugInformation': 'true', # /DEBUG
115              },
116            },
117          },
118        },
119        'conditions' : [
120          # Gyp's ninja generator depends on these specially named
121          # configurations to build 64-bit on Windows.
122          # See http://skbug.com/2348
123          #
124          # We handle the 64- vs 32-bit variations elsewhere, so I think it's
125          # OK for us to just make these inherit non-archwidth-specific
126          # configurations without modification.
127          #
128          # See http://skbug.com/2442 : These targets cause problems in the
129          # MSVS build, so only include them if gyp is generating a ninja build.
130          [ '"ninja" in "<!(echo %GYP_GENERATORS%)"', {
131            'configurations': {
132              'Debug_x64': {
133                'inherit_from': ['Debug'],
134              },
135              'Release_x64': {
136                'inherit_from': ['Release'],
137              },
138              'Release_Developer_x64': {
139                'inherit_from': ['Release_Developer'],
140              },
141            },
142          }],
143          [ 'skia_arch_width == 64', {
144            'msvs_configuration_platform': 'x64',
145          }],
146          [ 'skia_arch_width == 32', {
147            'msvs_configuration_platform': 'Win32',
148          }],
149          [ 'skia_warnings_as_errors', {
150            'msvs_settings': {
151              'VCCLCompilerTool': {
152                'WarnAsError': 'true',
153                'AdditionalOptions': [
154                  '/we4189', # initialized but unused var warning
155                ],
156              },
157            },
158          }],
159          [ 'skia_win_exceptions', {
160            'msvs_settings': {
161              'VCCLCompilerTool': {
162                'AdditionalOptions': [
163                  '/EHsc',
164                ],
165              },
166            },
167          }],
168          [ 'skia_win_ltcg', {
169            'configurations': {
170              'Release': {
171                'msvs_settings': {
172                  'VCCLCompilerTool': {
173                    'WholeProgramOptimization': 'true', #/GL
174                  },
175                  'VCLinkerTool': {
176                    'LinkTimeCodeGeneration': '1',      # useLinkTimeCodeGeneration /LTCG
177                  },
178                  'VCLibrarianTool': {
179                    'LinkTimeCodeGeneration': 'true',   # useLinkTimeCodeGeneration /LTCG
180                  },
181                },
182              },
183            },
184          }],
185        ],
186      },
187    ],
188
189    # The following section is common to linux + derivatives and android
190    [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "nacl", "chromeos", "android"]',
191      {
192        'cflags': [
193          '-g',
194          '-fno-exceptions',
195          '-fstrict-aliasing',
196
197          '-Wall',
198          '-Wextra',
199          '-Winit-self',
200          '-Wpointer-arith',
201
202          '-Wno-c++11-extensions',
203          '-Wno-unused-parameter',
204        ],
205        'cflags_cc': [
206          '-fno-rtti',
207          '-Wnon-virtual-dtor',
208          '-Wno-invalid-offsetof',  # GCC <4.6 is old-school strict about what is POD.
209        ],
210        'conditions': [
211          [ 'skia_os != "chromeos"', {
212            'conditions': [
213              [ 'skia_arch_width == 64 and skia_arch_type == "x86"', {
214                'cflags': [
215                  '-m64',
216                ],
217                'ldflags': [
218                  '-m64',
219                ],
220              }],
221              [ 'skia_arch_width == 32 and skia_arch_type == "x86"', {
222                'cflags': [
223                  '-m32',
224                ],
225                'ldflags': [
226                  '-m32',
227                ],
228              }],
229            ],
230          }],
231          [ 'skia_warnings_as_errors', {
232            'cflags': [
233              '-Werror',
234            ],
235          }],
236          # For profiling; reveals some costs, exaggerates others (e.g. trivial setters & getters).
237          [ 'skia_disable_inlining', {
238            'cflags': [
239              '-fno-inline',
240              '-fno-default-inline',
241              '-finline-limit=0',
242              '-fno-omit-frame-pointer',
243            ],
244          }],
245          [ 'skia_arch_type == "arm" and arm_thumb == 1', {
246            'cflags': [
247              '-mthumb',
248            ],
249            # The --fix-cortex-a8 switch enables a link-time workaround for
250            # an erratum in certain Cortex-A8 processors.  The workaround is
251            # enabled by default if you target the ARM v7-A arch profile.
252            # It can be enabled otherwise by specifying --fix-cortex-a8, or
253            # disabled unconditionally by specifying --no-fix-cortex-a8.
254            #
255            # The erratum only affects Thumb-2 code.
256            'conditions': [
257              [ 'arm_version < 7', {
258                'ldflags': [
259                  '-Wl,--fix-cortex-a8',
260                ],
261              }],
262            ],
263          }],
264          [ 'skia_arch_type == "arm" and arm_version >= 7', {
265            'cflags': [
266              '-march=armv7-a',
267            ],
268            'ldflags': [
269              '-march=armv7-a',
270            ],
271            'conditions': [
272              [ 'arm_neon == 1', {
273                'defines': [
274                  'SK_ARM_HAS_NEON',
275                ],
276                'cflags': [
277                  '-mfpu=neon',
278                ],
279              }],
280              [ 'arm_neon_optional == 1', {
281                'defines': [
282                  'SK_ARM_HAS_OPTIONAL_NEON',
283                ],
284              }],
285              [ 'skia_os != "chromeos"', {
286                'cflags': [
287                  '-mfloat-abi=softfp',
288                ],
289              }],
290            ],
291          }],
292          [ 'skia_arch_type == "mips"', {
293            'cflags': [
294              '-EL',
295            ],
296            'conditions': [
297              [ 'mips_arch_variant == "mips32r2"', {
298                'cflags': [
299                  '-march=mips32r2',
300                ],
301                'conditions': [
302                  [ 'mips_dsp == 1', {
303                    'cflags': [
304                      '-mdsp',
305                    ],
306                    'defines': [
307                      'SK_MIPS_HAS_DSP',
308                    ],
309                  }],
310                  [ 'mips_dsp == 2', {
311                    'cflags': [
312                      '-mdspr2',
313                    ],
314                    'defines': [
315                      'SK_MIPS_HAS_DSP',
316                      'SK_MIPS_HAS_DSPR2',
317                    ],
318                  }],
319                ],
320              }],
321            ],
322          }],
323        ],
324      },
325    ],
326
327    ['skia_android_framework', {
328      'includes' : [
329        'skia_for_android_framework_defines.gypi',
330      ],
331      'cflags': [
332        # Skia does not enforce this usage pattern so we disable it here to avoid
333        # unecessary log spew when building
334        '-Wno-unused-parameter',
335
336        # Android's -D_FORTIFY_SOURCE=2 extensions are incompatibile with SkString.
337        # Revert to -D_FORTIFY_SOURCE=1
338        '-U_FORTIFY_SOURCE',
339        '-D_FORTIFY_SOURCE=1',
340      ],
341      # Remove flags which are either unnecessary or problematic for the
342      # Android framework build. Many of these flags are removed simply because
343      # they were not previously in the Android framework makefile, and we did
344      # did not intend to add them when generating the makefile.
345      # TODO (scroggo): Investigate whether any of these flags are actually
346      # needed/would be beneficial.
347      'cflags!': [
348        # Android has one makefile, used for both debugging (after manual
349        # modification) and release. Turn off debug info by default.
350        '-g',
351        '-march=armv7-a',
352        '-mthumb',
353        '-mfpu=neon',
354        '-mfloat-abi=softfp',
355        '-fno-exceptions',
356        '-fstrict-aliasing',
357        # Remove flags to turn on warnings, since most people building Android
358        # are not focused on Skia and do not need the extra warning info.
359        '-Wall',
360        '-Wextra',
361        '-Winit-self',
362        '-Wpointer-arith',
363      ],
364      'cflags_cc!': [
365        '-fno-rtti',
366        '-Wnon-virtual-dtor',
367      ],
368      'defines': [
369        'DCT_IFAST_SUPPORTED',
370        # using freetype's embolden allows us to adjust fake bold settings at
371        # draw-time, at which point we know which SkTypeface is being drawn
372        'SK_USE_FREETYPE_EMBOLDEN',
373        'SK_SFNTLY_SUBSETTER "sample/chromium/font_subsetter.h"',
374        # When built as part of the system image we can enable certian non-NDK
375        # compliant optimizations.
376        'SK_BUILD_FOR_ANDROID_FRAMEWORK',
377        # Optimizations for chromium (m30)
378        'GR_GL_CUSTOM_SETUP_HEADER "gl/GrGLConfig_chrome.h"',
379        'IGNORE_ROT_AA_RECT_OPT',
380        'SkLONGLONG int64_t',
381        'SK_DEFAULT_FONT_CACHE_LIMIT   (768 * 1024)',
382        # Transitional, for deprecated SkCanvas::SaveFlags methods.
383        'SK_ATTR_DEPRECATED=SK_NOTHING_ARG1',
384        'SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024)',
385        'SK_IGNORE_ETC1_SUPPORT',
386        # Defines from skia_for_android_framework_defines.gypi
387        '<@(skia_for_android_framework_defines)',
388      ],
389    }],
390
391    [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "nacl", "chromeos"]',
392      {
393        'defines': [
394          'SK_SAMPLES_FOR_X',
395          'SK_BUILD_FOR_UNIX',
396        ],
397        'configurations': {
398          'Coverage': {
399            'cflags': ['--coverage'],
400            'ldflags': ['--coverage'],
401          },
402          'Debug': {
403          },
404          'Release': {
405            'cflags': [
406              '-O<(skia_release_optimization_level)',
407            ],
408            'defines': [ 'NDEBUG' ],
409          },
410        },
411        'conditions' : [
412          [ 'skia_shared_lib', {
413            'defines': [
414              'SKIA_DLL',
415              'SKIA_IMPLEMENTATION=1',
416            ],
417          }],
418          [ 'skia_os == "nacl"', {
419            'defines': [
420              'SK_BUILD_FOR_NACL',
421            ],
422            'variables': {
423              'nacl_sdk_root': '<!(echo ${NACL_SDK_ROOT})',
424            },
425            'link_settings': {
426              'libraries': [
427                '-lppapi',
428                '-lppapi_cpp',
429                '-lnosys',
430                '-pthread',
431              ],
432              'ldflags': [
433                '-L<(nacl_sdk_root)/lib/newlib_x86_<(skia_arch_width)/Release',
434                '-L<(nacl_sdk_root)/ports/lib/newlib_x86_<(skia_arch_width)/Release',
435              ],
436            },
437          }],
438          # Enable asan, tsan, etc.
439          [ 'skia_sanitizer', {
440            'cflags': [
441              '-fsanitize=<(skia_sanitizer)',
442            ],
443            'ldflags': [
444              '-fsanitize=<(skia_sanitizer)',
445            ],
446            'conditions' : [
447              [ 'skia_sanitizer == "thread"', {
448                'defines': [ 'SK_DYNAMIC_ANNOTATIONS_ENABLED=1' ],
449              }],
450              [ 'skia_sanitizer == "undefined"', {
451                'cflags_cc!': ['-fno-rtti'],
452              }],
453            ],
454          }],
455          [ 'skia_clang_build', {
456            'cflags_cc': [
457                # Build in C++11 mode to make sure we'll have an easy time switching.
458                '-std=c++11',
459                '-Wno-unknown-warning-option',  # Allows unknown warnings.
460                '-Wno-deprecated',              # From Qt, via debugger (older Clang).
461                '-Wno-deprecated-register',     # From Qt, via debugger (newer Clang).
462            ],
463            'cflags': [
464                # Extra warnings we like but that only Clang knows about.
465                '-Wstring-conversion',
466            ],
467            'cflags!': [
468                '-mfpmath=sse',  # Clang doesn't need to be told this, and sometimes gets confused.
469            ],
470          }],
471          [ 'skia_keep_frame_pointer', {
472            'cflags': [ '-fno-omit-frame-pointer' ],
473          }],
474        ],
475      },
476    ],
477
478    [ 'skia_os == "mac"',
479      {
480        'defines': [ 'SK_BUILD_FOR_MAC' ],
481        'configurations': {
482          'Coverage': {
483            'xcode_settings': {
484               'GCC_OPTIMIZATION_LEVEL': '0',
485               'GCC_GENERATE_TEST_COVERAGE_FILES': 'YES',
486               'GCC_INSTRUMENT_PROGRAM_FLOW_ARCS' : 'YES',
487            },
488          },
489          'Debug': {
490            'xcode_settings': { 'GCC_OPTIMIZATION_LEVEL': '0' },
491          },
492          'Release': {
493            'xcode_settings': { 'GCC_OPTIMIZATION_LEVEL': '<(skia_release_optimization_level)', },
494            'defines': [ 'NDEBUG' ],
495          },
496        },
497        'xcode_settings': {
498          'conditions': [
499            [ 'skia_warnings_as_errors', { 'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES' }],
500            [ 'skia_arch_width == 32', { 'ARCHS': ['i386']   }],
501            [ 'skia_arch_width == 64', { 'ARCHS': ['x86_64'] }],
502            [ 'skia_osx_deployment_target==""', {
503              'MACOSX_DEPLOYMENT_TARGET': '10.6', # -mmacos-version-min, passed in env to ld.
504            }, {
505              'MACOSX_DEPLOYMENT_TARGET': '<(skia_osx_deployment_target)',
506            }],
507          ],
508          'GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS': 'YES',  # -mssse3
509          'GCC_SYMBOLS_PRIVATE_EXTERN':                'NO',   # -fvisibility=hidden
510          'GCC_INLINES_ARE_PRIVATE_EXTERN':            'NO',   # -fvisibility-inlines-hidden
511          'WARNING_CFLAGS': [
512            '-Wall',
513            '-Wextra',
514            '-Wno-unused-parameter',
515            '-Wno-uninitialized',  # Disabled because we think GCC 4.2 is bad at this.
516          ],
517        },
518      },
519    ],
520
521    [ 'skia_os == "ios"',
522      {
523        'defines': [
524          'SK_BUILD_FOR_IOS',
525        ],
526        'conditions' : [
527          [ 'skia_warnings_as_errors', {
528            'xcode_settings': {
529              'OTHER_CPLUSPLUSFLAGS': [
530                '-Werror',
531              ],
532            },
533          }],
534        ],
535        'configurations': {
536          'Debug': {
537            'xcode_settings': {
538              'GCC_OPTIMIZATION_LEVEL': '0',
539            },
540          },
541          'Release': {
542            'xcode_settings': {
543              'GCC_OPTIMIZATION_LEVEL': '<(skia_release_optimization_level)',
544            },
545            'defines': [ 'NDEBUG' ],
546          },
547        },
548        'xcode_settings': {
549          'ARCHS': ['armv7'],
550          'CODE_SIGNING_REQUIRED': 'NO',
551          'CODE_SIGN_IDENTITY[sdk=iphoneos*]': '',
552          'IPHONEOS_DEPLOYMENT_TARGET': '<(ios_sdk_version)',
553          'SDKROOT': 'iphoneos',
554          'TARGETED_DEVICE_FAMILY': '1,2',
555          'OTHER_CPLUSPLUSFLAGS': [
556            '-fvisibility=hidden',
557            '-fvisibility-inlines-hidden',
558          ],
559          'GCC_THUMB_SUPPORT': 'NO',
560        },
561      },
562    ],
563
564    [ 'skia_os == "android"',
565      {
566        'defines': [
567          'SK_BUILD_FOR_ANDROID',
568
569          # Android Text Tuning
570          'SK_GAMMA_EXPONENT=1.4',
571          'SK_GAMMA_CONTRAST=0.0',
572        ],
573        # Android defines a fixed gamma exponent instead of using SRGB
574        'defines!': [
575          'SK_GAMMA_SRGB',
576        ],
577        'configurations': {
578          'Debug': {
579            'cflags': ['-g']
580          },
581          'Release': {
582            'cflags': ['-O2'],
583          },
584        },
585        'libraries': [
586          '-llog',
587        ],
588        'cflags': [
589          '-fuse-ld=gold',
590        ],
591        'conditions': [
592          [ 'skia_arch_type == "x86"', {
593            'cflags': [
594              '-mssse3',
595            ],
596          }],
597          [ 'skia_android_framework', {
598            'cflags!': [
599              '-fuse-ld=gold',
600            ],
601          }],
602          [ 'skia_shared_lib', {
603            'defines': [
604              'SKIA_DLL',
605              'SKIA_IMPLEMENTATION=1',
606              # Needed until we fix skbug.com/2440.
607              'SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG',
608            ],
609          }],
610          [ 'skia_profile_enabled == 1', {
611            'cflags': ['-g', '-fno-omit-frame-pointer', '-marm', '-mapcs'],
612          }],
613        ],
614      },
615    ],
616
617    # We can POD-style initialization of static mutexes to avoid generating
618    # static initializers if we're using a pthread-compatible thread interface.
619    [ 'skia_os != "win"', {
620      'defines': [
621        'SK_USE_POSIX_THREADS',
622      ],
623    }],
624
625    [ 'skia_moz2d', {
626      'defines': [
627        # add flags here (e.g. SK_SUPPORT_LEGACY_...) needed by moz2d
628      ],
629    }],
630
631    [ 'skia_is_bot', {
632      'defines': [ 'SK_CRASH_HANDLER' ],
633    }],
634
635  ], # end 'conditions'
636  # The Xcode SYMROOT must be at the root. See build/common.gypi in chromium for more details
637  'xcode_settings': {
638    'SYMROOT': '<(DEPTH)/xcodebuild',
639  },
640}
641