File: wayland_protocol.gni

package info (click to toggle)
qt6-webengine 6.4.2-final%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,090,536 kB
  • sloc: cpp: 17,808,031; ansic: 5,245,139; javascript: 3,178,881; python: 1,361,176; asm: 648,577; xml: 571,140; java: 196,952; sh: 96,408; objc: 88,289; perl: 70,982; cs: 39,145; fortran: 24,137; makefile: 20,242; pascal: 12,634; sql: 10,875; yacc: 9,671; tcl: 8,385; php: 6,188; lisp: 2,848; lex: 2,263; ada: 727; ruby: 623; awk: 339; sed: 37
file content (94 lines) | stat: -rw-r--r-- 2,675 bytes parent folder | download | duplicates (5)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Template to generate wayland protocol code with wayland-scanner.
#
# Example:
#  wayland_protocol("foo") {
#    sources = [ "foo.xml" ]
#  }

import("//third_party/wayland/features.gni")

template("wayland_protocol") {
  assert(defined(invoker.sources), "Need sources for wayland protocol")

  # Calculate the output paths.
  protocol_outputs = []
  output_dirs = []
  foreach(protocol, invoker.sources) {
    dir = "$root_gen_dir/" + rebase_path(get_path_info(protocol, "dir"), "//")
    name = get_path_info(protocol, "name")
    protocol_outputs += [
      "${dir}/${name}-protocol.c",
      "${dir}/${name}-client-protocol.h",
      "${dir}/${name}-server-protocol.h",
    ]
    output_dirs += [ dir ]
  }

  action_name = "${target_name}_gen"
  config_name = "${target_name}_config"
  source_set_name = "${target_name}"

  # Action which runs wayland-scanner to generate the code.
  action(action_name) {
    visibility = [ ":$source_set_name" ]
    script = "//third_party/wayland/wayland_scanner_wrapper.py"
    sources = invoker.sources
    outputs = protocol_outputs

    # Paths in invoker.sources are relative to the invoker.
    # Make it relative to the src root.
    args = rebase_path(invoker.sources, "//")

    args += [
      "--src-root",
      rebase_path("//", root_build_dir),
    ]
    args += [
      "--root-gen-dir",
      rebase_path(root_gen_dir, root_build_dir),
    ]

    if (use_system_wayland_scanner) {
      args += [
        "--cmd",
        system_wayland_scanner_path,
      ]
    } else {
      wayland_scanner_label =
          "//third_party/wayland:wayland_scanner($host_toolchain)"
      deps = [ wayland_scanner_label ]
      wayland_scanner_path = get_label_info(wayland_scanner_label,
                                            "root_out_dir") + "/wayland_scanner"
      cmd = "./" + rebase_path(wayland_scanner_path, root_build_dir)
      args += [
        "--cmd",
        cmd,
      ]
    }
  }

  # Config to include the generated headers only with the file names.
  # e.g. #include <foo-client-protocol.h>
  config(config_name) {
    include_dirs = output_dirs
  }

  # Source set which consists of the generated code.
  source_set(source_set_name) {
    sources = get_target_outputs(":$action_name")

    deps = [
      ":$action_name",
      "//third_party/wayland:wayland_util",
    ]

    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]

    public_configs = [ ":$config_name" ]
  }
}