Changeset 240510 in webkit
- Timestamp:
- Jan 25, 2019 2:23:54 PM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r240509 r240510 1 2019-01-25 Keith Rollin <krollin@apple.com> 2 3 Complete the implementation of generate-xcfilelists 4 https://bugs.webkit.org/show_bug.cgi?id=193782 5 6 Reviewed by Alex Christensen. 7 8 A preliminary version of generate-xcfilelists was added in r238008. 9 This patch updates that script in order to: 10 11 - Support checking of .xcfilelists 12 - Perform better execution of `make DerivedSources.make` by 13 relaunching generate-xcfilelists under xcodebuild 14 - Support incremental generation and checking of .xcfilelists 15 - Support supplementary .xcfilelists files from WebKitAdditions 16 - Support being wrapped by parallel version of generate-xcfilelists in 17 Internal that adds support for (re)generating WebKit projects in 18 that repo. 19 - Support builds that have been performed in WebKitBuild as well as 20 ~/Library/Developer/code/DerivedData 21 - Increase robustness and debugging facilities. 22 23 * Scripts/generate-xcfilelists: 24 1 25 2019-01-25 Brent Fulgham <bfulgham@apple.com> 2 26 -
trunk/Tools/Scripts/generate-xcfilelists
r238854 r240510 1 #!/bin/ sh1 #!/bin/bash 2 2 # 3 # Copyright (C) 2018 Apple Inc. All rights reserved.3 # Copyright (C) 2018-2019 Apple Inc. All rights reserved. 4 4 # 5 5 # Redistribution and use in source and binary forms, with or without … … 38 38 # files instead. 39 39 # 40 # The generated DerivedSources.make .xcfilelist files are created in in the 41 # same directory as the DerivedSources.make file. The generated UnifiedSources 42 # .xcfilelist files are created in ${PROJECT_DIR}. 40 # This script not only generates .xcfilelists, but -- when given a "check" 41 # command -- it also checks that they are up-to-date. In this mode, the 42 # .xcfilelist files are created in a temporary location and are then compared 43 # to the versions checked into the repository. If there are differences, the 44 # user is notified so that they know that the .xcfilelist files need to be 45 # regenerated. This facility can be incorporated into a build phase, a check-in 46 # hook, or into the EWS (perhaps as part of check-webkit-style). 43 47 # 44 # This script assumes that the generated/derived sources are created in the 45 # following location, and incorporates that path into the paths it stores in 46 # the .xcfilelists: 47 # 48 # $(BUILT_PRODUCTS_DIR)/DerivedSources/${PROJECT_NAME}/ 49 # 50 # Sometimes the generated files are stored in sub-directories, as with 51 # unified-sources. In other cases, we need to take into account the fact that 52 # generated/derived files are stored in a directory with a legacy name. For 53 # instance, WebKit files are stored in a WebKit2 directory, and WebKitLegacy 54 # files are stored in a WebKit directory. This discrepancy should probably be 55 # cleaned up some day. 56 # 57 # This script not only generates .xcfilelists, but -- when given a --check 58 # command line parameters -- it also checks that they are up-to-date. In this 59 # mode, the .xcfilelist files are created in a temporary location and are then 60 # compared to the versions checked into the repository. If there are 61 # differences, the user is notified so that they know that the .xcfilelist 62 # files need to be regenerated. This facility can be incorporated into a 63 # build phase, a check-in hook, or into the EWS (perhaps as part of 64 # check-webkit-style). 65 66 67 HERE="$(cd "$(dirname "$0")" && pwd -P)" 68 69 70 # Print an error message and exit. 48 # As part of its operation, this script can sub-launch itself under Xcode. It 49 # does this in order to establish the context in which builds occur. In 50 # particular, it does this in order to set needed environment variables. In 51 # order to protect against environment variable name collision, all variable 52 # names in this script start with "GX_". 53 54 55 function stdout() 56 { 57 (( ${GX_QUIET} )) || echo "$@" >&1 58 } 59 60 61 function stderr() 62 { 63 echo "$@" >&2 64 } 65 66 67 function remove_extra_spaces() 68 { 69 echo $1 70 } 71 72 function print_option() 73 { 74 local GX_OPTION="$1" 75 local GX_MESSAGE="$(remove_extra_spaces "$2")" 76 77 local GX_LINE 78 local GX_LINE_WIDTH=90 79 local GX_OPTION_WIDTH=17 80 81 if (( ${#GX_OPTION} <= GX_OPTION_WIDTH )) 82 then 83 local GX_MESSAGE_CATENATED=$(printf " %-${GX_OPTION_WIDTH}s %s" "$GX_OPTION" "$GX_MESSAGE") 84 if (( ${#GX_MESSAGE_CATENATED} <= GX_LINE_WIDTH )) 85 then 86 stderr "${GX_MESSAGE_CATENATED}" 87 return 88 fi 89 90 local GX_MESSAGE_FIRST_LINE="${GX_MESSAGE_CATENATED:0:${GX_LINE_WIDTH}}" # Get the first 80 characters 91 GX_MESSAGE_FIRST_LINE="${GX_MESSAGE_FIRST_LINE% *}" # Trim back to the last space 92 GX_MESSAGE="${GX_MESSAGE_CATENATED:${#GX_MESSAGE_FIRST_LINE}+1}" # Get the rest after that space 93 94 stderr "${GX_MESSAGE_FIRST_LINE}" 95 else 96 stderr " ${GX_OPTION}" 97 fi 98 99 while IFS='' read -r GX_LINE 100 do 101 GX_LINE=$(printf " %${GX_OPTION_WIDTH}s %s" "" "$GX_LINE") 102 stderr "${GX_LINE}" 103 done < <(echo "${GX_MESSAGE}" | fold -w $(( GX_LINE_WIDTH - GX_OPTION_WIDTH - 3)) -s) 104 } 105 106 107 function join_by() 108 { 109 local GX_DELIM=$1 110 shift 111 112 echo -n "$1" 113 shift 114 115 printf "%s" "${@/#/${GX_DELIM}}" 116 } 117 118 119 function usage() 120 { 121 local GX_JOINED_PROJECT_TAGS=$(join_by ", " "${GX_PROJECT_TAGS[@]}") 122 123 stderr "Usage: $(basename "${GX_ME}") [OPTION...] COMMAND [PARAMETER...]" 124 stderr "" 125 stderr "Generate or check .xcfilelist files" 126 stderr "" 127 stderr "Commands:" 128 stderr "" 129 print_option "generate" "Generate a complete and up-to-date set of 130 .xcfilelist files and copy them to their appropriate places in the 131 project directories." 132 print_option "generate-xcode" "Generate .xcfilelist files for the current 133 target configuration an copy them to their appropriate places in the 134 project directories. Invoked from withing Xcode to update the current 135 build if needed." 136 print_option "check" "Generate a complete and up-to-date set of .xcfilelist 137 files and compare them to their counterparts in the project 138 directories." 139 print_option "check-xcode" "Generate .xcfilelist files for the current 140 target configuration and see if any files appear that aren't in the 141 checked-in .xcfilelist files. Invoked from within Xcode to validate the 142 current build." 143 print_option "subgenerate" "Generate an .xcfilelist file for a particular 144 combination of project, platform, and configuration. This operation is 145 performed in the context of an Xcode build in order to inherit the same 146 environment as that build." 147 print_option "help" "Print this text and exit." 148 stderr "" 149 stderr "Options:" 150 stderr "" 151 print_option "--project <project>" "Specify which project for which to 152 generate .xcfilelist files or to check. Possible values are 153 (${GX_JOINED_PROJECT_TAGS}). Default is to iterate over all projects." 154 print_option "--platform <platform>" "Specify which platform for which to 155 generate .xcfilelist files or to check. Possible values are (macosx, 156 iphoneos). Default is to iterate over all platforms, filtered to those 157 platforms that a particular project supports (e.g., you can't specify 158 'iphoneos' for WebKitTestRunner)." 159 print_option "--configuration <configuration>" "Specify which configuration 160 for which to generate .xcfilelist files or to check, Possible values 161 are (release, debug). Default is to iterate over all configurations." 162 print_option "--xcode" "Specify that existing build output can be found in 163 the directory created by the Xcode IDE (in ~/Library/Developer/Xcode)." 164 print_option "--webkitbuild" "Specify that existing build output can be 165 found in the directory used by the WebKit make files or the 166 build-webkit script (that is, in WebKitBuild or in the directory 167 identified by WEBKIT_OUTPUTDIR). This option is the default, so it 168 doesn't really get you anything by specifying this option (or by my 169 implementing it)." 170 print_option "--nocleanup" "Disable cleaning up temporary files after a 171 subgenerate operation. Normally these are cleaned up, but if 172 'subgenerate' is part of an overall 'generate' operation, then the 173 'generate' operation needs to keep around the temporary files until it 174 can complete aggregating them." 175 stderr "" 176 print_option "--dry-run" "When running through the requested process, don't 177 make any material changes. For example, for 'generate', create the new 178 .xcfilelist files, but don't copy them into their final locations" 179 print_option "--debug" "Provide verbose output." 180 print_option "--quiet" "Don't print any std output." 181 print_option "--help" "Print this text and exit." 182 stderr "" 183 } 184 185 186 function cleanup() 187 { 188 if (( ${GX_DO_CLEANUP} )) && (( ${GX_DEFERRED_EXIT_CODE} == 0 )) 189 then 190 rm -rf "${GX_TEMP}" &> /dev/null 191 fi 192 } 193 194 195 function my_exit() 196 { 197 local GX_ERR=$1 198 exit $GX_ERR 199 } 200 71 201 72 202 function die() 73 203 { 74 echo "### $@" 1>&2 75 exit 1 76 } 77 78 79 # Utility: replace one string with another in a file. 204 local GX_ERR=$2 205 [[ "$GX_ERR" == "" ]] && GX_ERR=1 206 stderr "### (${FUNCNAME[@]}) $1" 207 my_exit $GX_ERR 208 } 209 210 211 function log_debug() 212 { 213 (( "${GX_DEBUG}" > 0 )) && stderr "... $@" 214 } 215 216 217 function log_debug_var() 218 { 219 local GX_VAR_NAME=$1 220 local GX_IS_ARRAY=$(declare -p ${GX_VAR_NAME} 2> /dev/null | grep -q '^declare -a' && echo 1 || echo 0) 221 222 if (( $GX_IS_ARRAY )) 223 then 224 log_debug $(printf "%-47s = (%s)" $GX_VAR_NAME "$(eval echo \$\{${GX_VAR_NAME}\[\@\]\})") 225 else 226 log_debug $(printf "%-47s = %s" $GX_VAR_NAME "$(eval echo \$\{${GX_VAR_NAME}\})") 227 fi 228 } 229 230 231 function log_callstack_and_parameters() 232 { 233 if (( "${GX_DEBUG}" > "1" )) 234 then 235 local GX_ARGS=("$@") 236 local GX_CALLSTACK=("${FUNCNAME[@]}") 237 unset GX_CALLSTACK[0] 238 stderr "... (${GX_CALLSTACK[@]}): ${GX_ARGS[@]}" 239 fi 240 } 241 242 243 function log_progress() 244 { 245 stdout "... $@" 246 } 247 248 249 function log_progress_long() 250 { 251 local GX_MESSAGE="$(remove_extra_spaces "$1")" 252 local GX_LINE 253 while IFS='' read -r GX_LINE 254 do 255 log_progress $GX_LINE 256 done < <(echo "${GX_MESSAGE}" | fold -w 86 -s) 257 } 258 259 260 function normalize_directory_path() 261 { 262 log_callstack_and_parameters "$@" 263 264 [[ -z "$1" ]] && { echo "$1"; return; } 265 cd "$1" 2> /dev/null || { echo "$1"; return; } 266 pwd -P 267 } 268 269 270 function normalize_file_path() 271 { 272 log_callstack_and_parameters "$@" 273 274 [[ -z "$1" ]] && { echo "$1"; return; } 275 echo $(normalize_directory_path "$(dirname "$1")")/$(basename "$1") 276 } 277 278 279 function call() 280 { 281 log_callstack_and_parameters "$@" 282 283 local GX_FN="$1" 284 [[ "$(type -t ${GX_FN})" == "function" ]] || return $? 285 eval "${GX_FN}" 286 } 287 288 289 function set_project_specific_settings_for_JavaScriptCore() 290 { 291 log_callstack_and_parameters "$@" 292 293 GX_PS_PROJECT_FILE_PATH="${GX_OPENSOURCE_DIR}/Source/JavaScriptCore/JavaScriptCore.xcodeproj" # Can't use PROJECT_FILE_PATH because this is used pre-Xcode. 294 GX_PS_DERIVEDSOURCES_GENERATOR_RELATIVE_PATH="Scripts/generate-derived-sources.sh" 295 GX_PS_UNIFIEDSOURCES_GENERATOR_RELATIVE_PATH="Scripts/generate-unified-sources.sh" 296 GX_PS_PLATFORM_NAMES=(macosx iphoneos) 297 } 298 299 300 function set_project_specific_settings_for_WebCore() 301 { 302 log_callstack_and_parameters "$@" 303 304 GX_PS_PROJECT_FILE_PATH="${GX_OPENSOURCE_DIR}/Source/WebCore/WebCore.xcodeproj" # Can't use PROJECT_FILE_PATH because this is used pre-Xcode. 305 GX_PS_DERIVEDSOURCES_GENERATOR_RELATIVE_PATH="Scripts/generate-derived-sources.sh" 306 GX_PS_UNIFIEDSOURCES_GENERATOR_RELATIVE_PATH="Scripts/generate-unified-sources.sh" 307 GX_PS_PLATFORM_NAMES=(macosx iphoneos) 308 } 309 310 311 function set_project_specific_settings_for_WebKit() 312 { 313 log_callstack_and_parameters "$@" 314 315 GX_PS_PROJECT_FILE_PATH="${GX_OPENSOURCE_DIR}/Source/WebKit/WebKit.xcodeproj" # Can't use PROJECT_FILE_PATH because this is used pre-Xcode. 316 GX_PS_DERIVED_SOURCES_DIR="${BUILT_PRODUCTS_DIR}/DerivedSources/WebKit2" 317 GX_PS_DERIVEDSOURCES_GENERATOR_RELATIVE_PATH="Scripts/generate-derived-sources.sh" 318 GX_PS_UNIFIEDSOURCES_GENERATOR_RELATIVE_PATH="Scripts/generate-unified-sources.sh" 319 GX_PS_PLATFORM_NAMES=(macosx iphoneos) 320 } 321 322 323 function set_project_specific_settings_for_DumpRenderTree() 324 { 325 log_callstack_and_parameters "$@" 326 327 GX_PS_PROJECT_FILE_PATH="${GX_OPENSOURCE_DIR}/Tools/DumpRenderTree/DumpRenderTree.xcodeproj" # Can't use PROJECT_FILE_PATH because this is used pre-Xcode. 328 GX_PS_DERIVEDSOURCES_GENERATOR_RELATIVE_PATH="Scripts/generate-derived-sources.sh" 329 GX_PS_PLATFORM_NAMES=(macosx) 330 } 331 332 333 function set_project_specific_settings_for_WebKitTestRunner() 334 { 335 log_callstack_and_parameters "$@" 336 337 GX_PS_PROJECT_FILE_PATH="${GX_OPENSOURCE_DIR}/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj" # Can't use PROJECT_FILE_PATH because this is used pre-Xcode. 338 GX_PS_DERIVEDSOURCES_GENERATOR_RELATIVE_PATH="Scripts/generate-derived-sources.sh" 339 GX_PS_PLATFORM_NAMES=(macosx) 340 } 341 342 343 function set_project_specific_settings() 344 { 345 log_callstack_and_parameters "$@" 346 347 # Unset the variables that the set_project_specific_settings_for_FOO 348 # functions set. We need to do this in case the function for project BAR 349 # doesn't define one or more of them, causing it to inherit the settings 350 # for a previous project FOO. 351 # 352 # To achieve this unsetting, we prefix all the variables we want to unset 353 # with "GX_PS_" ("PS for "project specific"). We can then gather all 354 # variables that start with this prefix and unset them. 355 356 unset ${!GX_PS_*} 357 358 [[ -n "${GX_PROJECT_TAG}" ]] || die "GX_PROJECT_TAG is not defined." 359 360 call set_project_specific_settings_for_${GX_PROJECT_TAG} || die "Could not set build variables for ${GX_PROJECT_TAG}." 361 } 362 363 364 function set_common_project_settings() 365 { 366 log_callstack_and_parameters "$@" 367 368 local GX_EFFECTIVE_PROJECT_FILE_PATH="${GX_PS_PROJECT_FILE_PATH}" 369 local GX_EFFECTIVE_PROJECT_DIR=$(dirname "${GX_EFFECTIVE_PROJECT_FILE_PATH}") 370 371 [[ -n "${GX_EFFECTIVE_PROJECT_FILE_PATH}" ]] || die "GX_EFFECTIVE_PROJECT_FILE_PATH is not defined." 372 [[ -d "${GX_EFFECTIVE_PROJECT_FILE_PATH}" ]] || die "${GX_EFFECTIVE_PROJECT_FILE_PATH} is not a directory." 373 [[ -n "${GX_EFFECTIVE_PROJECT_DIR}" ]] || die "GX_EFFECTIVE_PROJECT_DIR is not defined." 374 [[ -d "${GX_EFFECTIVE_PROJECT_DIR}" ]] || die "${GX_EFFECTIVE_PROJECT_DIR} is not a directory." 375 376 # Get the paths to the scripts that drive the generation of the 377 # .xcfilelists or the data going into the .xcfilelists. 378 379 GX_DERIVEDSOURCES_GENERATOR="${GX_PS_DERIVEDSOURCES_GENERATOR_RELATIVE_PATH:+${GX_EFFECTIVE_PROJECT_DIR}/${GX_PS_DERIVEDSOURCES_GENERATOR_RELATIVE_PATH}}" 380 GX_UNIFIEDSOURCES_GENERATOR="${GX_PS_UNIFIEDSOURCES_GENERATOR_RELATIVE_PATH:+${GX_EFFECTIVE_PROJECT_DIR}/${GX_PS_UNIFIEDSOURCES_GENERATOR_RELATIVE_PATH}}" 381 382 [[ -n "${GX_DERIVEDSOURCES_GENERATOR}" ]] && { [[ -f "${GX_DERIVEDSOURCES_GENERATOR}" ]] || die "${GX_DERIVEDSOURCES_GENERATOR} does not exist."; } 383 [[ -n "${GX_UNIFIEDSOURCES_GENERATOR}" ]] && { [[ -f "${GX_UNIFIEDSOURCES_GENERATOR}" ]] || die "${GX_UNIFIEDSOURCES_GENERATOR} does not exist."; } 384 385 # Get the paths to the locations of the final .xcfilelist files. 386 387 local GX_BASE_PATH="${GX_EFFECTIVE_PROJECT_DIR}/${GX_PS_XCFILELIST_RELATIVE_PATH}" 388 GX_INPUT_DERIVED_XCFILELIST_PROJECT_PATH="${GX_BASE_PATH}/DerivedSources-input.xcfilelist" 389 GX_OUTPUT_DERIVED_XCFILELIST_PROJECT_PATH="${GX_BASE_PATH}/DerivedSources-output.xcfilelist" 390 GX_INPUT_UNIFIED_XCFILELIST_PROJECT_PATH="${GX_BASE_PATH}/UnifiedSources-input.xcfilelist" 391 GX_OUTPUT_UNIFIED_XCFILELIST_PROJECT_PATH="${GX_BASE_PATH}/UnifiedSources-output.xcfilelist" 392 393 # Get the paths to the locations of the temporary .xcfilelist files (the 394 # ones being built up before being moved to their final locations). 395 396 GX_INPUT_DERIVED_XCFILELIST_PROJECT_TEMP_PATH="${GX_TEMP}/${GX_INPUT_DERIVED_XCFILELIST_PROJECT_PATH}" 397 GX_OUTPUT_DERIVED_XCFILELIST_PROJECT_TEMP_PATH="${GX_TEMP}/${GX_OUTPUT_DERIVED_XCFILELIST_PROJECT_PATH}" 398 GX_INPUT_UNIFIED_XCFILELIST_PROJECT_TEMP_PATH="${GX_TEMP}/${GX_INPUT_UNIFIED_XCFILELIST_PROJECT_PATH}" 399 GX_OUTPUT_UNIFIED_XCFILELIST_PROJECT_TEMP_PATH="${GX_TEMP}/${GX_OUTPUT_UNIFIED_XCFILELIST_PROJECT_PATH}" 400 401 # Collect the default per-project commands to execute during the generate, 402 # merge, and compare stages. 403 404 GX_SUBGENERATE_ACTIONS=() 405 GX_MERGE_ACTIONS=() 406 GX_CHECK_ACTIONS=() 407 408 if [[ -n "${GX_DERIVEDSOURCES_GENERATOR}" ]] 409 then 410 GX_SUBGENERATE_ACTIONS+=(generate_derivedsources_xcfilelists) 411 GX_MERGE_ACTIONS+=(merge_derivedsources_xcfilelists) 412 GX_CHECK_ACTIONS+=(check_derivedsources_xcfilelists) 413 fi 414 415 if [[ -n "${GX_UNIFIEDSOURCES_GENERATOR}" ]] 416 then 417 GX_SUBGENERATE_ACTIONS+=(generate_unifiedsources_xcfilelists) 418 GX_MERGE_ACTIONS+=(merge_unifiedsources_xcfilelists) 419 GX_CHECK_ACTIONS+=(check_unifiedsources_xcfilelists) 420 fi 421 422 [[ -z "${GX_PS_DERIVED_SOURCES_DIR}" ]] && GX_PS_DERIVED_SOURCES_DIR="${BUILT_PRODUCTS_DIR}/DerivedSources/${PROJECT_NAME}" 423 424 GX_TEMP_INPUT_XCFILELIST="${GX_TEMP}/input.xcfilelist" 425 GX_TEMP_OUTPUT_XCFILELIST="${GX_TEMP}/output.xcfilelist" 426 } 427 428 429 function dump_project_settings() 430 { 431 log_callstack_and_parameters "$@" 432 433 log_debug_var BUILD_SCRIPTS_DIR 434 log_debug_var BUILT_PRODUCTS_DIR 435 log_debug_var CONFIGURATION 436 log_debug_var DERIVED_SOURCES_DIR 437 log_debug_var JAVASCRIPTCORE_PRIVATE_HEADERS_DIR 438 log_debug_var PROJECT_DIR 439 log_debug_var PROJECT_FILE_PATH 440 log_debug_var PROJECT_NAME 441 log_debug_var WEBCORE_PRIVATE_HEADERS_DIR 442 log_debug_var WEBKIT2_PRIVATE_HEADERS_DIR 443 log_debug 444 log_debug_var GX_PS_PROJECT_FILE_PATH 445 log_debug_var GX_PS_DERIVEDSOURCES_GENERATOR_RELATIVE_PATH 446 log_debug_var GX_PS_UNIFIEDSOURCES_GENERATOR_RELATIVE_PATH 447 log_debug_var GX_PS_XCFILELIST_RELATIVE_PATH 448 log_debug_var GX_PS_PLATFORM_NAMES 449 log_debug 450 log_debug_var GX_PROJECT_TAG 451 log_debug_var GX_PLATFORM_NAME 452 log_debug_var GX_CONFIGURATION 453 log_debug 454 log_debug_var GX_EFFECTIVE_PROJECT_FILE_PATH 455 log_debug_var GX_EFFECTIVE_PROJECT_DIR 456 log_debug 457 log_debug_var GX_DERIVEDSOURCES_GENERATOR 458 log_debug_var GX_UNIFIEDSOURCES_GENERATOR 459 log_debug 460 log_debug_var GX_INPUT_DERIVED_XCFILELIST_PROJECT_TEMP_PATH 461 log_debug_var GX_OUTPUT_DERIVED_XCFILELIST_PROJECT_TEMP_PATH 462 log_debug_var GX_INPUT_UNIFIED_XCFILELIST_PROJECT_TEMP_PATH 463 log_debug_var GX_OUTPUT_UNIFIED_XCFILELIST_PROJECT_TEMP_PATH 464 log_debug 465 log_debug_var GX_INPUT_DERIVED_XCFILELIST_PROJECT_PATH 466 log_debug_var GX_OUTPUT_DERIVED_XCFILELIST_PROJECT_PATH 467 log_debug_var GX_INPUT_UNIFIED_XCFILELIST_PROJECT_PATH 468 log_debug_var GX_OUTPUT_UNIFIED_XCFILELIST_PROJECT_PATH 469 log_debug 470 log_debug_var GX_PS_DERIVED_SOURCES_DIR 471 log_debug 472 log_debug_var GX_SUBGENERATE_ACTIONS 473 log_debug_var GX_MERGE_ACTIONS 474 log_debug_var GX_CHECK_ACTIONS 475 } 476 477 478 function set_project_settings() 479 { 480 log_callstack_and_parameters "$@" 481 482 [[ -z "${GX_PROJECT_TAG}" ]] && return 483 484 set_project_specific_settings 485 set_common_project_settings 486 dump_project_settings 487 } 488 489 490 function ensure_directories_exist() 491 { 492 log_callstack_and_parameters "$@" 493 494 local GX_DIR 495 for GX_DIR in "$@" 496 do 497 log_debug "Creating ${GX_DIR}" 498 mkdir -p "${GX_DIR}" &> /dev/null || die "Unable to create "${GX_DIR}"." 499 done 500 } 501 502 503 function create_empty_files() 504 { 505 log_callstack_and_parameters "$@" 506 507 local GX_FILE 508 for GX_FILE in "$@" 509 do 510 ensure_directories_exist "$(dirname "${GX_FILE}")" 511 512 log_debug "Creating ${GX_FILE}" 513 echo -n '' > "${GX_FILE}" 514 done 515 } 516 517 518 function append_xcfilelist_header() 519 { 520 log_callstack_and_parameters "$@" 521 522 local GX_FILE 523 for GX_FILE in "$@" 524 do 525 echo '# This file is generated by the generate-xcfilelists script.' >> "${GX_FILE}" 526 done 527 } 528 529 530 function sort_and_unique_in_place() 531 { 532 sort -u "$1" -o "$1" 533 } 534 80 535 81 536 function replace() 82 537 { 83 FILE="$1" 84 PATTERN="$2" 85 REPLACEMENT="$3" 86 87 sed -E -e "s|^${PATTERN}/|${REPLACEMENT}/|" -i '' "${FILE}" 88 } 89 90 # Given an .xcfilelist list file containing partial paths to the generated 91 # files, modify each path to also include the actual location of generated 92 # files for the given project. For instance, modify "UnifiedSources1.cpp" to 93 # "$(BUILT_PRODUCTS_DIR)/DerivedSources/MyProject/UnifiedSources1.cpp". 94 95 function prepend_prefix_to_all_paths() 96 { 97 FILE="$1" 98 sed -E -e "s|^|${DERIVED_SOURCES_DIR}/|" -i '' "${FILE}" 99 } 100 101 102 # Utility: given a list of directories, return the first one that actually 103 # exists. 104 105 function find_first_existing() 106 { 107 ITEMS=("$@") 108 for ITEM in "${ITEMS[@]}" 538 log_callstack_and_parameters "$@" 539 540 local GX_FILE="$1" 541 local GX_PATTERN="$2" 542 local GX_REPLACEMENT="$3" 543 544 [[ -n "${GX_FILE}" ]] || die "GX_FILE is not defined." 545 [[ -f "${GX_FILE}" ]] || die "${GX_FILE} does not exist." 546 547 sed -E -e "s|${GX_PATTERN}|${GX_REPLACEMENT}|" -i '' "${GX_FILE}" 548 } 549 550 551 function unexpand() 552 { 553 log_callstack_and_parameters "$@" 554 555 local GX_FILE="$1" 556 local GX_VAR="$2" 557 local GX_VALUE=$(eval echo \$${GX_VAR}) 558 559 [[ -n "${GX_VALUE}" ]] && replace "${GX_FILE}" "^${GX_VALUE}/" "\$\($GX_VAR\)/" 560 } 561 562 563 function find_additions() 564 { 565 # Find additions and removals so that we can report them. 566 # 567 # UPDATE: We can't really report removals. It's possible -- even 568 # overwhelmingly likely -- that we are generating .xcfilelist information 569 # for only a subset of the possible configurations for which we build. For 570 # example, a developer may be building for macOS and iOS, but not watchOS. 571 # In situations like this, we'll be generating the .xcfilelist for those 572 # two platforms, but any files specific to watchOS will not be discovered 573 # and won't be included in the .xcfilelists. If we were to report those 574 # watchOS files as files that should be removed from the .xcfilelists, then 575 # the watchOS build may fail. So, for now, let any obsolete files 576 # accumulate in the .xcfilelist files; they're mostly harmless. 577 578 local GX_NEW="$1" 579 local GX_ORIG="$2" 580 local GX_ADDITIONS="$3" 581 582 [[ -f "${GX_NEW}" ]] || die "${GX_NEW} does not exist." 583 [[ -f "${GX_ORIG}" ]] || die "${GX_ORIG} does not exist." 584 585 comm -2 -3 <(sort "${GX_NEW}") <(sort "${GX_ORIG}") > "${GX_ADDITIONS}" 586 } 587 588 589 function get_sdks() 590 { 591 log_callstack_and_parameters "$@" 592 593 (( ${#GX_SDKS[@]} )) && return 594 595 GX_SDKS=($( 596 xcodebuild -showsdks \ 597 | grep -e '\s-sdk\s' \ 598 | sed -E \ 599 -e 's/.*-sdk ([^[:digit:]]+)$/\1/' \ 600 -e 's/.*-sdk ([^[:digit:]]+)([[:digit:]\.]+)$/\1/' \ 601 -e 's/.*-sdk ([^[:digit:]]+)([[:digit:]\.]+)([^[:digit:]]+)$/\1.\3/' \ 602 | sort -u 603 )) 604 605 (( ${#GX_SDKS[@]} )) || die "Unable to find any SDKs." 606 } 607 608 609 function get_canonical_configuration() 610 { 611 log_callstack_and_parameters "$@" 612 613 local GX_PROVISIONAL_CONFIGURATION=$(echo "$1" | tr '[:upper:]' '[:lower:]') 614 615 [[ "${GX_PROVISIONAL_CONFIGURATION}" == "" ]] && { echo ""; return; } 616 617 [[ "${GX_PROVISIONAL_CONFIGURATION}" == "debug" ]] && { echo "Debug"; return; } 618 [[ "${GX_PROVISIONAL_CONFIGURATION}" == "release" ]] && { echo "Release"; return; } 619 [[ "${GX_PROVISIONAL_CONFIGURATION}" == "production" ]] && { echo "Production"; return; } 620 [[ "${GX_PROVISIONAL_CONFIGURATION}" == "profiling" ]] && { echo "Profiling"; return; } 621 622 die "Unrecognized configuration: $1" 623 } 624 625 626 function get_canonical_platform_name() 627 { 628 log_callstack_and_parameters "$@" 629 630 local GX_PROVISIONAL_PLATFORM_NAME=$(echo "$1" | tr '[:upper:]' '[:lower:]') 631 632 [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "" ]] && { echo ""; return; } 633 634 [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "ios" ]] && { echo "iphoneos"; return; } 635 [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "iphone" ]] && { echo "iphoneos"; return; } 636 [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "ipad" ]] && { echo "iphoneos"; return; } 637 [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "iphoneos" ]] && { echo "iphoneos"; return; } 638 639 [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "mac" ]] && { echo "macosx"; return; } 640 [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "osx" ]] && { echo "macosx"; return; } 641 [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "macos" ]] && { echo "macosx"; return; } 642 [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "macosx" ]] && { echo "macosx"; return; } 643 644 die "Unrecognized platform name: $1" 645 } 646 647 648 function get_sdk_name() 649 { 650 log_callstack_and_parameters "$@" 651 652 local GX_SDK=$(get_canonical_platform_name "$1") 653 local GX_INTERNAL_SDK="${GX_SDK}.internal" 654 655 get_sdks 656 657 # Prefer an internal SDK if one exists. 658 659 [[ " ${GX_SDKS[@]} " =~ " ${GX_INTERNAL_SDK} " ]] && { echo "${GX_INTERNAL_SDK}"; return; } 660 [[ " ${GX_SDKS[@]} " =~ " ${GX_SDK} " ]] && { echo "${GX_SDK}"; return; } 661 662 die "Unsupported SDK: ${GX_SDK}." 663 } 664 665 666 function invoke_each_action() 667 { 668 log_callstack_and_parameters "$@" 669 670 local GX_ACTION 671 for GX_ACTION in "$@" 109 672 do 110 [[ -e "${ITEM}" ]] && { echo "${ITEM}"; return 0; }673 eval "${GX_ACTION}" 111 674 done 675 } 676 677 678 function for_each_configuration() 679 { 680 log_callstack_and_parameters "$@" 681 682 if [[ -z "${GX_CONFIGURATION}" ]] 683 then 684 for GX_CONFIGURATION in "${GX_CONFIGURATIONS[@]}" 685 do 686 eval "$@" 687 done 688 689 GX_CONFIGURATION= 690 else 691 eval "$@" 692 fi 693 } 694 695 696 function for_each_platform() 697 { 698 log_callstack_and_parameters "$@" 699 700 if [[ -z "${GX_PLATFORM_NAME}" ]] 701 then 702 for GX_PLATFORM_NAME in "${GX_PS_PLATFORM_NAMES[@]}" 703 do 704 eval "$@" 705 done 706 707 GX_PLATFORM_NAME= 708 else 709 eval "$@" 710 fi 711 } 712 713 714 function for_each_project() 715 { 716 log_callstack_and_parameters "$@" 717 718 if [[ -z "${GX_PROJECT_TAG}" ]] 719 then 720 for GX_PROJECT_TAG in "${GX_PROJECT_TAGS[@]}" 721 do 722 set_project_settings 723 eval "$@" 724 done 725 726 GX_PROJECT_TAG= 727 else 728 set_project_settings 729 eval "$@" 730 fi 731 } 732 733 734 function generate_derivedsources_xcfilelists() 735 { 736 log_callstack_and_parameters "$@" 737 738 create_empty_files "${GX_TEMP_INPUT_XCFILELIST}" "${GX_TEMP_OUTPUT_XCFILELIST}" 739 740 local GX_DERIVEDSOURCES_EXTRACTOR="${GX_HERE}/extract-dependencies-from-makefile" 741 742 [[ -n "${GX_DERIVEDSOURCES_GENERATOR}" ]] || die "GX_DERIVEDSOURCES_GENERATOR is not defined." 743 [[ -x "${GX_DERIVEDSOURCES_GENERATOR}" ]] || die "${GX_DERIVEDSOURCES_GENERATOR} does not exist or is not executable." 744 [[ -x "${GX_DERIVEDSOURCES_EXTRACTOR}" ]] || die "${GX_DERIVEDSOURCES_EXTRACTOR} does not exist or is not executable." 745 746 log_debug "Creating derived .xcfilelists for ${PROJECT_NAME}/${PLATFORM_NAME}/${CONFIGURATION}" 747 748 "${GX_DERIVEDSOURCES_GENERATOR}" \ 749 NO_SUPPLEMENTAL_FILES=1 \ 750 --no-builtin-rules \ 751 --dry-run \ 752 --always-make \ 753 --debug=abvijm all \ 754 1> "${GX_TEMP}/std.out" 2> "${GX_TEMP}/std.err" 755 local GX_RESULT=$? 756 757 if (( ${GX_RESULT} )) 758 then 759 sed -E -e 's/^/... /' < "${GX_TEMP}/std.err" 760 die "Error generating derived sources: error = ${GX_RESULT}" ${GX_RESULT} 761 fi 762 763 cat "${GX_TEMP}/std.out" \ 764 | "${GX_DERIVEDSOURCES_EXTRACTOR}" \ 765 --input "${GX_TEMP_INPUT_XCFILELIST}" \ 766 --output "${GX_TEMP_OUTPUT_XCFILELIST}" 767 local GX_RESULT=$? 768 769 (( ${GX_RESULT} )) && die "Error extracting dependencies from DerivedSources.make: error = ${GX_RESULT}" 770 [[ -f "${GX_TEMP_INPUT_XCFILELIST}" ]] || die "${GX_TEMP_INPUT_XCFILELIST} was not generated." 771 [[ -f "${GX_TEMP_OUTPUT_XCFILELIST}" ]] || die "${GX_TEMP_OUTPUT_XCFILELIST} was not generated." 772 773 replace "${GX_TEMP_INPUT_XCFILELIST}" '^WebCore/' '$(PROJECT_DIR)/' 774 replace "${GX_TEMP_INPUT_XCFILELIST}" '^JavaScriptCore/' '$(PROJECT_DIR)/' 775 replace "${GX_TEMP_INPUT_XCFILELIST}" '^JavaScriptCorePrivateHeaders/' '$(JAVASCRIPTCORE_PRIVATE_HEADERS_DIR)/' 776 replace "${GX_TEMP_INPUT_XCFILELIST}" '^WebKit2PrivateHeaders/' '$(WEBKIT2_PRIVATE_HEADERS_DIR)/' 777 unexpand "${GX_TEMP_INPUT_XCFILELIST}" PROJECT_DIR 778 unexpand "${GX_TEMP_INPUT_XCFILELIST}" WEBKITADDITIONS_HEADERS_FOLDER_PATH 779 unexpand "${GX_TEMP_INPUT_XCFILELIST}" WEBCORE_PRIVATE_HEADERS_DIR 780 unexpand "${GX_TEMP_INPUT_XCFILELIST}" WEBKIT2_PRIVATE_HEADERS_DIR 781 unexpand "${GX_TEMP_INPUT_XCFILELIST}" JAVASCRIPTCORE_PRIVATE_HEADERS_DIR 782 unexpand "${GX_TEMP_INPUT_XCFILELIST}" BUILT_PRODUCTS_DIR 783 784 replace "${GX_TEMP_OUTPUT_XCFILELIST}" "^" "${GX_PS_DERIVED_SOURCES_DIR}/" 785 unexpand "${GX_TEMP_OUTPUT_XCFILELIST}" BUILT_PRODUCTS_DIR 786 787 merge_xcfilelists_helper "${GX_TEMP_INPUT_XCFILELIST}" "${GX_INPUT_DERIVED_XCFILELIST_PROJECT_TEMP_PATH}" 788 merge_xcfilelists_helper "${GX_TEMP_OUTPUT_XCFILELIST}" "${GX_OUTPUT_DERIVED_XCFILELIST_PROJECT_TEMP_PATH}" 789 } 790 791 792 function generate_unifiedsources_xcfilelists() 793 { 794 log_callstack_and_parameters "$@" 795 796 create_empty_files "${GX_TEMP_INPUT_XCFILELIST}" "${GX_TEMP_OUTPUT_XCFILELIST}" 797 798 [[ -n "${GX_UNIFIEDSOURCES_GENERATOR}" ]] || die "GX_UNIFIEDSOURCES_GENERATOR is not defined." 799 [[ -x "${GX_UNIFIEDSOURCES_GENERATOR}" ]] || die "${GX_UNIFIEDSOURCES_GENERATOR} does not exist or is not executable." 800 801 local GX_BUILD_SCRIPTS_DIR="${GX_OPENSOURCE_DIR}/Source/WTF/Scripts" 802 [[ -d "${GX_BUILD_SCRIPTS_DIR}" ]] || die "${GX_BUILD_SCRIPTS_DIR} does not exist or is not a directory." 803 [[ -f "${GX_BUILD_SCRIPTS_DIR}/generate-unified-source-bundles.rb" ]] || die "${GX_BUILD_SCRIPTS_DIR}/generate-unified-source-bundles.rb does not exist or is not a file." 804 805 log_debug "Creating unified .xcfilelists for ${PROJECT_NAME}/${PLATFORM_NAME}/${CONFIGURATION}" 806 807 BUILD_SCRIPTS_DIR="${GX_BUILD_SCRIPTS_DIR}" \ 808 "${GX_UNIFIEDSOURCES_GENERATOR}" \ 809 --generate-xcfilelists \ 810 --input-xcfilelist-path "${GX_TEMP_INPUT_XCFILELIST}" \ 811 --output-xcfilelist-path "${GX_TEMP_OUTPUT_XCFILELIST}" 812 GX_RESULT=$? 813 814 (( ${GX_RESULT} )) && die "Error generating unified sources: error = ${GX_RESULT}" 815 [[ -f "${GX_TEMP_INPUT_XCFILELIST}" ]] || die "${GX_TEMP_INPUT_XCFILELIST} was not generated." 816 [[ -f "${GX_TEMP_OUTPUT_XCFILELIST}" ]] || die "${GX_TEMP_OUTPUT_XCFILELIST} was not generated." 817 818 unexpand "${GX_TEMP_INPUT_XCFILELIST}" BUILT_PRODUCTS_DIR 819 unexpand "${GX_TEMP_OUTPUT_XCFILELIST}" BUILT_PRODUCTS_DIR 820 821 merge_xcfilelists_helper "${GX_TEMP_INPUT_XCFILELIST}" "${GX_INPUT_UNIFIED_XCFILELIST_PROJECT_TEMP_PATH}" 822 merge_xcfilelists_helper "${GX_TEMP_OUTPUT_XCFILELIST}" "${GX_OUTPUT_UNIFIED_XCFILELIST_PROJECT_TEMP_PATH}" 823 } 824 825 826 function subgenerate_xcfilelists() 827 { 828 log_callstack_and_parameters "$@" 829 830 invoke_each_action "${GX_SUBGENERATE_ACTIONS[@]}" 831 } 832 833 834 function sublaunch_under_xcode() 835 { 836 log_callstack_and_parameters "$@" 837 838 # Sublaunch the script for the given project, for each platform for which 839 # the project is built, and for Debug and Release configurations. 840 841 local GX_ARGS=("$@") 842 (( ${GX_DRY_RUN} )) && GX_ARGS+=("--dry-run") 843 (( ${GX_DEBUG} )) && { for n in $(seq $GX_DEBUG); do GX_ARGS+=("--debug"); done; } 844 (( ${GX_QUIET} )) && GX_ARGS+=("--quiet") 845 846 local GX_SDK_NAME=$(get_sdk_name "${GX_PLATFORM_NAME}") 847 848 log_debug "Sublaunching for: ${GX_PROJECT_TAG}/${GX_PLATFORM_NAME}/${GX_CONFIGURATION}" 849 850 local GX_XCODE_PARAMETERS=( 851 -project "${GX_PS_PROJECT_FILE_PATH}" 852 -sdk "${GX_SDK_NAME}" 853 -configuration "${GX_CONFIGURATION}" 854 -target "Apply Configuration to XCFileLists" 855 ) 856 857 if (( ${GX_USE_WEBKITBUILD_BUILD_OUTPUT} )) 858 then 859 local GX_WEBKITBUILD_DIR="${WEBKIT_OUTPUTDIR:-${GX_OPENSOURCE_DIR}/WebKitBuild}" 860 [[ -d "${GX_WEBKITBUILD_DIR}" ]] || die "${GX_WEBKITBUILD_DIR} does not exist." 861 862 GX_XCODE_PARAMETERS+=( 863 SYMROOT="${GX_WEBKITBUILD_DIR}" 864 OBJROOT="${GX_WEBKITBUILD_DIR}" 865 SHARED_PRECOMPS_DIR="${GX_WEBKITBUILD_DIR}/PrecompiledHeaders" 866 ) 867 fi 868 869 if (( $GX_DEBUG > 0 )) 870 then 871 WK_SUBLAUNCH_SCRIPT_PARAMETERS=("${GX_ARGS[@]}") xcodebuild "${GX_XCODE_PARAMETERS[@]}" 872 else 873 WK_SUBLAUNCH_SCRIPT_PARAMETERS=("${GX_ARGS[@]}") xcodebuild "${GX_XCODE_PARAMETERS[@]}" | grep '^\.\.\. ' 874 fi 875 876 local GX_RESULT=${PIPESTATUS[0]} 877 (( ${GX_RESULT} )) && die "Error sub-launching under xcode: error = ${GX_RESULT}" 878 } 879 880 881 function reset_project_specific_temp_files() 882 { 883 log_callstack_and_parameters "$@" 884 885 create_empty_files \ 886 "${GX_INPUT_DERIVED_XCFILELIST_PROJECT_TEMP_PATH}" "${GX_OUTPUT_DERIVED_XCFILELIST_PROJECT_TEMP_PATH}" \ 887 "${GX_INPUT_UNIFIED_XCFILELIST_PROJECT_TEMP_PATH}" "${GX_OUTPUT_UNIFIED_XCFILELIST_PROJECT_TEMP_PATH}" 888 } 889 890 891 function generate_xcfilelists() 892 { 893 log_callstack_and_parameters "$@" 894 895 reset_project_specific_temp_files 896 897 for_each_platform \ 898 for_each_configuration \ 899 sublaunch_under_xcode \ 900 "${GX_SUBEXECUTE_SCRIPT}" subgenerate --nocleanup --project "${GX_PROJECT_TAG}" 901 } 902 903 904 function merge_xcfilelists_helper() 905 { 906 log_callstack_and_parameters "$@" 907 908 local GX_SOURCE="$1" 909 local GX_DEST="$2" 910 local GX_ADDITIONS="${GX_TEMP}/diff_added.tmp" 911 912 append_xcfilelist_header "${GX_SOURCE}" 913 sort_and_unique_in_place "${GX_SOURCE}" 914 915 find_additions "${GX_SOURCE}" "${GX_DEST}" "${GX_ADDITIONS}" 916 917 if [[ -s "${GX_ADDITIONS}" ]] 918 then 919 cat "${GX_SOURCE}" >> "${GX_DEST}" 920 sort_and_unique_in_place "${GX_DEST}" 921 return 0 922 fi 923 112 924 return 1 113 925 } 114 926 115 927 116 # Given a checked-in .xcfilelist and a newly-generated one stored in a 117 # temporary location, compare the two to see if there are any changes that need 118 # to be accounted for. If there are differences, print out a notice and prep 119 # the script to exit with code 2. 120 121 function check_xcfilelist() 122 { 123 local ORIG="$1" 124 local TEMP="$2" 125 126 if ! diff -q "${ORIG}" "${TEMP}" &> /dev/null 127 then 128 echo "### xcfilelist changed:" 129 diff -u "${ORIG}" "${TEMP}" 130 DEFERRED_EXIT_CODE=2 131 fi 132 133 rm "${TEMP}" 134 } 135 136 137 function set_build_variables_for_JavaScriptCore() 138 { 139 PROJECT_NAME=JavaScriptCore 140 PROJECT_DIR="${OPENSOURCE_DIR}/Source/${PROJECT_NAME}" 141 GENERATOR="${PROJECT_DIR}/Scripts/generate-derived-sources.sh" 142 DERIVED_SOURCES_MAKE="${PROJECT_DIR}/DerivedSources.make" 143 DERIVED_SOURCES_DIR="${BUILT_PRODUCTS_DIR}/DerivedSources/${PROJECT_NAME}" 144 145 export FRAMEWORK_SEARCH_PATHS= 146 export HEADER_SEARCH_PATHS=" 147 ${BUILT_PRODUCTS_DIR}/DerivedSources/JavaScriptCore 148 . 149 ${BUILT_PRODUCTS_DIR}/usr/local/include" 150 export SYSTEM_FRAMEWORK_SEARCH_PATHS=" 151 ${SDKROOT}/System/Library/PrivateFrameworks" 152 export SYSTEM_HEADER_SEARCH_PATHS= 153 } 154 155 156 function set_build_variables_for_WebCore() 157 { 158 PROJECT_NAME=WebCore 159 PROJECT_DIR="${OPENSOURCE_DIR}/Source/${PROJECT_NAME}" 160 GENERATOR="${PROJECT_DIR}/Scripts/generate-derived-sources.sh" 161 DERIVED_SOURCES_MAKE="${PROJECT_DIR}/DerivedSources.make" 162 DERIVED_SOURCES_DIR="${BUILT_PRODUCTS_DIR}/DerivedSources/${PROJECT_NAME}" 163 164 export FRAMEWORK_SEARCH_PATHS=" 165 ${BUILT_PRODUCTS_DIR}" 166 export HEADER_SEARCH_PATHS=" 167 PAL 168 ForwardingHeaders 169 /usr/include/libxslt 170 /usr/include/libxml2 171 ${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore 172 ${BUILT_PRODUCTS_DIR}/usr/local/include 173 ${BUILT_PRODUCTS_DIR}/usr/local/include/WebKitAdditions 174 ${SDKROOT}/usr/local/include/WebKitAdditions 175 ${BUILT_PRODUCTS_DIR}/usr/local/include/webrtc 176 ${SDKROOT}/usr/local/include/webrtc 177 ${BUILT_PRODUCTS_DIR}/usr/local/include/webrtc/sdk/objc/Framework/Headers 178 ${SDKROOT}/usr/local/include/webrtc/sdk/objc/Framework/Headers 179 ${PROJECT_DIR}" 180 export SYSTEM_FRAMEWORK_SEARCH_PATHS=" 181 ${SDKROOT}/System/Library/PrivateFrameworks 182 ${SDKROOT}/System/Library/Frameworks" 183 export SYSTEM_HEADER_SEARCH_PATHS= 184 } 185 186 187 function set_build_variables_for_WebKit() 188 { 189 PROJECT_NAME=WebKit 190 PROJECT_DIR="${OPENSOURCE_DIR}/Source/${PROJECT_NAME}" 191 GENERATOR="${PROJECT_DIR}/Scripts/generate-derived-sources.sh" 192 DERIVED_SOURCES_MAKE="${PROJECT_DIR}/DerivedSources.make" 193 DERIVED_SOURCES_DIR="${BUILT_PRODUCTS_DIR}/DerivedSources/WebKit2" 194 195 export FRAMEWORK_SEARCH_PATHS=" 196 ${BUILT_PRODUCTS_DIR}" 197 export HEADER_SEARCH_PATHS=" 198 ${BUILT_PRODUCTS_DIR}/usr/local/include 199 ${BUILT_PRODUCTS_DIR}/WebCore.framework/PrivateHeaders/ForwardingHeaders 200 ${BUILT_PRODUCTS_DIR}/DerivedSources/WebKit2 201 ${BUILT_PRODUCTS_DIR}/usr/local/include/WebKitAdditions 202 ${SDKROOT}/usr/local/include/WebKitAdditions 203 ${BUILT_PRODUCTS_DIR}/usr/local/include/webrtc 204 ${SDKROOT}/usr/local/include/webrtc 205 ${PROJECT_DIR}" 206 export SYSTEM_FRAMEWORK_SEARCH_PATHS=" 207 ${SDKROOT}/System/Library/PrivateFrameworks 208 ${SDKROOT}/System/Library/Frameworks" 209 export SYSTEM_HEADER_SEARCH_PATHS= 210 } 211 212 213 function set_build_variables_for_DumpRenderTree() 214 { 215 PROJECT_NAME=DumpRenderTree 216 PROJECT_DIR="${OPENSOURCE_DIR}/Tools/${PROJECT_NAME}" 217 GENERATOR="${PROJECT_DIR}/Scripts/generate-derived-sources.sh" 218 DERIVED_SOURCES_MAKE="${PROJECT_DIR}/DerivedSources.make" 219 DERIVED_SOURCES_DIR="${BUILT_PRODUCTS_DIR}/DerivedSources/${PROJECT_NAME}" 220 221 export FRAMEWORK_SEARCH_PATHS= 222 export HEADER_SEARCH_PATHS= 223 export SYSTEM_FRAMEWORK_SEARCH_PATHS= 224 export SYSTEM_HEADER_SEARCH_PATHS= 225 } 226 227 function set_build_variables_for_WebKitTestRunner() 228 { 229 PROJECT_NAME=WebKitTestRunner 230 PROJECT_DIR="${OPENSOURCE_DIR}/Tools/${PROJECT_NAME}" 231 GENERATOR="${PROJECT_DIR}/Scripts/generate-derived-sources.sh" 232 DERIVED_SOURCES_MAKE="${PROJECT_DIR}/DerivedSources.make" 233 DERIVED_SOURCES_DIR="${BUILT_PRODUCTS_DIR}/DerivedSources/${PROJECT_NAME}" 234 235 export FRAMEWORK_SEARCH_PATHS= 236 export HEADER_SEARCH_PATHS= 237 export SYSTEM_FRAMEWORK_SEARCH_PATHS= 238 export SYSTEM_HEADER_SEARCH_PATHS= 239 } 240 241 242 function dump_variables() 243 { 244 echo "ACTION = ${ACTION}" 245 echo "OS = ${OS}" 246 echo "PLATFORM_NAME = ${PLATFORM_NAME}" 247 echo "SDKROOT = ${SDKROOT}" 248 echo "SRCROOT = ${SRCROOT}" 249 echo "BUILD_SCRIPTS_DIR = ${BUILD_SCRIPTS_DIR}" 250 echo "BUILT_PRODUCTS_DIR = ${BUILT_PRODUCTS_DIR}" 251 echo "WEBCORE_PRIVATE_HEADERS_DIR = ${WEBCORE_PRIVATE_HEADERS_DIR}" 252 echo "WEBKIT2_PRIVATE_HEADERS_DIR = ${WEBKIT2_PRIVATE_HEADERS_DIR}" 253 echo "JAVASCRIPTCORE_PRIVATE_HEADERS_DIR = ${JAVASCRIPTCORE_PRIVATE_HEADERS_DIR}" 254 echo "WEBKITADDITIONS_HEADER_SEARCH_PATHS = ${WEBKITADDITIONS_HEADER_SEARCH_PATHS}" 255 echo "" 256 echo "PROJECT_NAME = ${PROJECT_NAME}" 257 echo "PROJECT_DIR = ${PROJECT_DIR}" 258 echo "GENERATOR = ${GENERATOR}" 259 echo "DERIVED_SOURCES_MAKE = ${DERIVED_SOURCES_MAKE}" 260 echo "DERIVED_SOURCES_DIR = ${DERIVED_SOURCES_DIR}" 261 echo "" 262 echo "FRAMEWORK_SEARCH_PATHS = ${FRAMEWORK_SEARCH_PATHS}" 263 echo "HEADER_SEARCH_PATHS = ${HEADER_SEARCH_PATHS}" 264 echo "SYSTEM_FRAMEWORK_SEARCH_PATHS = ${SYSTEM_FRAMEWORK_SEARCH_PATHS}" 265 } 266 267 268 function set_build_variables() 269 { 270 PROJECT_TAG="$1" 271 272 export ACTION=build 273 export OS=MACOS 274 export PLATFORM_NAME=macosx 275 export SDKROOT="$(xcrun -show-sdk-path)" 276 export BUILD_SCRIPTS_DIR="${OPENSOURCE_DIR}/Source/WTF/Scripts" 277 export BUILT_PRODUCTS_DIR="$(find_first_existing "${OPENSOURCE_DIR}/WebKitBuild/"{Debug,Release}*)" 278 [[ -n "${SDKROOT}" ]] || die "SDKROOT is not defined" 279 [[ -e "${BUILD_SCRIPTS_DIR}" ]] || die "$BUILD_SCRIPTS_DIR does not exist" 280 [[ -n "${BUILT_PRODUCTS_DIR}" ]] || die "BUILT_PRODUCTS_DIR is not defined. You may need to build WebKit first." 281 282 export WEBCORE_PRIVATE_HEADERS_DIR="${BUILT_PRODUCTS_DIR}/WebCore.framework/PrivateHeaders" 283 export WEBKIT2_PRIVATE_HEADERS_DIR="${BUILT_PRODUCTS_DIR}/WebKit.framework/PrivateHeaders" 284 export JAVASCRIPTCORE_PRIVATE_HEADERS_DIR="${BUILT_PRODUCTS_DIR}/JavaScriptCore.framework/PrivateHeaders" 285 export WEBKITADDITIONS_HEADER_SEARCH_PATHS="${BUILT_PRODUCTS_DIR}/usr/local/include/WebKitAdditions ${SDKROOT}/usr/local/include/WebKitAdditions" 286 [[ -e "${WEBCORE_PRIVATE_HEADERS_DIR}" ]] || die "$WEBCORE_PRIVATE_HEADERS_DIR does not exist. You may need to build WebKit first." 287 [[ -e "${JAVASCRIPTCORE_PRIVATE_HEADERS_DIR}" ]] || die "$JAVASCRIPTCORE_PRIVATE_HEADERS_DIR does not exist. You may need to build WebKit first." 288 # [[ -e "${WEBKITADDITIONS_HEADER_SEARCH_PATHS}" ]] || die "$WEBKITADDITIONS_HEADER_SEARCH_PATHS does not exist. You may need to build WebKit first." 289 290 local FN=set_build_variables_for_${PROJECT_TAG} 291 local IS_FUNCTION=$(type -t $FN) 292 [[ "${IS_FUNCTION}" == "function" ]] && eval $FN || die "Could not set build variables for ${PROJECT_TAG}" 293 294 # Do these after project-specific initialization. 295 296 export SRCROOT="${PROJECT_DIR}" 297 298 [[ -e "${PROJECT_DIR}" ]] || die "$PROJECT_DIR does not exist" 299 [[ -e "${GENERATOR}" ]] || die "$GENERATOR does not exist" 300 [[ -e "${DERIVED_SOURCES_MAKE}" ]] || die "$DERIVED_SOURCES_MAKE does not exist" 301 [[ -e "${DERIVED_SOURCES_DIR}" ]] || die "$DERIVED_SOURCES_DIR does not exist" 302 303 # dump_variables 304 } 305 306 307 function sort_files() 308 { 309 sort "${INPUT_XCFILELIST_PATH}" -o "${INPUT_XCFILELIST_PATH}" 310 sort "${OUTPUT_XCFILELIST_PATH}" -o "${OUTPUT_XCFILELIST_PATH}" 311 } 312 313 314 # If we're doing a check (as opposed to generating the files), then redirect 315 # the script to generate the files in a temporary location (so that we can 316 # compare those to the originals later). 317 318 function check_prolog() 319 { 320 if (( ${DO_CHECK} )) 321 then 322 INPUT_XCFILELIST_PATH_ORIG="${INPUT_XCFILELIST_PATH}" 323 INPUT_XCFILELIST_PATH="/tmp/${INPUT_XCFILELIST_PATH##/}" 324 OUTPUT_XCFILELIST_PATH_ORIG="${OUTPUT_XCFILELIST_PATH}" 325 OUTPUT_XCFILELIST_PATH="/tmp/${OUTPUT_XCFILELIST_PATH##/}" 326 mkdir -p "$(dirname "${INPUT_XCFILELIST_PATH}")" 327 mkdir -p "$(dirname "${OUTPUT_XCFILELIST_PATH}")" 928 function merge_derivedsources_xcfilelists() 929 { 930 log_callstack_and_parameters "$@" 931 932 log_debug "Merging ${GX_INPUT_DERIVED_XCFILELIST_PROJECT_TEMP_PATH} into ${GX_INPUT_DERIVED_XCFILELIST_PROJECT_PATH}" 933 log_debug "Merging ${GX_OUTPUT_DERIVED_XCFILELIST_PROJECT_TEMP_PATH} into ${GX_OUTPUT_DERIVED_XCFILELIST_PROJECT_PATH}" 934 935 if (( ! ${GX_DRY_RUN} )) 936 then 937 merge_xcfilelists_helper "${GX_INPUT_DERIVED_XCFILELIST_PROJECT_TEMP_PATH}" "${GX_INPUT_DERIVED_XCFILELIST_PROJECT_PATH}" && GX_DEFERRED_EXIT_CODE=3 938 log_debug "GX_DEFERRED_EXIT_CODE = $GX_DEFERRED_EXIT_CODE" 939 940 merge_xcfilelists_helper "${GX_OUTPUT_DERIVED_XCFILELIST_PROJECT_TEMP_PATH}" "${GX_OUTPUT_DERIVED_XCFILELIST_PROJECT_PATH}" && GX_DEFERRED_EXIT_CODE=3 941 log_debug "GX_DEFERRED_EXIT_CODE = $GX_DEFERRED_EXIT_CODE" 942 fi 943 } 944 945 946 function merge_unifiedsources_xcfilelists() 947 { 948 log_callstack_and_parameters "$@" 949 950 log_debug "Merging ${GX_INPUT_UNIFIED_XCFILELIST_PROJECT_TEMP_PATH} into ${GX_INPUT_UNIFIED_XCFILELIST_PROJECT_PATH}" 951 log_debug "Merging ${GX_OUTPUT_UNIFIED_XCFILELIST_PROJECT_TEMP_PATH} into ${GX_OUTPUT_UNIFIED_XCFILELIST_PROJECT_PATH}" 952 953 if (( ! ${GX_DRY_RUN} )) 954 then 955 merge_xcfilelists_helper "${GX_INPUT_UNIFIED_XCFILELIST_PROJECT_TEMP_PATH}" "${GX_INPUT_UNIFIED_XCFILELIST_PROJECT_PATH}" && GX_DEFERRED_EXIT_CODE=3 956 log_debug "GX_DEFERRED_EXIT_CODE = $GX_DEFERRED_EXIT_CODE" 957 958 merge_xcfilelists_helper "${GX_OUTPUT_UNIFIED_XCFILELIST_PROJECT_TEMP_PATH}" "${GX_OUTPUT_UNIFIED_XCFILELIST_PROJECT_PATH}" && GX_DEFERRED_EXIT_CODE=3 959 log_debug "GX_DEFERRED_EXIT_CODE = $GX_DEFERRED_EXIT_CODE" 960 fi 961 } 962 963 964 function merge_xcfilelists() 965 { 966 log_callstack_and_parameters "$@" 967 968 invoke_each_action "${GX_MERGE_ACTIONS[@]}" 969 970 log_debug "GX_DEFERRED_EXIT_CODE = $GX_DEFERRED_EXIT_CODE" 971 } 972 973 974 function check_xcfilelists_helper() 975 { 976 log_callstack_and_parameters "$@" 977 978 local GX_NEW="$1" 979 local GX_ORIG="$2" 980 local GX_ADDITIONS="${GX_TEMP}/diff_added.tmp" 981 982 log_debug "Checking ${GX_NEW} against ${GX_ORIG}" 983 984 find_additions "${GX_NEW}" "${GX_ORIG}" "${GX_ADDITIONS}" 985 986 if [[ -s "${GX_ADDITIONS}" ]] 987 then 988 log_progress 989 log_progress "------------------------------------------------------------------------------" 990 log_progress "Found added files for ${GX_ORIG}:" 991 log_progress "------------------------------------------------------------------------------" 992 993 local GX_LINE 994 while IFS='' read -r GX_LINE 995 do 996 log_progress "${GX_LINE}" 997 done < "${GX_ADDITIONS}" 998 999 log_progress "------------------------------------------------------------------------------" 1000 1001 GX_DEFERRED_EXIT_CODE=2 1002 fi 1003 } 1004 1005 1006 function check_derivedsources_xcfilelists() 1007 { 1008 log_callstack_and_parameters "$@" 1009 1010 check_xcfilelists_helper "${GX_INPUT_DERIVED_XCFILELIST_PROJECT_TEMP_PATH}" "${GX_INPUT_DERIVED_XCFILELIST_PROJECT_PATH}" 1011 check_xcfilelists_helper "${GX_OUTPUT_DERIVED_XCFILELIST_PROJECT_TEMP_PATH}" "${GX_OUTPUT_DERIVED_XCFILELIST_PROJECT_PATH}" 1012 } 1013 1014 1015 function check_unifiedsources_xcfilelists() 1016 { 1017 log_callstack_and_parameters "$@" 1018 1019 check_xcfilelists_helper "${GX_INPUT_UNIFIED_XCFILELIST_PROJECT_TEMP_PATH}" "${GX_INPUT_UNIFIED_XCFILELIST_PROJECT_PATH}" 1020 check_xcfilelists_helper "${GX_OUTPUT_UNIFIED_XCFILELIST_PROJECT_TEMP_PATH}" "${GX_OUTPUT_UNIFIED_XCFILELIST_PROJECT_PATH}" 1021 } 1022 1023 1024 function check_xcfilelists() 1025 { 1026 log_callstack_and_parameters "$@" 1027 1028 invoke_each_action "${GX_CHECK_ACTIONS[@]}" 1029 } 1030 1031 1032 function report_merge_results() 1033 { 1034 log_callstack_and_parameters "$@" 1035 1036 log_debug "GX_DEFERRED_EXIT_CODE = $GX_DEFERRED_EXIT_CODE" 1037 1038 if (( ${GX_DEFERRED_EXIT_CODE} )) 1039 then 1040 log_progress 1041 1042 local GX_MESSAGE='".xcfilelist" files tell the build system what files 1043 are consumed and produced by the "Run Script" build phases in 1044 Xcode. At least one of these .xcfilelist files was out of date and 1045 has been updated. You now need to restart your build.' 1046 1047 log_progress_long "${GX_MESSAGE}" 1048 fi 1049 } 1050 1051 1052 function report_remediation_steps() 1053 { 1054 log_callstack_and_parameters "$@" 1055 1056 if (( ${GX_DEFERRED_EXIT_CODE} )) 1057 then 1058 log_progress 1059 1060 # We can either be called from within an xcodebuild context (meaning 1061 # that we are being called during a build to validate the .xcfilelists 1062 # for the current build configuration) or from the command line (to 1063 # validate all .xcfilelists). We'll determine which of these is the 1064 # case by checking $GX_PROJECT_TAG (which will have been set via the 1065 # --project <TAG> option passed in to us when we're invoked in this 1066 # context). 1067 # 1068 # Further, if called from within xcodebuild, it's important to know if 1069 # we're being called from within Xcode or being invoked by a Makefile. 1070 # If the former, the output/build files we are looking for are found in 1071 # ~/Library/Developer/Xcode/DerivedData. Otherwise, they'll be found in 1072 # OpenSource/WebKitBuild (or whatever $WEBKIT_OUTPUTDIR points to). We 1073 # need to distinguish between these so that we can tell the user how to 1074 # invoke us in a way that finds the right output/build files. 1075 # 1076 # If invoked from the command line, we really can't tell where the 1077 # output files are, so give the user advice in this area. 1078 1079 local GX_MESSAGE='".xcfilelist" files tell the build system what files 1080 are consumed and produced by the "Run Script" build phases in 1081 Xcode. At least one of these .xcfilelist files are out of date and 1082 need to be regenerated. Regenerate these files by running 1083 `Tools/Scripts/generate-xcfilelists generate' 1084 1085 if [[ -n "${GX_PROJECT_TAG}" ]] 1086 then 1087 local GX_MESSAGE+=" --project ${GX_PROJECT_TAG}" 1088 if [[ "${SYMROOT}" =~ Library/Developer/Xcode/DerivedData ]] 1089 then 1090 local GX_MESSAGE+=" --xcode" 1091 fi 1092 else 1093 if (( ${GX_USE_XCODE_BUILD_OUTPUT} )) 1094 then 1095 local GX_MESSAGE+=" --xcode" 1096 fi 1097 fi 1098 1099 local GX_MESSAGE+='`, or manually add the file or files shown above to 1100 the indicated .xcfilelist files. Then restart your build. When 1101 submitting, include the updated .xcfilelist files.' 1102 1103 log_progress_long "${GX_MESSAGE}" 1104 fi 1105 } 1106 1107 1108 function do_generate() 1109 { 1110 # Invoked from the command line to generate .xcfilelist files. Use any 1111 # specified project, platform, and/or configuration. Any of those that 1112 # aren't specified results in our iterating over all possible values for 1113 # the unspecified value. 1114 1115 log_callstack_and_parameters "$@" 1116 1117 if [[ -z "${GX_PROJECT_TAG}" ]] 1118 then 1119 log_progress "=== Generating all .xcfilelists ===" 328 1120 else 329 echo "### Generating: ${INPUT_XCFILELIST_PATH}" 330 echo "### Generating: ${OUTPUT_XCFILELIST_PATH}" 331 fi 332 } 333 334 335 # If we're doing a check, then diff the new files against the originals. 336 337 function check_epilog() 338 { 339 if (( ${DO_CHECK} )) 340 then 341 echo "### Checking: ${INPUT_XCFILELIST_PATH}" 342 check_xcfilelist "${INPUT_XCFILELIST_PATH_ORIG}" "${INPUT_XCFILELIST_PATH}" 343 344 echo "### Checking: ${OUTPUT_XCFILELIST_PATH}" 345 check_xcfilelist "${OUTPUT_XCFILELIST_PATH_ORIG}" "${OUTPUT_XCFILELIST_PATH}" 346 fi 347 } 348 349 350 # Generate .xcfilelist files based on the output of DerivedSources.make when 351 # invoked to print out its dependency list. 352 353 function generate_xcfilelists_from_derivedsources() 354 { 355 set_build_variables "$1" 356 357 local DERIVED_SOURCES_MAKE_PATH="$(dirname "${DERIVED_SOURCES_MAKE}")" 358 INPUT_XCFILELIST_PATH="${DERIVED_SOURCES_MAKE_PATH}/DerivedSources-input.xcfilelist" 359 OUTPUT_XCFILELIST_PATH="${DERIVED_SOURCES_MAKE_PATH}/DerivedSources-output.xcfilelist" 360 361 # See comments in generate_xcfilelists_from_unifiedsources for what we're 362 # trying to achieve with FEATURE_DEFINES. 363 364 export FEATURE_DEFINES="$(grep 'ifeq.*findstring .*FEATURE_DEFINES.*' "${DERIVED_SOURCES_MAKE}" | sed -E -e 's/.*, (.*)\)/\1/')" 365 366 # Generate the .xcfilelist files. 367 368 check_prolog 369 370 "${GENERATOR}" NO_SUPPLEMENTAL_FILES=1 --no-builtin-rules --dry-run --always-make --debug=abvijm all | 371 "${OPENSOURCE_DIR}"/Tools/Scripts/extract-dependencies-from-makefile --input "${INPUT_XCFILELIST_PATH}" --output "${OUTPUT_XCFILELIST_PATH}" 372 373 replace "${INPUT_XCFILELIST_PATH}" 'WebCore' '$(PROJECT_DIR)' 374 replace "${INPUT_XCFILELIST_PATH}" 'JavaScriptCore' '$(PROJECT_DIR)' 375 replace "${INPUT_XCFILELIST_PATH}" 'JavaScriptCorePrivateHeaders' '$(JAVASCRIPTCORE_PRIVATE_HEADERS_DIR)' 376 replace "${INPUT_XCFILELIST_PATH}" 'WebKit2PrivateHeaders' '$(WEBKIT2_PRIVATE_HEADERS_DIR)' 377 replace "${INPUT_XCFILELIST_PATH}" "${PROJECT_DIR}" '$(PROJECT_DIR)' 378 replace "${INPUT_XCFILELIST_PATH}" "${WEBCORE_PRIVATE_HEADERS_DIR}" '$(WEBCORE_PRIVATE_HEADERS_DIR)' 379 replace "${INPUT_XCFILELIST_PATH}" "${WEBKIT2_PRIVATE_HEADERS_DIR}" '$(WEBKIT2_PRIVATE_HEADERS_DIR)' 380 replace "${INPUT_XCFILELIST_PATH}" "${JAVASCRIPTCORE_PRIVATE_HEADERS_DIR}" '$(JAVASCRIPTCORE_PRIVATE_HEADERS_DIR)' 381 replace "${INPUT_XCFILELIST_PATH}" "${BUILT_PRODUCTS_DIR}" '$(BUILT_PRODUCTS_DIR)' 382 383 prepend_prefix_to_all_paths "${OUTPUT_XCFILELIST_PATH}" 384 replace "${OUTPUT_XCFILELIST_PATH}" "${BUILT_PRODUCTS_DIR}" '$(BUILT_PRODUCTS_DIR)' 385 386 sort_files 387 check_epilog 388 } 389 390 391 # Generate .xcfilelist files for "unified sources" derived files. We generate 392 # two files: UnifiedSources-input.xcfilelist (the original source files that 393 # get bundled into the various UnifiedSource*.cpp/mm files) and 394 # UnifiedSources-output.xcfilelist (the list of UnifiedSource*.cpp/mm files). 395 # Both of these are generated from the same Sources*.txt files used by 396 # generate-unified-source-bundles.rb. The .xcfilelist files are written into 397 # the associated project directory. 398 399 function generate_xcfilelists_from_unifiedsources() 400 { 401 set_build_variables "$1" 402 403 INPUT_XCFILELIST_PATH="${PROJECT_DIR}/UnifiedSources-input.xcfilelist" 404 OUTPUT_XCFILELIST_PATH="${PROJECT_DIR}/UnifiedSources-output.xcfilelist" 405 406 # Define FEATURE_DEFINES in order to enable every possible feature, thus 407 # including every possible input file into the generated .xcfilelist file. 408 # This may over-specify the input -- that is, include files that aren't 409 # actually included in the UnifiedSources files -- but that's OK. The worst 410 # that will happen is that one of these extra files will get modified and 411 # we'll unnecessarily go through the Generate Unified Sources phase. This 412 # will unnecessarily go through the process of generating the 413 # UnifiedSources, but since that process writes/updates the UnifiedSources 414 # files only if their contents actually change, we won't end up changing 415 # any UnifiedSources files and nothing gets unnecessarily recompiled. 416 417 export FEATURE_DEFINES="$(cd "${PROJECT_DIR}"; grep '#if' $(find . -name 'Sources*.txt') | sed -E -e 's/.*if (ENABLE.*)/\1/')" 418 419 # Generate the .xcfilelist files. 420 421 check_prolog 422 423 "${PROJECT_DIR}/Scripts/generate-unified-sources.sh" \ 424 --generate-xcfilelists \ 425 --input-xcfilelist-path "${INPUT_XCFILELIST_PATH}" \ 426 --output-xcfilelist-path "${OUTPUT_XCFILELIST_PATH}" 427 428 replace "${INPUT_XCFILELIST_PATH}" "${BUILT_PRODUCTS_DIR}" '$(BUILT_PRODUCTS_DIR)' 429 replace "${OUTPUT_XCFILELIST_PATH}" "${BUILT_PRODUCTS_DIR}" '$(BUILT_PRODUCTS_DIR)' 430 431 sort_files 432 check_epilog 433 } 1121 log_progress "=== Generating .xcfilelists for ${GX_PROJECT_TAG} ===" 1122 fi 1123 1124 for_each_project \ 1125 generate_xcfilelists 1126 } 1127 1128 1129 function do_merge() 1130 { 1131 # Implicitly invoked for generate and generate-xcode operations to move the 1132 # temporary results into the Xcode project. 1133 1134 log_callstack_and_parameters "$@" 1135 1136 if [[ -z "${GX_PROJECT_TAG}" ]] 1137 then 1138 log_progress "=== Merging all .xcfilelists into place ===" 1139 else 1140 log_progress "=== Merging .xcfilelists for ${GX_PROJECT_TAG} ===" 1141 fi 1142 1143 for_each_project \ 1144 merge_xcfilelists 1145 1146 log_debug "GX_DEFERRED_EXIT_CODE = $GX_DEFERRED_EXIT_CODE" 1147 } 1148 1149 1150 function do_check() 1151 { 1152 # Implicitly invoked for check and check-xcode operations to check the 1153 # temporary results against the Xcode project. 1154 1155 log_callstack_and_parameters "$@" 1156 1157 # Being invoked from the command-line to check everything. 1158 1159 if [[ -z "${GX_PROJECT_TAG}" ]] 1160 then 1161 log_progress "=== Checking all .xcfilelists ===" 1162 else 1163 log_progress "=== Checking .xcfilelists for ${GX_PROJECT_TAG} ===" 1164 fi 1165 1166 for_each_project \ 1167 check_xcfilelists 1168 } 1169 1170 1171 function do_subgenerate() 1172 { 1173 # Invoked from within an Xcode context to generate .xcfilelist files. Use 1174 # the project, platform, an configuration established in the environment. 1175 1176 log_callstack_and_parameters "$@" 1177 1178 [[ -n "${GX_PROJECT_TAG}" ]] || die "GX_PROJECT_TAG is not defined." 1179 [[ -n "${PROJECT_NAME}" ]] || die "subgenerate should only be invoked in an Xcode context." 1180 1181 log_progress "=== Generating .xcfilelists for ${PROJECT_NAME}/${PLATFORM_NAME}/${CONFIGURATION} ===" 1182 1183 set_project_settings 1184 1185 # We're called during generate-xcode, check-xcode, and subgenerate 1186 # operations. We need to reset our project-specific temp files for the 1187 # first two, but not the last one. 1188 1189 (( ${GX_DO_SUBGENERATE} )) || reset_project_specific_temp_files 1190 1191 subgenerate_xcfilelists 1192 } 1193 1194 1195 function main() 1196 { 1197 log_callstack_and_parameters "$@" 1198 1199 log_debug_var GX_ME 1200 log_debug_var GX_HERE 1201 log_debug_var GX_ROOT_DIR 1202 log_debug_var GX_OPENSOURCE_DIR 1203 log_debug_var GX_TEMP 1204 log_debug_var GX_PROJECT_TAGS 1205 log_debug_var GX_CONFIGURATIONS 1206 log_debug_var GX_SUBEXECUTE_SCRIPT 1207 log_debug_var GX_DO_GENERATE 1208 log_debug_var GX_DO_GENERATE_XCODE 1209 log_debug_var GX_DO_CHECK 1210 log_debug_var GX_DO_CHECK_XCODE 1211 log_debug_var GX_DO_SUBGENERATE 1212 log_debug_var GX_DO_CLEANUP 1213 log_debug_var GX_USE_XCODE_BUILD_OUTPUT 1214 log_debug_var GX_USE_WEBKITBUILD_BUILD_OUTPUT 1215 log_debug_var GX_DRY_RUN 1216 log_debug_var GX_DEBUG 1217 log_debug_var GX_QUIET 1218 log_debug_var GX_ORIG_ARGS 1219 1220 if (( ${GX_DO_HELP} )) 1221 then 1222 usage 1223 my_exit 0 1224 fi 1225 1226 if (( GX_DO_GENERATE + GX_DO_GENERATE_XCODE + GX_DO_CHECK + GX_DO_CHECK_XCODE + GX_DO_SUBGENERATE + GX_DO_HELP < 1 )) 1227 then 1228 stderr "### One of generate, generate-xcode, check, check-xcode, subgenerate, or --help must be specified." 1229 my_exit 1 1230 fi 1231 1232 if (( GX_DO_GENERATE + GX_DO_GENERATE_XCODE + GX_DO_CHECK + GX_DO_CHECK_XCODE + GX_DO_SUBGENERATE + GX_DO_HELP > 1 )) 1233 then 1234 stderr "### Only one of generate, generate-xcode, check, check-xcode, subgenerate, or --help can be specified." 1235 my_exit 1 1236 fi 1237 1238 [[ -z "${GX_PROJECT_TAG}" || ( " ${GX_PROJECT_TAGS[@]} " =~ " ${GX_PROJECT_TAG} " ) ]] || { die "Unrecognized project: ${GX_PROJECT_TAG}"; } 1239 GX_PLATFORM_NAME=$(get_canonical_platform_name "${GX_PLATFORM_NAME}") 1240 GX_CONFIGURATION=$(get_canonical_configuration "${GX_CONFIGURATION}") 1241 1242 if (( ${GX_DO_GENERATE} )) 1243 then 1244 do_generate 1245 call post_generate_hook 1246 1247 do_merge 1248 call post_merge_hook 1249 1250 report_merge_results 1251 elif (( ${GX_DO_GENERATE_XCODE} )) 1252 then 1253 do_subgenerate 1254 call post_generate_hook 1255 1256 do_merge 1257 call post_merge_hook 1258 1259 report_merge_results 1260 elif (( ${GX_DO_CHECK} )) 1261 then 1262 do_generate 1263 call post_generate_hook 1264 1265 do_check 1266 call post_check_hook 1267 1268 report_remediation_steps 1269 elif (( ${GX_DO_CHECK_XCODE} )) 1270 then 1271 do_subgenerate 1272 call post_generate_hook 1273 1274 do_check 1275 call post_check_hook 1276 1277 report_remediation_steps 1278 elif (( ${GX_DO_SUBGENERATE} )) 1279 then 1280 do_subgenerate 1281 else 1282 stderr "### No subcommand provided" 1283 usage 1284 my_exit 1 1285 fi 1286 1287 my_exit ${GX_DEFERRED_EXIT_CODE} 1288 } 1289 1290 1291 # Initialize and sanity check 1292 1293 GX_ORIG_ARGS=("$@") 1294 1295 GX_DO_GENERATE=0 1296 GX_DO_GENERATE_XCODE=0 1297 GX_DO_CHECK=0 1298 GX_DO_CHECK_XCODE=0 1299 GX_DO_SUBGENERATE=0 1300 GX_DO_HELP=0 1301 GX_DO_CLEANUP=0 1302 GX_USE_XCODE_BUILD_OUTPUT=0 1303 GX_USE_WEBKITBUILD_BUILD_OUTPUT=1 1304 GX_DRY_RUN=0 1305 GX_DEBUG=0 1306 GX_QUIET=0 1307 1308 GX_DEFERRED_EXIT_CODE=0 1309 GX_PROJECT_TAG= 1310 GX_PLATFORM_NAME= 1311 GX_CONFIGURATION= 1312 GX_SDKS=() 1313 1314 GX_ME=$(normalize_file_path "${BASH_SOURCE[0]}") 1315 GX_HERE=$(dirname "${GX_ME}") 1316 GX_ROOT_DIR=$(normalize_directory_path "${GX_HERE}/../../..") 1317 GX_OPENSOURCE_DIR="${GX_ROOT_DIR}/OpenSource" 1318 GX_TEMP=$(normalize_directory_path /tmp/generate-xcfilelists) 1319 GX_PROJECT_TAGS=(JavaScriptCore WebCore WebKit DumpRenderTree WebKitTestRunner) 1320 GX_CONFIGURATIONS=(Release Debug) 1321 GX_SUBEXECUTE_SCRIPT="${GX_ME}" 1322 1323 [[ -n "${GX_ROOT_DIR}" ]] || die "Could not find GX_ROOT_DIR." 1324 [[ -n "${GX_OPENSOURCE_DIR}" ]] || die "Could not find GX_OPENSOURCE_DIR." 1325 [[ -d "${GX_ROOT_DIR}" ]] || die "${GX_ROOT_DIR} does not exist." 1326 [[ -d "${GX_OPENSOURCE_DIR}" ]] || die "${GX_OPENSOURCE_DIR} does not exist." 1327 1328 trap cleanup EXIT 1329 1330 ensure_directories_exist "${GX_TEMP}" 434 1331 435 1332 436 1333 # Process command-line parameters. 437 438 ROOT_DIR="$(cd "${HERE}/../../.." && pwd -P)"439 OPENSOURCE_DIR="${ROOT_DIR}/OpenSource"440 [[ -n "${ROOT_DIR}" ]] || die "Could not find ROOT_DIR"441 [[ -n "${OPENSOURCE_DIR}" ]] || die "Could not find OPENSOURCE_DIR"442 [[ -e "${OPENSOURCE_DIR}" ]] || die "$OPENSOURCE_DIR does not exist"443 444 DO_CHECK=0445 DEFERRED_EXIT_CODE=0446 1334 447 1335 while [[ "${1:+x}" ]] 448 1336 do 449 1337 case "${1}" in 450 --check) DO_CHECK=1; ;; 451 *) echo "### Unknown parameter: ${1}"; exit 1; ;; 1338 generate) GX_DO_GENERATE=1 ;; 1339 generate-xcode) GX_DO_GENERATE_XCODE=1 ;; 1340 check) GX_DO_CHECK=1 ;; 1341 check-xcode) GX_DO_CHECK_XCODE=1 ;; 1342 subgenerate) GX_DO_SUBGENERATE=1 ;; 1343 help) GX_DO_HELP=1 ;; 1344 1345 --project) shift; GX_PROJECT_TAG="$1" ;; 1346 --platform) shift; GX_PLATFORM_NAME="$1" ;; 1347 --configuration)shift; GX_CONFIGURATION="$1" ;; 1348 --xcode) GX_USE_XCODE_BUILD_OUTPUT=1; GX_USE_WEBKITBUILD_BUILD_OUTPUT=0 ;; 1349 --webkitbuild) GX_USE_XCODE_BUILD_OUTPUT=0; GX_USE_WEBKITBUILD_BUILD_OUTPUT=1 ;; 1350 --nocleanup) GX_DO_CLEANUP=0 ;; 1351 1352 -n | --dry-run) GX_DRY_RUN=1 ;; 1353 -d | --debug) GX_DEBUG=$(( $GX_DEBUG + 1 )) ;; 1354 -q | --quiet) GX_QUIET=1 ;; 1355 -h | --help) GX_DO_HELP=1 ;; 1356 1357 *) stderr "### Unknown command: $1" 1358 usage 1359 my_exit 1 ;; 452 1360 esac 453 1361 shift 454 1362 done 455 1363 456 generate_xcfilelists_from_derivedsources JavaScriptCore 457 generate_xcfilelists_from_derivedsources WebCore 458 generate_xcfilelists_from_derivedsources WebKit 459 generate_xcfilelists_from_derivedsources DumpRenderTree 460 generate_xcfilelists_from_derivedsources WebKitTestRunner 461 462 generate_xcfilelists_from_unifiedsources JavaScriptCore 463 generate_xcfilelists_from_unifiedsources WebCore 464 generate_xcfilelists_from_unifiedsources WebKit 465 466 467 SOURCED=$([[ "$0" == "${BASH_SOURCE[@]}" ]] && echo 0 || echo 1) 468 if (( ! $SOURCED )) 1364 1365 GX_SOURCED=$([[ "$0" == "${BASH_SOURCE[@]}" ]] && echo 0 || echo 1) 1366 if (( ! ${GX_SOURCED} )) 469 1367 then 470 exit ${DEFERRED_EXIT_CODE} 1368 GX_INTERNAL_ME="${GX_ROOT_DIR}/Internal/Tools/Scripts/generate-xcfilelists" 1369 if [[ -x "${GX_INTERNAL_ME}" ]] 1370 then 1371 "${GX_INTERNAL_ME}" "${GX_ORIG_ARGS[@]}" 1372 else 1373 main 1374 fi 471 1375 fi 472
Note: See TracChangeset
for help on using the changeset viewer.