• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1load("//bazel:macros.bzl", "go_binary", "go_library", "py_binary")
2
3go_library(
4    name = "interface_lib",
5    srcs = [
6        "gen_interface.go",
7        "templates.go",
8    ],
9    importpath = "go.skia.org/skia/tools/gpu/gl/interface",
10    visibility = ["//visibility:private"],
11    deps = ["@com_github_flynn_json5//:json5"],
12)
13
14go_binary(
15    name = "interface",
16    embed = [":interface_lib"],
17    visibility = ["//visibility:public"],
18)
19
20_GENERATE_INTERFACE = """
21import os
22import subprocess
23import sys
24
25# Change into the Skia root directory
26# https://bazel.build/docs/user-manual#running-executables
27# Note: Bazel eats single quotes, so we must use double quotes.
28os.chdir(os.environ["BUILD_WORKSPACE_DIRECTORY"])
29
30# execpath returns the path to the given label relative to the Skia root.
31# https://bazel.build/reference/be/make-variables#predefined_label_variables
32gen_interface_exe = "$(execpath :interface)"
33interface_json = "$(execpath interface.json5)"
34
35cmd = [
36    gen_interface_exe, "--in_table", interface_json,
37    "--out_dir", "src/gpu/ganesh/gl",
38]
39if "--dryrun" in sys.argv:
40    cmd.append("--dryrun")
41
42print(subprocess.check_output(cmd, encoding="utf-8"))
43"""
44
45genrule(
46    name = "create_generate_gl_interfaces_script",
47    outs = ["generate_gl_interfaces.py"],
48    cmd = "echo '%s' > $@" % _GENERATE_INTERFACE,
49    exec_tools = [
50        ":interface",
51        ":interface.json5",
52    ],
53)
54
55py_binary(
56    name = "generate_gl_interfaces",
57    srcs = [":generate_gl_interfaces.py"],
58    data = [
59        ":interface",
60        ":interface.json5",
61    ],
62    tags = ["no-remote"],
63)
64