Bug 220080 - [Cocoa] Add a script to generate the "Feature Flags" plist file
Summary: [Cocoa] Add a script to generate the "Feature Flags" plist file
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Peng Liu
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-12-21 20:54 PST by Peng Liu
Modified: 2021-01-14 13:41 PST (History)
6 users (show)

See Also:


Attachments
Patch (20.26 KB, patch)
2020-12-21 21:19 PST, Peng Liu
dbates: review+
Details | Formatted Diff | Diff
Revise the patch based on Dan's comments (20.61 KB, patch)
2020-12-22 12:02 PST, Peng Liu
no flags Details | Formatted Diff | Diff
Patch for landing (21.68 KB, patch)
2021-01-14 10:44 PST, Peng Liu
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peng Liu 2020-12-21 20:54:19 PST
[Cocoa] Add a script to generate the "Feature Flags" plist file
Comment 1 Peng Liu 2020-12-21 21:19:42 PST
Created attachment 416652 [details]
Patch
Comment 2 Daniel Bates 2020-12-21 22:25:42 PST
Comment on attachment 416652 [details]
Patch

Didn't really look at this patch closely, but it jogged a memory: I think merging plists can be done with: "/usr/libexec/plistbuddy -c merge file2 : file1" or something like that, though it overwrites file1.
Comment 3 Daniel Bates 2020-12-21 22:26:58 PST
^^^ I think : not needed. I don't know. See man page,
Comment 4 Peng Liu 2020-12-21 22:33:44 PST
(In reply to Daniel Bates from comment #2)
> Comment on attachment 416652 [details]
> Patch
> 
> Didn't really look at this patch closely, but it jogged a memory: I think
> merging plists can be done with: "/usr/libexec/plistbuddy -c merge file2 :
> file1" or something like that, though it overwrites file1.

Yes, PlistBuddy supports merging two plists, but it skips duplicated keys.
Comment 5 Daniel Bates 2020-12-21 23:32:22 PST
Comment on attachment 416652 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=416652&action=review

> Source/WebKit/FeatureFlags/WebKit-ios.plist:60
> +    <key>WebGL2</key>

Ok as is, this key and 2 below don't seem to have same formatting.

> Source/WebKit/Scripts/generate-feature-flags-plist.sh:26
> +if [[ ${WK_PLATFORM_NAME} == "appletvos" ]]; then

Does this work for simulator, too? Same question apples to ios and watch.

> Source/WebKit/Scripts/generate-feature-flags-plist.sh:35
> +    exit 0;

This seems like a programmer error to reach. If so. consider emitting error message and exiting with non-zero return code. Error message should conform to special Xcode syntax to get nice GUI results:

error: Message.

 See <https://stackoverflow.com/questions/7239312/can-i-fully-customise-an-xcode-4-run-script-build-phase-error-warning-within-the> Etc etc.

> Source/WebKit/Scripts/generate-feature-flags-plist.sh:37
> +

Ok as is, consider adding "set -e" so that command failure below causes script to exit immediately.

> Source/WebKit/WebKit.xcodeproj/project.pbxproj:13099
> +				"$(INSTALL_ROOT)/$(WK_INSTALL_PATH_PREFIX)/$(SYSTEM_LIBRARY_DIR)/FeatureFlags/Domain/WebKit.plist",

Ok as is. Is this necessary?
Comment 6 Daniel Bates 2020-12-21 23:44:18 PST
Comment on attachment 416652 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=416652&action=review

Forgot to check Python...

> Source/WebKit/Scripts/combine-feature-flags-plist.py:32
> +        return 1

Ok as is. Consider emitting usage message.

> Source/WebKit/Scripts/combine-feature-flags-plist.py:40
> +        try:

Is this correct place for this? What about line above? Consider having script give precise error message when can't open each file. This will make it easier to debug if it fails.

> Source/WebKit/Scripts/combine-feature-flags-plist.py:45
> +                        return 1

Ok as is. Consider emitting error message to help debugging.

> Source/WebKit/Scripts/combine-feature-flags-plist.py:49
> +            pass

Ok as is. Consider emitting error message + exit with non-zero status, Use Xcode special format see earlier comment.
Comment 7 Daniel Bates 2020-12-21 23:45:24 PST
Comment on attachment 416652 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=416652&action=review

> Source/WebKit/Scripts/combine-feature-flags-plist.py:1
> +#!/usr/bin/env python

Is this correct for python3?
Comment 8 Daniel Bates 2020-12-21 23:45:32 PST
Comment on attachment 416652 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=416652&action=review

> Source/WebKit/Scripts/combine-feature-flags-plist.py:1
> +#!/usr/bin/env python

Is this correct for python3?
Comment 9 Peng Liu 2020-12-22 09:22:37 PST
(In reply to Daniel Bates from comment #8)
> Comment on attachment 416652 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=416652&action=review
> 
> > Source/WebKit/Scripts/combine-feature-flags-plist.py:1
> > +#!/usr/bin/env python
> 
> Is this correct for python3?

Since the shell script runs the python script using the interpreter explicitly, we can remove this line.
Comment 10 Peng Liu 2020-12-22 09:30:53 PST
Comment on attachment 416652 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=416652&action=review

>> Source/WebKit/Scripts/combine-feature-flags-plist.py:32
>> +        return 1
> 
> Ok as is. Consider emitting usage message.

Will fix it.

>> Source/WebKit/Scripts/combine-feature-flags-plist.py:40
>> +        try:
> 
> Is this correct place for this? What about line above? Consider having script give precise error message when can't open each file. This will make it easier to debug if it fails.

Agree, will fix it.

>> Source/WebKit/Scripts/generate-feature-flags-plist.sh:26
>> +if [[ ${WK_PLATFORM_NAME} == "appletvos" ]]; then
> 
> Does this work for simulator, too? Same question apples to ios and watch.

No, only supports the four platforms listed here.

>> Source/WebKit/Scripts/generate-feature-flags-plist.sh:35
>> +    exit 0;
> 
> This seems like a programmer error to reach. If so. consider emitting error message and exiting with non-zero return code. Error message should conform to special Xcode syntax to get nice GUI results:
> 
> error: Message.
> 
>  See <https://stackoverflow.com/questions/7239312/can-i-fully-customise-an-xcode-4-run-script-build-phase-error-warning-within-the> Etc etc.

This is the intended behavior. For simulators, we will ignore the plist file.

>> Source/WebKit/Scripts/generate-feature-flags-plist.sh:37
>> +
> 
> Ok as is, consider adding "set -e" so that command failure below causes script to exit immediately.

Good point, will fix it.

>> Source/WebKit/WebKit.xcodeproj/project.pbxproj:13099
>> +				"$(INSTALL_ROOT)/$(WK_INSTALL_PATH_PREFIX)/$(SYSTEM_LIBRARY_DIR)/FeatureFlags/Domain/WebKit.plist",
> 
> Ok as is. Is this necessary?

Yes, it was a mistake to use {} here.
Comment 11 Peng Liu 2020-12-22 09:33:50 PST
Daniel, thanks for the review!
By the way, what is the current guideline about adding python code? Does the code need to support both python 2 and 3?
Comment 12 Peng Liu 2020-12-22 12:02:29 PST
Created attachment 416679 [details]
Revise the patch based on Dan's comments
Comment 13 Peng Liu 2020-12-22 12:04:39 PST
Comment on attachment 416679 [details]
Revise the patch based on Dan's comments

This patch includes a Python3 script.
Comment 14 Daniel Bates 2020-12-22 18:40:02 PST
Comment on attachment 416679 [details]
Revise the patch based on Dan's comments

View in context: https://bugs.webkit.org/attachment.cgi?id=416679&action=review

> Source/WebKit/Scripts/combine-feature-flags-plist.py:1
> +#

Ok as-is. Sorry, I think I caused some confusion with my last review. Consider adding shebang line, but I think shebang line should be: #!/usr/bin/env python3

From <https://docs.python.org/3/using/unix.html>

Also consider making this script executable (maybe it is already - didn't look at raw diff) this way with ^^^ script can be run from command line directly...

> Source/WebKit/Scripts/generate-feature-flags-plist.sh:53
> +    python3 "${SRCROOT}/Scripts/combine-feature-flags-plist.py" "${WEBKIT_PLIST_DIR}/${WEBKIT_PLIST_FILE_NAME}" "${INTERNAL_WEBKIT_PLIST_DIR}/${WEBKIT_PLIST_FILE_NAME}" "${DEST_DIR}/WebKit.plist"

No need for explicit python3 interpreter call if add shebang ...
Comment 15 Radar WebKit Bug Importer 2020-12-28 20:55:14 PST
<rdar://problem/72715339>
Comment 16 Peng Liu 2021-01-14 10:44:43 PST
Created attachment 417633 [details]
Patch for landing
Comment 17 EWS 2021-01-14 13:40:59 PST
Committed r271498: <https://trac.webkit.org/changeset/271498>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 417633 [details].