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