Debian Codegraph @

bazel/external/libpng/BUILD.bazel

raw
1 # This file will be copied into //third_party/externals/libpng via the new_local_repository
2 # rule in WORKSPACE.bazel, so all files should be relative to that path.
3
4 load("@rules_cc//cc:cc_library.bzl", "cc_library")
5
6 # We define this here because the emscripten toolchain calls the cpu wasm, whereas the
7 # bazelbuild/platforms call it wasm32. https://github.com/emscripten-core/emsdk/issues/919
8 config_setting(
9 name = "cpu_wasm",
10 values = {
11 "cpu": "wasm",
12 },
13 )
14
15 LIBPNG_SRCS = [
16 "png.c",
17 "pngconf.h",
18 "pngdebug.h",
19 "pngerror.c",
20 "pngget.c",
21 "pnginfo.h",
22 "pngmem.c",
23 "pngpread.c",
24 "pngpriv.h",
25 "pngread.c",
26 "pngrio.c",
27 "pngrtran.c",
28 "pngrutil.c",
29 "pngset.c",
30 "pngstruct.h",
31 "pngtrans.c",
32 "pngwio.c",
33 "pngwrite.c",
34 "pngwtran.c",
35 "pngwutil.c",
36 "pnglibconf.h",
37 ] + select({
38 "@platforms//cpu:x86_64": [
39 "intel/filter_sse2_intrinsics.c",
40 "intel/intel_init.c",
41 ],
42 "@platforms//cpu:arm64": [
43 "arm/arm_init.c",
44 "arm/filter_neon_intrinsics.c",
45 "arm/palette_neon_intrinsics.c",
46 ],
47 # No SIMD support in wasm for now
48 ":cpu_wasm": [],
49 # The default is to avoid using SIMD
50 "//conditions:default": [],
51 })
52
53 PNG_DEFINES = ["PNG_SET_OPTION_SUPPORTED"] + select({
54 "@platforms//cpu:x86_64": ["PNG_INTEL_SSE"],
55 "//conditions:default": [],
56 })
57
58 cc_library(
59 name = "libpng",
60 srcs = LIBPNG_SRCS,
61 hdrs = [
62 "png.h",
63 "pngconf.h",
64 "pnglibconf.h",
65 ],
66 copts = [
67 "-Wno-unused-but-set-variable",
68 "-Wno-macro-redefined",
69 ],
70 includes = [
71 # This allows #include <png.h> to work
72 ".",
73 ],
74 local_defines = PNG_DEFINES,
75 # This is included by pnglibconf.h, but because it is not a .h
76 # file, we must tell Bazel to explicitly bring it in as an "includable".
77 textual_hdrs = ["scripts/pnglibconf.h.prebuilt"],
78 visibility = ["//visibility:public"],
79 deps = ["@zlib"],
80 )
81
82 # Creates a file called pnglibconf.h that includes the default png settings with one
83 # modification, undefining PNG_READ_OPT_PLTE_SUPPORTED.
84 genrule(
85 name = "create_skia_pnglibconf.h",
86 outs = ["pnglibconf.h"],
87 cmd = "echo '#include \"scripts/pnglibconf.h.prebuilt\"\n#undef PNG_READ_OPT_PLTE_SUPPORTED' > $@",
88 cmd_bat = "echo #include \"scripts/pnglibconf.h.prebuilt\" > $@ && echo #undef PNG_READ_OPT_PLTE_SUPPORTED >> $@",
89 )