Add ENABLE_PERIODIC_MEMORY_MONITOR flag.
[WebKit-https.git] / Source / cmake / OptionsPlayStation.cmake
1 set(PORT PlayStation)
2
3 string(APPEND CMAKE_C_FLAGS_RELEASE " -g")
4 string(APPEND CMAKE_CXX_FLAGS_RELEASE " -g")
5 set(CMAKE_CONFIGURATION_TYPES "Debug" "Release")
6
7 include(Sign)
8
9 add_definitions(-DWTF_PLATFORM_PLAYSTATION=1)
10 add_definitions(-DBPLATFORM_PLAYSTATION=1)
11
12 add_definitions(-DSCE_LIBC_DISABLE_CPP14_HEADER_WARNING= -DSCE_LIBC_DISABLE_CPP17_HEADER_WARNING=)
13
14 set(ENABLE_API_TESTS ON CACHE BOOL "Build API Tests")
15 set(ENABLE_WEBCORE ON CACHE BOOL "Build WebCore")
16 set(ENABLE_WEBKIT ON CACHE BOOL "Build WebKit")
17 set(ENABLE_WEBKIT_LEGACY OFF)
18 set(ENABLE_WEBINSPECTORUI OFF)
19
20 if (NOT ENABLE_WEBCORE)
21     set(ENABLE_WEBKIT OFF)
22 endif ()
23
24 WEBKIT_OPTION_BEGIN()
25
26 # Turn off JIT
27 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_JIT PRIVATE OFF)
28 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FTL_JIT PRIVATE OFF)
29 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DFG_JIT PRIVATE OFF)
30
31 # Enabled features
32 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCESSIBILITY PRIVATE OFF)
33 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ASYNC_SCROLLING PRIVATE ON)
34 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_PERIODIC_MEMORY_MONITOR PRIVATE ON)
35 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SMOOTH_SCROLLING PRIVATE ON)
36
37 # Experimental features
38 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_APPLICATION_MANIFEST PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
39 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_PAINTING_API PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
40 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_TYPED_OM PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
41 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FILTERS_LEVEL_2 PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
42 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GPU_PROCESS PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
43 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LAYOUT_FORMATTING_CONTEXT PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
44 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REMOTE_INSPECTOR PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
45 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SERVICE_WORKER PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
46 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
47 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_CRYPTO PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
48
49 # Features to investigate
50 #
51 # Features that are temporarily turned off because an implementation is not
52 # present at this time
53 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GAMEPAD PRIVATE OFF)
54 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_AUDIO PRIVATE OFF)
55
56 # TLS debugging feature
57 WEBKIT_OPTION_DEFINE(ENABLE_TLS_DEBUG "Enable TLS key log support" PRIVATE OFF)
58
59 # Reenable after updating fontconfig
60 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VARIATION_FONTS PRIVATE OFF)
61
62 # No support planned
63 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FTPDIR PRIVATE OFF)
64 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GEOLOCATION PRIVATE OFF)
65 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MATHML PRIVATE OFF)
66 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_METER_ELEMENT PRIVATE OFF)
67 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETSCAPE_PLUGIN_API PRIVATE OFF)
68 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NOTIFICATIONS PRIVATE OFF)
69 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SVG_FONTS PRIVATE OFF)
70 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_USERSELECT_ALL PRIVATE OFF)
71 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_USER_MESSAGE_HANDLERS PRIVATE OFF)
72 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_XSLT PRIVATE OFF)
73
74 WEBKIT_OPTION_END()
75
76 if (DEFINED ENV{WEBKIT_IGNORE_PATH})
77     set(CMAKE_IGNORE_PATH $ENV{WEBKIT_IGNORE_PATH})
78 endif ()
79
80 # Do not use a separate directory based on configuration when building
81 # with the Visual Studio generator
82 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
83 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
84 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
85 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
86 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
87 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
88
89 # Default to hidden visibility
90 set(CMAKE_CXX_VISIBILITY_PRESET hidden)
91 set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
92
93 # Specify third party library directory
94 if (NOT WEBKIT_LIBRARIES_DIR)
95     if (DEFINED ENV{WEBKIT_LIBRARIES})
96         set(WEBKIT_LIBRARIES_DIR "$ENV{WEBKIT_LIBRARIES}" CACHE PATH "Path to PlayStationRequirements")
97     else ()
98         set(WEBKIT_LIBRARIES_DIR "${CMAKE_SOURCE_DIR}/WebKitLibraries/playstation" CACHE PATH "Path to PlayStationRequirements")
99     endif ()
100 endif ()
101
102 list(APPEND CMAKE_PREFIX_PATH ${WEBKIT_LIBRARIES_DIR})
103
104 find_library(C_STD_LIBRARY c)
105 find_library(KERNEL_LIBRARY kernel)
106
107 find_package(Cairo REQUIRED)
108 find_package(CURL REQUIRED)
109 find_package(EGL REQUIRED)
110 find_package(Fontconfig REQUIRED)
111 find_package(Freetype REQUIRED)
112 find_package(HarfBuzz REQUIRED COMPONENTS ICU)
113 find_package(ICU 60.2 REQUIRED COMPONENTS data i18n uc)
114 find_package(JPEG REQUIRED)
115 find_package(LibPSL REQUIRED)
116 find_package(LibXml2 REQUIRED)
117 find_package(OpenSSL REQUIRED)
118 find_package(PNG REQUIRED)
119 find_package(SQLite3 REQUIRED)
120 find_package(Threads REQUIRED)
121 find_package(WebP REQUIRED COMPONENTS demux)
122 find_package(WPE REQUIRED)
123 find_package(ZLIB REQUIRED)
124
125 # TODO: Add a check for HAVE_RSA_PSS for support of CryptoAlgorithmRSA_PSS
126 # https://bugs.webkit.org/show_bug.cgi?id=206635
127
128 SET_AND_EXPOSE_TO_BUILD(HAVE_PTHREAD_SETNAME_NP ON)
129
130 SET_AND_EXPOSE_TO_BUILD(USE_CAIRO ON)
131 SET_AND_EXPOSE_TO_BUILD(USE_CURL ON)
132 SET_AND_EXPOSE_TO_BUILD(USE_FREETYPE ON)
133 SET_AND_EXPOSE_TO_BUILD(USE_HARFBUZZ ON)
134 SET_AND_EXPOSE_TO_BUILD(USE_LIBWPE ON)
135 SET_AND_EXPOSE_TO_BUILD(USE_OPENSSL ON)
136 SET_AND_EXPOSE_TO_BUILD(USE_WPE_RENDERER ON)
137
138 SET_AND_EXPOSE_TO_BUILD(USE_INSPECTOR_SOCKET_SERVER ${ENABLE_REMOTE_INSPECTOR})
139 SET_AND_EXPOSE_TO_BUILD(USE_UNIX_DOMAIN_SOCKETS ON)
140
141 # Rendering options
142 SET_AND_EXPOSE_TO_BUILD(ENABLE_GRAPHICS_CONTEXT_GL ON)
143 SET_AND_EXPOSE_TO_BUILD(USE_COORDINATED_GRAPHICS ON)
144 SET_AND_EXPOSE_TO_BUILD(USE_EGL ON)
145 SET_AND_EXPOSE_TO_BUILD(USE_NICOSIA TRUE)
146 SET_AND_EXPOSE_TO_BUILD(USE_OPENGL_ES ON)
147 SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER ON)
148 SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER_GL ON)
149 SET_AND_EXPOSE_TO_BUILD(USE_TILED_BACKING_STORE ON)
150
151 # Override headers directories
152 set(ANGLE_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/ANGLE/Headers)
153 set(WTF_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/WTF/Headers)
154 set(JavaScriptCore_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/JavaScriptCore/Headers)
155 set(JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/JavaScriptCore/PrivateHeaders)
156 set(PAL_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/PAL/Headers)
157 set(WebCore_PRIVATE_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/WebCore/PrivateHeaders)
158 set(WebKitLegacy_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/WebKitLegacy/Headers)
159 set(WebKit_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/WebKit/Headers)
160 set(WebKit_PRIVATE_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/WebKit/PrivateHeaders)
161
162 # Override derived sources directories
163 set(WTF_DERIVED_SOURCES_DIR ${CMAKE_BINARY_DIR}/WTF/DerivedSources)
164 set(JavaScriptCore_DERIVED_SOURCES_DIR ${CMAKE_BINARY_DIR}/JavaScriptCore/DerivedSources)
165 set(WebCore_DERIVED_SOURCES_DIR ${CMAKE_BINARY_DIR}/WebCore/DerivedSources)
166 set(WebKitLegacy_DERIVED_SOURCES_DIR ${CMAKE_BINARY_DIR}/WebKitLegacy/DerivedSources)
167 set(WebKit_DERIVED_SOURCES_DIR ${CMAKE_BINARY_DIR}/WebKit/DerivedSources)
168
169 # Override scripts directories
170 set(WTF_SCRIPTS_DIR ${CMAKE_BINARY_DIR}/WTF/Scripts)
171 set(JavaScriptCore_SCRIPTS_DIR ${CMAKE_BINARY_DIR}/JavaScriptCore/Scripts)
172
173 # Create a shared JavaScriptCore with WTF and bmalloc exposed through it.
174 #
175 # Use OBJECT libraries for bmalloc and WTF. This is the modern CMake way to emulate
176 # the behavior of --whole-archive. If this is not done then all the exports will
177 # not be exposed.
178 set(bmalloc_LIBRARY_TYPE OBJECT)
179 set(WTF_LIBRARY_TYPE OBJECT)
180 set(JavaScriptCore_LIBRARY_TYPE SHARED)
181
182 # Create a shared WebKit
183 #
184 # Use OBJECT libraries for PAL and WebCore. The size of a libWebCore.a is too much
185 # for ranlib.
186 set(PAL_LIBRARY_TYPE OBJECT)
187 set(WebCore_LIBRARY_TYPE OBJECT)
188 set(WebKit_LIBRARY_TYPE SHARED)
189
190 # Enable multi process builds for Visual Studio
191 if (NOT ${CMAKE_GENERATOR} MATCHES "Ninja")
192     add_definitions(/MP)
193 endif ()
194
195 find_package(libdl)
196 if (TARGET libdl::dl)
197     add_link_options("$<$<OR:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>,$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>>:$<TARGET_PROPERTY:libdl::dl,IMPORTED_LOCATION_RELEASE>>")
198     add_link_options("$<$<OR:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>,$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>>:$<TARGET_PROPERTY:libdl::dl,INTERFACE_LINK_OPTIONS>>")
199 endif ()
200
201 function(add_library target type)
202     _add_library(${ARGV})
203     if ("${type}" STREQUAL "SHARED")
204         sign(${target})
205     endif ()
206 endfunction()
207
208 macro(WEBKIT_EXECUTABLE _target)
209     _WEBKIT_EXECUTABLE(${_target})
210     playstation_setup_libc(${_target})
211     playstation_setup_fp(${_target})
212     if (NOT ${_target} MATCHES "^LLInt")
213         sign(${_target})
214     endif ()
215     if (PLAYSTATION_${_target}_WRAP)
216         foreach (WRAP ${PLAYSTATION_${_target}_WRAP})
217             target_link_options(${_target} PRIVATE -Wl,--wrap=${WRAP})
218         endforeach ()
219     endif ()
220 endmacro()
221
222 function(PLAYSTATION_COPY_SHARED_LIBRARIES target_name)
223     set(oneValueArgs PREFIX DESTINATION)
224     set(multiValueArgs FILES)
225     cmake_parse_arguments(opt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
226     if (opt_PREFIX)
227         set(prefix ${opt_PREFIX})
228     else ()
229         set(prefix ${WEBKIT_LIBRARIES_DIR})
230     endif ()
231     if (opt_DESTINATION)
232         set(destination ${opt_DESTINATION})
233     else ()
234         set(destination ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
235     endif ()
236
237     set(stub_libs)
238     list(REMOVE_DUPLICATES opt_FILES)
239     foreach (file IN LISTS opt_FILES)
240         if (NOT ${file} MATCHES ".*_stub_weak.a")
241             continue()
242         endif ()
243         file(RELATIVE_PATH _relative ${prefix} ${file})
244         if (NOT ${_relative} MATCHES "^\.\./.*")
245             get_filename_component(lib ${file} NAME)
246             list(APPEND stub_libs ${lib})
247         endif ()
248     endforeach ()
249
250     set(dst_shared_libs)
251     foreach (lib IN LISTS stub_libs)
252         string(REPLACE "_stub_weak.a" ".sprx" shared_lib ${lib})
253         set(src_file "${prefix}/bin/${shared_lib}")
254         if (NOT EXISTS ${src_file})
255             continue()
256         endif ()
257         set(dst_file "${destination}/${shared_lib}")
258         add_custom_command(OUTPUT ${dst_file}
259             COMMAND ${CMAKE_COMMAND} -E copy ${src_file} ${dst_file}
260             MAIN_DEPENDENCY ${file}
261             VERBATIM
262         )
263         list(APPEND dst_shared_libs ${dst_file})
264     endforeach ()
265     add_custom_target(${target_name} ALL DEPENDS ${dst_shared_libs})
266 endfunction()