[bazel] Add executable for skslc

This ports the GN skia_executable [1] and adds third_party
Bazel rules for spirv_cross, translated from [2]. spirv_cross,
unlike spirv_tools, did not have pre-made Bazel rules.

This binary compiles and links with

    bazelisk build //tools/skslc --config=clang

[1] ad324a31e6/BUILD.gn (L712)
[2] ad324a31e6/third_party/spirv-cross/BUILD.gn (L10)

Change-Id: I4abd51889552153fc7e64a5f7f3d9f0f597524e7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/528044
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
This commit is contained in:
Kevin Lubick 2022-04-08 11:29:33 -04:00 committed by Ravi Mistry
parent 7c18d94692
commit a9f6ceebed
12 changed files with 110 additions and 4 deletions

View File

@ -28,6 +28,8 @@ build --flag_alias=disable_effect_serialization=//bazel/common_config_settings:d
build --flag_alias=enable_effect_serialization=no//bazel/common_config_settings:disable_effect_serialization
build --flag_alias=enable_vma=//bazel/common_config_settings:use_vulkan_memory_allocator
build --flag_alias=disable_vma=no//bazel/common_config_settings:use_vulkan_memory_allocator
build --flag_alias=enable_skslc=//bazel/common_config_settings:enable_skslc
build --flag_alias=disable_skslc=no//bazel/common_config_settings:enable_skslc
# CanvasKit flags
build --flag_alias=ck_enable_fonts=//modules/canvaskit:enable_fonts

View File

