Merge remote-tracking branch 'origin/v0.12' into v0.12
[platform/upstream/nodejs.git] / common.gypi
1 {
2   'variables': {
3     'asan%': 0,
4     'werror': '',                     # Turn off -Werror in V8 build.
5     'visibility%': 'hidden',          # V8's visibility setting
6     'target_arch%': 'ia32',           # set v8's target architecture
7     'host_arch%': 'ia32',             # set v8's host architecture
8     'want_separate_host_toolset%': 0, # V8 should not build target and host
9     'library%': 'static_library',     # allow override to 'shared_library' for DLL/.so builds
10     'component%': 'static_library',   # NB. these names match with what V8 expects
11     'msvs_multi_core_compile': '0',   # we do enable multicore compiles, but not using the V8 way
12     'gcc_version%': 'unknown',
13     'clang%': 0,
14     'python%': 'python',
15
16     'node_tag%': '',
17     'uv_library%': 'static_library',
18
19     # Default to -O0 for debug builds.
20     'v8_optimized_debug%': 0,
21
22     # Enable disassembler for `--print-code` v8 options
23     'v8_enable_disassembler': 1,
24
25     # Enable V8's post-mortem debugging only on unix flavors.
26     'conditions': [
27       ['OS == "win"', {
28         'os_posix': 0,
29         'v8_postmortem_support': 'false'
30       }, {
31         'os_posix': 1,
32         'v8_postmortem_support': 'true'
33       }],
34       ['GENERATOR == "ninja" or OS== "mac"', {
35         'OBJ_DIR': '<(PRODUCT_DIR)/obj',
36         'V8_BASE': '<(PRODUCT_DIR)/libv8_base.a',
37       }, {
38         'OBJ_DIR': '<(PRODUCT_DIR)/obj.target',
39         'V8_BASE': '<(PRODUCT_DIR)/obj.target/deps/v8/tools/gyp/libv8_base.a',
40       }],
41     ],
42   },
43
44   'target_defaults': {
45     'default_configuration': 'Release',
46     'configurations': {
47       'Debug': {
48         'variables': {
49           'v8_enable_handle_zapping%': 1,
50         },
51         'defines': [ 'DEBUG', '_DEBUG' ],
52         'cflags': [ '-g', '-O0' ],
53         'conditions': [
54           ['target_arch=="x64"', {
55             'msvs_configuration_platform': 'x64',
56           }],
57         ],
58         'msvs_settings': {
59           'VCCLCompilerTool': {
60             'RuntimeLibrary': 1, # static debug
61             'Optimization': 0, # /Od, no optimization
62             'MinimalRebuild': 'false',
63             'OmitFramePointers': 'false',
64             'BasicRuntimeChecks': 3, # /RTC1
65           },
66           'VCLinkerTool': {
67             'LinkIncremental': 2, # enable incremental linking
68           },
69         },
70         'xcode_settings': {
71           'GCC_OPTIMIZATION_LEVEL': '0', # stop gyp from defaulting to -Os
72         },
73       },
74       'Release': {
75         'variables': {
76           'v8_enable_handle_zapping%': 0,
77         },
78         'cflags': [ '-O3', '-ffunction-sections', '-fdata-sections' ],
79         'conditions': [
80           ['target_arch=="x64"', {
81             'msvs_configuration_platform': 'x64',
82           }],
83           ['OS=="solaris"', {
84             # pull in V8's postmortem metadata
85             'ldflags': [ '-Wl,-z,allextract' ]
86           }],
87           ['OS!="mac" and OS!="win"', {
88             'cflags': [ '-fno-omit-frame-pointer' ],
89           }],
90         ],
91         'msvs_settings': {
92           'VCCLCompilerTool': {
93             'RuntimeLibrary': 0, # static release
94             'Optimization': 3, # /Ox, full optimization
95             'FavorSizeOrSpeed': 1, # /Ot, favour speed over size
96             'InlineFunctionExpansion': 2, # /Ob2, inline anything eligible
97             'WholeProgramOptimization': 'true', # /GL, whole program optimization, needed for LTCG
98             'OmitFramePointers': 'true',
99             'EnableFunctionLevelLinking': 'true',
100             'EnableIntrinsicFunctions': 'true',
101             'RuntimeTypeInfo': 'false',
102             'ExceptionHandling': '0',
103             'AdditionalOptions': [
104               '/MP', # compile across multiple CPUs
105             ],
106           },
107           'VCLibrarianTool': {
108             'AdditionalOptions': [
109               '/LTCG', # link time code generation
110             ],
111           },
112           'VCLinkerTool': {
113             'LinkTimeCodeGeneration': 1, # link-time code generation
114             'OptimizeReferences': 2, # /OPT:REF
115             'EnableCOMDATFolding': 2, # /OPT:ICF
116             'LinkIncremental': 1, # disable incremental linking
117           },
118         },
119       }
120     },
121     # Forcibly disable -Werror.  We support a wide range of compilers, it's
122     # simply not feasible to squelch all warnings, never mind that the
123     # libraries in deps/ are not under our control.
124     'cflags!': ['-Werror'],
125     'msvs_settings': {
126       'VCCLCompilerTool': {
127         'StringPooling': 'true', # pool string literals
128         'DebugInformationFormat': 3, # Generate a PDB
129         'WarningLevel': 3,
130         'BufferSecurityCheck': 'true',
131         'ExceptionHandling': 1, # /EHsc
132         'SuppressStartupBanner': 'true',
133         'WarnAsError': 'false',
134       },
135       'VCLibrarianTool': {
136       },
137       'VCLinkerTool': {
138         'conditions': [
139           ['target_arch=="x64"', {
140             'TargetMachine' : 17 # /MACHINE:X64
141           }],
142         ],
143         'GenerateDebugInformation': 'true',
144         'RandomizedBaseAddress': 2, # enable ASLR
145         'DataExecutionPrevention': 2, # enable DEP
146         'AllowIsolation': 'true',
147         'SuppressStartupBanner': 'true',
148         'target_conditions': [
149           ['_type=="executable"', {
150             'SubSystem': 1, # console executable
151           }],
152         ],
153       },
154     },
155     'msvs_disabled_warnings': [4351, 4355, 4800],
156     'conditions': [
157       ['asan != 0', {
158         'cflags+': [
159           '-fno-omit-frame-pointer',
160           '-fsanitize=address',
161           '-w',  # http://crbug.com/162783
162         ],
163         'cflags_cc+': [ '-gline-tables-only' ],
164         'cflags!': [ '-fomit-frame-pointer' ],
165         'ldflags': [ '-fsanitize=address' ],
166       }],
167       ['OS == "win"', {
168         'msvs_cygwin_shell': 0, # prevent actions from trying to use cygwin
169         'defines': [
170           'WIN32',
171           # we don't really want VC++ warning us about
172           # how dangerous C functions are...
173           '_CRT_SECURE_NO_DEPRECATE',
174           # ... or that C implementations shouldn't use
175           # POSIX names
176           '_CRT_NONSTDC_NO_DEPRECATE',
177           'BUILDING_V8_SHARED=1',
178           'BUILDING_UV_SHARED=1',
179         ],
180       }],
181       [ 'OS in "linux freebsd openbsd solaris"', {
182         'cflags': [ '-pthread', ],
183         'ldflags': [ '-pthread' ],
184       }],
185       [ 'OS in "linux freebsd openbsd solaris android"', {
186         'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ],
187         'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++0x' ],
188         'ldflags': [ '-rdynamic' ],
189         'target_conditions': [
190           ['_type=="static_library"', {
191             'standalone_static_library': 1, # disable thin archive which needs binutils >= 2.19
192           }],
193         ],
194         'conditions': [
195           [ 'target_arch=="ia32"', {
196             'cflags': [ '-m32' ],
197             'ldflags': [ '-m32' ],
198           }],
199           [ 'target_arch=="x32"', {
200             'cflags': [ '-mx32' ],
201             'ldflags': [ '-mx32' ],
202           }],
203           [ 'target_arch=="x64"', {
204             'cflags': [ '-m64' ],
205             'ldflags': [ '-m64' ],
206           }],
207           [ 'OS=="solaris"', {
208             'cflags': [ '-pthreads' ],
209             'ldflags': [ '-pthreads' ],
210             'cflags!': [ '-pthread' ],
211             'ldflags!': [ '-pthread' ],
212           }],
213         ],
214       }],
215       [ 'OS=="android"', {
216         'defines': ['_GLIBCXX_USE_C99_MATH'],
217         'libraries': [ '-llog' ],
218       }],
219       ['OS=="mac"', {
220         'defines': ['_DARWIN_USE_64_BIT_INODE=1'],
221         'xcode_settings': {
222           'ALWAYS_SEARCH_USER_PATHS': 'NO',
223           'GCC_CW_ASM_SYNTAX': 'NO',                # No -fasm-blocks
224           'GCC_DYNAMIC_NO_PIC': 'NO',               # No -mdynamic-no-pic
225                                                     # (Equivalent to -fPIC)
226           'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',        # -fno-exceptions
227           'GCC_ENABLE_CPP_RTTI': 'NO',              # -fno-rtti
228           'GCC_ENABLE_PASCAL_STRINGS': 'NO',        # No -mpascal-strings
229           'GCC_THREADSAFE_STATICS': 'NO',           # -fno-threadsafe-statics
230           'PREBINDING': 'NO',                       # No -Wl,-prebind
231           'MACOSX_DEPLOYMENT_TARGET': '10.5',       # -mmacosx-version-min=10.5
232           'USE_HEADERMAP': 'NO',
233           'OTHER_CFLAGS': [
234             '-fno-strict-aliasing',
235           ],
236           'WARNING_CFLAGS': [
237             '-Wall',
238             '-Wendif-labels',
239             '-W',
240             '-Wno-unused-parameter',
241           ],
242         },
243         'target_conditions': [
244           ['_type!="static_library"', {
245             'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
246           }],
247         ],
248         'conditions': [
249           ['target_arch=="ia32"', {
250             'xcode_settings': {'ARCHS': ['i386']},
251           }],
252           ['target_arch=="x64"', {
253             'xcode_settings': {'ARCHS': ['x86_64']},
254           }],
255           ['clang==1', {
256             'xcode_settings': {
257               'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
258               'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++0x',  # -std=gnu++0x
259             },
260           }],
261         ],
262       }],
263       ['OS=="freebsd" and node_use_dtrace=="true"', {
264         'libraries': [ '-lelf' ],
265       }],
266       ['OS=="freebsd"', {
267         'ldflags': [
268           '-Wl,--export-dynamic',
269         ],
270       }]
271     ],
272   }
273 }