# -*- python -*-

load("@drake//tools/install:install.bzl", "install", "install_files")
load("@drake//tools/skylark:py.bzl", "py_binary", "py_library")

licenses(["notice"])  # MIT

py_library(
    name = "meshcat",
    srcs = glob([
        "src/meshcat/*.py",
        "src/meshcat/servers/*.py",
    ]),
    data = glob([
        "src/meshcat/viewer/dist/*.html",
        "src/meshcat/viewer/dist/*.js",
    ]),
    imports = ["src"],
    visibility = ["//visibility:public"],
)

py_binary(
    name = "meshcat-server",
    srcs = ["@drake//tools/workspace/meshcat_python:meshcat-server.py"],
    legacy_create_init = 0,
    visibility = ["//visibility:public"],
    deps = [":meshcat"],
)

install_files(
    name = "install-meshcat-server",
    dest = "bin",
    files = ["@drake//tools/workspace/meshcat_python:meshcat-server"],
    allowed_externals = [
        "@drake//tools/workspace/meshcat_python:meshcat-server",
    ],
)

install(
    name = "install",
    install_tests = [
        "@drake//tools/workspace/meshcat_python:test/meshcat-server-install-test.py",  # noqa
    ],
    targets = [":meshcat"],
    docs = ["LICENSE.txt"],
    py_strip_prefix = ["src"],
    visibility = ["//visibility:public"],
    deps = [":install-meshcat-server"],
)
