Skip to content

Commit 6350c54

Browse files
committed
[CMake] codesign JavaScriptCore binary products
https://bugs.webkit.org/show_bug.cgi?id=316946 rdar://179410684 Reviewed by Geoffrey Garen and Yusuke Suzuki. The binaries produced by the CMake build with the Apple internal SDK are not signed and don't have any entitlements. This causes JSC to not JIT and other fun things. This causes a bunch of JSC tests to fail. I added a WEBKIT_PROCESS_ENTITLEMENTS function so we can add codesigning for subsequent build products in the future from the same shared function. Canonical link: https://commits.webkit.org/315113@main
1 parent 346f097 commit 6350c54

5 files changed

Lines changed: 46 additions & 7 deletions

File tree

‎Source/JavaScriptCore/shell/PlatformCocoa.cmake‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,13 @@ set_source_files_properties(${testapi_OBJC_SOURCES} PROPERTIES
1212
COMPILE_FLAGS -fobjc-arc
1313
SKIP_PRECOMPILE_HEADERS ON
1414
)
15+
16+
WEBKIT_PROCESS_ENTITLEMENTS(jsc PROJECT JavaScriptCore)
17+
if (DEVELOPER_MODE)
18+
WEBKIT_PROCESS_ENTITLEMENTS(testapi PROJECT JavaScriptCore)
19+
WEBKIT_PROCESS_ENTITLEMENTS(testRegExp PROJECT JavaScriptCore)
20+
WEBKIT_PROCESS_ENTITLEMENTS(testmasm PROJECT JavaScriptCore)
21+
WEBKIT_PROCESS_ENTITLEMENTS(testb3 PROJECT JavaScriptCore)
22+
WEBKIT_PROCESS_ENTITLEMENTS(testair PROJECT JavaScriptCore)
23+
WEBKIT_PROCESS_ENTITLEMENTS(testdfg PROJECT JavaScriptCore)
24+
endif ()

‎Source/cmake/OptionsCocoa.cmake‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ find_package(Threads REQUIRED)
6060

6161
string(REGEX MATCH "^[0-9]+" _sdk_major "${_sdk_version}")
6262
set(_additions_candidates
63-
"${CMAKE_SOURCE_DIR}/WebKitLibraries/SDKs/${_sdk_prefix}${_sdk_major}.0-additions.sdk/usr/local/include"
64-
"${CMAKE_SOURCE_DIR}/WebKitLibraries/SDKs/${_sdk_prefix}${_sdk_major_minor}-additions.sdk/usr/local/include"
63+
"${CMAKE_SOURCE_DIR}/WebKitLibraries/SDKs/${WEBKIT_SDK_NAME}${_sdk_major}.0-additions.sdk/usr/local/include"
64+
"${CMAKE_SOURCE_DIR}/WebKitLibraries/SDKs/${WEBKIT_SDK_NAME}${_sdk_major_minor}-additions.sdk/usr/local/include"
6565
)
6666
set(_additions_found FALSE)
6767
foreach (_additions IN LISTS _additions_candidates)
@@ -73,7 +73,7 @@ foreach (_additions IN LISTS _additions_candidates)
7373
endif ()
7474
endforeach ()
7575
if (NOT _additions_found)
76-
file(GLOB _all_additions "${CMAKE_SOURCE_DIR}/WebKitLibraries/SDKs/${_sdk_prefix}*-additions.sdk")
76+
file(GLOB _all_additions "${CMAKE_SOURCE_DIR}/WebKitLibraries/SDKs/${WEBKIT_SDK_NAME}*-additions.sdk")
7777
list(SORT _all_additions)
7878
list(REVERSE _all_additions)
7979
foreach (_additions_sdk IN LISTS _all_additions)
@@ -94,7 +94,6 @@ endif ()
9494
unset(_sdk_version)
9595
unset(_sdk_major)
9696
unset(_sdk_major_minor)
97-
unset(_sdk_prefix)
9897
unset(_additions_candidates)
9998
unset(_additions)
10099
unset(_additions_found)

