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