Bug 236995

Summary: Use ArgumentParser for parsing args in generate-compile-commands
Product: WebKit Reporter: Brandon <brandonstewart>
Component: Tools / TestsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, emw, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Brandon 2022-02-21 13:46:00 PST
Use ArgumentParser for parsing args in generate-compile-commands
Comment 1 Brandon 2022-02-21 13:49:05 PST
Created attachment 452771 [details]
Patch
Comment 2 Alexey Proskuryakov 2022-02-21 14:12:51 PST
Comment on attachment 452771 [details]
Patch

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

> Tools/Scripts/generate-compile-commands:39
> +parser = argparse.ArgumentParser(description='Generate compile_commands.json', usage='generate-compile-commands WebKitBuild/Release')

Can/should this say something about how it's used overall, via `make EXPORT_COMPILE_COMMANDS=YES`? I've been following this project relatively closely, and yet I'm not sure how to set up code completion in BBEdit using this.

Or maybe there could be a wiki page, linked from here.

> Tools/Scripts/generate-compile-commands:40
> +parser.add_argument('built_products_dir', help='path to the build directory containing generated compile commands (ex: WebKitBuild/Release)')

This seems like it should be required=True
Comment 3 Elliott Williams 2022-02-21 17:36:57 PST
LGTM!

(In reply to Alexey Proskuryakov from comment #2)
> 
> > Tools/Scripts/generate-compile-commands:40
> > +parser.add_argument('built_products_dir', help='path to the build directory containing generated compile commands (ex: WebKitBuild/Release)')
> 
> This seems like it should be required=True

Positional arguments are `required` by default, so it should be fine as-is.
Comment 4 Brandon 2022-02-21 18:38:03 PST
(In reply to Alexey Proskuryakov from comment #2)
> Comment on attachment 452771 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=452771&action=review
> 
> > Tools/Scripts/generate-compile-commands:39
> > +parser = argparse.ArgumentParser(description='Generate compile_commands.json', usage='generate-compile-commands WebKitBuild/Release')
> 
> Can/should this say something about how it's used overall, via `make
> EXPORT_COMPILE_COMMANDS=YES`? I've been following this project relatively
> closely, and yet I'm not sure how to set up code completion in BBEdit using
> this.
> 
> Or maybe there could be a wiki page, linked from here.
> 

Created a page on trac on how to setup clangd.
https://trac.webkit.org/wiki/Clangd

It may be useful to link to the trac page in this command.

> > Tools/Scripts/generate-compile-commands:40
> > +parser.add_argument('built_products_dir', help='path to the build directory containing generated compile commands (ex: WebKitBuild/Release)')
> 
> This seems like it should be required=True

If you call generate-compile-comamnds without an argument it will throw an error with a description on how to use it.

> generate-compile-commands
usage: generate-compile-commands WebKitBuild/Release
generate-compile-commands: error: the following arguments are required: built_products_dir
Comment 5 Brandon 2022-02-21 19:38:27 PST
Created attachment 452817 [details]
Patch
Comment 6 Brandon 2022-02-21 19:39:15 PST
Added better documentation on usage

> generate-compile-commands -h
usage:
                  make r EXPORT_COMPILE_COMMANDS=YES
                  generate-compile-commands WebKitBuild/Release

                  https://trac.webkit.org/wiki/Clangd


Generate compile_commands.json

positional arguments:
  built_products_dir  path to the build directory containing generated compile commands (ex:
                      WebKitBuild/Release)

optional arguments:
  -h, --help          show this help message and exit
Comment 7 EWS 2022-02-21 22:44:52 PST
Committed r290289 (247613@main): <https://commits.webkit.org/247613@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 452817 [details].
Comment 8 Radar WebKit Bug Importer 2022-02-21 22:45:21 PST
<rdar://problem/89276925>