1# Copyright 2012 The Android Open Source Project
2#
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6{
7  # Get ready for the ugly...
8  #
9  # - We have to nest our variables dictionaries multiple levels deep, so that
10  #   this and other gyp files can rely on previously-set variable values in
11  #   their 'variables': { 'conditions': [] } clauses.
12  #
13  #   Example 1:
14  #   Within this file, we use the value of variable 'skia_os' to set the
15  #   value of variable 'os_posix', so 'skia_os' must be defined within a
16  #   "more inner" (enclosed) scope than 'os_posix'.
17  #
18  #   Example 2:
19  #   http://src.chromium.org/viewvc/chrome/trunk/src/third_party/libjpeg/libjpeg.gyp?revision=102306 ,
20  #   which we currently import into our build, uses the value of 'os_posix'
21  #   within the 'conditions' list in its 'variables' dict.
22  #   In order for that to work, it needs the value of 'os_posix' to have been
23  #   set within a "more inner" (enclosed) scope than its own 'variables' dict.
24  #
25  # - On the other hand, key/value pairs of a given 'variable' dict are only
26  #   inherited by:
27  #   1. directly enclosing 'variable' dicts, and
28  #   2. "sibling" 'variable' dicts (which, I guess, are combined into a single
29  #      'variable' dict during gyp processing)
30  #   and NOT inherited by "uncles" (siblings of directly enclosing 'variable'
31  #   dicts), so we have to re-define every variable at every enclosure level
32  #   within our ridiculous matryoshka doll of 'variable' dicts.  That's why
33  #   we have variable definitions like this:  'skia_os%': '<(skia_os)',
34  #
35  # See http://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?revision=127004 ,
36  # which deals with these same constraints in a similar manner.
37  #
38  'variables': {  # level 1
39    'angle_path%': '../',
40
41    'skia_mojo%': '0',
42
43    'variables': {  # level 2
44      # Variables needed by conditions list within the level-2 variables dict.
45      'variables': {  # level 3
46        'variables': { # level 4
47          # We use 'skia_os' instead of 'OS' throughout our gyp files, to allow
48          # for cross-compilation (e.g. building for either MacOS or iOS on Mac).
49          # We set it automatically based on 'OS' (the host OS), but allow the
50          # user to override it via GYP_DEFINES if they like.
51          'skia_os%': '<(OS)',
52        },
53        'skia_os%': '<(skia_os)',
54        'vulkan_merged_into_skia': '1',
55        'skia_android_framework%': 0,
56        'conditions' : [
57          [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "mac"]', {
58            'skia_arch_type%': 'x86_64',
59          }, {
60            'skia_arch_type%': 'x86',
61          }],
62          # RAW codec needs exceptions. Due to that, it is a separate target. Its usage can be
63          # controlled by skia_codec_decodes_raw.
64          ['skia_os == "win"', {
65            'skia_codec_decodes_raw%' : 0,
66          }, {
67            'skia_codec_decodes_raw%' : 1,
68          }],
69        ],
70        'arm_version%': 0,
71        'arm_neon%': 0,
72        'skia_egl%': 0,
73      },
74
75      # Re-define all variables defined within the level-3 'variables' dict,
76      # so that siblings of the level-2 'variables' dict can see them.
77      # (skia_os will depend on skia_android_framework.)
78      'skia_android_framework%': '<(skia_android_framework)',
79      'skia_codec_decodes_raw%': '<(skia_codec_decodes_raw)',
80      'skia_arch_type%': '<(skia_arch_type)',
81      'arm_version%': '<(arm_version)',
82      'arm_neon%': '<(arm_neon)',
83      'skia_egl%': '<(skia_egl)',
84      'vulkan_merged_into_skia%': '<(vulkan_merged_into_skia)',
85      'conditions': [
86        [ 'skia_android_framework == 1', {
87          'skia_os%': 'android',
88          'skia_chrome_utils%': 0,
89          'skia_use_android_framework_defines%': 1,
90          'skia_use_system_json%': 1,
91        }, {
92          'skia_os%': '<(skia_os)',
93          'skia_chrome_utils%': 1,
94          'skia_use_android_framework_defines%': 0,
95          'skia_use_system_json%': 0,
96        }],
97        [ 'skia_os == "win"', {
98          'os_posix%': 0,
99        }, {
100          'os_posix%': 1,
101        }],
102        [ 'skia_os == "linux"', {
103          # ANGLE on linux require these two variable be defined.
104          'chromeos%': 0,
105          'use_x11%': 1,
106        }],
107        [ 'skia_os == "android"', {
108          'skia_static_initializers%': 0,
109          'skia_egl%': 1,
110        }, {
111          'skia_static_initializers%': 1,
112        }],
113        [ 'skia_os == "ios"', {
114          'skia_arch_type%': 'arm',
115          'arm_version%': 7,
116          'arm_neon%': 0, # neon asm files known not to work with the ios build
117        }],
118        [ 'skia_os == "android" and not skia_android_framework',
119          # skia_freetype_static - on OS variants that normally would
120          #     dynamically link the system FreeType library, don't do
121          #     that; instead statically link to the version in
122          #     third_party/freetype and third_party/externals/freetype.
123          {
124            'skia_freetype_static%': '1',
125          }, {
126            'skia_freetype_static%': '0',
127          }
128        ],
129      ],
130
131      # skia_no_fontconfig - On POSIX systems that would normally use the
132      #     SkFontHost_fontconfig interface; use the SkFontHost_linux
133      #     version instead.
134      'skia_no_fontconfig%': '0',
135      'skia_embedded_fonts%': '0',
136
137      'skia_sanitizer%': '',
138      'skia_mesa%': 0,
139      'skia_gpu_extra_dependency_path%': '',
140      'skia_gpu_extra_tests_path%': '',
141      'skia_stroke_path_rendering%': 0,
142      'skia_android_path_rendering%': 0,
143      'skia_resource_cache_mb_limit%': 0,
144      'skia_resource_cache_count_limit%': 0,
145      'skia_angle%': 0,
146      'skia_command_buffer%': 0,
147      'skia_gdi%': 0,
148      'skia_gpu%': 1,
149      'skia_osx_deployment_target%': '',
150      'skia_pdf%': 1,
151      'skia_profile_enabled%': 0,
152      'skia_vulkan%': 0,
153      'skia_win_debuggers_path%': '',
154      'skia_shared_lib%': 0,
155      'skia_force_distance_field_text%': 0,
156      'skia_is_bot%': '<!(python -c "import os; print os.environ.get(\'CHROME_HEADLESS\', 0)")',
157
158      # These variables determine the default optimization level for different
159      # compilers.
160      'skia_default_vs_optimization_level': 3, # full (/Ox)
161      'skia_default_gcc_optimization_level': 3, # -O3
162    },
163
164    'conditions': [
165      [ 'skia_os in ["mac", "linux", "freebsd", "openbsd", "solaris", "android", "win"] '
166            'and skia_android_framework == 0', {
167        'skia_warnings_as_errors%': 1,
168      }, {
169        'skia_warnings_as_errors%': 0,
170      }],
171
172      # This variable allows the user to customize the optimization level used
173      # by the compiler.  The user should be aware that this has different
174      # meanings for different compilers and should exercise caution when
175      # overriding it.
176      [ 'skia_os == "win"', {
177        'skia_release_optimization_level%': '<(skia_default_vs_optimization_level)',
178      }, {
179        'skia_release_optimization_level%': '<(skia_default_gcc_optimization_level)',
180      }],
181      [ 'skia_os == "linux"', {
182        # ANGLE on linux require these two variable be defined.
183        'chromeos%': 0,
184        'use_x11%': 1,
185      }],
186      [ 'skia_sanitizer', {
187        'skia_clang_build': 1,
188        'skia_keep_frame_pointer': 1,
189      }, {
190        'skia_clang_build%': 0,
191        'skia_keep_frame_pointer%': 0,
192      }],
193      [ 'skia_shared_lib or skia_sanitizer or skia_os == "android" or (skia_os == "linux" and (skia_angle == 1 or skia_command_buffer == 1))', {
194          'skia_pic%' : 1,
195        }, {
196          'skia_pic%' : 0,
197        }
198      ],
199    ],
200
201    # Re-define all variables defined within the level-2 'variables' dict,
202    # so that siblings of the level-1 'variables' dict can see them.
203    'arm_version%': '<(arm_version)',
204    'arm_neon%': '<(arm_neon)',
205    'arm_neon_optional%': 0,
206    'mips_arch_variant%': 'mips32',
207    'mips_dsp%': 0,
208    'skia_os%': '<(skia_os)',
209    'os_posix%': '<(os_posix)',
210
211    'skia_freetype_static%': '<(skia_freetype_static)',
212    'skia_no_fontconfig%': '<(skia_no_fontconfig)',
213    'skia_embedded_fonts%': '<(skia_embedded_fonts)',
214    'skia_sanitizer%': '<(skia_sanitizer)',
215    'skia_sanitizer_blacklist%':
216      '<!(python -c "import sys; import os; print os.path.abspath(sys.argv[1])" ../tools/xsan.blacklist)',
217    'skia_mesa%': '<(skia_mesa)',
218    'skia_gpu_extra_dependency_path%': '<(skia_gpu_extra_dependency_path)',
219    'skia_gpu_extra_tests_path%': '<(skia_gpu_extra_tests_path)',
220    'skia_stroke_path_rendering%': '<(skia_stroke_path_rendering)',
221    'skia_android_framework%': '<(skia_android_framework)',
222    'skia_codec_decodes_raw%': '<(skia_codec_decodes_raw)',
223    'skia_use_android_framework_defines%': '<(skia_use_android_framework_defines)',
224    'skia_use_system_json%': '<(skia_use_system_json)',
225    'skia_android_path_rendering%': '<(skia_android_path_rendering)',
226    'skia_resource_cache_mb_limit%': '<(skia_resource_cache_mb_limit)',
227    'skia_resource_cache_count_limit%': '<(skia_resource_cache_count_limit)',
228    'skia_angle%': '<(skia_angle)',
229    'skia_arch_type%': '<(skia_arch_type)',
230    'skia_chrome_utils%': '<(skia_chrome_utils)',
231    'skia_command_buffer%': '<(skia_command_buffer)',
232    'skia_gdi%': '<(skia_gdi)',
233    'skia_gpu%': '<(skia_gpu)',
234    'skia_vulkan%': '<(skia_vulkan)',
235    'skia_win_exceptions%': 0,
236    'skia_win_ltcg%': '<(skia_is_bot)',
237    'skia_osx_deployment_target%': '<(skia_osx_deployment_target)',
238    'skia_pdf%': '<(skia_pdf)',
239    'skia_pdf_generate_pdfa%': 0,  # emit larger PDF/A-2b file
240    'skia_profile_enabled%': '<(skia_profile_enabled)',
241    'skia_shared_lib%': '<(skia_shared_lib)',
242    'skia_force_distance_field_text%': '<(skia_force_distance_field_text)',
243    'skia_static_initializers%': '<(skia_static_initializers)',
244    'ios_sdk_version%': '6.0',
245    'skia_win_debuggers_path%': '<(skia_win_debuggers_path)',
246    'skia_disable_inlining%': 0,
247    'skia_moz2d%': 0,
248    'skia_is_bot%': '<(skia_is_bot)',
249    'skia_egl%': '<(skia_egl)',
250    'skia_use_sdl%': 0,
251    'skia_fast%': 0,
252    'skia_dump_stats%': 0,
253    'skia_build_server%': 0,
254    'vulkan_merged_into_skia%': '<(vulkan_merged_into_skia)',
255    'skia_fast_flags': [
256        '-O3',                   # Even for Debug builds.
257        '-march=native',         # Use all features of and optimize for THIS machine.
258        '-fomit-frame-pointer',  # Sometimes an extra register is nice, and cuts a push/pop.
259        #'-ffast-math',           # Optimize float math even when it breaks IEEE compliance.
260        #'-flto'                  # Enable link-time optimization.
261    ],
262
263    # These are referenced by our .gypi files that list files (e.g. core.gypi)
264    #
265    'skia_src_path%': '../src',
266    'skia_include_path%': '../include',
267  },
268}
269