Implement RegExp Unicode property escapes
[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/UnicodePatternTables.h
370     MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/Scripts/generateYarrUnicodePropertyTables.py
371     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
372     COMMAND ${PYTHON_EXECUTABLE} ${JAVASCRIPTCORE_DIR}/Scripts/generateYarrUnicodePropertyTables.py ${JAVASCRIPTCORE_DIR}/ucd ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/yarr/UnicodePatternTables.h
373     VERBATIM)
374 list(APPEND JavaScriptCore_HEADERS ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/yarr/UnicodePatternTables.h)
375 WEBKIT_ADD_SOURCE_DEPENDENCIES(${CMAKE_CURRENT_SOURCE_DIR}/yarr/UnicodePatternTables.cpp ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/yarr/UnicodePatternTables.h)
376
377 add_custom_command(
378     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/yarr/YarrCanonicalizeUnicode.cpp
379     MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/yarr/generateYarrCanonicalizeUnicode
380     DEPENDS ${JAVASCRIPTCORE_DIR}/ucd/CaseFolding.txt
381     COMMAND ${PYTHON_EXECUTABLE} ${JAVASCRIPTCORE_DIR}/yarr/generateYarrCanonicalizeUnicode ${JAVASCRIPTCORE_DIR}/ucd/CaseFolding.txt ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/yarr/YarrCanonicalizeUnicode.cpp
382     VERBATIM)
383
384 #GENERATOR: "KeywordLookup.h": keyword decision tree used by the lexer
385 add_custom_command(
386     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/KeywordLookup.h
387     MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/KeywordLookupGenerator.py
388     DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/parser/Keywords.table
389     COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/KeywordLookupGenerator.py ${CMAKE_CURRENT_SOURCE_DIR}/parser/Keywords.table > ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/KeywordLookup.h
390     VERBATIM)
391 list(APPEND JavaScriptCore_HEADERS ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/KeywordLookup.h)
392 WEBKIT_ADD_SOURCE_DEPENDENCIES(${CMAKE_CURRENT_SOURCE_DIR}/parser/Lexer.cpp ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/KeywordLookup.h)
393
394
395 # Inspector Interfaces
396
397 set(JavaScriptCore_INSPECTOR_SCRIPTS_DIR "${JAVASCRIPTCORE_DIR}/inspector/scripts")
398
399 set(JavaScriptCore_INSPECTOR_PROTOCOL_SCRIPTS
400     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/generate-inspector-protocol-bindings.py
401     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/cpp_generator.py
402     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/cpp_generator_templates.py
403     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generate_js_backend_commands.py
404     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generate_cpp_backend_dispatcher_header.py
405     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generate_cpp_backend_dispatcher_implementation.py
406     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generate_cpp_frontend_dispatcher_header.py
407     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generate_cpp_frontend_dispatcher_implementation.py
408     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generate_cpp_protocol_types_header.py
409     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generate_cpp_protocol_types_implementation.py
410     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generator.py
411     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/generator_templates.py
412     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/__init__.py
413     ${JavaScriptCore_INSPECTOR_SCRIPTS_DIR}/codegen/models.py
414 )
415
416 set(JavaScriptCore_INSPECTOR_DOMAINS
417     ${JAVASCRIPTCORE_DIR}/inspector/protocol/ApplicationCache.json
418     ${JAVASCRIPTCORE_DIR}/inspector/protocol/CSS.json
419     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Canvas.json
420     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Console.json
421     ${JAVASCRIPTCORE_DIR}/inspector/protocol/DOM.json
422     ${JAVASCRIPTCORE_DIR}/inspector/protocol/DOMDebugger.json
423     ${JAVASCRIPTCORE_DIR}/inspector/protocol/DOMStorage.json
424     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Database.json
425     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Debugger.json
426     ${JAVASCRIPTCORE_DIR}/inspector/protocol/GenericTypes.json
427     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Heap.json
428     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Inspector.json
429     ${JAVASCRIPTCORE_DIR}/inspector/protocol/LayerTree.json
430     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Network.json
431     ${JAVASCRIPTCORE_DIR}/inspector/protocol/OverlayTypes.json
432     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Page.json
433     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Recording.json
434     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Runtime.json
435     ${JAVASCRIPTCORE_DIR}/inspector/protocol/ScriptProfiler.json
436     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Timeline.json
437     ${JAVASCRIPTCORE_DIR}/inspector/protocol/Worker.json
438 )
439
440 if (ENABLE_INDEXED_DATABASE)
441     list(APPEND JavaScriptCore_INSPECTOR_DOMAINS
442         ${JAVASCRIPTCORE_DIR}/inspector/protocol/IndexedDB.json
443     )
444 endif ()
445
446 if (ENABLE_RESOURCE_USAGE)
447     list(APPEND JavaScriptCore_INSPECTOR_DOMAINS
448         ${JAVASCRIPTCORE_DIR}/inspector/protocol/Memory.json
449     )
450 endif ()
451
452 add_custom_command(
453     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/CombinedDomains.json
454     MAIN_DEPENDENCY ${JavaScriptCore_SCRIPTS_DIR}/generate-combined-inspector-json.py
455     DEPENDS ${JavaScriptCore_INSPECTOR_DOMAINS}
456     COMMAND ${PYTHON_EXECUTABLE} ${JavaScriptCore_SCRIPTS_DIR}/generate-combined-inspector-json.py ${JavaScriptCore_INSPECTOR_DOMAINS} > ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/CombinedDomains.json
457     VERBATIM)
458
459 # Inspector Backend Dispatchers, Frontend Dispatchers, Type Builders
460 file(MAKE_DIRECTORY ${DERIVED_SOURCES_WEBINSPECTORUI_DIR}/UserInterface/Protocol)
461 file(MAKE_DIRECTORY ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector)
462 add_custom_command(
463     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorBackendDispatchers.cpp
464            ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorBackendDispatchers.h
465            ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorFrontendDispatchers.cpp
466            ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorFrontendDispatchers.h
467            ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorProtocolObjects.cpp
468            ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorProtocolObjects.h
469            ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorBackendCommands.js
470     MAIN_DEPENDENCY ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/CombinedDomains.json
471     DEPENDS ${JavaScriptCore_INSPECTOR_PROTOCOL_SCRIPTS}
472     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
473     VERBATIM)
474
475 # JSCBuiltins
476
477 set(BUILTINS_GENERATOR_SCRIPTS
478     ${JavaScriptCore_SCRIPTS_DIR}/builtins.py
479     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generator.py
480     ${JavaScriptCore_SCRIPTS_DIR}/builtins_model.py
481     ${JavaScriptCore_SCRIPTS_DIR}/builtins_templates.py
482     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generate_combined_header.py
483     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generate_combined_implementation.py
484     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generate_separate_header.py
485     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generate_separate_implementation.py
486     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generate_wrapper_header.py
487     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generate_wrapper_implementation.py
488     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generate_internals_wrapper_header.py
489     ${JavaScriptCore_SCRIPTS_DIR}/builtins_generate_internals_wrapper_implementation.py
490     ${JavaScriptCore_SCRIPTS_DIR}/generate-js-builtins.py
491     ${JavaScriptCore_SCRIPTS_DIR}/lazywriter.py
492 )
493
494 set(JavaScriptCore_BUILTINS_SOURCES
495     ${JAVASCRIPTCORE_DIR}/builtins/AsyncFromSyncIteratorPrototype.js
496     ${JAVASCRIPTCORE_DIR}/builtins/ArrayConstructor.js
497     ${JAVASCRIPTCORE_DIR}/builtins/ArrayIteratorPrototype.js
498     ${JAVASCRIPTCORE_DIR}/builtins/ArrayPrototype.js
499     ${JAVASCRIPTCORE_DIR}/builtins/AsyncFunctionPrototype.js
500     ${JAVASCRIPTCORE_DIR}/builtins/AsyncIteratorPrototype.js
501     ${JAVASCRIPTCORE_DIR}/builtins/AsyncGeneratorPrototype.js
502     ${JAVASCRIPTCORE_DIR}/builtins/DatePrototype.js
503     ${JAVASCRIPTCORE_DIR}/builtins/FunctionPrototype.js
504     ${JAVASCRIPTCORE_DIR}/builtins/GeneratorPrototype.js
505     ${JAVASCRIPTCORE_DIR}/builtins/GlobalObject.js
506     ${JAVASCRIPTCORE_DIR}/builtins/GlobalOperations.js
507     ${JAVASCRIPTCORE_DIR}/builtins/InspectorInstrumentationObject.js
508     ${JAVASCRIPTCORE_DIR}/builtins/InternalPromiseConstructor.js
509     ${JAVASCRIPTCORE_DIR}/builtins/IteratorHelpers.js
510     ${JAVASCRIPTCORE_DIR}/builtins/IteratorPrototype.js
511     ${JAVASCRIPTCORE_DIR}/builtins/MapIteratorPrototype.js
512     ${JAVASCRIPTCORE_DIR}/builtins/MapPrototype.js
513     ${JAVASCRIPTCORE_DIR}/builtins/ModuleLoaderPrototype.js
514     ${JAVASCRIPTCORE_DIR}/builtins/NumberConstructor.js
515     ${JAVASCRIPTCORE_DIR}/builtins/NumberPrototype.js
516     ${JAVASCRIPTCORE_DIR}/builtins/ObjectConstructor.js
517     ${JAVASCRIPTCORE_DIR}/builtins/PromiseConstructor.js
518     ${JAVASCRIPTCORE_DIR}/builtins/PromiseOperations.js
519     ${JAVASCRIPTCORE_DIR}/builtins/PromisePrototype.js
520     ${JAVASCRIPTCORE_DIR}/builtins/ReflectObject.js
521     ${JAVASCRIPTCORE_DIR}/builtins/RegExpPrototype.js
522     ${JAVASCRIPTCORE_DIR}/builtins/SetIteratorPrototype.js
523     ${JAVASCRIPTCORE_DIR}/builtins/SetPrototype.js
524     ${JAVASCRIPTCORE_DIR}/builtins/StringConstructor.js
525     ${JAVASCRIPTCORE_DIR}/builtins/StringIteratorPrototype.js
526     ${JAVASCRIPTCORE_DIR}/builtins/StringPrototype.js
527     ${JAVASCRIPTCORE_DIR}/builtins/TypedArrayConstructor.js
528     ${JAVASCRIPTCORE_DIR}/builtins/TypedArrayPrototype.js
529 )
530
531 add_custom_command(
532     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/JSCBuiltins.cpp ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/JSCBuiltins.h
533     MAIN_DEPENDENCY ${JavaScriptCore_SCRIPTS_DIR}/generate-js-builtins.py
534     DEPENDS ${JavaScriptCore_BUILTINS_SOURCES} ${BUILTINS_GENERATOR_SCRIPTS}
535     COMMAND ${PYTHON_EXECUTABLE} ${JavaScriptCore_SCRIPTS_DIR}/generate-js-builtins.py --framework JavaScriptCore --output-directory ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR} --combined ${JavaScriptCore_BUILTINS_SOURCES}
536     VERBATIM)
537
538 list(APPEND JavaScriptCore_HEADERS
539     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorBackendDispatchers.h
540     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorFrontendDispatchers.h
541     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/inspector/InspectorProtocolObjects.h
542     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/JSCBuiltins.h
543 )
544
545 add_custom_command(
546     OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/AirOpcode.h ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/AirOpcodeGenerated.h
547     MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/b3/air/AirOpcode.opcodes
548     DEPENDS ${JAVASCRIPTCORE_DIR}/b3/air/opcode_generator.rb
549     COMMAND ${RUBY_EXECUTABLE} ${JAVASCRIPTCORE_DIR}/b3/air/opcode_generator.rb ${JAVASCRIPTCORE_DIR}/b3/air/AirOpcode.opcodes VERBATIM
550     WORKING_DIRECTORY ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}
551 )
552
553 list(APPEND JavaScriptCore_HEADERS
554     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/AirOpcode.h
555     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/AirOpcodeGenerated.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 ()