aboutsummaryrefslogtreecommitdiff
path: root/bindgen
diff options
context:
space:
mode:
Diffstat (limited to 'bindgen')
-rw-r--r--bindgen/gen_ir.py5
-rw-r--r--bindgen/gen_odin.py3
-rw-r--r--bindgen/gen_zig.py7
3 files changed, 12 insertions, 3 deletions
diff --git a/bindgen/gen_ir.py b/bindgen/gen_ir.py
index 3b3947e4..cbeea3e8 100644
--- a/bindgen/gen_ir.py
+++ b/bindgen/gen_ir.py
@@ -1,7 +1,7 @@
#-------------------------------------------------------------------------------
# Generate an intermediate representation of a clang AST dump.
#-------------------------------------------------------------------------------
-import json, sys, subprocess
+import re, json, sys, subprocess
def is_api_decl(decl, prefix):
if 'name' in decl:
@@ -136,6 +136,9 @@ def gen(header_path, source_path, module, main_prefix, dep_prefixes, with_commen
outp['decls'] = []
with open(header_path, 'r') as f:
source = f.read()
+ first_comment = re.search(r"/\*(.*?)\*/", source, re.S).group(1)
+ if first_comment and "Project URL" in first_comment:
+ outp['comment'] = first_comment
for decl in inp['inner']:
is_dep = is_dep_decl(decl, dep_prefixes)
if is_api_decl(decl, main_prefix) or is_dep:
diff --git a/bindgen/gen_odin.py b/bindgen/gen_odin.py
index 8d4588f9..42d58705 100644
--- a/bindgen/gen_odin.py
+++ b/bindgen/gen_odin.py
@@ -509,6 +509,9 @@ def gen_module(inp, c_prefix, dep_prefixes):
l('// machine generated, do not edit')
l('')
l(f"package sokol_{inp['module']}")
+ if inp.get('comment'):
+ l('')
+ c(inp['comment'])
gen_imports(dep_prefixes)
gen_helpers(inp)
prefix = inp['prefix']
diff --git a/bindgen/gen_zig.py b/bindgen/gen_zig.py
index 446585e4..f90e53ec 100644
--- a/bindgen/gen_zig.py
+++ b/bindgen/gen_zig.py
@@ -126,10 +126,10 @@ def l(s):
global out_lines
out_lines += s + '\n'
-def c(s, indent=""):
+def c(s, indent="", comment="///"):
if not s:
return
- prefix = f"{indent}///"
+ prefix = f"{indent}{comment}"
for line in textwrap.dedent(s).splitlines():
l(f"{prefix} {line}" if line else prefix )
@@ -554,6 +554,9 @@ def gen_helpers(inp):
def gen_module(inp, dep_prefixes):
l('// machine generated, do not edit')
+ if inp.get('comment'):
+ l('')
+ c(inp['comment'], comment="//")
l('')
gen_imports(inp, dep_prefixes)
gen_helpers(inp)