Bug 236995 - Use ArgumentParser for parsing args in generate-compile-commands
Summary: Use ArgumentParser for parsing args in generate-compile-commands
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-21 13:46 PST by Brandon
Modified: 2022-02-21 22:45 PST (History)
3 users (show)

See Also:


Attachments
Patch (1.81 KB, patch)
2022-02-21 13:49 PST, Brandon
no flags Details | Formatted Diff | Diff
Patch (1.97 KB, patch)
2022-02-21 19:38 PST, Brandon
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>