blob: 284920dcab0ac7d59623093febcff30471ed3db9 [file] [log] [blame]
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
load("@io_bazel_rules_docker//container:container.bzl", "container_push")
load("@io_bazel_rules_docker//docker/util:run.bzl", "container_run_and_commit")
# gazelle:prefix go.skia.org/infra
gazelle(name = "gazelle")
exports_files(
["tsconfig.json"],
visibility = ["//visibility:public"],
)
buildifier(
name = "buildifier",
exclude_patterns = ["./**/node_modules/*"],
lint_mode = "warn",
)
############################################
# Custom Remote Build Execution toolchain. #
############################################
# Generates a custom toolchain container for Remote Build Execution which extends the default RBE
# ubuntu16-04 container with any extra dependencies needed for Skia Infrastructure build targets.
#
# This container can be pushed to GCR via the container_push target defined below.
#
# Notes:
#
# - This target is tagged with "no-remote" because the container_run_and_commit rule calls the
# Docker binary, which requires the Docker daemon to be running. This fails on RBE with error
# "Cannot connect to the Docker daemon at [...]. Is the docker daemon running?". By tagging this
# target with "no-remote", we tell Bazel to build this target locally, even with --config=remote.
#
# - The output of this rule is a >3GB .tar with the container image, so this target can take
# several minutes to build. This is OK because we only need to rebuild this container very
# occasionally, and Bazel will cache the output artifact.
#
# Reference:
# https://cloud.google.com/remote-build-execution/docs/create-custom-toolchain#creating_a_custom_toolchain_container
container_run_and_commit(
name = "rbe_container_skia_infra",
commands = [
# The add-apt-repository command does not work without fixing the python3 symlink first.
"rm /usr/bin/python3",
"ln -s /usr/bin/python3.5 /usr/bin/python3",
# Install the add-apt-repository command.
"apt-get update",
"yes | apt-get install software-properties-common",
# Add the Chrome repository.
"curl -fsSL https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -",
"add-apt-repository 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main'",
"apt-get update",
# Install Chrome and fonts to support major charsets.
#
# This is necessary for the karma_test rule to work, which runs web tests on a headless
# Chrome, and also for the bundled version of Chromium that Puppeteer installs to
# render fonts properly.
#
# Adapted from:
# https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker
"yes | apt-get install " + " ".join([
"google-chrome-stable",
"fonts-ipafont-gothic",
"fonts-wqy-zenhei",
"fonts-thai-tlwg",
"fonts-kacst",
"fonts-freefont-ttf",
# Prevent "error while loading shared libraries: libXss.so.1" in Puppeteer tests.
# See https://github.com/puppeteer/puppeteer/issues/6192.
"libxss1",
]),
],
image = "@rbe_ubuntu1604//image",
tags = ["no-remote"],
)
# This target can be used to upload the custom RBE container toolchain to GCR. It will be available
# as gcr.io/skia-public/rbe-container-skia-infra.
#
# Note: this can take several minutes to finish because it will upload a >3GB .tar file to GCR.
container_push(
name = "push_rbe_container_skia_infra",
format = "Docker",
image = ":rbe_container_skia_infra_commit.tar", # Generated by :rbe_container_skia_infra.
registry = "gcr.io",
repository = "skia-public/rbe-container-skia-infra",
tag = "{STABLE_DOCKER_TAG}",
)
####################################################################################################
# Support for "~"-prefixed Sass imports of elements-sk styles, e.g.: #
# #
# @import '~elements-sk/themes/themes'; #
# #
# This hack is necessary to maintain compatibility with the Webpack build, which uses the #
# css-loader plugin to inline CSS imports. Said plugin adds all NPM packages to the Sass compiler #
# import path with the "~" prefix. See https://webpack.js.org/loaders/css-loader/#import for more. #
####################################################################################################
ELEMENTS_SK_SCSS = [
# To regenerate this list, please run the following Bash command:
#
# $ find infra-sk/node_modules/elements-sk -name "*.scss" \
# | sed -E "s/infra-sk\//\/\/infra-sk:/" | sort
"//infra-sk:node_modules/elements-sk/checkbox-sk/checkbox-sk.scss",
"//infra-sk:node_modules/elements-sk/collapse-sk/collapse-sk.scss",
"//infra-sk:node_modules/elements-sk/colors.scss",
"//infra-sk:node_modules/elements-sk/icon/icon-sk.scss",
"//infra-sk:node_modules/elements-sk/multi-select-sk/multi-select-sk.scss",
"//infra-sk:node_modules/elements-sk/nav-links-sk/nav-links-sk.scss",
"//infra-sk:node_modules/elements-sk/radio-sk/radio-sk.scss",
"//infra-sk:node_modules/elements-sk/select-sk/select-sk.scss",
"//infra-sk:node_modules/elements-sk/spinner-sk/spinner-sk.scss",
"//infra-sk:node_modules/elements-sk/styles/buttons/buttons.scss",
"//infra-sk:node_modules/elements-sk/styles/select/select.scss",
"//infra-sk:node_modules/elements-sk/styles/table/table.scss",
"//infra-sk:node_modules/elements-sk/tabs-panel-sk/tabs-panel-sk.scss",
"//infra-sk:node_modules/elements-sk/tabs-sk/tabs-sk.scss",
"//infra-sk:node_modules/elements-sk/themes/color-palette.scss",
"//infra-sk:node_modules/elements-sk/themes/themes.scss",
"//infra-sk:node_modules/elements-sk/toast-sk/toast-sk.scss",
]
TILDE_ELEMENTS_SK_SCSS = [f.replace("//infra-sk:node_modules/", "~") for f in ELEMENTS_SK_SCSS]
# Recursively copies all *.scss files from //infra-sk/node_modules/elements-sk to //~elements-sk.
genrule(
name = "~elements-sk_generator",
srcs = ELEMENTS_SK_SCSS,
outs = TILDE_ELEMENTS_SK_SCSS,
cmd =
"for FILENAME in $(SRCS); do " +
" TILDE_FILENAME=`echo $$FILENAME | sed -E 's/infra-sk\\/node_modules\\/(.*)/~\\1/'`; " +
" TILDE_DIR=$$(dirname $$TILDE_FILENAME); " +
" mkdir -p $(RULEDIR)/$$TILDE_DIR; " +
" cp $$FILENAME $(RULEDIR)/$$TILDE_FILENAME; " +
"done",
)
# Do not use directly. Use //infra-sk:elements-sk_scss instead, which includes these files as well.
filegroup(
name = "~elements-sk",
srcs = TILDE_ELEMENTS_SK_SCSS,
visibility = ["//infra-sk:__pkg__"],
)