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