1load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") 2 3# This first example only needs the core Skia functionality and the pathops 4# module. Thus, the client defines a cc_library (skia_core_and_pathops) with 5# those components and then depending on that library. 6cc_binary( 7 name = "path_combiner", 8 srcs = ["src/path_main.cpp"], 9 linkopts = [ 10 "-fuse-ld=lld", 11 "-lpthread", 12 ], 13 deps = [":skia_core_and_pathops"], 14) 15 16cc_library( 17 name = "skia_core_and_pathops", 18 deps = [ 19 "@skia//:core", 20 "@skia//:pathops", 21 ], 22) 23 24cc_binary( 25 name = "png_decoder", 26 srcs = ["src/decode_png_main.cpp"], 27 linkopts = [ 28 "-fuse-ld=lld", 29 "-lpthread", 30 ], 31 deps = [ 32 "@skia//:core", 33 "@skia//:png_decode_codec", 34 ], 35) 36 37cc_binary( 38 name = "decode_everything", 39 srcs = ["src/decode_everything.cpp"], 40 linkopts = select({ 41 "@platforms//os:linux": [ 42 "-fuse-ld=lld", 43 "-lpthread", 44 ], 45 "//conditions:default": [], 46 }), 47 deps = [ 48 "@skia//:bmp_decode_codec", 49 "@skia//:core", 50 "@skia//:gif_decode_codec", 51 "@skia//:ico_decode_codec", 52 "@skia//:jpeg_decode_codec", 53 "@skia//:jpegxl_decode_codec", 54 "@skia//:png_decode_codec", 55 "@skia//:wbmp_decode_codec", 56 "@skia//:webp_decode_codec", 57 ], 58) 59 60cc_binary( 61 name = "write_text_to_png", 62 srcs = ["src/write_text_to_png.cpp"], 63 linkopts = [ 64 "-fuse-ld=lld", 65 "-lpthread", 66 ], 67 deps = [ 68 "@skia//:core", 69 "@skia//:png_encode_codec", 70 ] + select({ 71 "@platforms//os:linux": [ 72 "@skia//:fontmgr_fontconfig_freetype", 73 "@skia//:freetype_support", 74 ], 75 "@platforms//os:macos": ["@skia//:fontmgr_coretext"], 76 "//conditions:default": ["@skia//:fontmgr_empty_freetype"], 77 }), 78) 79 80cc_binary( 81 name = "shape_text", 82 srcs = ["src/shape_text.cpp"], 83 linkopts = [ 84 "-fuse-ld=lld", 85 "-lpthread", 86 ], 87 deps = [ 88 "@skia//:core", 89 "@skia//:fontmgr_empty_freetype", 90 "@skia//:jpeg_encode_codec", 91 "@skia//:skparagraph_harfbuzz_skunicode", 92 "@skia//:skunicode_icu", 93 ], 94) 95 96cc_binary( 97 name = "use_ganesh_gl", 98 srcs = ["src/ganesh_gl.cpp"], 99 linkopts = [ 100 ] + select( 101 { 102 "@platforms//os:windows": [], 103 "//conditions:default": [ 104 "-lpthread", 105 ], 106 }, 107 ) + select( 108 { 109 "@platforms//os:linux": [ 110 "-lGL", 111 "-lX11", 112 ], 113 "@platforms//os:windows": [ 114 "-lgdi32", 115 "-lOpenGL32", 116 "-luser32", 117 ], 118 "//conditions:default": [], 119 }, 120 ), 121 deps = [ 122 "@skia//:core", 123 "@skia//:ganesh_gl", 124 "@skia//:webp_encode_codec", 125 ] + select({ 126 "@platforms//os:linux": ["@skia//:ganesh_glx_factory"], 127 "@platforms//os:macos": [ 128 ":gl_context_helper", 129 "@skia//:ganesh_gl_mac_factory", 130 ], 131 "@platforms//os:windows": [ 132 "@skia//:ganesh_gl_win_factory", 133 ], 134 "//conditions:default": ["@platforms//:incompatible"], 135 }), 136) 137 138objc_library( 139 name = "gl_context_helper", 140 srcs = ["src/gl_context_helper.mm"], 141 hdrs = ["src/gl_context_helper.h"], 142 copts = ["-DGL_SILENCE_DEPRECATION"], 143 includes = ["src"], 144 sdk_frameworks = [ 145 "OpenGL", 146 ], 147) 148 149cc_binary( 150 name = "use_ganesh_vulkan", 151 srcs = ["src/ganesh_vulkan.cpp"], 152 linkopts = [ 153 "-lpthread", 154 ], 155 deps = [ 156 "@skia//:core", 157 "@skia//:ganesh_vulkan", 158 ], 159) 160 161cc_binary( 162 name = "use_ganesh_metal", 163 srcs = ["src/ganesh_metal.cpp"], 164 target_compatible_with = select({ 165 "@platforms//os:macos": [], 166 "@platforms//os:ios": [], 167 "//conditions:default": ["@platforms//:incompatible"], 168 }), 169 deps = [ 170 ":ganesh_metal_context_helper", 171 "@skia//:core", 172 "@skia//:ganesh_metal", 173 "@skia//:jpeg_encode_codec", 174 ], 175) 176 177objc_library( 178 name = "ganesh_metal_context_helper", 179 srcs = ["src/ganesh_metal_context_helper.mm"], 180 hdrs = ["src/ganesh_metal_context_helper.h"], 181 includes = ["src"], 182 sdk_frameworks = [ 183 # Without MetalKit added as a dependency, `[*device newCommandQueue]` fails 184 "MetalKit", 185 "Metal", 186 ], 187 target_compatible_with = select({ 188 "@platforms//os:macos": [], 189 "@platforms//os:ios": [], 190 "//conditions:default": ["@platforms//:incompatible"], 191 }), 192 deps = [ 193 "@skia//:core", 194 "@skia//:ganesh_metal", 195 ], 196) 197 198cc_binary( 199 name = "use_graphite_native_metal", 200 srcs = ["src/graphite_native_metal.cpp"], 201 target_compatible_with = select({ 202 "@platforms//os:macos": [], 203 "@platforms//os:ios": [], 204 "//conditions:default": ["@platforms//:incompatible"], 205 }), 206 deps = [ 207 ":graphite_metal_context_helper", 208 "@skia//:core", 209 "@skia//:graphite_native_metal", 210 "@skia//:jpeg_encode_codec", 211 ], 212) 213 214objc_library( 215 name = "graphite_metal_context_helper", 216 srcs = ["src/graphite_metal_context_helper.mm"], 217 hdrs = ["src/graphite_metal_context_helper.h"], 218 includes = ["src"], 219 sdk_frameworks = [ 220 # Without MetalKit added as a dependency, `[*device newCommandQueue]` fails 221 "MetalKit", 222 "Metal", 223 ], 224 target_compatible_with = select({ 225 "@platforms//os:macos": [], 226 "@platforms//os:ios": [], 227 "//conditions:default": ["@platforms//:incompatible"], 228 }), 229 deps = [ 230 "@skia//:core", 231 "@skia//:graphite_native_metal", 232 ], 233) 234 235cc_binary( 236 name = "use_graphite_native_vulkan", 237 srcs = ["src/graphite_native_vulkan.cpp"], 238 linkopts = [ 239 "-lpthread", 240 ], 241 deps = [ 242 "@skia//:core", 243 "@skia//:graphite_native_vulkan", 244 "@vulkan_headers", 245 ], 246) 247 248cc_binary( 249 name = "use_skresources", 250 srcs = ["src/use_skresources.cpp"], 251 linkopts = [ 252 "-lpthread", 253 ], 254 deps = [ 255 "@skia//:core", 256 "@skia//:jpeg_decode_codec", 257 "@skia//:png_decode_codec", 258 "@skia//:skresources", 259 ], 260) 261 262cc_binary( 263 name = "svg_with_primitive", 264 srcs = ["src/svg_renderer.cpp"], 265 linkopts = [ 266 "-lpthread", 267 ], 268 deps = [ 269 "@skia//:core", 270 "@skia//:png_encode_codec", 271 "@skia//:skshaper_core", 272 "@skia//:svg_renderer", 273 ] + select({ 274 "@platforms//os:linux": ["@skia//:fontmgr_fontconfig_freetype"], 275 "@platforms//os:macos": ["@skia//:fontmgr_coretext"], 276 "//conditions:default": [], 277 }), 278) 279 280cc_binary( 281 name = "svg_with_harfbuzz", 282 srcs = ["src/svg_renderer.cpp"], 283 linkopts = [ 284 "-lpthread", 285 ], 286 deps = [ 287 "@skia//:core", 288 "@skia//:png_encode_codec", 289 "@skia//:skshaper_harfbuzz", 290 "@skia//:skshaper_unicode", 291 "@skia//:skunicode_icu", 292 "@skia//:svg_renderer", 293 ] + select({ 294 "@platforms//os:linux": ["@skia//:fontmgr_fontconfig_freetype"], 295 "@platforms//os:macos": ["@skia//:fontmgr_coretext"], 296 "//conditions:default": [], 297 }), 298) 299 300cc_binary( 301 name = "write_to_pdf", 302 srcs = ["src/write_to_pdf.cpp"], 303 linkopts = [ 304 "-lpthread", 305 ], 306 deps = [ 307 "@skia//:core", 308 "@skia//:pdf_writer", 309 ] + select({ 310 "@platforms//os:linux": ["@skia//:fontmgr_fontconfig_freetype"], 311 "@platforms//os:macos": ["@skia//:fontmgr_coretext"], 312 "//conditions:default": [], 313 }), 314) 315