forked from colemickens/platform2-sommelier
-
Notifications
You must be signed in to change notification settings - Fork 3
/
wayland_protocol.gni
63 lines (60 loc) · 1.65 KB
/
wayland_protocol.gni
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# GN template to generate static library for given Wayland protorol description files.
# Parameters:
# sources
# Wayland protocol description XML file paths.
# out_dir (optional)
# Directory to output generated source files. Relative to gen/ directory.
template("wayland_protocol_library") {
forward_variables_from(invoker, [ "out_dir" ])
if (!defined(out_dir)) {
out_dir = "."
}
wayland_dir = "${root_gen_dir}/${out_dir}"
generators = [
{
subcommand = "code"
output_suffix = "-protocol.c"
},
{
subcommand = "client-header"
output_suffix = "-client-protocol.h"
},
{
subcommand = "server-header"
output_suffix = "-server-protocol.h"
},
]
generator_actions = []
foreach(g, generators) {
action_name = "${target_name}_${g.subcommand}"
generator_actions += [ ":" + action_name ]
action_foreach(action_name) {
sources = invoker.sources
script = "//common-mk/file_generator_wrapper.py"
output_file = "${wayland_dir}/{{source_name_part}}${g.output_suffix}"
outputs = [ output_file ]
args = [
"wayland-scanner",
g.subcommand,
"{{source}}",
output_file,
]
}
}
static_library(target_name) {
if (defined(invoker.configs)) {
configs += invoker.configs
}
deps = generator_actions
sources = []
foreach(t, deps) {
sources += get_target_outputs(t)
}
if (defined(invoker.deps)) {
deps += invoker.deps
}
}
}