‎Source/cmake/OptionsIOS.cmake‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ WEBKIT_OPTION_END()
106106

107107
if (CMAKE_IOS_SIMULATOR OR CMAKE_OSX_SYSROOT MATCHES "[Ss]imulator")
108108
set(WEBKIT_PLATFORM_NAME "iPhoneSimulator")
109-
set(_sdk_prefix "iphonesimulator")
109+
set(WEBKIT_SDK_NAME "iphonesimulator")
110110
else ()
111111
set(WEBKIT_PLATFORM_NAME "iPhoneOS")
112-
set(_sdk_prefix "iphoneos")
112+
set(WEBKIT_SDK_NAME "iphoneos")
113113
endif ()
114114
string(REGEX MATCH "^[0-9]+\\.[0-9]+" _sdk_major_minor "${_sdk_version}")
115115
if (_sdk_major_minor AND (NOT CMAKE_OSX_DEPLOYMENT_TARGET OR CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS _sdk_major_minor))

‎Source/cmake/OptionsMac.cmake‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
156156
unset(_host_os_major_minor)
157157
endif ()
158158

159-
set(_sdk_prefix "macosx")
159+
set(WEBKIT_SDK_NAME "macosx")
160160
set(WEBKIT_PLATFORM_NAME "MacOSX")
161161

162162
include(OptionsCocoa)

‎Source/cmake/WebKitXcodeSDK.cmake‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,36 @@ function(WEBKIT_RESOLVE_TOOL OUTPUT_VAR _tool)
5656
endif ()
5757
endfunction()
5858

59+
# Run Source/${PROJECT}/Scripts/process-entitlements.sh against an executable
60+
# target and ad-hoc codesign it with the resulting entitlements. Mirrors the
61+
# Xcode build's "Process Entitlements" build phase plus the signing step.
62+
#
63+
# Usage:
64+
# WEBKIT_PROCESS_ENTITLEMENTS(target PROJECT name [PRODUCT_NAME name])
65+
#
66+
# PROJECT names the directory under Source/ containing Scripts/process-entitlements.sh
67+
# (e.g. JavaScriptCore, WebKit). PRODUCT_NAME defaults to the CMake target name;
68+
# set it explicitly when the script's dispatcher keys off a different name.
69+
function(WEBKIT_PROCESS_ENTITLEMENTS _target)
70+
cmake_parse_arguments(_arg "" "PROJECT;PRODUCT_NAME" "" ${ARGN})
71+
if (NOT _arg_PROJECT)
72+
message(FATAL_ERROR "WEBKIT_PROCESS_ENTITLEMENTS(${_target}): PROJECT is required")
73+
endif ()
74+
if (NOT _arg_PRODUCT_NAME)
75+
set(_arg_PRODUCT_NAME ${_target})
76+
endif ()
77+
set(_xcent ${CMAKE_CURRENT_BINARY_DIR}/${_target}.xcent)
78+
add_custom_command(TARGET ${_target} POST_BUILD
79+
COMMAND ${CMAKE_COMMAND} -E env
80+
WK_PROCESSED_XCENT_FILE=${_xcent}
81+
WK_PLATFORM_NAME=${WEBKIT_SDK_NAME}
82+
PRODUCT_NAME=${_arg_PRODUCT_NAME}
83+
${CMAKE_SOURCE_DIR}/Source/${_arg_PROJECT}/Scripts/process-entitlements.sh
84+
COMMAND codesign --force --sign - --entitlements ${_xcent} $<TARGET_FILE:${_target}>
85+
VERBATIM
86+
)
87+
endfunction()
88+
5989

6090
# ----------------------------------------------------------------------------
6191
# Initialization logic. Sets CMAKE_OSX_SYSROOT if needed, and pins compiler

0 commit comments

Comments
 (0)