xref: /aosp_15_r20/external/skia/tools/gpu/gl/interface/BUILD.bazel (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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 = os.path.abspath("$(execpath :interface)")
33interface_json = os.path.abspath("$(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    # This must be in srcs and not tools because otherwise the path will
48    # be resolved incorrectly (as if it were built for the host config
49    # and not the exec config).
50    srcs = [":interface"],
51    outs = ["generate_gl_interfaces.py"],
52    cmd = "echo '%s' > $@" % _GENERATE_INTERFACE,
53    tools = [
54        ":interface.json5",
55    ],
56)
57
58py_binary(
59    name = "generate_gl_interfaces",
60    srcs = [":generate_gl_interfaces.py"],
61    data = [
62        ":interface",
63        ":interface.json5",
64    ],
65    tags = ["no-remote-exec"],
66)
67