@ -25,6 +25,14 @@ GENERAL_DEFINES = [
"SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1",
],
"//conditions:default": [],
}) + select({
"//bazel/common_config_settings:enable_skslc_true": [
"SKSL_STANDALONE",
"SK_DISABLE_TRACING",
"SK_ENABLE_SPIRV_CROSS",
"SK_ENABLE_SPIRV_VALIDATION",
],
"//conditions:default": [],
})
GPU_DEFINES = select({

View File

@ -22,6 +22,7 @@ known_good_builds:
bazelisk build //:skia_core --config=clang
bazelisk build //src/sksl/lex:sksllex --config=clang
bazelisk build //tools/skdiff --config=clang
bazelisk build //tools/skslc --config=clang
bazelisk build //modules/canvaskit:canvaskit_wasm --compilation_mode opt --sandbox_base=/dev/shm
# Test the enforcement of include what you use
@ -41,6 +42,7 @@ rbe_known_good_builds:
bazelisk build //:skia_core --config=linux-rbe
bazelisk build //src/sksl/lex:sksllex --config=linux-rbe
bazelisk build //tools/skdiff --config=linux-rbe
bazelisk build //tools/skslc --config=linux-rbe
# TODO(kjlubick) CanvasKit in release mode (i.e. with Closure) requires
# https://github.com/emscripten-core/emscripten/pull/16640 to land
bazelisk build //modules/canvaskit:canvaskit_wasm --compilation_mode dbg --config=linux-rbe \

View File

@ -7,8 +7,9 @@ It is based off of https://github.com/bazelbuild/examples/tree/main/rules/starla
"""
_bool_flags = [
"//bazel/common_config_settings:use_icu",
"//bazel/common_config_settings:enable_skslc",
"//bazel/common_config_settings:is_skia_dev_build",
"//bazel/common_config_settings:use_icu",
]
_string_flags = [

View File

@ -207,3 +207,9 @@ bool_flag(
flag_name = "use_vulkan_memory_allocator",
public = False, # Users should use :vulkan_with_vma
)
bool_flag(
default = False,
flag_name = "enable_skslc",
)

View File

@ -109,6 +109,7 @@ cc_library(
cc_library(
name = "osfile",
visibility = ["//tools/skslc:__pkg__"],
deps = [":SkOSFile_stdio_src"] + select({
"@platforms//os:windows": [":SkOSFile_win_src"],
"//conditions:default": [":SkOSFile_posix_src"],

View File

@ -117,6 +117,37 @@ cc_library(
],
)
cc_library(
name = "skslc_deps",
visibility = ["//:__subpackages__"],
deps = [
"//src/core:SkArenaAlloc_src",
"//src/core:SkBlockAllocator_src",
"//src/core:SkCpu_src",
"//src/core:SkData_src",
"//src/core:SkHalf_src",
"//src/core:SkMalloc_src",
"//src/core:SkMath_src",
"//src/core:SkMatrixInvert_src",
"//src/core:SkSemaphore_src",
"//src/core:SkStream_src",
"//src/core:SkStringUtils_src",
"//src/core:SkString_src",
"//src/core:SkThreadID_src",
"//src/core:SkUtils_src",
"//src/core:SkVM_src",
"//src/gpu/ganesh:GrMemoryPool_src",
"//src/ports:SkMemory_malloc_src",
"//src/ports:SkOSFile_stdio_src",
"//src/utils:SkJSONWriter_src",
"//src/utils:SkJSON_src",
"//src/utils:SkParse_src",
"//src/utils:SkShaderUtils_src",
"//src/utils:SkUTF_src",
"//src/utils:SkVMVisualizer_src",
],
)
generated_cc_atom(
name = "GLSL.std.450_hdr",
hdrs = ["GLSL.std.450.h"],
@ -270,6 +301,7 @@ generated_cc_atom(
"//src/sksl/ir:SkSLVariableReference_hdr",
"//src/sksl/ir:SkSLVariable_hdr",
"//src/sksl/transform:SkSLTransform_hdr",
"@spirv_tools",
],
)

View File

@ -323,7 +323,10 @@ generated_cc_atom(
name = "SkSLSPIRVtoHLSL_src",
srcs = ["SkSLSPIRVtoHLSL.cpp"],
visibility = ["//:__subpackages__"],
deps = [":SkSLSPIRVtoHLSL_hdr"],
deps = [
":SkSLSPIRVtoHLSL_hdr",
"//third_party:spirv_cross",
],
)
generated_cc_atom(

View File

@ -3512,3 +3512,37 @@ cc_library(
],
visibility = ["//visibility:private"], # only used by :dawn
)
cc_library(
name = "spirv_cross",
srcs = [
"externals/spirv-cross/GLSL.std.450.h",
"externals/spirv-cross/spirv.hpp",
"externals/spirv-cross/spirv_cfg.cpp",
"externals/spirv-cross/spirv_cfg.hpp",
"externals/spirv-cross/spirv_common.hpp",
"externals/spirv-cross/spirv_cpp.cpp",
"externals/spirv-cross/spirv_cpp.hpp",
"externals/spirv-cross/spirv_cross.cpp",
"externals/spirv-cross/spirv_cross.hpp",
"externals/spirv-cross/spirv_cross_containers.hpp",
"externals/spirv-cross/spirv_cross_error_handling.hpp",
"externals/spirv-cross/spirv_cross_parsed_ir.cpp",
"externals/spirv-cross/spirv_cross_parsed_ir.hpp",
"externals/spirv-cross/spirv_glsl.cpp",
"externals/spirv-cross/spirv_glsl.hpp",
"externals/spirv-cross/spirv_hlsl.cpp",
"externals/spirv-cross/spirv_msl.cpp",
"externals/spirv-cross/spirv_msl.hpp",
"externals/spirv-cross/spirv_parser.cpp",
"externals/spirv-cross/spirv_parser.hpp",
"externals/spirv-cross/spirv_reflect.cpp",
"externals/spirv-cross/spirv_reflect.hpp",
],
hdrs = [
"externals/spirv-cross/spirv_hlsl.hpp",
],
defines = ["SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS"],
visibility = ["//:__subpackages__"],
)

View File

@ -62,8 +62,8 @@
"sample/chromium/font_subsetter.h": "SK_GAZELLE_IGNORE TODO //third_party:sfntly",
"third_party/externals/spirv-cross/spirv_hlsl.hpp": "SK_GAZELLE_IGNORE TODO //third_party:spirv_cross",
"spirv-tools/libspirv.hpp": "SK_GAZELLE_IGNORE TODO //third_party:spirv_tools",
"third_party/externals/spirv-cross/spirv_hlsl.hpp": "//third_party:spirv_cross",
"spirv-tools/libspirv.hpp": "@spirv_tools//:spirv_tools",
"vk_platform.h": "//include/third_party/vulkan/vulkan:vk_platform_hdr",
"vulkan_android.h": "//include/third_party/vulkan/vulkan:vulkan_android_hdr",

View File

@ -1,4 +1,19 @@
load("//bazel:cc_binary_with_flags.bzl", "cc_binary_with_flags")
load("//bazel:macros.bzl", "generated_cc_atom")
load("@rules_cc//cc:defs.bzl", "cc_binary")
cc_binary_with_flags(
name = "skslc",
set_flags = {
"enable_skslc": ["True"],
},
deps = [
":Main_src",
"//src/ports:osfile",
"//src/sksl:skslc_deps",
"//src/sksl:srcs",
],
)
generated_cc_atom(
name = "Main_src",
@ -23,5 +38,6 @@ generated_cc_atom(
"//src/sksl/tracing:SkVMDebugTrace_hdr",
"//src/utils:SkShaderUtils_hdr",
"//src/utils:SkVMVisualizer_hdr",
"@spirv_tools",
],
)

View File

@ -462,6 +462,7 @@ generated_cc_atom(
"//tools/flags:CommandLineFlags_hdr",
"//tools/flags:CommonFlags_hdr",
"//tools/trace:EventTracingPriv_hdr",
"@spirv_tools",
],
)