[libc-commits] [libc] [libc] Add some integration features into newhdrgen (PR #114272)

via libc-commits libc-commits at lists.llvm.org
Wed Oct 30 10:22:39 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {darker}-->


:warning: Python code formatter, darker found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
darker --check --diff -r 5192cb772ad58af4b557539791ff8de60ab450a3...0e5a892f3a3e3dc9d77695cf7f3a4c9a08702aba libc/newhdrgen/yaml_to_classes.py
``````````

</details>

<details>
<summary>
View the diff from darker here.
</summary>

``````````diff
--- yaml_to_classes.py	2024-10-30 17:17:11.000000 +0000
+++ yaml_to_classes.py	2024-10-30 17:22:05.940222 +0000
@@ -236,11 +236,11 @@
     )
     parser.add_argument(
         "--libc-dir",
         help="Path to llvm-libc source tree",
         type=Path,
-        default=Path(__file__).parents[1]
+        default=Path(__file__).parents[1],
     )
     parser.add_argument(
         "--depfile",
         help="Path to write a depfile",
         type=argparse.FileType("w"),
@@ -272,30 +272,37 @@
         help="Flag to use GpuHeader for exporting declarations",
     )
     args = parser.parse_args()
 
     def write_to_file(path, contents):
-        if not args.write_if_changed or not path.exists() or path.read_text() != contents:
+        if (
+            not args.write_if_changed
+            or not path.exists()
+            or path.read_text() != contents
+        ):
             path.write_text(contents)
 
     if args.h_def_file and not args.yaml_file:
         libc_include_dir = args.libc_dir / "include"
         libc_yaml_dir = args.libc_dir / "newhdrgen" / "yaml"
-        args.yaml_file = libc_yaml_dir / args.h_def_file.with_suffix("").with_suffix(".yaml").relative_to(libc_include_dir)
+        args.yaml_file = libc_yaml_dir / args.h_def_file.with_suffix("").with_suffix(
+            ".yaml"
+        ).relative_to(libc_include_dir)
 
     if args.output_dir:
         output_file_path = args.output_dir
         if output_file_path.is_dir():
             libc_yaml_dir = args.libc_dir / "newhdrgen" / "yaml"
-            output_file_path /= args.yaml_file.relative_to(libc_yaml_dir).with_suffix(".h")
+            output_file_path /= args.yaml_file.relative_to(libc_yaml_dir).with_suffix(
+                ".h"
+            )
             output_file_path.parent.mkdir(parents=True, exist_ok=True)
     else:
         output_file_path = args.yaml_file.with_suffix(".h")
 
     if args.depfile and args.h_def_file:
-        args.depfile.write(
-            f"{output_file_path}: {args.h_def_file} {args.yaml_file}\n")
+        args.depfile.write(f"{output_file_path}: {args.h_def_file} {args.yaml_file}\n")
         args.depfile.close()
 
     if args.add_function:
         add_function_to_yaml(yaml_file, args.add_function)
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/114272


More information about the libc-commits mailing list