mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2025-12-29 11:20:08 +01:00
src: pass the headerfile as jinja extra data
This removes another special handling of the C bindings from the scanner.
This commit is contained in:
parent
d127f02f0a
commit
c350ac2ee3
3 changed files with 8 additions and 10 deletions
|
|
@ -84,7 +84,8 @@ ei_proto_headers = custom_target('ei-proto-headers',
|
|||
ei_proto_sources = custom_target('ei-proto-sources',
|
||||
input: protocol_xml,
|
||||
output: ['ei-proto.c'],
|
||||
command: [scanner, '--component=ei', '--output=@OUTPUT@', '@INPUT@', proto_c_template])
|
||||
command: [scanner, '--component=ei', '--output=@OUTPUT@', '@INPUT@',
|
||||
'--jinja-extra-data={"headerfile": "ei-proto.h"}', proto_c_template])
|
||||
src_libei = files(
|
||||
'src/brei-shared.c',
|
||||
'src/libei.c',
|
||||
|
|
@ -137,7 +138,8 @@ eis_proto_headers = custom_target('eis-proto-headers',
|
|||
eis_proto_sources = custom_target('eis-proto-sources',
|
||||
input: protocol_xml,
|
||||
output: ['eis-proto.c'],
|
||||
command: [scanner, '--component=eis', '--output=@OUTPUT@', '@INPUT@', proto_c_template])
|
||||
command: [scanner, '--component=eis', '--output=@OUTPUT@', '@INPUT@',
|
||||
'--jinja-extra-data={"headerfile": "eis-proto.h"}', proto_c_template])
|
||||
|
||||
src_libeis = files(
|
||||
'src/brei-shared.c',
|
||||
|
|
|
|||
|
|
@ -738,7 +738,7 @@ def parse(protofile: Path, component: str) -> Protocol:
|
|||
|
||||
|
||||
def generate_source(
|
||||
proto: Protocol, headerfile: Optional[str], template: Path, component: str, extra_data: Optional[dict]
|
||||
proto: Protocol, template: Path, component: str, extra_data: Optional[dict]
|
||||
) -> jinja2.environment.TemplateStream:
|
||||
assert component in ["ei", "eis", "brei"]
|
||||
|
||||
|
|
@ -746,8 +746,6 @@ def generate_source(
|
|||
data["component"] = component
|
||||
data["interfaces"] = proto.interfaces
|
||||
data["extra"] = extra_data
|
||||
if headerfile:
|
||||
data["headerfile"] = headerfile
|
||||
|
||||
env = jinja2.Environment(
|
||||
loader=jinja2.FileSystemLoader(os.fspath(template.parent)),
|
||||
|
|
@ -848,8 +846,6 @@ def main() -> None:
|
|||
print(f"Protocol XML error: {e}", file=sys.stderr)
|
||||
raise SystemExit(1)
|
||||
|
||||
headerfile = f"{Path(ns.output).stem}.h" if ns.output != "-" else None
|
||||
|
||||
if ns.jinja_extra_data is not None:
|
||||
import json
|
||||
|
||||
|
|
@ -874,7 +870,7 @@ def main() -> None:
|
|||
extra_data = None
|
||||
|
||||
stream = generate_source(
|
||||
proto=proto, headerfile=headerfile, template=ns.template, component=ns.component, extra_data=extra_data
|
||||
proto=proto, template=ns.template, component=ns.component, extra_data=extra_data
|
||||
)
|
||||
|
||||
file = sys.stdout if ns.output == "-" else open(ns.output, "w")
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@
|
|||
#include "brei-shared.h"
|
||||
#include "brei-proto.h"
|
||||
|
||||
{% if headerfile %}
|
||||
#include "{{headerfile}}"
|
||||
{% if extra.headerfile %}
|
||||
#include "{{extra.headerfile}}"
|
||||
{% endif %}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue