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