Bug 1794893 - WebGLMemoryTracker ensured-registered in WebGLContext::ctor. r=gfx...
[gecko.git] / third_party / jpeg-xl / lib / BUILD
blob39e61de0eba580a5d30e57082bea08c7627605dd
1 # Copyright (c) the JPEG XL Project Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style
4 # license that can be found in the LICENSE file.
6 # Load sources/headers/tests lists.
7 load(
8     "jxl_lists.bzl",
9     "libjxl_base_sources",
10     "libjxl_cms_sources",
11     "libjxl_codec_apng_sources",
12     "libjxl_codec_exr_sources",
13     "libjxl_codec_gif_sources",
14     "libjxl_codec_jpegli_sources",
15     "libjxl_codec_jpg_sources",
16     "libjxl_codec_jxl_sources",
17     "libjxl_codec_npy_sources",
18     "libjxl_codec_pgx_sources",
19     "libjxl_codec_pnm_sources",
20     "libjxl_dec_box_sources",
21     "libjxl_dec_jpeg_sources",
22     "libjxl_dec_sources",
23     "libjxl_enc_sources",
24     "libjxl_extras_for_tools_sources",
25     "libjxl_extras_sources",
26     #'libjxl_gbench_sources',
27     "libjxl_jpegli_lib_version",
28     "libjxl_jpegli_libjpeg_helper_files",
29     "libjxl_jpegli_sources",
30     "libjxl_jpegli_testlib_files",
31     "libjxl_jpegli_tests",
32     "libjxl_major_version",
33     "libjxl_minor_version",
34     "libjxl_patch_version",
35     "libjxl_public_headers",
36     "libjxl_testlib_files",
37     "libjxl_tests",
38     "libjxl_threads_public_headers",
39     "libjxl_threads_sources",
41 load(
42     "jxl_vars.bzl",
43     "libjxl_deps_brotli",
44     "libjxl_deps_exr",
45     "libjxl_deps_gif",
46     "libjxl_deps_gtest",
47     "libjxl_deps_hwy",
48     "libjxl_deps_hwy_nanobenchmark",
49     "libjxl_deps_hwy_test_util",
50     "libjxl_deps_jpeg",
51     "libjxl_deps_png",
52     "libjxl_deps_runfiles",
53     "libjxl_deps_skcms",
54     "libjxl_deps_testdata",
55     "libjxl_root_package",
56     "libjxl_test_shards",
57     "libjxl_test_timeouts",
59 load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
60 load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
62 DEFAULT_VISIBILITY = ["//:__subpackages__"]
64 DEFAULT_COMPATIBILITY = []
66 INCLUDES_DIR = "include"
68 package(
69     default_visibility = ["//:__subpackages__"],
72 licenses(["notice"])
74 exports_files(["LICENSE"])
76 EXPORT_TEMPLATE = """
77 #ifndef @_EXPORT_H
78 #define @_EXPORT_H
80 #define @_EXPORT
81 #define @_NO_EXPORT
83 #ifndef @_DEPRECATED
84 #  define @_DEPRECATED __attribute__ ((__deprecated__))
85 #endif
87 #endif
88 """
90 JXL_EXPORT_H = INCLUDES_DIR + "/jxl/jxl_export.h"
92 genrule(
93     name = "create_jxl_export",
94     outs = [JXL_EXPORT_H],
95     cmd = "echo '" + EXPORT_TEMPLATE.replace("@", "JXL") + "' > $@",
96     compatible_with = DEFAULT_COMPATIBILITY,
99 JXL_CMS_EXPORT_H = INCLUDES_DIR + "/jxl/jxl_cms_export.h"
101 genrule(
102     name = "create_jxl_cms_export",
103     outs = [JXL_CMS_EXPORT_H],
104     cmd = "echo '" + EXPORT_TEMPLATE.replace("@", "JXL_CMS") + "' > $@",
105     compatible_with = DEFAULT_COMPATIBILITY,
108 JXL_THREADS_EXPORT_H = INCLUDES_DIR + "/jxl/jxl_threads_export.h"
110 genrule(
111     name = "create_jxl_threads_export",
112     outs = [JXL_THREADS_EXPORT_H],
113     cmd = "echo '" + EXPORT_TEMPLATE.replace("@", "JXL_THREADS") + "' > $@",
114     compatible_with = DEFAULT_COMPATIBILITY,
117 JXL_VERSION_H = INCLUDES_DIR + "/jxl/version.h"
119 expand_template(
120     name = "expand_jxl_version",
121     out = JXL_VERSION_H,
122     compatible_with = DEFAULT_COMPATIBILITY,
123     substitutions = {
124         "@JPEGXL_MAJOR_VERSION@": str(libjxl_major_version),
125         "@JPEGXL_MINOR_VERSION@": str(libjxl_minor_version),
126         "@JPEGXL_PATCH_VERSION@": str(libjxl_patch_version),
127     },
128     template = "jxl/version.h.in",
131 cc_library(
132     name = "jxl_version",
133     hdrs = [JXL_VERSION_H],
134     compatible_with = DEFAULT_COMPATIBILITY,
135     strip_include_prefix = INCLUDES_DIR,
138 JPEGLI_JCONFIG_H = INCLUDES_DIR + "/jpegli/jconfig.h"
140 JPEGLI_JMORECFG_H = INCLUDES_DIR + "/jpegli/jmorecfg.h"
142 JPEGLI_JPEGLIB_H = INCLUDES_DIR + "/jpegli/jpeglib.h"
144 copy_file(
145     name = "expand_jconfig",
146     src = "@libjpeg_turbo//:jconfig.h",
147     out = JPEGLI_JCONFIG_H,
148     compatible_with = DEFAULT_COMPATIBILITY,
151 copy_file(
152     name = "copy_jmorecfg",
153     src = "@libjpeg_turbo//:jmorecfg.h",
154     out = JPEGLI_JMORECFG_H,
155     compatible_with = DEFAULT_COMPATIBILITY,
158 copy_file(
159     name = "copy_jpeglib",
160     src = "@libjpeg_turbo//:jpeglib.h",
161     out = JPEGLI_JPEGLIB_H,
162     compatible_with = DEFAULT_COMPATIBILITY,
165 cc_library(
166     name = "includes",
167     hdrs = libjxl_public_headers + [
168         JXL_EXPORT_H,
169         JXL_CMS_EXPORT_H,
170     ],
171     compatible_with = DEFAULT_COMPATIBILITY,
172     strip_include_prefix = INCLUDES_DIR,
173     deps = [":jxl_version"],
176 cc_library(
177     name = "libjpeg_includes",
178     hdrs = [
179         JPEGLI_JCONFIG_H,
180         JPEGLI_JMORECFG_H,
181         JPEGLI_JPEGLIB_H,
182     ],
183     compatible_with = DEFAULT_COMPATIBILITY,
184     strip_include_prefix = INCLUDES_DIR + "/jpegli",
187 cc_library(
188     name = "base",
189     srcs = [path for path in libjxl_base_sources if path.endswith(".cc")],
190     hdrs = [path for path in libjxl_base_sources if path.endswith(".h")],
191     compatible_with = DEFAULT_COMPATIBILITY,
192     deps = [
193         ":includes",
194     ] + libjxl_deps_hwy,
197 cc_library(
198     name = "jpegxl",
199     srcs = libjxl_dec_sources + libjxl_dec_box_sources + libjxl_dec_jpeg_sources + libjxl_enc_sources + libjxl_cms_sources,
200     compatible_with = DEFAULT_COMPATIBILITY,
201     defines = [
202         "JPEGXL_ENABLE_SKCMS=1",
203     ],
204     deps = [
205         ":base",
206         ":includes",
207     ] + libjxl_deps_brotli + libjxl_deps_hwy + libjxl_deps_skcms,
210 cc_library(
211     name = "jpegxl_private",
212     hdrs = [
213         path
214         for path in libjxl_dec_sources + libjxl_dec_box_sources + libjxl_dec_jpeg_sources + libjxl_enc_sources + libjxl_cms_sources
215         if path.endswith(".h") and not path.endswith("-inl.h")
216     ],
217     compatible_with = DEFAULT_COMPATIBILITY,
218     deps = [":jpegxl"],
221 cc_library(
222     name = "jpegxl_threads",
223     srcs = libjxl_threads_sources,
224     hdrs = libjxl_threads_public_headers + [JXL_THREADS_EXPORT_H],
225     compatible_with = DEFAULT_COMPATIBILITY,
226     strip_include_prefix = INCLUDES_DIR,
227     deps = [
228         ":base",
229         ":includes",
230     ],
233 CODEC_FILES = libjxl_codec_apng_sources + libjxl_codec_exr_sources + libjxl_codec_gif_sources + libjxl_codec_jpegli_sources + libjxl_codec_jpg_sources + libjxl_codec_jxl_sources + libjxl_codec_npy_sources + libjxl_codec_pgx_sources + libjxl_codec_pnm_sources
235 CODEC_SRCS = [path for path in CODEC_FILES if path.endswith(".cc")]
237 CODEC_HDRS = [path for path in CODEC_FILES if path.endswith(".h")]
239 cc_library(
240     name = "jpegli",
241     srcs = libjxl_jpegli_sources,
242     hdrs = [
243         "jpegli/common_internal.h",  # TODO(eustas): should not be here
244     ],
245     compatible_with = DEFAULT_COMPATIBILITY,
246     deps = [
247         ":jpegxl_private",
248         ":libjpeg_includes",
249     ] + libjxl_deps_hwy,
252 # TODO(eustas): build codecs separately?
253 cc_library(
254     name = "jpegxl_extras",
255     srcs = libjxl_extras_sources + libjxl_extras_for_tools_sources + CODEC_SRCS,
256     hdrs = CODEC_HDRS,
257     compatible_with = DEFAULT_COMPATIBILITY,
258     defines = [
259         "JPEGXL_ENABLE_APNG=1",
260         "JPEGXL_ENABLE_EXR=1",
261         "JPEGXL_ENABLE_GIF=1",
262         "JPEGXL_ENABLE_JPEG=1",
263         "JPEGXL_ENABLE_JPEGLI=1",
264     ],
265     deps = [
266         ":jpegli",
267         ":jpegxl_private",
268         ":jpegxl_threads",
269         ":jxl_version",
270     ] + libjxl_deps_exr + libjxl_deps_gif + libjxl_deps_jpeg + libjxl_deps_png,
273 TESTLIB_FILES = libjxl_testlib_files + libjxl_jpegli_testlib_files + libjxl_jpegli_libjpeg_helper_files
275 cc_library(
276     name = "test_utils",
277     testonly = 1,
278     srcs = [path for path in TESTLIB_FILES if not path.endswith(".h")],
279     hdrs = [path for path in TESTLIB_FILES if path.endswith(".h")],
280     compatible_with = DEFAULT_COMPATIBILITY,
281     defines = [
282         'JPEGXL_ROOT_PACKAGE=\'"' + libjxl_root_package + '"\'',
283     ],
284     deps = [
285         ":jpegli",
286         ":jpegxl_extras",
287         ":jpegxl_private",
288     ] + libjxl_deps_runfiles,
291 TESTS = [path.partition(".")[0] for path in libjxl_tests + libjxl_jpegli_tests]
294     cc_test(
295         name = test,
296         timeout = libjxl_test_timeouts.get(test, "moderate"),
297         srcs = [
298             test + ".cc",
299             "jpegli/testing.h",
300             "jxl/testing.h",
301         ],
302         data = ["//:testdata"],
303         shard_count = libjxl_test_shards.get(test, 1),
304         deps = [
305             ":jpegxl_extras",
306             ":jpegxl_private",
307             ":jpegxl_threads",
308             ":test_utils",
309         ] + libjxl_deps_gtest + libjxl_deps_hwy_test_util + libjxl_deps_hwy_nanobenchmark,
310     )
311     for test in TESTS