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