Bug 224880

Summary: [Python 3] Update gni-to-cmake.py
Product: WebKit Reporter: Don Olmstead <don.olmstead>
Component: Tools / TestsAssignee: Don Olmstead <don.olmstead>
Status: RESOLVED FIXED    
Severity: Normal CC: annulen, dino, ews-watchlist, graouts, gsnedders, gyuyoung.kim, jdarpinian, kbr, kondapallykalyan, ryuan.choi, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
ews-feeder: commit-queue-
Patch
none
Patch
none
Patch
none
Patch none

Description Don Olmstead 2021-04-21 10:56:26 PDT
...
Comment 1 Don Olmstead 2021-04-21 11:09:51 PDT
Created attachment 426715 [details]
Patch
Comment 2 EWS Watchlist 2021-04-21 11:10:52 PDT
Note that there are important steps to take when updating ANGLE. See https://trac.webkit.org/wiki/UpdatingANGLE
Comment 3 James Darpinian 2021-04-21 11:27:51 PDT
Comment on attachment 426715 [details]
Patch

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

Thanks for fixing for Python 3!

> Source/ThirdParty/ANGLE/gni-to-cmake.py:20
> +parser.add_argument('--prepend', default='', help='the path to prepend to each file name')

You'll need to update Tools/Scripts/update-angle which calls this script to use the new long form --prepend argument.

> Source/ThirdParty/ANGLE/gni-to-cmake.py:68
> +out.write('# ./gni-to-cmake.py {} {}'.format(args.gni, args.cmake))

I would prefer to keep this the way it was, with quoting/escaping, including all arguments instead of a subset, and without hardcoding the script name. Does it need tweaking for Python 3 or Windows? I guess the argument escaping isn't strictly correct for Windows cmd but I think that's OK.
Comment 4 Don Olmstead 2021-04-21 11:46:37 PDT
Created attachment 426721 [details]
Patch
Comment 5 Sam Sneddon [:gsnedders] 2021-04-21 11:49:38 PDT
Comment on attachment 426721 [details]
Patch

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

> Source/ThirdParty/ANGLE/gni-to-cmake.py:24
> +file = open(args.gni, 'rb').read().decode('utf-8')

file = open(args.gni, 'r', encoding="utf-8", newline="").read() would be better (or omit the newline if you're happy for them to be converted)

Better still would be using a context manager given Python 3 will warn when it GCs the unclosed file object.

> Source/ThirdParty/ANGLE/gni-to-cmake.py:65
> +out = open(args.cmake, 'w')

needs an explicit encoding=

also another file that needs closed
Comment 6 Don Olmstead 2021-04-21 12:05:51 PDT
Created attachment 426722 [details]
Patch

Making it more Pythonic
Comment 7 James Darpinian 2021-04-21 12:11:07 PDT
Comment on attachment 426722 [details]
Patch

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

> Source/ThirdParty/ANGLE/gni-to-cmake.py:68
> +        cmake.write('# "./gni-to-cmake.py" "{}" "{}"'.format(args.gni, args.cmake))

The name of the script is still hardcoded. Can you change it back to printing everything in sys.argv including argv[0], instead of hardcoding the script name and a fixed list of arguments?
Comment 8 Don Olmstead 2021-04-21 12:17:35 PDT
Created attachment 426725 [details]
Patch
Comment 9 James Darpinian 2021-04-21 12:21:50 PDT
Comment on attachment 426725 [details]
Patch

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

Thanks, looks good! I'm not a reviewer so someone else will have to r+.

> Source/ThirdParty/ANGLE/D3D.cmake:2
> +# "./gni-to-cmake.py" "src/libANGLE/renderer/d3d/BUILD.gn" "D3D.cmake" --prepend "D3D.cmake"

Rerun the script to fix this line.
Comment 10 Don Olmstead 2021-04-21 12:27:37 PDT
Created attachment 426729 [details]
Patch
Comment 11 Kenneth Russell 2021-04-21 12:33:18 PDT
Comment on attachment 426729 [details]
Patch

r+ mostly on jdarpinian's thorough review - also looks fine per quick scan.
Comment 12 EWS 2021-04-21 14:13:49 PDT
Committed r276390 (236865@main): <https://commits.webkit.org/236865@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 426729 [details].
Comment 13 Radar WebKit Bug Importer 2021-04-22 18:00:56 PDT
<rdar://problem/77048391>