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