diff --git a/.bazelrc b/.bazelrc index 67ac68a05b..95a3ac1ace 100644 --- a/.bazelrc +++ b/.bazelrc @@ -54,6 +54,8 @@ build --flag_alias=disable_skslc=no//bazel/common_config_settings:enable_skslc build --flag_alias=enable_skslc=//bazel/common_config_settings:enable_skslc build --flag_alias=disable_sksl_tracing=no//bazel/common_config_settings:enable_sksl_tracing build --flag_alias=enable_sksl_tracing=//bazel/common_config_settings:enable_sksl_tracing +build --flag_alias=disable_svg_canvas=no//bazel/common_config_settings:enable_svg_canvas +build --flag_alias=enable_svg_canvas=//bazel/common_config_settings:enable_svg_canvas build --flag_alias=disable_tracing=no//bazel/common_config_settings:enable_tracing build --flag_alias=enable_tracing=//bazel/common_config_settings:enable_tracing build --flag_alias=disable_vma=no//bazel/common_config_settings:use_vulkan_memory_allocator diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index fb9357465c..a90a2d124d 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -217,6 +217,13 @@ new_local_repository( workspace_file_content = "", ) +new_local_repository( + name = "expat", + build_file = "bazel/external/expat/BUILD.bazel", + path = "third_party/externals/expat", + workspace_file_content = "", +) + new_local_repository( name = "libjpeg_turbo", build_file = "bazel/external/libjpeg_turbo/BUILD.bazel", diff --git a/bazel/common_config_settings/BUILD.bazel b/bazel/common_config_settings/BUILD.bazel index b92e38dd7d..77ef58dcc7 100644 --- a/bazel/common_config_settings/BUILD.bazel +++ b/bazel/common_config_settings/BUILD.bazel @@ -227,6 +227,11 @@ bool_flag( flag_name = "enable_tracing", ) +bool_flag( + default = False, + flag_name = "enable_svg_canvas", +) + bool_flag( default = False, flag_name = "is_skia_dev_build", diff --git a/bazel/external/expat/BUILD.bazel b/bazel/external/expat/BUILD.bazel new file mode 100644 index 0000000000..ece634dbb4 --- /dev/null +++ b/bazel/external/expat/BUILD.bazel @@ -0,0 +1,68 @@ +# This file will be copied into //third_party/externals/libjpeg-turbo via the new_local_repository +# rule in WORKSPACE.bazel, so all files should be relative to that path. + +genrule( + name = "create_expat_config_file", + srcs = [], + outs = ["include/expat_config.h"], + cmd = """cat > $@ << 'EOF' +#define HAVE_INTTYPES_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRING_H 1 +#define STDC_HEADERS 1 +#define XML_CONTEXT_BYTES 1024 +#define XML_DTD 1 +#define XML_NS 1 +EOF""", +) + +EXPAT_HDRS = [ + "expat/lib/expat.h", +] + +EXPAT_SRCS = [ + "expat/lib/ascii.h", + "expat/lib/asciitab.h", + "expat/lib/expat.h", + "expat/lib/expat_external.h", + "expat/lib/iasciitab.h", + "expat/lib/internal.h", + "expat/lib/latin1tab.h", + "expat/lib/nametab.h", + "expat/lib/siphash.h", + "expat/lib/utf8tab.h", + "expat/lib/winconfig.h", + "expat/lib/xmlparse.c", + "expat/lib/xmlrole.c", + "expat/lib/xmlrole.h", + "expat/lib/xmltok.c", + "expat/lib/xmltok.h", + "expat/lib/xmltok_impl.h", + # Our generated configuration file + "include/expat_config.h", +] + +TEXTUAL_HDRS = [ + "expat/lib/xmltok_impl.c", + "expat/lib/xmltok_ns.c", +] + +cc_library( + name = "expat", + srcs = EXPAT_SRCS, + hdrs = EXPAT_HDRS, + defines = [ + "HAVE_MEMMOVE", + "XML_DEV_URANDOM", + "XML_STATIC", + ], + includes = [ + "expat/lib", + "include", + ], + # strip_include_prefix = "expat/lib", + textual_hdrs = TEXTUAL_HDRS, + visibility = ["//visibility:public"], +) diff --git a/bazel/external/libjpeg_turbo/BUILD.bazel b/bazel/external/libjpeg_turbo/BUILD.bazel index 11ce1dd791..94eed39169 100644 --- a/bazel/external/libjpeg_turbo/BUILD.bazel +++ b/bazel/external/libjpeg_turbo/BUILD.bazel @@ -120,7 +120,6 @@ cc_library( "jpeglibmangler.h", ], local_defines = JPEGTURBO_DEFINES, - strip_include_prefix = "", textual_hdrs = [ "jccolext.c", "jdmrgext.c", diff --git a/bazel/macros.bzl b/bazel/macros.bzl index 7c2c04e50c..065a42cb54 100644 --- a/bazel/macros.bzl +++ b/bazel/macros.bzl @@ -8,13 +8,16 @@ load("@rules_python//python:defs.bzl", _py_binary = "py_binary") load("@py_deps//:requirements.bzl", _requirement = "requirement") load("@bazel_gazelle//:def.bzl", _gazelle = "gazelle") load("@emsdk//emscripten_toolchain:wasm_rules.bzl", _wasm_cc_binary = "wasm_cc_binary") +load("@io_bazel_rules_go//go:def.bzl", _go_binary = "go_binary", _go_library = "go_library") # re-export symbols that are commonly used or that are not supported in G3 # (and thus we need to stub out) -selects = _selects +gazelle = _gazelle +go_binary = _go_binary +go_library = _go_library py_binary = _py_binary requirement = _requirement -gazelle = _gazelle +selects = _selects wasm_cc_binary = _wasm_cc_binary def select_multi(values_map, default): @@ -64,6 +67,11 @@ def select_multi(values_map, default): }) return rv +# buildifier: disable=unnamed-macro +def cc_binary(**kwargs): + """A shim around cc_binary that lets us tweak settings for G3 if necessary.""" + native.cc_binary(**kwargs) + # buildifier: disable=unnamed-macro def cc_library(**kwargs): """A shim around cc_library that lets us tweak settings for G3 if necessary.""" diff --git a/include/BUILD.bazel b/include/BUILD.bazel index 8c6eb0a037..ed01ef6cb4 100644 --- a/include/BUILD.bazel +++ b/include/BUILD.bazel @@ -16,7 +16,6 @@ filegroup( "//include/encode:public_hdrs", "//include/pathops:public_hdrs", "//include/ports:public_hdrs", - "//include/svg:public_hdrs", "//include/third_party/skcms:public_hdrs", "//include/utils:public_hdrs", ] + select({ @@ -25,6 +24,9 @@ filegroup( }) + select({ "//bazel/common_config_settings:has_gpu_backend": ["//include/gpu:public_hdrs"], "//conditions:default": [], + }) + select({ + "//bazel/common_config_settings:enable_svg_canvas_true": ["//include/svg:public_hdrs"], + "//conditions:default": [], }), visibility = ["//:__pkg__"], ) diff --git a/src/BUILD.bazel b/src/BUILD.bazel index 3f3940ff8c..10411d2083 100644 --- a/src/BUILD.bazel +++ b/src/BUILD.bazel @@ -29,6 +29,12 @@ filegroup( }) + select({ "//bazel/common_config_settings:needs_sksl": ["//src/sksl:srcs"], "//conditions:default": [], + }) + select({ + "//bazel/common_config_settings:enable_svg_canvas_true": [ + "//src/svg:srcs", + "//src/xml:srcs", + ], + "//conditions:default": [], }), visibility = ["//:__pkg__"], ) @@ -57,6 +63,12 @@ filegroup( }) + select({ "//bazel/common_config_settings:needs_sksl": ["//src/sksl:private_hdrs"], "//conditions:default": [], + }) + select({ + "//bazel/common_config_settings:enable_svg_canvas_true": [ + "//src/svg:private_hdrs", + "//src/xml:private_hdrs", + ], + "//conditions:default": [], }), visibility = ["//:__pkg__"], ) @@ -75,5 +87,10 @@ cc_library( }) + select({ "//bazel/common_config_settings:needs_sksl": ["//src/sksl:deps"], "//conditions:default": [], + }) + select({ + "//bazel/common_config_settings:enable_svg_canvas_true": [ + "//src/xml:deps", + ], + "//conditions:default": [], }), ) diff --git a/src/svg/BUILD.bazel b/src/svg/BUILD.bazel new file mode 100644 index 0000000000..2ea4438fbb --- /dev/null +++ b/src/svg/BUILD.bazel @@ -0,0 +1,22 @@ +load("//bazel:macros.bzl", "exports_files_legacy") + +licenses(["notice"]) + +exports_files_legacy() + +filegroup( + name = "srcs", + srcs = [ + "SkSVGCanvas.cpp", + "SkSVGDevice.cpp", + ], + visibility = ["//src:__pkg__"], +) + +filegroup( + name = "private_hdrs", + srcs = [ + "SkSVGDevice.h", + ], + visibility = ["//src:__pkg__"], +) diff --git a/src/xml/BUILD.bazel b/src/xml/BUILD.bazel index 69666adff2..3f908457e6 100644 --- a/src/xml/BUILD.bazel +++ b/src/xml/BUILD.bazel @@ -1,5 +1,37 @@ -load("//bazel:macros.bzl", "exports_files_legacy") +load("//bazel:macros.bzl", "cc_library", "exports_files_legacy", "split_srcs_and_hdrs") licenses(["notice"]) exports_files_legacy() + +XML_FILES = [ + "SkDOM.cpp", + "SkDOM.h", + "SkXMLParser.cpp", + "SkXMLParser.h", + "SkXMLWriter.cpp", + "SkXMLWriter.h", +] + +split_srcs_and_hdrs( + name = "xml", + files = XML_FILES, +) + +filegroup( + name = "srcs", + srcs = [":xml_srcs"], + visibility = ["//src:__pkg__"], +) + +filegroup( + name = "private_hdrs", + srcs = [":xml_hdrs"], + visibility = ["//src:__pkg__"], +) + +cc_library( + name = "deps", + visibility = ["//src:__pkg__"], + deps = ["@expat"], +)