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