1""" 2SkOpts is built differently than the rest of our source files. See //src/core/SkOpts.h for 3a bit more background about what SkOpts is for and how it works. 4 5Instead of bubbling all the headers and sources up to the top level where they are compiled in 6one large library, we only bubble up the headers, so the default implementations in those files 7can be built against the minimum version of Skia (which the whole library is compiled with). 8 9We create several libraries that contain a single source file and may need to access any of 10Skia's headers. These libraries are each compiled with a different set of compiler flags 11(e.g. architecture options) and linked into the final library or binary. 12""" 13 14load("@skia_user_config//:copts.bzl", "DEFAULT_COPTS") 15load("//bazel:flags.bzl", "selects") 16load("//bazel:skia_rules.bzl", "exports_files_legacy", "skia_cc_deps", "skia_cc_library", "skia_filegroup") 17 18package( 19 default_applicable_licenses = ["//:license"], 20 features = [ 21 # While the OPTS_HDRS are already pulled in as textual_headers, 22 # any implicit dependency on the system headers also needs to be textual. 23 "-use_header_modules", 24 ], 25) 26 27licenses(["notice"]) 28 29exports_files_legacy() 30 31skia_filegroup( 32 name = "private_hdrs", 33 srcs = [ 34 "SkBitmapProcState_opts.h", 35 "SkBlitMask_opts.h", 36 "SkBlitRow_opts.h", 37 "SkMemset_opts.h", 38 "SkOpts_RestoreTarget.h", 39 "SkOpts_SetTarget.h", 40 "SkRasterPipeline_opts.h", 41 "SkSwizzler_opts.inc", 42 ], 43 visibility = [ 44 "//src:__pkg__", 45 ], 46) 47 48skia_cc_library( 49 name = "legacy_hsw", # https://en.wikipedia.org/wiki/Advanced_Vector_Extensions#Advanced_Vector_Extensions_2 50 srcs = [ 51 "SkOpts_hsw.cpp", 52 "//include/core:opts_srcs", 53 "//include/private:opts_srcs", 54 "//include/private/base:private_hdrs", 55 "//src/base:private_hdrs", 56 "//src/core:opts_srcs", 57 "//src/shaders:opts_srcs", 58 "//src/sksl/tracing:opts_srcs", 59 ], 60 copts = DEFAULT_COPTS + ["-march=haswell"], 61 textual_hdrs = [ 62 "SkRasterPipeline_opts.h", 63 ], 64 deps = [ 65 "//modules/skcms", # Needed to implement SkRasterPipeline_opts.h 66 "@skia_user_config//:user_config", 67 ], 68) 69 70skia_cc_library( 71 name = "legacy_skx", 72 srcs = [ 73 "SkOpts_skx.cpp", 74 "//include/core:opts_srcs", 75 "//include/private:opts_srcs", 76 "//include/private/base:private_hdrs", 77 "//src/base:private_hdrs", 78 "//src/core:opts_srcs", 79 "//src/shaders:opts_srcs", 80 "//src/sksl/tracing:opts_srcs", 81 ], 82 copts = DEFAULT_COPTS + ["-march=skylake-avx512"], 83 textual_hdrs = [ 84 "SkRasterPipeline_opts.h", 85 ], 86 deps = [ 87 "//modules/skcms", # Needed to implement SkRasterPipeline_opts.h 88 "@skia_user_config//:user_config", 89 ], 90) 91 92skia_cc_deps( 93 name = "deps", 94 visibility = [ 95 "//:__pkg__", # Needed in G3 96 "//src:__pkg__", 97 ], 98 deps = selects.with_or({ 99 ("@platforms//cpu:x86_64", "@platforms//cpu:x86_32"): [ 100 ":legacy_hsw", 101 ":legacy_skx", 102 ], 103 # We have no architecture specific optimizations for ARM64 right now 104 "@platforms//cpu:arm64": [], 105 # None of these opts work on WASM, so do not even bother compiling them. 106 "//bazel/common_config_settings:cpu_wasm": [], 107 "//conditions:default": [], 108 }), 109) 110 111skia_cc_library( 112 name = "hsw", # https://en.wikipedia.org/wiki/Advanced_Vector_Extensions#Advanced_Vector_Extensions_2 113 srcs = [ 114 "SkOpts_hsw.cpp", 115 "//include/core:opts_srcs", 116 "//include/private:opts_srcs", 117 "//src/core:opts_srcs", 118 "//src/shaders:opts_srcs", 119 "//src/sksl/tracing:opts_srcs", 120 ], 121 copts = DEFAULT_COPTS + ["-march=haswell"], 122 textual_hdrs = [ 123 "SkRasterPipeline_opts.h", 124 ":private_hdrs", 125 ], 126 deps = [ 127 "//modules/skcms", # Needed to implement SkRasterPipeline_opts.h 128 "//src/base", 129 "@skia_user_config//:user_config", 130 ], 131) 132 133skia_cc_library( 134 name = "skx", 135 srcs = [ 136 "SkOpts_skx.cpp", 137 "//include/core:opts_srcs", 138 "//include/private:opts_srcs", 139 "//src/core:opts_srcs", 140 "//src/shaders:opts_srcs", 141 "//src/sksl/tracing:opts_srcs", 142 ], 143 copts = DEFAULT_COPTS + ["-march=skylake-avx512"], 144 textual_hdrs = [ 145 "SkRasterPipeline_opts.h", 146 ":private_hdrs", 147 ], 148 deps = [ 149 "//modules/skcms", # Needed to implement SkRasterPipeline_opts.h 150 "//src/base", 151 "@skia_user_config//:user_config", 152 ], 153) 154 155skia_cc_deps( 156 name = "opts", 157 visibility = ["//src/core:__pkg__"], 158 deps = selects.with_or({ 159 ("@platforms//cpu:x86_64", "@platforms//cpu:x86_32"): [ 160 ":hsw", 161 ":skx", 162 ], 163 "//bazel/common_config_settings:cpu_wasm": [], 164 "//conditions:default": [], 165 }), 166) 167 168skia_filegroup( 169 name = "textual_hdrs", 170 srcs = [ 171 "SkBitmapProcState_opts.h", 172 "SkBlitMask_opts.h", 173 "SkBlitRow_opts.h", 174 "SkMemset_opts.h", 175 "SkOpts_RestoreTarget.h", 176 "SkOpts_SetTarget.h", 177 "SkRasterPipeline_opts.h", 178 "SkSwizzler_opts.inc", 179 ], 180 visibility = [ 181 "//src/core:__pkg__", 182 ], 183) 184