Title: [290289] trunk/Tools
Revision
290289
Author
commit-qu...@webkit.org
Date
2022-02-21 22:43:37 -0800 (Mon, 21 Feb 2022)

Log Message

Use ArgumentParser for parsing args in generate-compile-commands
https://bugs.webkit.org/show_bug.cgi?id=236995

Patch by Brandon Stewart <brandonstew...@apple.com> on 2022-02-21
Reviewed by Alexey Proskuryakov.

Use argument parser instead of sys.argv[1] for getting build dir.

* Scripts/generate-compile-commands:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (290288 => 290289)


--- trunk/Tools/ChangeLog	2022-02-22 04:57:51 UTC (rev 290288)
+++ trunk/Tools/ChangeLog	2022-02-22 06:43:37 UTC (rev 290289)
@@ -1,3 +1,14 @@
+2022-02-21  Brandon Stewart  <brandonstew...@apple.com>
+
+        Use ArgumentParser for parsing args in generate-compile-commands
+        https://bugs.webkit.org/show_bug.cgi?id=236995
+
+        Reviewed by Alexey Proskuryakov.
+
+        Use argument parser instead of sys.argv[1] for getting build dir.
+
+        * Scripts/generate-compile-commands:
+
 2022-02-21  Wenson Hsieh  <wenson_hs...@apple.com>
 
         [iOS] Adjust some behaviors around the "Markup Image" action in the callout bar

Modified: trunk/Tools/Scripts/generate-compile-commands (290288 => 290289)


--- trunk/Tools/Scripts/generate-compile-commands	2022-02-22 04:57:51 UTC (rev 290288)
+++ trunk/Tools/Scripts/generate-compile-commands	2022-02-22 06:43:37 UTC (rev 290289)
@@ -33,7 +33,20 @@
 import sys
 import glob
 import json
+import argparse
 
+# Get command line args
+parser = argparse.ArgumentParser(description='Generate compile_commands.json', 
+            usage="""
+                  make r EXPORT_COMPILE_COMMANDS=YES
+                  generate-compile-commands WebKitBuild/Release
+
+                  https://trac.webkit.org/wiki/Clangd
+                  """)
+
+parser.add_argument('built_products_dir', help='path to the build directory containing generated compile commands (ex: WebKitBuild/Release)')
+opts = parser.parse_args()
+
 # Change to the root of WebKit Directory
 file_dir = os.path.dirname(os.path.realpath(__file__))
 base_dir = file_dir + "/../../"
@@ -40,7 +53,7 @@
 os.chdir(base_dir)
 
 # Check compile_commands folder exists
-compile_commands_dir = sys.argv[1] + "/compile_commands/"
+compile_commands_dir = opts.built_products_dir + "/compile_commands/"
 
 if not os.path.exists(compile_commands_dir):
     print("Please specify the build directory with compile_commands.")
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to