blob: 81a91bd6521af21bdc44da6a1d1218b40094439d [file] [log] [blame]
# Copyright 2017 The Fuchsia Authors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
config("freetype_config") {
include_dirs = [ "include" ]
cflags = [ "-Wno-macro-redefined" ]
# TODO(fxbug.dev/42078767): freetype2 has a lot of instances of this type of
# UB. We should come back and fix these. Disabling this check here though
# doesn't change anything since it wasn't until recently that this check was
# extended to cover C, so these bugs were already here.
cflags_c = [ "-fno-sanitize=function" ]
}
config("freetype_warnings") {
cflags = [
"-Wno-conversion",
"-Wno-implicit-fallthrough",
"-Wno-unused-function",
"-Wno-unused-variable",
]
}
config("freetype_config_for_rust_host") {
# Without `-fPIC`, we get the error:
# > ld.lld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly
# > segment
cflags = [
"-fPIC",
# TODO(https://fxbug.dev/321109569): Remove once the build issue in freetype2's copy of zlib is resolved.
"-fno-define-target-os-macros",
]
}
#TODO(mikejurka): Remove once we've migrated to the freetype2 target everywhere
group("freetype") {
public_deps = [ ":freetype2" ]
}
template("freetype_library") {
target(invoker.library_type, target_name) {
forward_variables_from(invoker, "*")
if (!defined(rust_host)) {
rust_host = false
}
shared_lib = library_type == "shared_library"
sources = [
"src/autofit/autofit.c",
"src/base/ftbase.c",
"src/base/ftbbox.c",
"src/base/ftbdf.c",
"src/base/ftbitmap.c",
"src/base/ftdebug.c",
"src/base/ftfstype.c",
"src/base/ftgasp.c",
"src/base/ftglyph.c",
"src/base/ftinit.c",
"src/base/ftmm.c",
"src/base/ftstroke.c",
"src/base/ftsynth.c",
"src/base/ftsystem.c",
"src/base/fttype1.c",
"src/gzip/ftgzip.c",
"src/lzw/ftlzw.c",
"src/psaux/psaux.c",
"src/pshinter/pshinter.c",
"src/psnames/psnames.c",
"src/sfnt/sfnt.c",
"src/smooth/smooth.c",
# Font Drivers. Drivers need to be enabled in ftmodule.h explicitly.
"src/cff/cff.c", # OpenType, (.cff, .cef)
"src/truetype/truetype.c", # TrueType
]
defines = [
"FT2_BUILD_LIBRARY",
"DARWIN_NO_CARBON",
# Long directory name to avoid accidentally using wrong headers.
"FT_CONFIG_MODULES_H=<freetype-fuchsia-config/ftmodule.h>",
"FT_CONFIG_OPTIONS_H=<freetype-fuchsia-config/ftoption.h>",
]
if (shared_lib) {
defines += [
"FT_EXPORT(x)=extern __attribute__(( visibility( \"default\" ) )) x",
"FT_EXPORT_DEF(x)=extern __attribute__(( visibility( \"default\" ) )) x",
"FT_EXPORT_VAR(x)=extern __attribute__(( visibility( \"default\" ) )) x",
]
} else {
# Reduce visibility of symbols.
defines += [ "FT_EXPORT(x)=x" ]
}
configs += [ ":freetype_warnings" ]
if (!rust_host) {
defines += [ "FT_CONFIG_OPTION_USE_PNG" ]
}
public_configs = [ ":freetype_config" ]
if (rust_host) {
public_configs += [
":freetype_config_for_rust_host",
":freetype_warnings",
]
}
if (rust_host) {
deps = [ "//third_party/zlib:zlib_for_rust_host" ]
} else {
deps = [
"//third_party/libpng",
"//third_party/zlib",
]
}
}
}
freetype_library("freetype2") {
# Shared libs are disabled in host toolchain.
if (current_toolchain == host_toolchain) {
library_type = "source_set"
} else {
library_type = "shared_library"
}
}
# TODO(36315): Remove workaround for Rust host_toolchain
freetype_library("freetype2_for_rust_host") {
library_type = "static_library"
rust_host = true
}