-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Made xcode_backend stop on error. #50664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Made xcode_backend stop on error. #50664
Conversation
cbracken
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to test with various settings of ARCH but if that looks good, lgtm modulo nits.
| # found in the LICENSE file. | ||
|
|
||
| # Exit on error | ||
| set -e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you verified that no valid code paths currently return non-zero? I remember filing a bug at one point wanting to add set -e to this script but needing to hold off. If we’re lucky, I documented the known cases on that issue. (No promises!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only one I could get to hit was the plistbuddy error, that's why I pulled that out to check for the presence before extraction.
| } | ||
|
|
||
| PlistHasField() { | ||
| if /usr/libexec/PlistBuddy -c "Print :$1" $2 1>/dev/null 2>/dev/null; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to use CMD > /dev/null 2>&1 for this check.
Here and elsewhere: Since this is bash consider using a double-square bracket test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the redirect, I don't think double bracket is what I want here since I'm checking the return code of the process.
|
\cc @jonahwilliams |
| assets_path="${FLTAssetsPath}" | ||
| # The value of assets_path can set by add FLTAssetsPath to | ||
| # AppFrameworkInfo.plist. | ||
| if PlistHasField "FLTAssetsPath" "${derived_dir}/AppFrameworkInfo.plist"; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be implemented in bash? Could it be something in the tool build instead?
jonahwilliams
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not add more logic to xcode_backend.sh if possible
| if PlistHasField "FLTAssetsPath" "${derived_dir}/AppFrameworkInfo.plist"; then | ||
| FLTAssetsPath=$(/usr/libexec/PlistBuddy -c "Print :FLTAssetsPath" "${derived_dir}/AppFrameworkInfo.plist" 2>/dev/null) | ||
| if [[ -n "$FLTAssetsPath" ]]; then | ||
| assets_path="${FLTAssetsPath}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This setting was never tested and regressed sometime in the past few months. Moving the asset override into Dart will let us cover it with a unit test at least.
Something here: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/build_system/targets/ios.dart#L286
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support that. In the meantime this just added error checking to the whole script. Check out the delta now, hardly touched it.
The function has been removed. Accomplished the same thing with checking the return status. |
jmagman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked out this branch, built Debug, Profile, Release, and archiving. Didn't see any errors.
jmagman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually what about line 185?
if [[ $? -ne 0 ]]; then
EchoError "Failed to package ${project_path}."
exit -1
fi
The "RunCommand" function messes it up. I had removed that one, but if it errors out it is going to halt at line line 13. I suspect the message "Failed to package $(project_path)" isn't all that useful considering the text that will be generated by the command failing. The 'exit -1' isn't an issue because we will halt when we get an error anyway. |
|
I thought of getting rid of "RunCommand" and using "-x" instead, but I tried to keep the change smaller. |
Can you remove the Failed to package $(project_path)" part since it's dead code? |
|
I could introduce: TestCommand() {
if [[ -n "$VERBOSE_SCRIPT_LOGGING" ]]; then
echo "♦ $*"
fi
if "$@"; then
return 0
else
return 1
fi
}but there was some resistance to adding more logic to the script. |
Honestly, I think we could implement almost this entire script in Dart. We need to keep the script itself forever, for backward compatibility with existing projects that invoke it in build phases, but we could probably make it a ~one-line script that just invokes the |
|
Right, long-term there are two different directions we can make improvements:
|
Description
Started trying to make xcode_backend.sh abort execution earlier if it runs into an error so that users will be reporting more apropos problems instead of linker errors.
Related Issues
#32454
Tests
Just manual testing.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.