3861baeef40961104a91905224060864ef33c1ca
[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_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_CAIRO ON)
130 SET_AND_EXPOSE_TO_BUILD(USE_CURL ON)
131 SET_AND_EXPOSE_TO_BUILD(USE_FREETYPE ON)
132 SET_AND_EXPOSE_TO_BUILD(USE_HARFBUZZ ON)
133 SET_AND_EXPOSE_TO_BUILD(USE_LIBWPE ON)
134 SET_AND_EXPOSE_TO_BUILD(USE_OPENSSL ON)
135 SET_AND_EXPOSE_TO_BUILD(USE_WPE_RENDERER ON)
136
137 SET_AND_EXPOSE_TO_BUILD(USE_INSPECTOR_SOCKET_SERVER ${ENABLE_REMOTE_INSPECTOR})
138 SET_AND_EXPOSE_TO_BUILD(USE_UNIX_DOMAIN_SOCKETS ON)
139
140 # Rendering options
141 SET_AND_EXPOSE_TO_BUILD(ENABLE_GRAPHICS_CONTEXT_GL ON)
142 SET_AND_EXPOSE_TO_BUILD(USE_COORDINATED_GRAPHICS ON)
143 SET_AND_EXPOSE_TO_BUILD(USE_EGL ON)
144 SET_AND_EXPOSE_TO_BUILD(USE_NICOSIA TRUE)
145 SET_AND_EXPOSE_TO_BUILD(USE_OPENGL_ES ON)
146 SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER ON)
147 SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER_GL ON)
148 SET_AND_EXPOSE_TO_BUILD(USE_TILED_BACKING_STORE ON)
149
150 # Override headers directories
151 set(ANGLE_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/ANGLE/Headers)
152 set(WTF_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/WTF/Headers)
153 set(JavaScriptCore_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/JavaScriptCore/Headers)
154 set(JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/JavaScriptCore/PrivateHeaders)
155 set(PAL_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/PAL/Headers)
156 set(WebCore_PRIVATE_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/WebCore/PrivateHeaders)
157 set(WebKitLegacy_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/WebKitLegacy/Headers)
158 set(WebKit_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/WebKit/Headers)
159 set(WebKit_PRIVATE_FRAMEWORK_HEADERS_DIR ${CMAKE_BINARY_DIR}/WebKit/PrivateHeaders)
160
161 # Override derived sources directories
162 set(WTF_DERIVED_SOURCES_DIR ${CMAKE_BINARY_DIR}/WTF/DerivedSources)
163 set(JavaScriptCore_DERIVED_SOURCES_DIR ${CMAKE_BINARY_DIR}/JavaScriptCore/DerivedSources)
164 set(WebCore_DERIVED_SOURCES_DIR ${CMAKE_BINARY_DIR}/WebCore/DerivedSources)
165 set(WebKitLegacy_DERIVED_SOURCES_DIR ${CMAKE_BINARY_DIR}/WebKitLegacy/DerivedSources)
166 set(WebKit_DERIVED_SOURCES_DIR ${CMAKE_BINARY_DIR}/WebKit/DerivedSources)
167
168 # Override scripts directories
169 set(WTF_SCRIPTS_DIR ${CMAKE_BINARY_DIR}/WTF/Scripts)
170 set(JavaScriptCore_SCRIPTS_DIR ${CMAKE_BINARY_DIR}/JavaScriptCore/Scripts)
171
172 # Create a shared JavaScriptCore with WTF and bmalloc exposed through it.
173 #
174 # Use OBJECT libraries for bmalloc and WTF. This is the modern CMake way to emulate
175 # the behavior of --whole-archive. If this is not done then all the exports will
176 # not be exposed.
177 set(bmalloc_LIBRARY_TYPE OBJECT)
178 set(WTF_LIBRARY_TYPE OBJECT)
179 set(JavaScriptCore_LIBRARY_TYPE SHARED)
180
181 # Create a shared WebKit
182 #
183 # Use OBJECT libraries for PAL and WebCore. The size of a libWebCore.a is too much
184 # for ranlib.
185 set(PAL_LIBRARY_TYPE OBJECT)
186 set(WebCore_LIBRARY_TYPE OBJECT)
187 set(WebKit_LIBRARY_TYPE SHARED)
188
189 # Enable multi process builds for Visual Studio
190 if (NOT ${CMAKE_GENERATOR} MATCHES "Ninja")
191     add_definitions(/MP)
192 endif ()
193
194 find_package(libdl)
195 if (TARGET libdl::dl)
196     add_link_options("$<$<OR:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>,$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>>:$<TARGET_PROPERTY:libdl::dl,IMPORTED_LOCATION_RELEASE>>")
197     add_link_options("$<$<OR:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>,$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>>:$<TARGET_PROPERTY:libdl::dl,INTERFACE_LINK_OPTIONS>>")
198 endif ()
199
200 function(add_library target type)
201     _add_library(${ARGV})
202     if ("${type}" STREQUAL "SHARED")
203         sign(${target})
204     endif ()
205 endfunction()
206
207 macro(WEBKIT_EXECUTABLE _target)
208     _WEBKIT_EXECUTABLE(${_target})
209     playstation_setup_libc(${_target})
210     playstation_setup_fp(${_target})
211     if (NOT ${_target} MATCHES "^LLInt")
212         sign(${_target})
213     endif ()
214     if (PLAYSTATION_${_target}_WRAP)
215         foreach (WRAP ${PLAYSTATION_${_target}_WRAP})
216             target_link_options(${_target} PRIVATE -Wl,--wrap=${WRAP})
217         endforeach ()
218     endif ()
219 endmacro()
220
221 function(PLAYSTATION_COPY_SHARED_LIBRARIES target_name)
222     set(oneValueArgs PREFIX DESTINATION)
223     set(multiValueArgs FILES)
224     cmake_parse_arguments(opt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
225     if (opt_PREFIX)
226         set(prefix ${opt_PREFIX})
227     else ()
228         set(prefix ${WEBKIT_LIBRARIES_DIR})
229     endif ()
230     if (opt_DESTINATION)
231         set(destination ${opt_DESTINATION})
232     else ()
233         set(destination ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
234     endif ()
235
236     set(stub_libs)
237     list(REMOVE_DUPLICATES opt_FILES)
238     foreach (file IN LISTS opt_FILES)
239         if (NOT ${file} MATCHES ".*_stub_weak.a")
240             continue()
241         endif ()
242         file(RELATIVE_PATH _relative ${prefix} ${file})
243         if (NOT ${_relative} MATCHES "^\.\./.*")
244             get_filename_component(lib ${file} NAME)
245             list(APPEND stub_libs ${lib})
246         endif ()
247     endforeach ()
248
249     set(dst_shared_libs)
250     foreach (lib IN LISTS stub_libs)
251         string(REPLACE "_stub_weak.a" ".sprx" shared_lib ${lib})
252         set(src_file "${prefix}/bin/${shared_lib}")
253         if (NOT EXISTS ${src_file})
254             continue()
255         endif ()
256         set(dst_file "${destination}/${shared_lib}")
257         add_custom_command(OUTPUT ${dst_file}
258             COMMAND ${CMAKE_COMMAND} -E copy ${src_file} ${dst_file}
259             MAIN_DEPENDENCY ${file}
260             VERBATIM
261         )
262         list(APPEND dst_shared_libs ${dst_file})
263     endforeach ()
264     add_custom_target(${target_name} ALL DEPENDS ${dst_shared_libs})
265 endfunction()