+if (WTF_USE_ICU_UNICODE)
+ list(APPEND JavaScriptCore_INCLUDE_DIRECTORIES
+ ${ICU_INCLUDE_DIRS}
+ )
+ list(APPEND JavaScriptCore_LIBRARIES
+ ${ICU_I18N_LIBRARIES}
+ )
+endif ()
+
+if (ENABLE_LLINT)
+ # We cannot check for RUBY_FOUND because it is set only when the full package is installed and
+ # the only thing we need is the interpreter. Unlike Python, cmake does not provide a macro
+ # for finding the only Ruby interpreter.
+ if (NOT RUBY_EXECUTABLE)
+ message(FATAL_ERROR "The Ruby interpreter is needed to generate LLInt files.")
+ endif ()
+
+ set(LLINT_ASM
+ llint/LowLevelInterpreter.asm
+ llint/LowLevelInterpreter32_64.asm
+ llint/LowLevelInterpreter64.asm
+ )
+
+ set(OFFLINE_ASM
+ offlineasm/arm.rb
+ offlineasm/ast.rb
+ offlineasm/backends.rb
+ offlineasm/cloop.rb
+ offlineasm/config.rb
+ offlineasm/instructions.rb
+ offlineasm/offsets.rb
+ offlineasm/opt.rb
+ offlineasm/parser.rb
+ offlineasm/registers.rb
+ offlineasm/risc.rb
+ offlineasm/self_hash.rb
+ offlineasm/settings.rb
+ offlineasm/transform.rb
+ offlineasm/x86.rb
+ )
+
+ add_custom_command(
+ OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntDesiredOffsets.h
+ MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/offlineasm/generate_offset_extractor.rb
+ DEPENDS ${LLINT_ASM} ${OFFLINE_ASM}
+ COMMAND ${RUBY_EXECUTABLE} ${JAVASCRIPTCORE_DIR}/offlineasm/generate_offset_extractor.rb ${JAVASCRIPTCORE_DIR}/llint/LowLevelInterpreter.asm ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntDesiredOffsets.h
+ VERBATIM)
+
+ # We add the header file directly to the ADD_EXECUTABLE call instead of setting the
+ # OBJECT_DEPENDS property in LLIntOffsetsExtractor.cpp because generate_offset_extractor.rb may
+ # not regenerate it in case the hash it calculates does not change.
+ # In this case, if some of the dependencies specified in the ADD_CUSTOM_COMMAND above have
+ # changed the command will always be called because the mtime of LLIntDesiredOffsets.h will
+ # always be older than that of its dependencies.
+ # Additionally, setting the OBJECT_DEPENDS property will make LLIntDesiredOffsets.h a Makefile
+ # dependency of both LLIntOffsetsExtractor and LLIntOffsetsExtractor.cpp, so the command will
+ # actually be run twice!
+ add_executable(LLIntOffsetsExtractor
+ ${JAVASCRIPTCORE_DIR}/llint/LLIntOffsetsExtractor.cpp
+ ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntDesiredOffsets.h
+ )
+ target_link_libraries(LLIntOffsetsExtractor WTF)
+
+ # The build system will execute asm.rb every time LLIntOffsetsExtractor's mtime is newer than
+ # LLIntAssembly.h's mtime. The problem we have here is: asm.rb has some built-in optimization
+ # that generates a checksum of the LLIntOffsetsExtractor binary, if the checksum of the new
+ # LLIntOffsetsExtractor matches, no output is generated. To make this target consistent and avoid
+ # running this command for every build, we artificially update LLIntAssembly.h's mtime (using touch)
+ # after every asm.rb run.
+ add_custom_command(
+ OUTPUT ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntAssembly.h
+ MAIN_DEPENDENCY ${JAVASCRIPTCORE_DIR}/offlineasm/asm.rb
+ DEPENDS LLIntOffsetsExtractor ${LLINT_ASM} ${OFFLINE_ASM}
+ COMMAND ${RUBY_EXECUTABLE} ${JAVASCRIPTCORE_DIR}/offlineasm/asm.rb ${JAVASCRIPTCORE_DIR}/llint/LowLevelInterpreter.asm $<TARGET_FILE:LLIntOffsetsExtractor> ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntAssembly.h
+ COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntAssembly.h
+ VERBATIM)
+
+ # The explanation for not making LLIntAssembly.h part of the OBJECT_DEPENDS property of some of
+ # the .cpp files below is similar to the one in the previous comment. However, since these .cpp
+ # files are used to build JavaScriptCore itself, we can just add LLIntAssembly.h to JSC_HEADERS
+ # since it is used in the add_library() call at the end of this file.
+ list(APPEND JavaScriptCore_HEADERS
+ ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/LLIntAssembly.h
+ )
+ list(APPEND JavaScriptCore_SOURCES
+ llint/LLIntCLoop.cpp
+ llint/LLIntData.cpp
+ llint/LLIntEntrypoints.cpp
+ llint/LLIntExceptions.cpp
+ llint/LLIntSlowPaths.cpp
+ llint/LLIntThunks.cpp
+ llint/LowLevelInterpreter.cpp
+ )
+endif ()
+
+set(HASH_LUT_GENERATOR ${CMAKE_CURRENT_SOURCE_DIR}/create_hash_table)
+macro(GENERATE_HASH_LUT _input _output)
+ add_custom_command(
+ OUTPUT ${_output}
+ DEPENDS ${HASH_LUT_GENERATOR} ${_input}
+ COMMAND ${PERL_EXECUTABLE} ${HASH_LUT_GENERATOR} ${_input} -i > ${_output}
+ VERBATIM)
+ list(APPEND JavaScriptCore_HEADERS ${_output})
+endmacro()