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