blob: 9ba6a4b5413e4b73636a4de3fbc021653931904b [file] [log] [blame]
David Ghandehari9e5b5872016-07-28 09:50:04 -07001# Copyright 2016 Google Inc. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14{
15 'includes': [
16 'mozjs.gypi',
17 ],
18 'variables': {
19 'common_jit_defines': [
David Ghandehariab2460b2016-08-30 10:52:21 -070020 'ENABLE_JIT=1',
21 'ENABLE_YARR_JIT=1',
David Ghandehari9e5b5872016-07-28 09:50:04 -070022 'JS_ION=1',
23 'JS_METHODJIT=1',
24 'JS_METHODJIT_TYPED_ARRAY=1',
David Ghandehari9e5b5872016-07-28 09:50:04 -070025 ],
26 },
27 'target_defaults': {
28 'defines': [
29 # This makes it so the embedded JavaScript that is generated in the
30 # CreateEmbeddedJS action is compressed.
31 'USE_ZLIB',
32 # Do not use the default js_xxx allocator function implementations, but
33 # include "jscustomallocator.h", which should implement them.
34 'JS_USE_CUSTOM_ALLOCATOR',
35 # Do not export symbols that are declare with JS_PUBLIC_[API|DATA].
36 'STATIC_JS_API',
David Ghandeharic53efd62016-10-04 01:07:30 -070037 # Option that enables support for running multiple threads of JavaScript
38 # code concurrently as long as no objects or strings are shared between
39 # them.
40 'JS_THREADSAFE',
David Ghandehari9e5b5872016-07-28 09:50:04 -070041 ],
David Ghandeharida5c4f02017-07-10 14:31:27 -070042 'msvs_disabled_warnings': [
43 # Level 2, Typename first seen as 'type1', but then seen as 'type2'.
44 4099,
David Ghandehari6e7f7a92017-08-03 13:57:17 -070045 # Level 1 - Conversion from 'type1' to 'type2' of a greater size.
46 # Typically when 32-bit value is assigned to a 64-bit pointer value.
47 4312,
David Ghandeharida5c4f02017-07-10 14:31:27 -070048 # Level 2, Possible loss of data due to type conversion.
49 4244,
50 # Level 3, Possible loss of data due to type conversion from size_t.
51 4267,
David Ghandehari6e7f7a92017-08-03 13:57:17 -070052 # Level 1, No suitable definition provided for explicit template
53 # instantiation request.
54 4661,
David Ghandeharida5c4f02017-07-10 14:31:27 -070055 ],
56 # Unfortunately, there is code that generate warnings in the headers.
57 'direct_dependent_settings': {
58 'msvs_disabled_warnings': [
59 # Level 2, Typename first seen as 'type1', but then seen as 'type2'.
60 4099,
61 # Level 2, Possible loss of data due to type conversion.
62 4244,
63 # Level 3, Possible loss of data due to type conversion from size_t.
64 4267,
65 ],
66 },
David Ghandehari9e5b5872016-07-28 09:50:04 -070067 'include_dirs': [
68 'cobalt_config/include',
69 'js/src',
70 'js/src/assembler',
71 'mfbt/double-conversion',
Andrew Topc2b40892017-01-19 14:03:49 -080072 '<(DEPTH)/third_party/icu/source/common',
David Ghandehari9e5b5872016-07-28 09:50:04 -070073 '<(generated_include_directory)',
74 ],
75 'conditions': [
76 [ 'target_arch == "x64"', {
77 'defines': [
78 'JS_CPU_X64=1',
79 'JS_PUNBOX64=1',
David Ghandehari9e5b5872016-07-28 09:50:04 -070080 ],
81 }],
82 [ 'target_arch == "x86"', {
83 'defines': [
84 'JS_CPU_X86=1',
85 'JS_NUNBOX32=1',
David Ghandehari9e5b5872016-07-28 09:50:04 -070086 ],
87 }],
88 [ 'target_arch == "arm"', {
89 'defines': [
90 'JS_CPU_ARM=1',
91 'JS_NUNBOX32=1',
David Ghandehariab2460b2016-08-30 10:52:21 -070092 ],
93 }],
David Ghandehari8c0a79f2016-10-26 10:51:48 -070094 [ 'target_arch == "mips"', {
95 'defines': [
96 'JS_CPU_MIPS=1',
97 'JS_NUNBOX32=1',
98 ],
99 }],
David Ghandehariab2460b2016-08-30 10:52:21 -0700100 [ 'cobalt_enable_jit == 1', {
101 'defines': [
David Ghandehari9e5b5872016-07-28 09:50:04 -0700102 '<@(common_jit_defines)',
103 ],
104 }],
David Ghandehari8c5039b2016-08-17 19:39:30 -0700105 [ 'use_asan == 1', {
106 'defines': [
107 'MOZ_ASAN',
108 ],
109 }],
David Ghandehari8c0a79f2016-10-26 10:51:48 -0700110 [ 'cobalt_config == "debug"', {
111 'defines': [
112 'DEBUG',
113 'JS_DEBUG',
114 ],
115 }],
Andrew Topa953d4e2016-11-22 22:38:45 -0800116 [ 'cobalt_config != "gold"', {
117 'defines': [
118 'JS_TRACE_LOGGING=1',
119 ],
120 }],
David Ghandehari9e5b5872016-07-28 09:50:04 -0700121 ],
122 },
123 'targets': [
124 {
125 # The SpiderMonkey library.
126 'target_name': 'mozjs_lib',
127 'type': 'static_library',
128 'sources': [ '<@(mozjs_sources)' ],
129 'defines': [
130 # Enable incremental garbage collection.
131 'JSGC_INCREMENTAL=1',
132
133 # See vm/Probes.h for different values. This was the value set by the
134 # configure script when building for linux-release.
135 'JS_DEFAULT_JITREPORT_GRANULARITY=3',
136
137 # Set this to enable the ECMAScript Internationalization API. Consider
138 # doing this after upgrading to a more recent version of ICU, since
139 # Cobalt's is older than the one SpiderMonkey needs for this.
140 # 'ENABLE_INTL_API=1',
141 ],
142 'cflags' : [
143 '-Wno-invalid-offsetof',
144 '-Wno-uninitialized',
145 '-Wno-unused',
146 '-include',
147 'js-confdefs.h',
148 ],
149 'conditions': [
Andrew Topa8b99852016-11-29 21:41:27 -0800150 # These W flags do not work with the ps3 compiler.
151 ['target_arch == "ps3"', {
152 'cflags!': [
153 '-Wno-invalid-offsetof',
154 '-Wno-uninitialized',
155 '-Wno-unused',
156 ]
157 }],
David Ghandehariab2460b2016-08-30 10:52:21 -0700158 [ 'target_arch == "x64" and cobalt_enable_jit == 1', {
David Ghandehari9e5b5872016-07-28 09:50:04 -0700159 'sources': [
160 'js/src/assembler/assembler/MacroAssemblerX86Common.cpp',
161 'js/src/jit/shared/Assembler-x86-shared.cpp',
162 'js/src/jit/shared/BaselineCompiler-x86-shared.cpp',
163 'js/src/jit/shared/BaselineIC-x86-shared.cpp',
164 'js/src/jit/shared/CodeGenerator-x86-shared.cpp',
165 'js/src/jit/shared/IonFrames-x86-shared.cpp',
166 'js/src/jit/shared/Lowering-x86-shared.cpp',
167 'js/src/jit/shared/MoveEmitter-x86-shared.cpp',
168 'js/src/jit/x64/Assembler-x64.cpp',
169 'js/src/jit/x64/Bailouts-x64.cpp',
170 'js/src/jit/x64/BaselineCompiler-x64.cpp',
171 'js/src/jit/x64/BaselineIC-x64.cpp',
172 'js/src/jit/x64/CodeGenerator-x64.cpp',
173 'js/src/jit/x64/Lowering-x64.cpp',
174 'js/src/jit/x64/MacroAssembler-x64.cpp',
175 'js/src/jit/x64/Trampoline-x64.cpp',
176 '<@(mozjs_jit_sources)',
177 ],
178 }],
David Ghandehariab2460b2016-08-30 10:52:21 -0700179 [ 'target_arch == "x86" and cobalt_enable_jit == 1', {
David Ghandehari9e5b5872016-07-28 09:50:04 -0700180 'sources': [
181 'js/src/assembler/assembler/MacroAssemblerX86Common.cpp',
182 'js/src/jit/shared/Assembler-x86-shared.cpp',
183 'js/src/jit/shared/BaselineCompiler-x86-shared.cpp',
184 'js/src/jit/shared/BaselineIC-x86-shared.cpp',
185 'js/src/jit/shared/CodeGenerator-x86-shared.cpp',
186 'js/src/jit/shared/IonFrames-x86-shared.cpp',
187 'js/src/jit/shared/Lowering-x86-shared.cpp',
188 'js/src/jit/shared/MoveEmitter-x86-shared.cpp',
189 'js/src/jit/x86/Assembler-x86.cpp',
190 'js/src/jit/x86/Bailouts-x86.cpp',
191 'js/src/jit/x86/BaselineCompiler-x86.cpp',
192 'js/src/jit/x86/BaselineIC-x86.cpp',
193 'js/src/jit/x86/CodeGenerator-x86.cpp',
194 'js/src/jit/x86/Lowering-x86.cpp',
195 'js/src/jit/x86/MacroAssembler-x86.cpp',
196 'js/src/jit/x86/Trampoline-x86.cpp',
197 '<@(mozjs_jit_sources)',
198 ],
199 }],
David Ghandehariab2460b2016-08-30 10:52:21 -0700200 [ 'target_arch == "arm" and cobalt_enable_jit == 1', {
David Ghandehari9e5b5872016-07-28 09:50:04 -0700201 'sources': [
202 'js/src/assembler/assembler/ARMAssembler.cpp',
203 'js/src/assembler/assembler/MacroAssemblerARM.cpp',
204 'js/src/jit/arm/Architecture-arm.cpp',
205 'js/src/jit/arm/Assembler-arm.cpp',
206 'js/src/jit/arm/Bailouts-arm.cpp',
207 'js/src/jit/arm/BaselineCompiler-arm.cpp',
208 'js/src/jit/arm/BaselineIC-arm.cpp',
209 'js/src/jit/arm/CodeGenerator-arm.cpp',
210 'js/src/jit/arm/IonFrames-arm.cpp',
211 'js/src/jit/arm/Lowering-arm.cpp',
212 'js/src/jit/arm/MacroAssembler-arm.cpp',
213 'js/src/jit/arm/MoveEmitter-arm.cpp',
214 'js/src/jit/arm/Trampoline-arm.cpp',
215 '<@(mozjs_jit_sources)',
216 ],
217 }],
David Ghandehari8c0a79f2016-10-26 10:51:48 -0700218 [ 'target_arch == "mips" and cobalt_enable_jit == 1', {
219 'sources': [
220 'js/src/jit/mips/Architecture-mips.cpp',
221 'js/src/jit/mips/Assembler-mips.cpp',
222 'js/src/jit/mips/Bailouts-mips.cpp',
223 'js/src/jit/mips/BaselineCompiler-mips.cpp',
224 'js/src/jit/mips/BaselineIC-mips.cpp',
225 'js/src/jit/mips/CodeGenerator-mips.cpp',
226 'js/src/jit/mips/Lowering-mips.cpp',
227 'js/src/jit/mips/MacroAssembler-mips.cpp',
228 'js/src/jit/mips/MoveEmitter-mips.cpp',
229 'js/src/jit/mips/Trampoline-mips.cpp',
230 '<@(mozjs_jit_sources)',
231 ]
232 }]
David Ghandehari9e5b5872016-07-28 09:50:04 -0700233 ],
234 'dependencies': [
235 'build_include_directory',
Andrew Topc2b40892017-01-19 14:03:49 -0800236 '<(DEPTH)/nb/nb.gyp:nb',
Andrew Top2ea22382016-12-08 09:47:36 -0800237 '<(DEPTH)/starboard/client_porting/pr_starboard/pr_starboard.gyp:pr_starboard',
David Ghandehari9e5b5872016-07-28 09:50:04 -0700238 '<(DEPTH)/third_party/icu/icu.gyp:icui18n',
239 '<(DEPTH)/third_party/zlib/zlib.gyp:zlib',
240 ],
241 'direct_dependent_settings': {
242 'include_dirs': [
243 'cobalt_config/include',
244 'js/src',
245 '<(generated_include_directory)',
246 ],
247 'defines': [
248 'JS_USE_CUSTOM_ALLOCATOR',
249 'STATIC_JS_API',
250 ],
251 'cflags' : [
252 '-Wno-invalid-offsetof',
253 '-Wno-uninitialized',
254 '-Wno-unused',
255 '-include',
256 'js-confdefs.h',
257 ],
Andrew Topa8b99852016-11-29 21:41:27 -0800258 'conditions': [
259 # These W flags do not work with the ps3 compiler.
260 ['target_arch == "ps3"', {
261 'cflags!': [
262 '-Wno-invalid-offsetof',
263 '-Wno-uninitialized',
264 '-Wno-unused',
265 ]
266 }],
267 ],
David Ghandehari9e5b5872016-07-28 09:50:04 -0700268 },
269 # Mark this target as a hard dependency because targets that depend on
270 # this one need to wait for the build_include_directory to be generated.
271 # The more correct things would be to insert that target as a dependency
272 # in direct_dependent_settings, but it wasn't as straightforward as I'd
273 # hoped.
274 'hard_dependency': 1,
275 },
276 {
277 # Command line SpiderMonkey shell.
278 'target_name': 'mozjs_shell',
279 'type': '<(final_executable_type)',
280 'sources': [
281 'js/src/shell/js.cpp',
282 'js/src/shell/jsheaptools.cpp',
283 'js/src/shell/jsoptparse.cpp',
Andrew Top2ea22382016-12-08 09:47:36 -0800284 'js/src/shell/TraceLoggingStub.cpp',
David Ghandehari9e5b5872016-07-28 09:50:04 -0700285 ],
286 'dependencies': [
287 'mozjs_lib',
288 '<(DEPTH)/starboard/starboard.gyp:starboard',
289 '<(DEPTH)/third_party/zlib/zlib.gyp:zlib',
David Ghandeharic3f1d402016-09-22 02:23:39 -0700290 ],
291 'actions': [
292 {
293 'action_name': 'copy_test_data',
294 'variables': {
295 'input_files': [
296 'js/src/tests/',
297 ],
298 'output_dir': 'mozjs/tests/',
299 },
300 'includes': ['../../starboard/build/copy_test_data.gypi'],
301 },
302 ],
303 },
304 {
305 'target_name': 'mozjs_shell_deploy',
306 'type': 'none',
307 'dependencies': [
308 'mozjs_shell',
309 ],
310 'variables': {
311 'executable_name': 'mozjs_shell',
312 },
313 'includes': [ '../../starboard/build/deploy.gypi' ],
David Ghandehari9e5b5872016-07-28 09:50:04 -0700314 },
315 {
316 # SpiderMonkey source expects to include files from a certain directory
317 # structure that is made by copying (or symlinking) the real source files
318 # into the destination directory structure.
319 'target_name': 'build_include_directory',
320 'type': 'none',
321 'copies': [
322 {
323 'destination': '<(generated_include_directory)/mozilla',
324 'files': [
325 'mfbt/Assertions.h',
326 'mfbt/Atomics.h',
327 'mfbt/Attributes.h',
328 'mfbt/BloomFilter.h',
329 'mfbt/Casting.h',
330 'mfbt/Char16.h',
331 'mfbt/CheckedInt.h',
332 'mfbt/Compiler.h',
333 'mfbt/Constants.h',
334 'mfbt/DebugOnly.h',
335 'mfbt/decimal/Decimal.h',
336 'mfbt/Endian.h',
337 'mfbt/EnumSet.h',
338 'mfbt/FloatingPoint.h',
339 'mfbt/GuardObjects.h',
340 'mfbt/HashFunctions.h',
341 'mfbt/Likely.h',
342 'mfbt/LinkedList.h',
343 'mfbt/MathAlgorithms.h',
344 'mfbt/MemoryChecking.h',
345 'mfbt/MSStdInt.h',
346 'mfbt/NullPtr.h',
347 'mfbt/PodOperations.h',
348 'mfbt/Poison.h',
349 'mfbt/Range.h',
350 'mfbt/RangedPtr.h',
351 'mfbt/RefPtr.h',
352 'mfbt/Scoped.h',
353 'mfbt/SHA1.h',
354 'mfbt/SplayTree.h',
355 'mfbt/StandardInteger.h',
356 'mfbt/ThreadLocal.h',
357 'mfbt/TypedEnum.h',
358 'mfbt/Types.h',
359 'mfbt/TypeTraits.h',
360 'mfbt/Util.h',
361 'mfbt/WeakPtr.h',
362 ],
363 },
364 {
365 'destination': '<(generated_include_directory)/js',
366 'files': [
367 'js/public/Anchor.h',
368 'js/public/CallArgs.h',
369 'js/public/CharacterEncoding.h',
370 'js/public/Date.h',
371 'js/public/GCAPI.h',
372 'js/public/HashTable.h',
373 'js/public/HeapAPI.h',
374 'js/public/LegacyIntTypes.h',
375 'js/public/MemoryMetrics.h',
376 'js/public/PropertyKey.h',
377 'js/public/RequiredDefines.h',
378 'js/public/RootingAPI.h',
379 'js/public/TemplateLib.h',
380 'js/public/Utility.h',
381 'js/public/Value.h',
382 'js/public/Vector.h',
383 ],
384 },
385 {
386 'destination': '<(generated_include_directory)',
387 'files': [
388 'js/src/perf/jsperf.h',
389 ],
390 },
391 ],
392 'dependencies': [
393 'generated_headers',
394 ],
395 'hard_dependency': 1,
396 },
397 {
398 'target_name': 'generated_headers',
399 'type': 'none',
400 'actions': [
401 {
402 # Embed JavaScript source into a header file.
403 'action_name': 'CreateEmbeddedJS',
404 'inputs': [ '<@(embedded_js_sources)', 'js/src/js.msg'],
405 'outputs': [
406 '<(embedded_js_file)',
407 '<(embedded_js_header)',
408 ],
409 'action': [
410 'python',
411 'js/src/builtin/embedjs.py',
412 '-DUSE_ZLIB',
413 '-p',
Andrew Topa8b99852016-11-29 21:41:27 -0800414 '<(CC_HOST) -E',
David Ghandehari9e5b5872016-07-28 09:50:04 -0700415 '-m',
416 'js/src/js.msg',
417 '-o',
418 '<(embedded_js_header)',
419 '-s',
420 '<(embedded_js_file)',
421 '<@(embedded_js_sources)'
422 ],
423 },
424 {
425 'action_name': 'CreateKeywordHeader',
426 'inputs': [],
427 'outputs': [ '<(generated_keyword_header)' ],
428 'action': [
429 '<(PRODUCT_DIR)/mozjs_keyword_header_gen',
430 '<(generated_keyword_header)',
431 ],
432 },
433 {
434 'action_name': 'CreateOpcodeLengthHeader',
435 'inputs': [],
436 'outputs': [ '<(generated_opcode_length_header)' ],
437 'action': [
438 '<(PRODUCT_DIR)/mozjs_opcode_length_header_gen',
439 '<(generated_opcode_length_header)',
440 ],
441 },
442 ],
443 'dependencies': [
444 'mozjs_keyword_header_gen#host',
445 'mozjs_opcode_length_header_gen#host'
446 ],
447 'hard_dependency': 1,
448 },
449 {
450 # Host tool used to generate a header file that defines a huge switch
451 # statement for JavaScript keywords.
452 'target_name': 'mozjs_keyword_header_gen',
David Ghandeharic53efd62016-10-04 01:07:30 -0700453 'type': 'executable',
David Ghandehari9e5b5872016-07-28 09:50:04 -0700454 'toolsets': ['host'],
455 'sources': [
456 'js/src/jskwgen.cpp',
457 ],
458 'hard_dependency': 1,
459 },
460 {
461 # Host tool used to generate a header file that defines opcode lengths.
462 'target_name': 'mozjs_opcode_length_header_gen',
David Ghandeharic53efd62016-10-04 01:07:30 -0700463 'type': 'executable',
David Ghandehari9e5b5872016-07-28 09:50:04 -0700464 'toolsets': ['host'],
465 'sources': [
466 'js/src/jsoplengen.cpp',
467 ],
468 'hard_dependency': 1,
469 },
470 ]
471}