56cebbe1f3fd278c7f7531d3c2ce9f1154ff6aac
[platform/upstream/nodejs.git] / deps / v8 / build / standalone.gypi
1 # Copyright 2012 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are
4 # met:
5 #
6 #     * Redistributions of source code must retain the above copyright
7 #       notice, this list of conditions and the following disclaimer.
8 #     * Redistributions in binary form must reproduce the above
9 #       copyright notice, this list of conditions and the following
10 #       disclaimer in the documentation and/or other materials provided
11 #       with the distribution.
12 #     * Neither the name of Google Inc. nor the names of its
13 #       contributors may be used to endorse or promote products derived
14 #       from this software without specific prior written permission.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 # Definitions to be used when building stand-alone V8 binaries.
29
30 {
31   # We need to include toolchain.gypi here for third-party sources that don't
32   # directly include it themselves.
33   'includes': ['toolchain.gypi'],
34   'variables': {
35     'component%': 'static_library',
36     'clang_dir%': 'third_party/llvm-build/Release+Asserts',
37     'clang_xcode%': 0,
38     'visibility%': 'hidden',
39     'v8_enable_backtrace%': 0,
40     'v8_enable_i18n_support%': 1,
41     'v8_deprecation_warnings': 1,
42     'msvs_multi_core_compile%': '1',
43     'mac_deployment_target%': '10.5',
44     'variables': {
45       'variables': {
46         'variables': {
47           'conditions': [
48             ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or \
49                OS=="netbsd" or OS=="mac" or OS=="qnx" or OS=="aix"', {
50               # This handles the Unix platforms we generally deal with.
51               # Anything else gets passed through, which probably won't work
52               # very well; such hosts should pass an explicit target_arch
53               # to gyp.
54               'host_arch%': '<!pymod_do_main(detect_v8_host_arch)',
55             }, {
56               # OS!="linux" and OS!="freebsd" and OS!="openbsd" and
57               # OS!="netbsd" and OS!="mac" and OS!="aix"
58               'host_arch%': 'ia32',
59             }],
60           ],
61         },
62         'host_arch%': '<(host_arch)',
63         'target_arch%': '<(host_arch)',
64       },
65       'host_arch%': '<(host_arch)',
66       'target_arch%': '<(target_arch)',
67       'v8_target_arch%': '<(target_arch)',
68
69       # goma settings.
70       # 1 to use goma.
71       # If no gomadir is set, it uses the default gomadir.
72       'use_goma%': 0,
73       'gomadir%': '',
74       'conditions': [
75         # Set default gomadir.
76         ['OS=="win"', {
77           'gomadir': 'c:\\goma\\goma-win',
78         }, {
79           'gomadir': '<!(/bin/echo -n ${HOME}/goma)',
80         }],
81       ],
82     },
83     'host_arch%': '<(host_arch)',
84     'target_arch%': '<(target_arch)',
85     'v8_target_arch%': '<(v8_target_arch)',
86     'werror%': '-Werror',
87     'use_goma%': '<(use_goma)',
88     'gomadir%': '<(gomadir)',
89
90     # .gyp files or targets should set v8_code to 1 if they build V8 specific
91     # code, as opposed to external code.  This variable is used to control such
92     # things as the set of warnings to enable, and whether warnings are treated
93     # as errors.
94     'v8_code%': 0,
95
96     # Speeds up Debug builds:
97     # 0 - Compiler optimizations off (debuggable) (default). This may
98     #     be 5x slower than Release (or worse).
99     # 1 - Turn on optimizations and disable slow DCHECKs, but leave
100     #     V8_ENABLE_CHECKS and most other assertions enabled.  This may cause
101     #     some v8 tests to fail in the Debug configuration.  This roughly
102     #     matches the performance of a Release build and can be used by
103     #     embedders that need to build their own code as debug but don't want
104     #     or need a debug version of V8. This should produce near-release
105     #     speeds.
106     'v8_optimized_debug%': 0,
107
108     # Use external files for startup data blobs:
109     # the JS builtins sources and the start snapshot.
110     # Embedders that don't use standalone.gypi will need to add
111     # their own default value.
112     'v8_use_external_startup_data%': 0,
113
114     # Relative path to icu.gyp from this file.
115     'icu_gyp_path': '../third_party/icu/icu.gyp',
116
117     'conditions': [
118       ['(v8_target_arch=="arm" and host_arch!="arm") or \
119         (v8_target_arch=="arm64" and host_arch!="arm64") or \
120         (v8_target_arch=="mipsel" and host_arch!="mipsel") or \
121         (v8_target_arch=="mips64el" and host_arch!="mips64el") or \
122         (v8_target_arch=="x64" and host_arch!="x64") or \
123         (OS=="android" or OS=="qnx")', {
124         'want_separate_host_toolset': 1,
125       }, {
126         'want_separate_host_toolset': 0,
127       }],
128       ['OS == "win"', {
129         'os_posix%': 0,
130       }, {
131         'os_posix%': 1,
132       }],
133       ['OS=="win" and use_goma==1', {
134         # goma doesn't support pch yet.
135         'chromium_win_pch': 0,
136         # goma doesn't support PDB yet, so win_z7=1 or fastbuild=1.
137         'conditions': [
138           ['win_z7==0 and fastbuild==0', {
139             'fastbuild': 1,
140           }],
141         ],
142       }],
143       ['(v8_target_arch=="ia32" or v8_target_arch=="x64" or v8_target_arch=="x87") and \
144         (OS=="linux" or OS=="mac")', {
145         'v8_enable_gdbjit%': 1,
146       }, {
147         'v8_enable_gdbjit%': 0,
148       }],
149       ['(OS=="linux" or OS=="mac") and (target_arch=="ia32" or target_arch=="x64")', {
150         'clang%': 1,
151       }, {
152         'clang%': 0,
153       }],
154     ],
155     # Default ARM variable settings.
156     'arm_version%': 'default',
157     'arm_fpu%': 'vfpv3',
158     'arm_float_abi%': 'default',
159     'arm_thumb': 'default',
160
161     # Default MIPS variable settings.
162     'mips_arch_variant%': 'r2',
163     # Possible values fp32, fp64, fpxx.
164     # fp32 - 32 32-bit FPU registers are available, doubles are placed in
165     #        register pairs.
166     # fp64 - 32 64-bit FPU registers are available.
167     # fpxx - compatibility mode, it chooses fp32 or fp64 depending on runtime
168     #        detection
169     'mips_fpu_mode%': 'fp32',
170   },
171   'target_defaults': {
172     'variables': {
173       'v8_code%': '<(v8_code)',
174     },
175     'default_configuration': 'Debug',
176     'configurations': {
177       'DebugBaseCommon': {
178         'cflags': [ '-g', '-O0' ],
179         'conditions': [
180           ['(v8_target_arch=="ia32" or v8_target_arch=="x87") and \
181             OS=="linux"', {
182             'defines': [
183               '_GLIBCXX_DEBUG'
184             ],
185           }],
186           [ 'OS=="aix"', {
187             'cflags': [ '-gxcoff' ],
188           }],
189         ],
190       },
191       'Optdebug': {
192         'inherit_from': [ 'DebugBaseCommon', 'DebugBase1' ],
193       },
194       'Debug': {
195         # Xcode insists on this empty entry.
196       },
197       'Release': {
198         # Xcode insists on this empty entry.
199       },
200     },
201     'target_conditions': [
202       ['v8_code == 0', {
203         'defines!': [
204           'DEBUG',
205         ],
206         'conditions': [
207           ['os_posix == 1 and OS != "mac"', {
208             'cflags!': [
209               '-Werror',
210             ],
211           }],
212           ['OS == "mac"', {
213             'xcode_settings': {
214               'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO',    # -Werror
215             },
216           }],
217           ['OS == "win"', {
218             'msvs_settings': {
219               'VCCLCompilerTool': {
220                 'WarnAsError': 'false',
221               },
222             },
223           }],
224         ],
225       }],
226     ],
227   },
228   'conditions': [
229     ['asan==1 and OS!="mac"', {
230       'target_defaults': {
231         'cflags_cc+': [
232           '-fno-omit-frame-pointer',
233           '-gline-tables-only',
234           '-fsanitize=address',
235           '-w',  # http://crbug.com/162783
236         ],
237         'cflags!': [
238           '-fomit-frame-pointer',
239         ],
240         'ldflags': [
241           '-fsanitize=address',
242         ],
243       },
244     }],
245     ['tsan==1 and OS!="mac"', {
246       'target_defaults': {
247         'cflags+': [
248           '-fno-omit-frame-pointer',
249           '-gline-tables-only',
250           '-fsanitize=thread',
251           '-fPIC',
252           '-Wno-c++11-extensions',
253         ],
254         'cflags!': [
255           '-fomit-frame-pointer',
256         ],
257         'ldflags': [
258           '-fsanitize=thread',
259           '-pie',
260         ],
261         'defines': [
262           'THREAD_SANITIZER',
263         ],
264       },
265     }],
266     ['asan==1 and OS=="mac"', {
267       'target_defaults': {
268         'xcode_settings': {
269           'OTHER_CFLAGS+': [
270             '-fno-omit-frame-pointer',
271             '-gline-tables-only',
272             '-fsanitize=address',
273             '-w',  # http://crbug.com/162783
274           ],
275           'OTHER_CFLAGS!': [
276             '-fomit-frame-pointer',
277           ],
278         },
279         'target_conditions': [
280           ['_type!="static_library"', {
281             'xcode_settings': {'OTHER_LDFLAGS': ['-fsanitize=address']},
282           }],
283         ],
284         'dependencies': [
285           '<(DEPTH)/build/mac/asan.gyp:asan_dynamic_runtime',
286         ],
287       },
288     }],
289     ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
290        or OS=="netbsd" or OS=="aix"', {
291       'target_defaults': {
292         'cflags': [
293           '-Wall',
294           '<(werror)',
295           '-W',
296           '-Wno-unused-parameter',
297           '-Wno-long-long',
298           '-pthread',
299           '-fno-exceptions',
300           '-pedantic',
301           # Don't warn about the "struct foo f = {0};" initialization pattern.
302           '-Wno-missing-field-initializers',
303         ],
304         'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-std=gnu++0x' ],
305         'ldflags': [ '-pthread', ],
306         'conditions': [
307           [ 'host_arch=="ppc64"', {
308             'cflags': [ '-mminimal-toc' ],
309           }],
310           [ 'visibility=="hidden" and v8_enable_backtrace==0', {
311             'cflags': [ '-fvisibility=hidden' ],
312           }],
313           [ 'component=="shared_library"', {
314             'cflags': [ '-fPIC', ],
315           }],
316         ],
317       },
318     }],
319     # 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"
320     #  or OS=="netbsd"'
321     ['OS=="qnx"', {
322       'target_defaults': {
323         'cflags': [
324           '-Wall',
325           '<(werror)',
326           '-W',
327           '-Wno-unused-parameter',
328           '-fno-exceptions',
329           # Don't warn about the "struct foo f = {0};" initialization pattern.
330           '-Wno-missing-field-initializers',
331         ],
332         'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-std=gnu++0x' ],
333         'conditions': [
334           [ 'visibility=="hidden"', {
335             'cflags': [ '-fvisibility=hidden' ],
336           }],
337           [ 'component=="shared_library"', {
338             'cflags': [ '-fPIC' ],
339           }],
340         ],
341         'target_conditions': [
342           [ '_toolset=="host" and host_os=="linux"', {
343             'cflags': [ '-pthread' ],
344             'ldflags': [ '-pthread' ],
345             'libraries': [ '-lrt' ],
346           }],
347           [ '_toolset=="target"', {
348             'cflags': [ '-Wno-psabi' ],
349             'libraries': [ '-lbacktrace', '-lsocket', '-lm' ],
350           }],
351         ],
352       },
353     }],  # OS=="qnx"
354     ['OS=="win"', {
355       'target_defaults': {
356         'defines': [
357           '_CRT_SECURE_NO_DEPRECATE',
358           '_CRT_NONSTDC_NO_DEPRECATE',
359           '_USING_V110_SDK71_',
360         ],
361         'conditions': [
362           ['component=="static_library"', {
363             'defines': [
364               '_HAS_EXCEPTIONS=0',
365             ],
366           }],
367         ],
368         'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
369         'msvs_disabled_warnings': [4355, 4800],
370         'msvs_settings': {
371           'VCCLCompilerTool': {
372             'MinimalRebuild': 'false',
373             'BufferSecurityCheck': 'true',
374             'EnableFunctionLevelLinking': 'true',
375             'RuntimeTypeInfo': 'false',
376             'WarningLevel': '3',
377             'WarnAsError': 'true',
378             'DebugInformationFormat': '3',
379             'Detect64BitPortabilityProblems': 'false',
380             'conditions': [
381               [ 'msvs_multi_core_compile', {
382                 'AdditionalOptions': ['/MP'],
383               }],
384               ['component=="shared_library"', {
385                 'ExceptionHandling': '1',  # /EHsc
386               }, {
387                 'ExceptionHandling': '0',
388               }],
389             ],
390           },
391           'VCLibrarianTool': {
392             'AdditionalOptions': ['/ignore:4221'],
393             'conditions': [
394               ['v8_target_arch=="x64"', {
395                 'TargetMachine': '17',  # x64
396               }, {
397                 'TargetMachine': '1',  # ia32
398               }],
399             ],
400           },
401           'VCLinkerTool': {
402             'AdditionalDependencies': [
403               'ws2_32.lib',
404             ],
405             'GenerateDebugInformation': 'true',
406             'MapFileName': '$(OutDir)\\$(TargetName).map',
407             'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
408             'FixedBaseAddress': '1',
409             # LinkIncremental values:
410             #   0 == default
411             #   1 == /INCREMENTAL:NO
412             #   2 == /INCREMENTAL
413             'LinkIncremental': '1',
414             # SubSystem values:
415             #   0 == not set
416             #   1 == /SUBSYSTEM:CONSOLE
417             #   2 == /SUBSYSTEM:WINDOWS
418             'SubSystem': '1',
419
420             'conditions': [
421               ['v8_enable_i18n_support==1', {
422                 'AdditionalDependencies': [
423                   'advapi32.lib',
424                 ],
425               }],
426               ['v8_target_arch=="x64"', {
427                 'MinimumRequiredVersion': '5.02',  # Server 2003.
428                 'TargetMachine': '17',  # x64
429               }, {
430                 'MinimumRequiredVersion': '5.01',  # XP.
431                 'TargetMachine': '1',  # ia32
432               }],
433             ],
434           },
435         },
436       },
437     }],  # OS=="win"
438     ['OS=="mac"', {
439       'xcode_settings': {
440         'SDKROOT': 'macosx',
441         'SYMROOT': '<(DEPTH)/xcodebuild',
442       },
443       'target_defaults': {
444         'xcode_settings': {
445           'ALWAYS_SEARCH_USER_PATHS': 'NO',
446           'GCC_C_LANGUAGE_STANDARD': 'c99',         # -std=c99
447           'GCC_CW_ASM_SYNTAX': 'NO',                # No -fasm-blocks
448           'GCC_DYNAMIC_NO_PIC': 'NO',               # No -mdynamic-no-pic
449                                                     # (Equivalent to -fPIC)
450           'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',        # -fno-exceptions
451           'GCC_ENABLE_CPP_RTTI': 'NO',              # -fno-rtti
452           'GCC_ENABLE_PASCAL_STRINGS': 'NO',        # No -mpascal-strings
453           # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden
454           'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
455           'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES',      # -fvisibility=hidden
456           'GCC_THREADSAFE_STATICS': 'NO',           # -fno-threadsafe-statics
457           'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor
458           # MACOSX_DEPLOYMENT_TARGET maps to -mmacosx-version-min
459           'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)',
460           'PREBINDING': 'NO',                       # No -Wl,-prebind
461           'SYMROOT': '<(DEPTH)/xcodebuild',
462           'USE_HEADERMAP': 'NO',
463           'OTHER_CFLAGS': [
464             '-fno-strict-aliasing',
465           ],
466           'WARNING_CFLAGS': [
467             '-Wall',
468             '-Wendif-labels',
469             '-W',
470             '-Wno-unused-parameter',
471             # Don't warn about the "struct foo f = {0};" initialization pattern.
472             '-Wno-missing-field-initializers',
473           ],
474         },
475         'conditions': [
476           ['werror==""', {
477             'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO'},
478           }, {
479             'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES'},
480           }],
481           ['clang==1', {
482             'xcode_settings': {
483               'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
484               'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++0x',  # -std=gnu++0x
485             },
486           }],
487         ],
488         'target_conditions': [
489           ['_type!="static_library"', {
490             'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
491           }],
492         ],  # target_conditions
493       },  # target_defaults
494     }],  # OS=="mac"
495     ['clang==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) '
496         'and OS!="win" and "<(GENERATOR)"=="make"', {
497       'make_global_settings': [
498         ['CC', '../<(clang_dir)/bin/clang'],
499         ['CXX', '../<(clang_dir)/bin/clang++'],
500         ['CC.host', '$(CC)'],
501         ['CXX.host', '$(CXX)'],
502       ],
503     }],
504     ['clang==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) '
505         'and OS!="win" and "<(GENERATOR)"=="ninja"', {
506       'make_global_settings': [
507         ['CC', '<(clang_dir)/bin/clang'],
508         ['CXX', '<(clang_dir)/bin/clang++'],
509         ['CC.host', '$(CC)'],
510         ['CXX.host', '$(CXX)'],
511       ],
512     }],
513     ['clang==1 and OS=="win"', {
514       'make_global_settings': [
515         # On Windows, gyp's ninja generator only looks at CC.
516         ['CC', '../<(clang_dir)/bin/clang-cl'],
517       ],
518     }],
519     # TODO(yyanagisawa): supports GENERATOR==make
520     #  make generator doesn't support CC_wrapper without CC
521     #  in make_global_settings yet.
522     ['use_goma==1 and ("<(GENERATOR)"=="ninja" or clang==1)', {
523       'make_global_settings': [
524        ['CC_wrapper', '<(gomadir)/gomacc'],
525        ['CXX_wrapper', '<(gomadir)/gomacc'],
526        ['CC.host_wrapper', '<(gomadir)/gomacc'],
527        ['CXX.host_wrapper', '<(gomadir)/gomacc'],
528       ],
529     }],
530   ],
531 }