-
Notifications
You must be signed in to change notification settings - Fork 0
/
wayland-protocols.bzl
45 lines (38 loc) · 1.27 KB
/
wayland-protocols.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# use `wayland-scanner` to generate files for wayland support
# FIXME: more robust way of finding the `wayland-scanner` binary
def _gen_variables(protocols):
srcs = []
outs = []
cmds = []
for obj in protocols:
client_header_out = "{}.h".format(obj['stem'])
private_code_out = "{}-code.h".format(obj['stem'])
src = obj['base'] + '/' + obj['name']
srcs += [src]
outs += [client_header_out, private_code_out]
cmd = "wayland-scanner {} {} $(RULEDIR)/{}"
cmds += [cmd.format('client-header', src, client_header_out)]
cmds += [cmd.format('private-code', src, private_code_out)]
return srcs, outs, cmds
def _wayland_generate_protocols(name, protocols, **kwargs):
srcs, outs, cmds = _gen_variables(protocols)
native.genrule(
name = name,
#srcs = srcs,
outs = outs,
cmd = ' && '.join(cmds),
**kwargs
)
def wayland_generate_protocols(name, protocols, **kwargs):
_, outs, _ = _gen_variables(protocols)
_wayland_generate_protocols(
name = '_' + name,
protocols = protocols,
)
native.cc_library(
name = name,
hdrs = outs,
include_prefix = '.',
visibility = ['//visibility:public'],
**kwargs
)