Title: [243527] trunk/Tools
- Revision
- 243527
- Author
- [email protected]
- Date
- 2019-03-26 16:51:10 -0700 (Tue, 26 Mar 2019)
Log Message
Update the way generate-xcfilelists returns strings from functions
https://bugs.webkit.org/show_bug.cgi?id=195975
<rdar://problem/49040807>
Reviewed by Dean Jackson.
There are places where generate-xcfilelists executes assignments with
statements like:
FOO=$(some_function)
where "some_function" return a string by echoing it. E.g.
some_function()
{
echo "Hello, World"
}
This is a common idiom, but it has a problem if "some_function" needs
to call "exit" in an attempt to halt the entire script right then and
there. Since "some_function" is called inside of $(), it's being
executed in a sub-shell. Calling exit in that sub-shell simply exits
that shell; it doesn't not exit the outer shell in which the main part
of the script is still running. As such, the main script keeps
executing when the intent was for the script to halt.
The solution to this is to use a different idiom for returning
strings. The one we now is to pass in the name of the variable to
receive the string result:
some_function()
{
variable_name=$1
eval $variable_name ="Hello, World"
}
The call site now looks like
some_function FOO
Because there's no invocation of a sub-shell, some_function can now
call "exit" if it wants to, and the entire script will exit at that
point.
* Scripts/generate-xcfilelists:
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (243526 => 243527)
--- trunk/Tools/ChangeLog 2019-03-26 23:50:33 UTC (rev 243526)
+++ trunk/Tools/ChangeLog 2019-03-26 23:51:10 UTC (rev 243527)
@@ -1,3 +1,51 @@
+2019-03-26 Keith Rollin <[email protected]>
+
+ Update the way generate-xcfilelists returns strings from functions
+ https://bugs.webkit.org/show_bug.cgi?id=195975
+ <rdar://problem/49040807>
+
+ Reviewed by Dean Jackson.
+
+ There are places where generate-xcfilelists executes assignments with
+ statements like:
+
+ FOO=$(some_function)
+
+ where "some_function" return a string by echoing it. E.g.
+
+ some_function()
+ {
+ echo "Hello, World"
+ }
+
+ This is a common idiom, but it has a problem if "some_function" needs
+ to call "exit" in an attempt to halt the entire script right then and
+ there. Since "some_function" is called inside of $(), it's being
+ executed in a sub-shell. Calling exit in that sub-shell simply exits
+ that shell; it doesn't not exit the outer shell in which the main part
+ of the script is still running. As such, the main script keeps
+ executing when the intent was for the script to halt.
+
+ The solution to this is to use a different idiom for returning
+ strings. The one we now is to pass in the name of the variable to
+ receive the string result:
+
+ some_function()
+ {
+ variable_name=$1
+ eval $variable_name ="Hello, World"
+ }
+
+ The call site now looks like
+
+ some_function FOO
+
+ Because there's no invocation of a sub-shell, some_function can now
+ call "exit" if it wants to, and the entire script will exit at that
+ point.
+
+ * Scripts/generate-xcfilelists:
+
2019-03-26 Chris Dumez <[email protected]>
Add basic layout test coverage for File Picker on iOS
Modified: trunk/Tools/Scripts/generate-xcfilelists (243526 => 243527)
--- trunk/Tools/Scripts/generate-xcfilelists 2019-03-26 23:50:33 UTC (rev 243526)
+++ trunk/Tools/Scripts/generate-xcfilelists 2019-03-26 23:51:10 UTC (rev 243527)
@@ -607,13 +607,14 @@
log_callstack_and_parameters "$@"
local GX_PROVISIONAL_CONFIGURATION=$(echo "$1" | tr '[:upper:]' '[:lower:]')
+ local GX_RESULT=$2
- [[ "${GX_PROVISIONAL_CONFIGURATION}" == "" ]] && { echo ""; return; }
+ [[ "${GX_PROVISIONAL_CONFIGURATION}" == "" ]] && { eval $GX_RESULT=""; return; }
- [[ "${GX_PROVISIONAL_CONFIGURATION}" == "debug" ]] && { echo "Debug"; return; }
- [[ "${GX_PROVISIONAL_CONFIGURATION}" == "release" ]] && { echo "Release"; return; }
- [[ "${GX_PROVISIONAL_CONFIGURATION}" == "production" ]] && { echo "Production"; return; }
- [[ "${GX_PROVISIONAL_CONFIGURATION}" == "profiling" ]] && { echo "Profiling"; return; }
+ [[ "${GX_PROVISIONAL_CONFIGURATION}" == "debug" ]] && { eval $GX_RESULT="Debug"; return; }
+ [[ "${GX_PROVISIONAL_CONFIGURATION}" == "release" ]] && { eval $GX_RESULT="Release"; return; }
+ [[ "${GX_PROVISIONAL_CONFIGURATION}" == "production" ]] && { eval $GX_RESULT="Production"; return; }
+ [[ "${GX_PROVISIONAL_CONFIGURATION}" == "profiling" ]] && { eval $GX_RESULT="Profiling"; return; }
die "Unrecognized configuration: $1"
}
@@ -624,27 +625,28 @@
log_callstack_and_parameters "$@"
local GX_PROVISIONAL_PLATFORM_NAME=$(echo "$1" | tr '[:upper:]' '[:lower:]')
+ local GX_RESULT=$2
- [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "" ]] && { echo ""; return; }
+ [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "" ]] && { eval $GX_RESULT=""; return; }
- [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "ios" ]] && { echo "iphoneos"; return; }
- [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "iphone" ]] && { echo "iphoneos"; return; }
- [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "ipad" ]] && { echo "iphoneos"; return; }
- [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "iphoneos" ]] && { echo "iphoneos"; return; }
- [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "iphonesimulator" ]] && { echo "iphonesimulator"; return; }
+ [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "ios" ]] && { eval $GX_RESULT="iphoneos"; return; }
+ [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "iphone" ]] && { eval $GX_RESULT="iphoneos"; return; }
+ [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "ipad" ]] && { eval $GX_RESULT="iphoneos"; return; }
+ [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "iphoneos" ]] && { eval $GX_RESULT="iphoneos"; return; }
+ [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "iphonesimulator" ]] && { eval $GX_RESULT="iphonesimulator"; return; }
- [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "mac" ]] && { echo "macosx"; return; }
- [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "osx" ]] && { echo "macosx"; return; }
- [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "macos" ]] && { echo "macosx"; return; }
- [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "macosx" ]] && { echo "macosx"; return; }
+ [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "mac" ]] && { eval $GX_RESULT="macosx"; return; }
+ [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "osx" ]] && { eval $GX_RESULT="macosx"; return; }
+ [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "macos" ]] && { eval $GX_RESULT="macosx"; return; }
+ [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "macosx" ]] && { eval $GX_RESULT="macosx"; return; }
- [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "tvos" ]] && { echo "appletvos"; return; }
- [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "appletvos" ]] && { echo "appletvos"; return; }
- [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "tvsimulator" ]] && { echo "appletvsimulator"; return; }
- [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "appletvsimulator" ]] && { echo "appletvsimulator"; return; }
+ [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "tvos" ]] && { eval $GX_RESULT="appletvos"; return; }
+ [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "appletvos" ]] && { eval $GX_RESULT="appletvos"; return; }
+ [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "tvsimulator" ]] && { eval $GX_RESULT="appletvsimulator"; return; }
+ [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "appletvsimulator" ]] && { eval $GX_RESULT="appletvsimulator"; return; }
- [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "watchos" ]] && { echo "watchos"; return; }
- [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "watchsimulator" ]] && { echo "watchsimulator"; return; }
+ [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "watchos" ]] && { eval $GX_RESULT="watchos"; return; }
+ [[ "${GX_PROVISIONAL_PLATFORM_NAME}" == "watchsimulator" ]] && { eval $GX_RESULT="watchsimulator"; return; }
die "Unrecognized platform name: $1"
}
@@ -654,7 +656,9 @@
{
log_callstack_and_parameters "$@"
- local GX_SDK=$(get_canonical_platform_name "$1")
+ local GX_SDK=$1
+ local GX_RESULT=$2
+ get_canonical_platform_name "${GX_SDK}" GX_SDK
local GX_INTERNAL_SDK="${GX_SDK}.internal"
get_sdks
@@ -661,8 +665,8 @@
# Prefer an internal SDK if one exists.
- [[ " ${GX_SDKS[@]} " =~ " ${GX_INTERNAL_SDK} " ]] && { echo "${GX_INTERNAL_SDK}"; return; }
- [[ " ${GX_SDKS[@]} " =~ " ${GX_SDK} " ]] && { echo "${GX_SDK}"; return; }
+ [[ " ${GX_SDKS[@]} " =~ " ${GX_INTERNAL_SDK} " ]] && { eval $GX_RESULT="${GX_INTERNAL_SDK}"; return; }
+ [[ " ${GX_SDKS[@]} " =~ " ${GX_SDK} " ]] && { eval $GX_RESULT="${GX_SDK}"; return; }
die "Unsupported SDK: ${GX_SDK}."
}
@@ -844,7 +848,8 @@
(( ${GX_DEBUG} )) && { for n in $(seq $GX_DEBUG); do GX_ARGS+=("--debug"); done; }
(( ${GX_QUIET} )) && GX_ARGS+=("--quiet")
- local GX_SDK_NAME=$(get_sdk_name "${GX_PLATFORM_NAME}")
+ local GX_SDK_NAME
+ get_sdk_name "${GX_PLATFORM_NAME}" GX_SDK_NAME
log_debug "Sublaunching for: ${GX_PROJECT_TAG}/${GX_PLATFORM_NAME}/${GX_CONFIGURATION}"
@@ -1232,8 +1237,8 @@
fi
[[ -z "${GX_PROJECT_TAG}" || ( " ${GX_PROJECT_TAGS[@]} " =~ " ${GX_PROJECT_TAG} " ) ]] || { die "Unrecognized project: ${GX_PROJECT_TAG}"; }
- GX_PLATFORM_NAME=$(get_canonical_platform_name "${GX_PLATFORM_NAME}")
- GX_CONFIGURATION=$(get_canonical_configuration "${GX_CONFIGURATION}")
+ get_canonical_platform_name "${GX_PLATFORM_NAME}" GX_PLATFORM_NAME
+ get_canonical_configuration "${GX_CONFIGURATION}" GX_CONFIGURATION
if (( ${GX_DO_GENERATE} ))
then
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes