xref: /aosp_15_r20/external/skia/bazel/external/freetype/BUILD.bazel (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1# This file will be copied into //third_party/externals/freetype via the new_local_repository
2# rule in WORKSPACE.bazel, so all files should be relative to that path.
3
4# We define this here because the emscripten toolchain calls the cpu wasm, whereas the
5# bazelbuild/platforms call it wasm32. https://github.com/emscripten-core/emsdk/issues/919
6config_setting(
7    name = "cpu_wasm",
8    values = {
9        "cpu": "wasm",
10    },
11)
12
13FREETYPE_PUBLIC_DEFINES = [
14    "FT_CONFIG_OPTION_SVG",
15    # FT_CONFIG_OPTION_USE_BROTLI TODO(kjlubick)
16    "FT_CONFIG_OPTION_USE_ZLIB",
17    #FT_CONFIG_OPTION_SYSTEM_ZLIB TODO(bungeman)
18    "SK_FREETYPE_MINIMUM_RUNTIME_VERSION_IS_BUILD_VERSION",
19] + select(
20    {
21        ":cpu_wasm": [
22            # Use a trimmed down set of options to reduce code size.
23            "FT_CONFIG_MODULES_H=<skia/no-type1/freetype/config/ftmodule.h>",
24            "FT_CONFIG_OPTIONS_H=<skia/no-type1/freetype/config/ftoption.h>",
25        ],
26        "@platforms//os:windows": [
27            # On Windows, the shell doesn't like the angle brackets, so we need
28            # to escape them, and we need to escape them twice (meaning that we
29            # also escape the escape character, '^') so that they make it
30            # through from Bazel to the trampoline script and from the
31            # trampoline script to Clang.
32            "FT_CONFIG_MODULES_H=^^^<skia/android/freetype/config/ftmodule.h^^^>",
33            "FT_CONFIG_OPTIONS_H=^^^<skia/android/freetype/config/ftoption.h^^^>",
34        ],
35        "//conditions:default": [
36            "FT_CONFIG_MODULES_H=<skia/android/freetype/config/ftmodule.h>",
37            "FT_CONFIG_OPTIONS_H=<skia/android/freetype/config/ftoption.h>",
38        ],
39    },
40)
41
42FREETYPE_LOCAL_DEFINES = ["FT2_BUILD_LIBRARY"]
43
44# Copy our freetype include files from the config subfolder so they can be more
45# easily accessed by how we set FT_CONFIG_MODULES_H. Because these files don't exist in
46# the original Freetype checkout, we have to put them in a separate workspace (we cannot
47# refer to them from the Skia workspace or that would be a circular dependency).
48genrule(
49    name = "copy_android_freetype_config",
50    srcs = [
51        "@freetype_config//:freetype-android/freetype/config/ftmodule.h",
52        "@freetype_config//:freetype-android/freetype/config/ftoption.h",
53    ],
54    outs = [
55        "builds/skia/android/freetype/config/ftmodule.h",
56        "builds/skia/android/freetype/config/ftoption.h",
57    ],
58    # SRCS is a space seperated list of files.
59    # RULEDIR is the directory containing this BUILD.bazel file (the root of the freetype directory)
60    # but only in the "genfiles tree", which does not persist after compilation.
61    cmd = "cp $(SRCS) $(RULEDIR)/builds/skia/android/freetype/config/",
62    cmd_bat = "for %f in ($(SRCS)) do copy %f $(RULEDIR)\\builds\\skia\\android\\freetype\\config",
63)
64
65# It is easiest to have multiple copy rules, one per output directory.
66genrule(
67    name = "copy_no_type1_freetype_config",
68    srcs = [
69        "@freetype_config//:freetype-no-type1/freetype/config/ftmodule.h",
70        "@freetype_config//:freetype-no-type1/freetype/config/ftoption.h",
71    ],
72    outs = [
73        "builds/skia/no-type1/freetype/config/ftmodule.h",
74        "builds/skia/no-type1/freetype/config/ftoption.h",
75    ],
76    # SRCS is a space seperated list of files.
77    # RULEDIR is the directory containing this BUILD.bazel file (the root of the freetype directory)
78    # but only in the "genfiles tree", which does not persist after compilation.
79    cmd = "cp $(SRCS) $(RULEDIR)/builds/skia/no-type1/freetype/config/",
80    cmd_bat = "for %f in ($(SRCS)) do copy %f $(RULEDIR)\\builds\\skia\\no-type1\\freetype\\config",
81)
82
83cc_library(
84    name = "freetype",
85    srcs = [
86        "include/freetype/internal/autohint.h",
87        "include/freetype/internal/cffotypes.h",
88        "include/freetype/internal/cfftypes.h",
89        "include/freetype/internal/compiler-macros.h",
90        "include/freetype/internal/ftcalc.h",
91        "include/freetype/internal/ftdebug.h",
92        "include/freetype/internal/ftdrv.h",
93        "include/freetype/internal/ftgloadr.h",
94        "include/freetype/internal/fthash.h",
95        "include/freetype/internal/ftmemory.h",
96        "include/freetype/internal/ftmmtypes.h",
97        "include/freetype/internal/ftobjs.h",
98        "include/freetype/internal/ftpsprop.h",
99        "include/freetype/internal/ftrfork.h",
100        "include/freetype/internal/ftserv.h",
101        "include/freetype/internal/ftstream.h",
102        "include/freetype/internal/fttrace.h",
103        "include/freetype/internal/ftvalid.h",
104        "include/freetype/internal/psaux.h",
105        "include/freetype/internal/pshints.h",
106        "include/freetype/internal/services/svbdf.h",
107        "include/freetype/internal/services/svcfftl.h",
108        "include/freetype/internal/services/svcid.h",
109        "include/freetype/internal/services/svfntfmt.h",
110        "include/freetype/internal/services/svgldict.h",
111        "include/freetype/internal/services/svgxval.h",
112        "include/freetype/internal/services/svkern.h",
113        "include/freetype/internal/services/svmetric.h",
114        "include/freetype/internal/services/svmm.h",
115        "include/freetype/internal/services/svotval.h",
116        "include/freetype/internal/services/svpfr.h",
117        "include/freetype/internal/services/svpostnm.h",
118        "include/freetype/internal/services/svprop.h",
119        "include/freetype/internal/services/svpscmap.h",
120        "include/freetype/internal/services/svpsinfo.h",
121        "include/freetype/internal/services/svsfnt.h",
122        "include/freetype/internal/services/svttcmap.h",
123        "include/freetype/internal/services/svtteng.h",
124        "include/freetype/internal/services/svttglyf.h",
125        "include/freetype/internal/services/svwinfnt.h",
126        "include/freetype/internal/sfnt.h",
127        "include/freetype/internal/svginterface.h",
128        "include/freetype/internal/t1types.h",
129        "include/freetype/internal/tttypes.h",
130        "include/freetype/internal/wofftypes.h",
131        "include/freetype/otsvg.h",
132        "include/freetype/t1tables.h",
133        "include/freetype/ttnameid.h",
134        "include/freetype/tttables.h",
135        "include/freetype/tttags.h",
136        "src/autofit/afblue.h",
137        "src/autofit/afcjk.h",
138        "src/autofit/afcover.h",
139        "src/autofit/afdummy.h",
140        "src/autofit/aferrors.h",
141        "src/autofit/afglobal.h",
142        "src/autofit/afhints.h",
143        "src/autofit/afindic.h",
144        "src/autofit/aflatin.h",
145        "src/autofit/afloader.h",
146        "src/autofit/afmodule.h",
147        "src/autofit/afranges.h",
148        "src/autofit/afscript.h",
149        "src/autofit/afshaper.h",
150        "src/autofit/afstyles.h",
151        "src/autofit/aftypes.h",
152        "src/autofit/afws-decl.h",
153        "src/autofit/afws-iter.h",
154        "src/autofit/autofit.c",
155        "src/autofit/ft-hb.c",
156        "src/autofit/ft-hb.h",
157        "src/base/ftbase.c",
158        "src/base/ftbase.h",
159        "src/base/ftbbox.c",
160        "src/base/ftbitmap.c",
161        "src/base/ftdebug.c",
162        "src/base/ftfstype.c",
163        "src/base/ftgasp.c",
164        "src/base/ftglyph.c",
165        "src/base/ftinit.c",
166        "src/base/ftmm.c",
167        "src/base/ftpatent.c",
168        "src/base/ftstroke.c",
169        "src/base/ftsynth.c",
170        "src/base/ftsystem.c",
171        "src/base/fttype1.c",
172        "src/base/ftwinfnt.c",
173        "src/base/md5.h",
174        "src/cff/cff.c",
175        "src/cff/cffcmap.h",
176        "src/cff/cffdrivr.h",
177        "src/cff/cfferrs.h",
178        "src/cff/cffgload.h",
179        "src/cff/cffload.h",
180        "src/cff/cffobjs.h",
181        "src/cff/cffparse.h",
182        "src/cff/cfftoken.h",
183        "src/cid/ciderrs.h",
184        "src/cid/cidgload.h",
185        "src/cid/cidload.h",
186        "src/cid/cidobjs.h",
187        "src/cid/cidparse.h",
188        "src/cid/cidriver.h",
189        "src/cid/cidtoken.h",
190        "src/cid/type1cid.c",
191        "src/gzip/crc32.h",
192        "src/gzip/ftgzip.c",
193        "src/gzip/ftzconf.h",
194        "src/gzip/inffast.h",
195        "src/gzip/inffixed.h",
196        "src/gzip/inflate.h",
197        "src/gzip/inftrees.h",
198        "src/gzip/zlib.h",
199        "src/gzip/zutil.h",
200        "src/psaux/afmparse.h",
201        "src/psaux/cffdecode.h",
202        "src/psaux/psarrst.h",
203        "src/psaux/psaux.c",
204        "src/psaux/psauxerr.h",
205        "src/psaux/psauxmod.h",
206        "src/psaux/psblues.h",
207        "src/psaux/psconv.h",
208        "src/psaux/pserror.h",
209        "src/psaux/psfixed.h",
210        "src/psaux/psfont.h",
211        "src/psaux/psft.h",
212        "src/psaux/psglue.h",
213        "src/psaux/pshints.h",
214        "src/psaux/psintrp.h",
215        "src/psaux/psobjs.h",
216        "src/psaux/psread.h",
217        "src/psaux/psstack.h",
218        "src/psaux/pstypes.h",
219        "src/psaux/t1cmap.h",
220        "src/psaux/t1decode.h",
221        "src/pshinter/pshalgo.h",
222        "src/pshinter/pshglob.h",
223        "src/pshinter/pshinter.c",
224        "src/pshinter/pshmod.h",
225        "src/pshinter/pshnterr.h",
226        "src/pshinter/pshrec.h",
227        "src/psnames/psmodule.h",
228        "src/psnames/psnamerr.h",
229        "src/psnames/psnames.c",
230        "src/psnames/pstables.h",
231        "src/raster/ftmisc.h",
232        "src/raster/ftraster.h",
233        "src/raster/ftrend1.h",
234        "src/raster/raster.c",
235        "src/raster/rasterrs.h",
236        "src/sfnt/pngshim.h",
237        "src/sfnt/sfdriver.h",
238        "src/sfnt/sferrors.h",
239        "src/sfnt/sfnt.c",
240        "src/sfnt/sfobjs.h",
241        "src/sfnt/sfwoff.h",
242        "src/sfnt/sfwoff2.h",
243        "src/sfnt/ttbdf.h",
244        "src/sfnt/ttcmap.h",
245        "src/sfnt/ttcmapc.h",
246        "src/sfnt/ttcolr.h",
247        "src/sfnt/ttcpal.h",
248        "src/sfnt/ttgpos.h",
249        "src/sfnt/ttkern.h",
250        "src/sfnt/ttload.h",
251        "src/sfnt/ttmtx.h",
252        "src/sfnt/ttpost.h",
253        "src/sfnt/ttsbit.h",
254        "src/sfnt/woff2tags.h",
255        "src/smooth/ftgrays.h",
256        "src/smooth/ftsmerrs.h",
257        "src/smooth/ftsmooth.h",
258        "src/smooth/smooth.c",
259        "src/svg/ftsvg.h",
260        "src/svg/svg.c",
261        "src/svg/svgtypes.h",
262        "src/truetype/truetype.c",
263        "src/truetype/ttdriver.h",
264        "src/truetype/tterrors.h",
265        "src/truetype/ttgload.h",
266        "src/truetype/ttgxvar.h",
267        "src/truetype/ttinterp.h",
268        "src/truetype/ttobjs.h",
269        "src/truetype/ttpload.h",
270        "src/type1/t1afm.h",
271        "src/type1/t1driver.h",
272        "src/type1/t1errors.h",
273        "src/type1/t1gload.h",
274        "src/type1/t1load.h",
275        "src/type1/t1objs.h",
276        "src/type1/t1parse.h",
277        "src/type1/t1tokens.h",
278        "src/type1/type1.c",
279    ],
280    hdrs = [
281        "include/freetype/config/ftconfig.h",
282        "include/freetype/config/ftheader.h",
283        # Ensure custom modules and options by removing the generic ones.
284        #"include/freetype/config/ftmodule.h",
285        #"include/freetype/config/ftoption.h",
286        "include/freetype/config/ftstdlib.h",
287        "include/freetype/config/integer-types.h",
288        "include/freetype/config/mac-support.h",
289        "include/freetype/config/public-macros.h",
290        "include/freetype/freetype.h",
291        "include/freetype/ftadvanc.h",
292        "include/freetype/ftbbox.h",
293        "include/freetype/ftbdf.h",
294        "include/freetype/ftbitmap.h",
295        "include/freetype/ftbzip2.h",
296        "include/freetype/ftcache.h",
297        "include/freetype/ftchapters.h",
298        "include/freetype/ftcid.h",
299        "include/freetype/ftcolor.h",
300        "include/freetype/ftdriver.h",
301        "include/freetype/fterrdef.h",
302        "include/freetype/fterrors.h",
303        "include/freetype/ftfntfmt.h",
304        "include/freetype/ftgasp.h",
305        "include/freetype/ftglyph.h",
306        "include/freetype/ftgxval.h",
307        "include/freetype/ftgzip.h",
308        "include/freetype/ftimage.h",
309        "include/freetype/ftincrem.h",
310        "include/freetype/ftlcdfil.h",
311        "include/freetype/ftlist.h",
312        "include/freetype/ftlogging.h",
313        "include/freetype/ftlzw.h",
314        "include/freetype/ftmac.h",
315        "include/freetype/ftmm.h",
316        "include/freetype/ftmodapi.h",
317        "include/freetype/ftmoderr.h",
318        "include/freetype/ftotval.h",
319        "include/freetype/ftoutln.h",
320        "include/freetype/ftparams.h",
321        "include/freetype/ftpfr.h",
322        "include/freetype/ftrender.h",
323        "include/freetype/ftsizes.h",
324        "include/freetype/ftsnames.h",
325        "include/freetype/ftstroke.h",
326        "include/freetype/ftsynth.h",
327        "include/freetype/ftsystem.h",
328        "include/freetype/fttrigon.h",
329        "include/freetype/fttypes.h",
330        "include/freetype/ftwinfnt.h",
331        "include/freetype/otsvg.h",
332        "include/freetype/t1tables.h",
333        "include/freetype/ttnameid.h",
334        "include/freetype/tttables.h",
335        "include/freetype/tttags.h",
336        "include/ft2build.h",
337        # These are copied in by some genrules
338        "builds/skia/android/freetype/config/ftmodule.h",
339        "builds/skia/android/freetype/config/ftoption.h",
340        "builds/skia/no-type1/freetype/config/ftmodule.h",
341        "builds/skia/no-type1/freetype/config/ftoption.h",
342    ],
343    copts = [
344        "-Wno-unused-function",
345    ],
346    defines = FREETYPE_PUBLIC_DEFINES,
347    includes = [
348        "builds",
349        "include",
350    ],
351    local_defines = FREETYPE_LOCAL_DEFINES,
352    # Freetype includes a lot of .c files. We need to make those available for inclusion explicitly.
353    textual_hdrs = [
354        "src/autofit/afblue.c",
355        "src/autofit/afcjk.c",
356        "src/autofit/afdummy.c",
357        "src/autofit/afglobal.c",
358        "src/autofit/afhints.c",
359        "src/autofit/afindic.c",
360        "src/autofit/aflatin.c",
361        "src/autofit/afloader.c",
362        "src/autofit/afmodule.c",
363        "src/autofit/afranges.c",
364        "src/autofit/afshaper.c",
365        "src/autofit/ft-hb.c",
366        "src/base/ftadvanc.c",
367        "src/base/ftbase.c",
368        "src/base/ftcalc.c",
369        "src/base/ftcolor.c",
370        "src/base/ftdbgmem.c",
371        "src/base/fterrors.c",
372        "src/base/ftfntfmt.c",
373        "src/base/ftgloadr.c",
374        "src/base/fthash.c",
375        "src/base/ftlcdfil.c",
376        "src/base/ftmac.c",
377        "src/base/ftobjs.c",
378        "src/base/ftoutln.c",
379        "src/base/ftpsprop.c",
380        "src/base/ftrfork.c",
381        "src/base/ftsnames.c",
382        "src/base/ftstream.c",
383        "src/base/fttrigon.c",
384        "src/base/ftutil.c",
385        "src/cff/cffcmap.c",
386        "src/cff/cffdrivr.c",
387        "src/cff/cffgload.c",
388        "src/cff/cffload.c",
389        "src/cff/cffobjs.c",
390        "src/cff/cffparse.c",
391        "src/cid/cidgload.c",
392        "src/cid/cidload.c",
393        "src/cid/cidobjs.c",
394        "src/cid/cidparse.c",
395        "src/cid/cidriver.c",
396        "src/gzip/adler32.c",
397        "src/gzip/crc32.c",
398        "src/gzip/inffast.c",
399        "src/gzip/inflate.c",
400        "src/gzip/inftrees.c",
401        "src/gzip/zutil.c",
402        "src/psaux/afmparse.c",
403        "src/psaux/cffdecode.c",
404        "src/psaux/psarrst.c",
405        "src/psaux/psauxmod.c",
406        "src/psaux/psblues.c",
407        "src/psaux/psconv.c",
408        "src/psaux/pserror.c",
409        "src/psaux/psfont.c",
410        "src/psaux/psft.c",
411        "src/psaux/pshints.c",
412        "src/psaux/psintrp.c",
413        "src/psaux/psobjs.c",
414        "src/psaux/psread.c",
415        "src/psaux/psstack.c",
416        "src/psaux/t1cmap.c",
417        "src/psaux/t1decode.c",
418        "src/pshinter/pshalgo.c",
419        "src/pshinter/pshglob.c",
420        "src/pshinter/pshmod.c",
421        "src/pshinter/pshrec.c",
422        "src/psnames/psmodule.c",
423        "src/raster/ftraster.c",
424        "src/raster/ftrend1.c",
425        "src/sfnt/pngshim.c",
426        "src/sfnt/sfdriver.c",
427        "src/sfnt/sfobjs.c",
428        "src/sfnt/sfwoff.c",
429        "src/sfnt/sfwoff2.c",
430        "src/sfnt/ttbdf.c",
431        "src/sfnt/ttcmap.c",
432        "src/sfnt/ttcolr.c",
433        "src/sfnt/ttcpal.c",
434        "src/sfnt/ttgpos.c",
435        "src/sfnt/ttkern.c",
436        "src/sfnt/ttload.c",
437        "src/sfnt/ttmtx.c",
438        "src/sfnt/ttpost.c",
439        "src/sfnt/ttsbit.c",
440        "src/sfnt/ttsvg.c",
441        "src/sfnt/ttsvg.h",
442        "src/sfnt/woff2tags.c",
443        "src/smooth/ftgrays.c",
444        "src/smooth/ftsmooth.c",
445        "src/svg/ftsvg.c",
446        "src/truetype/ttdriver.c",
447        "src/truetype/ttgload.c",
448        "src/truetype/ttgxvar.c",
449        "src/truetype/ttinterp.c",
450        "src/truetype/ttobjs.c",
451        "src/truetype/ttpload.c",
452        "src/type1/t1afm.c",
453        "src/type1/t1driver.c",
454        "src/type1/t1gload.c",
455        "src/type1/t1load.c",
456        "src/type1/t1objs.c",
457        "src/type1/t1parse.c",
458    ],
459    visibility = ["//visibility:public"],
460    deps = [
461        "@libpng",  # TODO(kjlubick) add brotli option
462    ],
463)
464