1{
2  'variables': {
3    'target_arch%': 'ia32',          # set v8's target architecture
4    'host_arch%': 'ia32',            # set v8's host architecture
5    'uv_library%': 'static_library', # allow override to 'shared_library' for DLL/.so builds
6    'msvs_multi_core_compile': '0',  # we do enable multicore compiles, but not using the V8 way
7  },
8
9  'target_defaults': {
10    'default_configuration': 'Debug',
11    'configurations': {
12      'Debug': {
13        'defines': [ 'DEBUG', '_DEBUG' ],
14        'cflags': [ '-g' ],
15        'msvs_settings': {
16          'VCCLCompilerTool': {
17            'target_conditions': [
18              ['uv_library=="static_library"', {
19                'RuntimeLibrary': 1, # /MTd static debug
20              }, {
21                'RuntimeLibrary': 3, # /MDd DLL debug
22              }],
23            ],
24            'Optimization': 0, # /Od, no optimization
25            'MinimalRebuild': 'false',
26            'OmitFramePointers': 'false',
27            'BasicRuntimeChecks': 3, # /RTC1
28          },
29          'VCLinkerTool': {
30            'LinkIncremental': 2, # enable incremental linking
31          },
32        },
33        'xcode_settings': {
34          'GCC_OPTIMIZATION_LEVEL': '0',
35        },
36        'conditions': [
37          ['OS != "zos"', {
38            'cflags': [ '-O0', '-fno-common', '-fwrapv' ]
39          }],
40          ['OS == "android"', {
41            'cflags': [ '-fPIE' ],
42            'ldflags': [ '-fPIE', '-pie' ]
43          }]
44        ]
45      },
46      'Release': {
47        'defines': [ 'NDEBUG' ],
48        'cflags': [
49          '-O3',
50        ],
51        'msvs_settings': {
52          'VCCLCompilerTool': {
53            'target_conditions': [
54              ['uv_library=="static_library"', {
55                'RuntimeLibrary': 0, # /MT static release
56              }, {
57                'RuntimeLibrary': 2, # /MD DLL release
58              }],
59            ],
60            'Optimization': 3, # /Ox, full optimization
61            'FavorSizeOrSpeed': 1, # /Ot, favour speed over size
62            'InlineFunctionExpansion': 2, # /Ob2, inline anything eligible
63            'WholeProgramOptimization': 'true', # /GL, whole program optimization, needed for LTCG
64            'OmitFramePointers': 'true',
65            'EnableFunctionLevelLinking': 'true',
66            'EnableIntrinsicFunctions': 'true',
67          },
68          'VCLibrarianTool': {
69            'AdditionalOptions': [
70              '/LTCG', # link time code generation
71            ],
72          },
73          'VCLinkerTool': {
74            'LinkTimeCodeGeneration': 1, # link-time code generation
75            'OptimizeReferences': 2, # /OPT:REF
76            'EnableCOMDATFolding': 2, # /OPT:ICF
77            'LinkIncremental': 1, # disable incremental linking
78          },
79        },
80        'conditions': [
81          ['OS != "zos"', {
82            'cflags': [
83              '-fdata-sections',
84              '-ffunction-sections',
85              '-fno-common',
86              '-fomit-frame-pointer',
87            ],
88          }],
89        ]
90      }
91    },
92    'msvs_settings': {
93      'VCCLCompilerTool': {
94        'StringPooling': 'true', # pool string literals
95        'DebugInformationFormat': 3, # Generate a PDB
96        'WarningLevel': 3,
97        'BufferSecurityCheck': 'true',
98        'ExceptionHandling': 1, # /EHsc
99        'SuppressStartupBanner': 'true',
100        'WarnAsError': 'false',
101        'AdditionalOptions': [
102           '/MP', # compile across multiple CPUs
103         ],
104      },
105      'VCLibrarianTool': {
106      },
107      'VCLinkerTool': {
108        'GenerateDebugInformation': 'true',
109        'RandomizedBaseAddress': 2, # enable ASLR
110        'DataExecutionPrevention': 2, # enable DEP
111        'AllowIsolation': 'true',
112        'SuppressStartupBanner': 'true',
113        'target_conditions': [
114          ['_type=="executable"', {
115            'SubSystem': 1, # console executable
116          }],
117        ],
118      },
119    },
120    'conditions': [
121      ['OS == "win"', {
122        'msvs_cygwin_shell': 0, # prevent actions from trying to use cygwin
123        'defines': [
124          'WIN32',
125          # we don't really want VC++ warning us about
126          # how dangerous C functions are...
127          '_CRT_SECURE_NO_DEPRECATE',
128          # ... or that C implementations shouldn't use
129          # POSIX names
130          '_CRT_NONSTDC_NO_DEPRECATE',
131        ],
132        'target_conditions': [
133          ['target_arch=="x64"', {
134            'msvs_configuration_platform': 'x64'
135          }]
136        ]
137      }],
138      ['OS in "freebsd dragonflybsd linux openbsd solaris android aix"', {
139        'cflags': [ '-Wall' ],
140        'cflags_cc': [ '-fno-rtti', '-fno-exceptions' ],
141        'target_conditions': [
142          ['_type=="static_library"', {
143            'standalone_static_library': 1, # disable thin archive which needs binutils >= 2.19
144          }],
145        ],
146        'conditions': [
147          [ 'host_arch != target_arch and target_arch=="ia32"', {
148            'cflags': [ '-m32' ],
149            'ldflags': [ '-m32' ],
150          }],
151          [ 'target_arch=="x32"', {
152            'cflags': [ '-mx32' ],
153            'ldflags': [ '-mx32' ],
154          }],
155          [ 'OS=="linux"', {
156            'cflags': [ '-ansi' ],
157          }],
158          [ 'OS=="solaris"', {
159            'cflags': [ '-pthreads' ],
160            'ldflags': [ '-pthreads' ],
161          }],
162          [ 'OS not in "solaris android zos"', {
163            'cflags': [ '-pthread' ],
164            'ldflags': [ '-pthread' ],
165          }],
166          [ 'OS=="aix" and target_arch=="ppc64"', {
167            'cflags': [ '-maix64' ],
168            'ldflags': [ '-maix64' ],
169          }],
170        ],
171      }],
172      ['OS=="mac"', {
173        'xcode_settings': {
174          'ALWAYS_SEARCH_USER_PATHS': 'NO',
175          'GCC_CW_ASM_SYNTAX': 'NO',                # No -fasm-blocks
176          'GCC_DYNAMIC_NO_PIC': 'NO',               # No -mdynamic-no-pic
177                                                    # (Equivalent to -fPIC)
178          'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',        # -fno-exceptions
179          'GCC_ENABLE_CPP_RTTI': 'NO',              # -fno-rtti
180          'GCC_ENABLE_PASCAL_STRINGS': 'NO',        # No -mpascal-strings
181          'GCC_THREADSAFE_STATICS': 'NO',           # -fno-threadsafe-statics
182          'PREBINDING': 'NO',                       # No -Wl,-prebind
183          'USE_HEADERMAP': 'NO',
184          'WARNING_CFLAGS': [
185            '-Wall',
186            '-Wendif-labels',
187            '-W',
188            '-Wno-unused-parameter',
189            '-Wstrict-prototypes',
190          ],
191        },
192        'conditions': [
193          ['target_arch=="ia32"', {
194            'xcode_settings': {'ARCHS': ['i386']},
195          }],
196          ['target_arch=="x64"', {
197            'xcode_settings': {'ARCHS': ['x86_64']},
198          }],
199        ],
200        'target_conditions': [
201          ['_type!="static_library"', {
202            'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
203          }],
204        ],
205      }],
206     ['OS=="solaris"', {
207       'cflags': [ '-fno-omit-frame-pointer' ],
208       # pull in V8's postmortem metadata
209       'ldflags': [ '-Wl,-z,allextract' ]
210     }],
211    ],
212  },
213}
214