summaryrefslogtreecommitdiff
path: root/hack/graphql_to_header.py
diff options
context:
space:
mode:
authorGravatar Anshul Gupta <ansg191@anshulg.com> 2025-04-09 13:24:53 -0700
committerGravatar Anshul Gupta <ansg191@anshulg.com> 2025-04-11 00:15:18 -0700
commitf277f41d83d450a1f28d350bb7d6da075d1d2741 (patch)
treee197a7de7e26b47cec57a46acdde4b6c74889ad5 /hack/graphql_to_header.py
downloadgithub-mirror-f277f41d83d450a1f28d350bb7d6da075d1d2741.tar.gz
github-mirror-f277f41d83d450a1f28d350bb7d6da075d1d2741.tar.zst
github-mirror-f277f41d83d450a1f28d350bb7d6da075d1d2741.zip
Initial Commit
Add cmake github workflow Install dependencies in gh action Fix missing directory Fix compiler errors Fix group name to gid conversion Force cjson to statically link Add header guards to query headers Add install and cpack to CMakeLists.txt Add config search and CLI arg parsing Improve docs for git.c Fix program continuing on -h flag
Diffstat (limited to 'hack/graphql_to_header.py')
-rw-r--r--hack/graphql_to_header.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/hack/graphql_to_header.py b/hack/graphql_to_header.py
new file mode 100644
index 0000000..da0107d
--- /dev/null
+++ b/hack/graphql_to_header.py
@@ -0,0 +1,26 @@
+import sys
+from pathlib import Path
+
+input_path = Path(sys.argv[1])
+output_path = Path(sys.argv[2])
+var_name = sys.argv[3]
+
+with input_path.open() as f:
+ lines = f.readlines()
+
+with output_path.open("w") as f:
+ f.write(
+ f'''#ifndef QUERIES_{var_name.upper()}_H
+#define QUERIES_{var_name.upper()}_H
+
+'''
+ )
+ f.write(f'const char *{var_name} =\n')
+ for line in lines:
+ escaped = line.rstrip('\n').replace('\\', '\\\\').replace('"', '\\"')
+ f.write(f' "{escaped}\\n"\n')
+ f.write(';\n')
+ f.write(
+ f'''
+#endif // QUERIES_{var_name.upper()}_H
+''')