JSC build should use unified sources for derived sources
[WebKit-https.git] / Source / JavaScriptCore / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.12)
2 include(WebKitCommon)
3 set_property(DIRECTORY . PROPERTY FOLDER "JavaScriptCore")
4
5 set(JavaScriptCore_INCLUDE_DIRECTORIES
6     "${CMAKE_BINARY_DIR}"
7     "${JAVASCRIPTCORE_DIR}"
8     "${JAVASCRIPTCORE_DIR}/.."
9     "${JAVASCRIPTCORE_DIR}/API"
10     "${JAVASCRIPTCORE_DIR}/ForwardingHeaders"
11     "${JAVASCRIPTCORE_DIR}/assembler"
12     "${JAVASCRIPTCORE_DIR}/b3"
13     "${JAVASCRIPTCORE_DIR}/b3/air"
14     "${JAVASCRIPTCORE_DIR}/bindings"
15     "${JAVASCRIPTCORE_DIR}/builtins"
16     "${JAVASCRIPTCORE_DIR}/bytecode"
17     "${JAVASCRIPTCORE_DIR}/bytecompiler"
18     "${JAVASCRIPTCORE_DIR}/dfg"
19     "${JAVASCRIPTCORE_DIR}/disassembler"
20     "${JAVASCRIPTCORE_DIR}/disassembler/udis86"
21     "${JAVASCRIPTCORE_DIR}/disassembler/ARM64"
22     "${JAVASCRIPTCORE_DIR}/domjit"
23     "${JAVASCRIPTCORE_DIR}/ftl"
24     "${JAVASCRIPTCORE_DIR}/heap"
25     "${JAVASCRIPTCORE_DIR}/debugger"
26     "${JAVASCRIPTCORE_DIR}/inspector"
27     "${JAVASCRIPTCORE_DIR}/inspector/agents"
28     "${JAVASCRIPTCORE_DIR}/inspector/augmentable"
29     "${JAVASCRIPTCORE_DIR}/inspector/remote"
30     "${JAVASCRIPTCORE_DIR}/interpreter"
31     "${JAVASCRIPTCORE_DIR}/jit"
32     "${JAVASCRIPTCORE_DIR}/llint"
33     "${JAVASCRIPTCORE_DIR}/parser"
34     "${JAVASCRIPTCORE_DIR}/profiler"
35     "${JAVASCRIPTCORE_DIR}/runtime"
36     "${JAVASCRIPTCORE_DIR}/tools"
37     "${JAVASCRIPTCORE_DIR}/wasm"
38     "${JAVASCRIPTCORE_DIR}/wasm/js"
39     "${JAVASCRIPTCORE_DIR}/yarr"
40     "${FORWARDING_HEADERS_DIR}"
41     "${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}"
42     "${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector"
43     "${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/runtime"
44     "${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/yarr"
45 )
46
47 set(JavaScriptCore_SYSTEM_INCLUDE_DIRECTORIES
48     "${ICU_INCLUDE_DIRS}"
49 )
50
51 WEBKIT_COMPUTE_SOURCES(JavaScriptCore)
52
53 set(JavaScriptCore_OBJECT_LUT_SOURCES
54     runtime/ArrayConstructor.cpp
55     runtime/ArrayIteratorPrototype.cpp
56     runtime/AsyncGeneratorPrototype.cpp
57     runtime/BooleanPrototype.cpp
58     runtime/DateConstructor.cpp
59     runtime/DatePrototype.cpp
60     runtime/ErrorPrototype.cpp
61     runtime/GeneratorPrototype.cpp
62     runtime/InspectorInstrumentationObject.cpp
63     runtime/IntlCollatorConstructor.cpp
64     runtime/IntlCollatorPrototype.cpp
65     runtime/IntlDateTimeFormatConstructor.cpp
66     runtime/IntlDateTimeFormatPrototype.cpp
67     runtime/IntlNumberFormatConstructor.cpp
68     runtime/IntlNumberFormatPrototype.cpp
69     runtime/JSDataViewPrototype.cpp
70     runtime/JSGlobalObject.cpp
71     runtime/JSInternalPromiseConstructor.cpp
72     runtime/JSONObject.cpp
73     runtime/JSPromiseConstructor.cpp
74     runtime/JSPromisePrototype.cpp
75     runtime/MapPrototype.cpp
76     runtime/ModuleLoaderPrototype.cpp
77     runtime/NumberConstructor.cpp
78     runtime/NumberPrototype.cpp
79     runtime/ObjectConstructor.cpp
80     runtime/ReflectObject.cpp
81     runtime/RegExpConstructor.cpp
82     runtime/RegExpPrototype.cpp
83     runtime/SetPrototype.cpp
84     runtime/StringConstructor.cpp
85     runtime/StringIteratorPrototype.cpp
86     runtime/StringPrototype.cpp
87     runtime/SymbolConstructor.cpp
88     runtime/SymbolPrototype.cpp
89
90     wasm/js/WebAssemblyCompileErrorConstructor.cpp
91     wasm/js/WebAssemblyCompileErrorPrototype.cpp
92     wasm/js/WebAssemblyInstanceConstructor.cpp
93     wasm/js/WebAssemblyInstancePrototype.cpp
94     wasm/js/WebAssemblyLinkErrorConstructor.cpp
95     wasm/js/WebAssemblyLinkErrorPrototype.cpp
96     wasm/js/WebAssemblyMemoryConstructor.cpp
97     wasm/js/WebAssemblyMemoryPrototype.cpp
98     wasm/js/WebAssemblyModuleConstructor.cpp
99     wasm/js/WebAssemblyModulePrototype.cpp
100     wasm/js/WebAssemblyPrototype.cpp
101     wasm/js/WebAssemblyRuntimeErrorConstructor.cpp
102     wasm/js/WebAssemblyRuntimeErrorPrototype.cpp
103     wasm/js/WebAssemblyTableConstructor.cpp
104     wasm/js/WebAssemblyTablePrototype.cpp
105 )
106
107 set(JavaScriptCore_LIBRARIES
108     WTF${DEBUG_SUFFIX}
109     ${ICU_I18N_LIBRARIES}
110     ${LLVM_LIBRARIES}
111 )
112
113 set(JavaScriptCore_SCRIPTS_SOURCES_DIR "${JAVASCRIPTCORE_DIR}/Scripts")
114
115 # Globbing relies on the fact that generator-specific file names are prefixed with their directory.
116 # Top-level scripts should have a file extension, since they are invoked during the build.
117
118 set(JavaScriptCore_SCRIPTS_SOURCES_PATHS
119     ${JavaScriptCore_SCRIPTS_SOURCES_DIR}/*.pl
120     ${JavaScriptCore_SCRIPTS_SOURCES_DIR}/*.py
121     ${JavaScriptCore_SCRIPTS_SOURCES_DIR}/builtins/builtins*.py
122 )
123
124 # Force JavaScriptCore to run scripts from the same staging path as WebCore.
125 set(JavaScriptCore_SCRIPTS_DIR "${FORWARDING_HEADERS_DIR}/JavaScriptCore/Scripts")
126
127 file(MAKE_DIRECTORY ${JavaScriptCore_SCRIPTS_DIR})
128
129 # The directory flattening performed below mirrors what the Mac port does with private headers.
130
131 file(GLOB JavaScriptCore_SCRIPTS_SOURCES ${JavaScriptCore_SCRIPTS_SOURCES_PATHS})
132
133 foreach (_file ${JavaScriptCore_SCRIPTS_SOURCES})
134     get_filename_component(_script "${_file}" NAME)
135     add_custom_command(
136         OUTPUT ${JavaScriptCore_SCRIPTS_DIR}/${_script}
137         MAIN_DEPENDENCY ${_file}
138         WORKING_DIRECTORY ${DERIVED_SOURCES_DIR}
139         COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_file} ${JavaScriptCore_SCRIPTS_DIR}/${_script}
140         VERBATIM)
141     list(APPEND JavaScriptCore_SCRIPTS ${JavaScriptCore_SCRIPTS_DIR}/${_script})
142 endforeach ()
143
144 set(UDIS_GEN_DEP
145     disassembler/udis86/ud_opcode.py
146 )
147
148 add_custom_command(
149     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/udis86_itab.c ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/udis86_itab.h
150     DEPENDS ${UDIS_GEN_DEP}
151     WORKING_DIRECTORY ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}
152     COMMAND ${PYTHON_EXECUTABLE} ${JAVASCRIPTCORE_DIR}/disassembler/udis86/ud_itab.py ${JAVASCRIPTCORE_DIR}/disassembler/udis86/optable.xml ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}
153     VERBATIM)
154
155 list(APPEND JavaScriptCore_HEADERS
156     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/udis86_itab.h
157 )
158
159 set(LLINT_ASM
160     llint/LowLevelInterpreter.asm
161     llint/LowLevelInterpreter32_64.asm
162     llint/LowLevelInterpreter64.asm
163 )
164
165 set(OFFLINE_ASM
166     offlineasm/arm.rb
167     offlineasm/arm64.rb
168     offlineasm/ast.rb
169     offlineasm/backends.rb
170     offlineasm/cloop.rb
171     offlineasm/config.rb
172     offlineasm/instructions.rb
173     offlineasm/mips.rb
174     offlineasm/offsets.rb
175     offlineasm/opt.rb
176     offlineasm/parser.rb
177     offlineasm/registers.rb
178     offlineasm/risc.rb
179     offlineasm/self_hash.rb
180     offlineasm/settings.rb
181     offlineasm/transform.rb
182     offlineasm/x86.rb
183 )
184
185 add_custom_command(
186     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/Bytecodes.h ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InitBytecodes.asm ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/BytecodeStructs.h
187     MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/generate-bytecode-files
188     DEPENDS ${JAVASCRIPTCORE_DIR}/generate-bytecode-files bytecode/BytecodeList.json
189     COMMAND ${PYTHON_EXECUTABLE} ${JAVASCRIPTCORE_DIR}/generate-bytecode-files --bytecodes_h ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/Bytecodes.h --init_bytecodes_asm ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InitBytecodes.asm --bytecode_structs_h ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/BytecodeStructs.h ${JAVASCRIPTCORE_DIR}/bytecode/BytecodeList.json
190     VERBATIM)
191
192 list(APPEND JavaScriptCore_HEADERS
193     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/Bytecodes.h
194     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/BytecodeStructs.h
195 )
196
197 if (WIN32)
198   set(OFFLINE_ASM_BACKEND "X86_WIN, X86_64_WIN, C_LOOP")
199 else ()
200     if (WTF_CPU_X86)
201         set(OFFLINE_ASM_BACKEND "X86")
202     elseif (WTF_CPU_X86_64)
203         set(OFFLINE_ASM_BACKEND "X86_64")
204     elseif (WTF_CPU_ARM64)
205         set(OFFLINE_ASM_BACKEND "ARM64")
206     elseif (ARM_THUMB2_DETECTED)
207         set(OFFLINE_ASM_BACKEND "ARMv7")
208     elseif (ARM_TRADITIONAL_DETECTED)
209         set(OFFLINE_ASM_BACKEND "ARMv7_TRADITIONAL")
210     elseif (WTF_CPU_MIPS)
211         set(OFFLINE_ASM_BACKEND "MIPS")
212     endif ()
213
214     if (NOT ENABLE_JIT)
215         set(OFFLINE_ASM_BACKEND "C_LOOP")
216     endif ()
217 endif ()
218
219 add_custom_command(
220     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntDesiredOffsets.h
221     MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/offlineasm/generate_offset_extractor.rb
222     DEPENDS ${LLINT_ASM} ${OFFLINE_ASM} ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InitBytecodes.asm
223     COMMAND ${RUBY_EXECUTABLE} ${JAVASCRIPTCORE_DIR}/offlineasm/generate_offset_extractor.rb -I${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/ ${JAVASCRIPTCORE_DIR}/llint/LowLevelInterpreter.asm ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntDesiredOffsets.h ${OFFLINE_ASM_BACKEND}
224     VERBATIM)
225
226 # We add the header files directly to the ADD_EXECUTABLE call instead of setting the
227 # OBJECT_DEPENDS property in LLIntOffsetsExtractor.cpp because generate_offset_extractor.rb and
228 # generate-bytecode-files may not regenerate the .h files in case the hash it calculates does not change.
229 # In this case, if some of the dependencies specified in the ADD_CUSTOM_COMMANDs above have
230 # changed the command will always be called because the mtime of the .h files will
231 # always be older than that of their dependencies.
232 # Additionally, setting the OBJECT_DEPENDS property will make the .h files a Makefile
233 # dependency of both LLIntOffsetsExtractor and LLIntOffsetsExtractor.cpp, so the command will
234 # actually be run multiple times!
235 add_executable(LLIntOffsetsExtractor
236     ${JAVASCRIPTCORE_DIR}/llint/LLIntOffsetsExtractor.cpp
237     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntDesiredOffsets.h ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/Bytecodes.h ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/BytecodeStructs.h
238 )
239 target_link_libraries(LLIntOffsetsExtractor WTF)
240
241 # The build system will execute asm.rb every time LLIntOffsetsExtractor's mtime is newer than
242 # LLIntAssembly.h's mtime. The problem we have here is: asm.rb has some built-in optimization
243 # that generates a checksum of the LLIntOffsetsExtractor binary, if the checksum of the new
244 # LLIntOffsetsExtractor matches, no output is generated. To make this target consistent and avoid
245 # running this command for every build, we artificially update LLIntAssembly.h's mtime (using touch)
246 # after every asm.rb run.
247 if (MSVC)
248     set(LLIntOutput LowLevelInterpreterWin.asm)
249     set(OFFLINE_ASM_ARGS --assembler=MASM)
250 else ()
251     set(LLIntOutput LLIntAssembly.h)
252 endif ()
253
254 add_custom_command(
255     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/${LLIntOutput}
256     MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/offlineasm/asm.rb
257     DEPENDS LLIntOffsetsExtractor ${LLINT_ASM} ${OFFLINE_ASM} ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InitBytecodes.asm
258     COMMAND ${RUBY_EXECUTABLE} ${JAVASCRIPTCORE_DIR}/offlineasm/asm.rb -I${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/ ${JAVASCRIPTCORE_DIR}/llint/LowLevelInterpreter.asm $<TARGET_FILE:LLIntOffsetsExtractor> ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/${LLIntOutput} ${OFFLINE_ASM_ARGS}
259     COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/${LLIntOutput}
260     WORKING_DIRECTORY ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}
261     VERBATIM)
262
263 # The explanation for not making LLIntAssembly.h part of the OBJECT_DEPENDS property of some of
264 # the .cpp files below is similar to the one in the previous comment. However, since these .cpp
265 # files are used to build JavaScriptCore itself, we can just add LLIntAssembly.h to JSC_HEADERS
266 # since it is used in the add_library() call at the end of this file.
267 if (MSVC)
268     enable_language(ASM_MASM)
269     if (CMAKE_SIZEOF_VOID_P EQUAL 4)
270         # Win32 needs /safeseh with assembly, but Win64 does not.
271         set(MASM_EXECUTABLE ml)
272         set(LLINT_MASM_FLAGS /safeseh /c /Fo)
273     else ()
274         set(MASM_EXECUTABLE ml64)
275         set(LLINT_MASM_FLAGS /c /Fo)
276     endif ()
277     add_custom_command(
278         OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LowLevelInterpreterWin.obj
279         DEPENDS ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LowLevelInterpreterWin.asm
280         COMMAND ${MASM_EXECUTABLE} ${LLINT_MASM_FLAGS} ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LowLevelInterpreterWin.obj ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LowLevelInterpreterWin.asm
281         VERBATIM)
282     list(APPEND JavaScriptCore_SOURCES ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LowLevelInterpreterWin.obj)
283 else ()
284     list(APPEND JavaScriptCore_HEADERS
285         ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntAssembly.h
286     )
287 endif ()
288
289 # WebAssembly generator
290
291 macro(GENERATE_PYTHON _generator _additional_deps _input _output)
292     add_custom_command(
293         OUTPUT ${_output}
294         MAIN_DEPENDENCY ${_generator}
295         DEPENDS ${_input} ${_additional_deps}
296         COMMAND ${PYTHON_EXECUTABLE} ${_generator} ${_input} ${_output}
297         VERBATIM)
298     list(APPEND JavaScriptCore_HEADERS ${_output})
299     WEBKIT_ADD_SOURCE_DEPENDENCIES(${_input} ${_output})
300 endmacro()
301 GENERATE_PYTHON(${CMAKE_CURRENT_SOURCE_DIR}/wasm/generateWasmOpsHeader.py ${CMAKE_CURRENT_SOURCE_DIR}/wasm/generateWasm.py ${CMAKE_CURRENT_SOURCE_DIR}/wasm/wasm.json ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/WasmOps.h)
302 GENERATE_PYTHON(${CMAKE_CURRENT_SOURCE_DIR}/wasm/generateWasmValidateInlinesHeader.py ${CMAKE_CURRENT_SOURCE_DIR}/wasm/generateWasm.py ${CMAKE_CURRENT_SOURCE_DIR}/wasm/wasm.json ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/WasmValidateInlines.h)
303 GENERATE_PYTHON(${CMAKE_CURRENT_SOURCE_DIR}/wasm/generateWasmB3IRGeneratorInlinesHeader.py ${CMAKE_CURRENT_SOURCE_DIR}/wasm/generateWasm.py ${CMAKE_CURRENT_SOURCE_DIR}/wasm/wasm.json ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/WasmB3IRGeneratorInlines.h)
304
305 # LUT generator
306
307 set(HASH_LUT_GENERATOR ${CMAKE_CURRENT_SOURCE_DIR}/create_hash_table)
308 macro(GENERATE_HASH_LUT _input _output)
309     add_custom_command(
310         OUTPUT ${_output}
311         MAIN_DEPENDENCY ${HASH_LUT_GENERATOR}
312         DEPENDS ${_input}
313         COMMAND ${PERL_EXECUTABLE} ${HASH_LUT_GENERATOR} ${_input} > ${_output}
314         VERBATIM)
315     list(APPEND JavaScriptCore_HEADERS ${_output})
316     WEBKIT_ADD_SOURCE_DEPENDENCIES(${_input} ${_output})
317 endmacro()
318
319 # GENERATOR 1-A: LUT creator
320
321 foreach (_file ${JavaScriptCore_OBJECT_LUT_SOURCES})
322     get_filename_component(_name ${_file} NAME_WE)
323     GENERATE_HASH_LUT(${CMAKE_CURRENT_SOURCE_DIR}/${_file} ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/${_name}.lut.h)
324 endforeach ()
325
326 set(JavaScriptCore_FORWARDING_HEADERS_DIRECTORIES
327     API
328     assembler
329     bindings
330     builtins
331     bytecode
332     debugger
333     dfg
334     disassembler
335     domjit
336     heap
337     inspector
338     interpreter
339     jit
340     llint
341     parser
342     profiler
343     runtime
344     wasm
345     yarr
346
347     collector/handles
348
349     inspector/agents
350     inspector/augmentable
351     inspector/remote
352
353     wasm/js
354 )
355
356 # GENERATOR 1-B: particular LUT creator (for 1 file only)
357 GENERATE_HASH_LUT(${CMAKE_CURRENT_SOURCE_DIR}/parser/Keywords.table ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/Lexer.lut.h)
358
359 #GENERATOR: "RegExpJitTables.h": tables used by Yarr
360 add_custom_command(
361     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/yarr/RegExpJitTables.h
362     MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/yarr/create_regex_tables
363     COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/yarr/create_regex_tables ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/yarr/RegExpJitTables.h
364     VERBATIM)
365 list(APPEND JavaScriptCore_HEADERS ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/yarr/RegExpJitTables.h)
366 WEBKIT_ADD_SOURCE_DEPENDENCIES(${CMAKE_CURRENT_SOURCE_DIR}/yarr/YarrPattern.cpp ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/yarr/RegExpJitTables.h)
367
368 add_custom_command(
369     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/yarr/YarrCanonicalizeUnicode.cpp
370     MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/yarr/generateYarrCanonicalizeUnicode
371     DEPENDS ${JAVASCRIPTCORE_DIR}/ucd/CaseFolding.txt
372     COMMAND ${PYTHON_EXECUTABLE} ${JAVASCRIPTCORE_DIR}/yarr/generateYarrCanonicalizeUnicode ${JAVASCRIPTCORE_DIR}/ucd/CaseFolding.txt ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/yarr/YarrCanonicalizeUnicode.cpp
373     VERBATIM)
374
375 #GENERATOR: "KeywordLookup.h": keyword decision tree used by the lexer
376 add_custom_command(
377     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/KeywordLookup.h
378     MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/KeywordLookupGenerator.py
379     DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/parser/Keywords.table
380     COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/KeywordLookupGenerator.py ${CMAKE_CURRENT_SOURCE_DIR}/parser/Keywords.table > ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/KeywordLookup.h
381     VERBATIM)
382 list(APPEND JavaScriptCore_HEADERS ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/KeywordLookup.h)
383 WEBKIT_ADD_SOURCE_DEPENDENCIES(${CMAKE_CURRENT_SOURCE_DIR}/parser/Lexer.cpp ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/KeywordLookup.h)
384
385
386 # Inspector Interfaces
387
388 set(JavaScriptCore_INSPECTOR_SCRIPTS_DIR "${JAVASCRIPTCORE_DIR}/inspector/scripts")
389
390 set(JavaScriptCore_INSPECTOR_PROTOCOL_SCRIPTS
391     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/generate-inspector-protocol-bindings.py
392     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/cpp_generator.py
393     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/cpp_generator_templates.py
394     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generate_js_backend_commands.py
395     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generate_cpp_backend_dispatcher_header.py
396     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generate_cpp_backend_dispatcher_implementation.py
397     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generate_cpp_frontend_dispatcher_header.py
398     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generate_cpp_frontend_dispatcher_implementation.py
399     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generate_cpp_protocol_types_header.py
400     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generate_cpp_protocol_types_implementation.py
401     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generator.py
402     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generator_templates.py
403     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/__init__.py
404     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/models.py
405 )
406
407 set(JavaScriptCore_INSPECTOR_DOMAINS
408     ${JAVASCRIPTCORE_DIR}/inspector/protocol/ApplicationCache.json
409     ${JAVASCRIPTCORE_DIR}/inspector/protocol/CSS.json
410     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Canvas.json
411     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Console.json
412     ${JAVASCRIPTCORE_DIR}/inspector/protocol/DOM.json
413     ${JAVASCRIPTCORE_DIR}/inspector/protocol/DOMDebugger.json
414     ${JAVASCRIPTCORE_DIR}/inspector/protocol/DOMStorage.json
415     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Database.json
416     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Debugger.json
417     ${JAVASCRIPTCORE_DIR}/inspector/protocol/GenericTypes.json
418     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Heap.json
419     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Inspector.json
420     ${JAVASCRIPTCORE_DIR}/inspector/protocol/LayerTree.json
421     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Network.json
422     ${JAVASCRIPTCORE_DIR}/inspector/protocol/OverlayTypes.json
423     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Page.json
424     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Recording.json
425     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Runtime.json
426     ${JAVASCRIPTCORE_DIR}/inspector/protocol/ScriptProfiler.json
427     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Timeline.json
428     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Worker.json
429 )
430
431 if (ENABLE_INDEXED_DATABASE)
432     list(APPEND JavaScriptCore_INSPECTOR_DOMAINS
433         ${JAVASCRIPTCORE_DIR}/inspector/protocol/IndexedDB.json
434     )
435 endif ()
436
437 if (ENABLE_RESOURCE_USAGE)
438     list(APPEND JavaScriptCore_INSPECTOR_DOMAINS
439         ${JAVASCRIPTCORE_DIR}/inspector/protocol/Memory.json
440     )
441 endif ()
442
443 add_custom_command(
444     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/CombinedDomains.json
445     MAIN_DEPENDENCY ${JavaScriptCore_SCRIPTS_DIR}/generate-combined-inspector-json.py
446     DEPENDS ${JavaScriptCore_INSPECTOR_DOMAINS}
447     COMMAND ${PYTHON_EXECUTABLE} ${JavaScriptCore_SCRIPTS_DIR}/generate-combined-inspector-json.py ${JavaScriptCore_INSPECTOR_DOMAINS} > ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/CombinedDomains.json
448     VERBATIM)
449
450 # Inspector Backend Dispatchers, Frontend Dispatchers, Type Builders
451 file(MAKE_DIRECTORY ${DERIVED_SOURCES_WEBINSPECTORUI_DIR}/UserInterface/Protocol)
452 file(MAKE_DIRECTORY ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector)
453 add_custom_command(
454     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorBackendDispatchers.cpp
455            ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorBackendDispatchers.h
456            ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorFrontendDispatchers.cpp
457            ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorFrontendDispatchers.h
458            ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorProtocolObjects.cpp
459            ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorProtocolObjects.h
460            ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorBackendCommands.js
461     MAIN_DEPENDENCY ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/CombinedDomains.json
462     DEPENDS ${JavaScriptCore_INSPECTOR_PROTOCOL_SCRIPTS}
463     COMMAND ${PYTHON_EXECUTABLE} ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/generate-inspector-protocol-bindings.py --outputDir "${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector" --framework JavaScriptCore ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/CombinedDomains.json
464     VERBATIM)
465
466 # JSCBuiltins
467
468 set(BUILTINS_GENERATOR_SCRIPTS
469     ${JavaScriptCore_SCRIPTS_DIR}/builtins.py
470     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generator.py
471     ${JavaScriptCore_SCRIPTS_DIR}/builtins_model.py
472     ${JavaScriptCore_SCRIPTS_DIR}/builtins_templates.py
473     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generate_combined_header.py
474     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generate_combined_implementation.py
475     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generate_separate_header.py
476     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generate_separate_implementation.py
477     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generate_wrapper_header.py
478     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generate_wrapper_implementation.py
479     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generate_internals_wrapper_header.py
480     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generate_internals_wrapper_implementation.py
481     ${JavaScriptCore_SCRIPTS_DIR}/generate-js-builtins.py
482     ${JavaScriptCore_SCRIPTS_DIR}/lazywriter.py
483 )
484
485 set(JavaScriptCore_BUILTINS_SOURCES
486     ${JAVASCRIPTCORE_DIR}/builtins/AsyncFromSyncIteratorPrototype.js
487     ${JAVASCRIPTCORE_DIR}/builtins/ArrayConstructor.js
488     ${JAVASCRIPTCORE_DIR}/builtins/ArrayIteratorPrototype.js
489     ${JAVASCRIPTCORE_DIR}/builtins/ArrayPrototype.js
490     ${JAVASCRIPTCORE_DIR}/builtins/AsyncFunctionPrototype.js
491     ${JAVASCRIPTCORE_DIR}/builtins/AsyncIteratorPrototype.js
492     ${JAVASCRIPTCORE_DIR}/builtins/AsyncGeneratorPrototype.js
493     ${JAVASCRIPTCORE_DIR}/builtins/DatePrototype.js
494     ${JAVASCRIPTCORE_DIR}/builtins/FunctionPrototype.js
495     ${JAVASCRIPTCORE_DIR}/builtins/GeneratorPrototype.js
496     ${JAVASCRIPTCORE_DIR}/builtins/GlobalObject.js
497     ${JAVASCRIPTCORE_DIR}/builtins/GlobalOperations.js
498     ${JAVASCRIPTCORE_DIR}/builtins/InspectorInstrumentationObject.js
499     ${JAVASCRIPTCORE_DIR}/builtins/InternalPromiseConstructor.js
500     ${JAVASCRIPTCORE_DIR}/builtins/IteratorHelpers.js
501     ${JAVASCRIPTCORE_DIR}/builtins/IteratorPrototype.js
502     ${JAVASCRIPTCORE_DIR}/builtins/MapIteratorPrototype.js
503     ${JAVASCRIPTCORE_DIR}/builtins/MapPrototype.js
504     ${JAVASCRIPTCORE_DIR}/builtins/ModuleLoaderPrototype.js
505     ${JAVASCRIPTCORE_DIR}/builtins/NumberConstructor.js
506     ${JAVASCRIPTCORE_DIR}/builtins/NumberPrototype.js
507     ${JAVASCRIPTCORE_DIR}/builtins/ObjectConstructor.js
508     ${JAVASCRIPTCORE_DIR}/builtins/PromiseConstructor.js
509     ${JAVASCRIPTCORE_DIR}/builtins/PromiseOperations.js
510     ${JAVASCRIPTCORE_DIR}/builtins/PromisePrototype.js
511     ${JAVASCRIPTCORE_DIR}/builtins/ReflectObject.js
512     ${JAVASCRIPTCORE_DIR}/builtins/RegExpPrototype.js
513     ${JAVASCRIPTCORE_DIR}/builtins/SetIteratorPrototype.js
514     ${JAVASCRIPTCORE_DIR}/builtins/SetPrototype.js
515     ${JAVASCRIPTCORE_DIR}/builtins/StringConstructor.js
516     ${JAVASCRIPTCORE_DIR}/builtins/StringIteratorPrototype.js
517     ${JAVASCRIPTCORE_DIR}/builtins/StringPrototype.js
518     ${JAVASCRIPTCORE_DIR}/builtins/TypedArrayConstructor.js
519     ${JAVASCRIPTCORE_DIR}/builtins/TypedArrayPrototype.js
520 )
521
522 add_custom_command(
523     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/JSCBuiltins.cpp ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/JSCBuiltins.h
524     MAIN_DEPENDENCY ${JavaScriptCore_SCRIPTS_DIR}/generate-js-builtins.py
525     DEPENDS ${JavaScriptCore_BUILTINS_SOURCES} ${BUILTINS_GENERATOR_SCRIPTS}
526     COMMAND ${PYTHON_EXECUTABLE} ${JavaScriptCore_SCRIPTS_DIR}/generate-js-builtins.py --framework JavaScriptCore --output-directory ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR} --combined ${JavaScriptCore_BUILTINS_SOURCES}
527     VERBATIM)
528
529 list(APPEND JavaScriptCore_HEADERS
530     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorBackendDispatchers.h
531     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorFrontendDispatchers.h
532     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorProtocolObjects.h
533     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/JSCBuiltins.h
534 )
535
536 add_custom_command(
537     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/AirOpcode.h ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/AirOpcodeGenerated.h
538     MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/b3/air/AirOpcode.opcodes
539     DEPENDS ${JAVASCRIPTCORE_DIR}/b3/air/opcode_generator.rb
540     COMMAND ${RUBY_EXECUTABLE} ${JAVASCRIPTCORE_DIR}/b3/air/opcode_generator.rb ${JAVASCRIPTCORE_DIR}/b3/air/AirOpcode.opcodes VERBATIM
541     WORKING_DIRECTORY ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}
542 )
543
544 list(APPEND JavaScriptCore_HEADERS
545     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/AirOpcode.h
546     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/AirOpcodeGenerated.h
547 )
548
549 add_custom_command(
550     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InjectedScriptSource.h ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InjectedScriptSource.min.js
551     MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/inspector/InjectedScriptSource.js
552     DEPENDS ${JavaScriptCore_SCRIPTS_DIR}/xxd.pl ${JavaScriptCore_SCRIPTS_DIR}/jsmin.py
553     COMMAND ${CMAKE_COMMAND} -E echo "//# sourceURL=__InjectedScript_InjectedScriptSource.js" > ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InjectedScriptSource.min.js
554     COMMAND ${PYTHON_EXECUTABLE} ${JavaScriptCore_SCRIPTS_DIR}/jsmin.py < ${JAVASCRIPTCORE_DIR}/inspector/InjectedScriptSource.js >> ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InjectedScriptSource.min.js
555     COMMAND ${PERL_EXECUTABLE} ${JavaScriptCore_SCRIPTS_DIR}/xxd.pl InjectedScriptSource_js ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InjectedScriptSource.min.js ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InjectedScriptSource.h
556     VERBATIM)
557
558 list(APPEND JavaScriptCore_HEADERS ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/InjectedScriptSource.h)
559
560 if (WTF_CPU_ARM)
561 elseif (WTF_CPU_ARM64)
562 elseif (WTF_CPU_ALPHA)
563 elseif (WTF_CPU_HPPA)
564 elseif (WTF_CPU_PPC)
565 elseif (WTF_CPU_PPC64)
566 elseif (WTF_CPU_PPC64LE)
567 elseif (WTF_CPU_S390)
568 elseif (WTF_CPU_S390X)
569 elseif (WTF_CPU_MIPS)
570 elseif (WTF_CPU_SH4)
571 elseif (WTF_CPU_X86)
572 elseif (WTF_CPU_X86_64)
573     if (MSVC AND ENABLE_JIT)
574         add_custom_command(
575             OUTPUT ${DERIVED_SOURCES_DIR}/JITStubsMSVC64.obj
576             MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/jit/JITStubsMSVC64.asm
577             COMMAND ml64 -nologo -c -Fo ${DERIVED_SOURCES_DIR}/JITStubsMSVC64.obj ${JAVASCRIPTCORE_DIR}/jit/JITStubsMSVC64.asm
578             VERBATIM)
579
580         list(APPEND JavaScriptCore_SOURCES ${DERIVED_SOURCES_DIR}/JITStubsMSVC64.obj)
581     endif ()
582 else ()
583     message(FATAL_ERROR "Unknown CPU")
584 endif ()
585
586 WEBKIT_FRAMEWORK_DECLARE(JavaScriptCore)
587 WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS()
588
589 WEBKIT_CREATE_FORWARDING_HEADERS(JavaScriptCore DIRECTORIES ${JavaScriptCore_FORWARDING_HEADERS_DIRECTORIES} FILES ${JavaScriptCore_FORWARDING_HEADERS_FILES})
590
591 target_include_directories(LLIntOffsetsExtractor PRIVATE ${JavaScriptCore_INCLUDE_DIRECTORIES})
592
593 add_subdirectory(shell)
594
595 WEBKIT_WRAP_SOURCELIST(${JavaScriptCore_SOURCES})
596 WEBKIT_FRAMEWORK(JavaScriptCore)
597
598 if (NOT "${PORT}" STREQUAL "Mac")
599     if (${JavaScriptCore_LIBRARY_TYPE} STREQUAL "SHARED")
600         WEBKIT_POPULATE_LIBRARY_VERSION(JAVASCRIPTCORE)
601         set_target_properties(JavaScriptCore PROPERTIES VERSION ${JAVASCRIPTCORE_VERSION} SOVERSION ${JAVASCRIPTCORE_VERSION_MAJOR})
602         install(TARGETS JavaScriptCore DESTINATION "${LIB_INSTALL_DIR}")
603     endif ()
604 endif ()
605
606 # Force staging of shared scripts, even if they aren't directly used to build JavaScriptCore.
607
608 add_custom_target(stageSharedScripts DEPENDS ${JavaScriptCore_SCRIPTS})
609 add_dependencies(JavaScriptCore stageSharedScripts)
610
611 if (MSVC)
612     add_custom_command(
613         TARGET JavaScriptCore
614         PRE_BUILD
615         COMMAND ${PERL_EXECUTABLE} ${WEBKIT_LIBRARIES_DIR}/tools/scripts/auto-version.pl ${DERIVED_SOURCES_DIR}
616         VERBATIM)
617
618     add_custom_command(
619         TARGET JavaScriptCore
620         POST_BUILD
621         COMMAND ${PERL_EXECUTABLE} ${WEBKIT_LIBRARIES_DIR}/tools/scripts/version-stamp.pl ${DERIVED_SOURCES_DIR} $<TARGET_FILE:JavaScriptCore>
622         VERBATIM)
623 endif ()