blob: 6e6f9872082ffb062b406367df4cbf804bc47147 [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 = []
if (is_clang) {
cflags += [
"-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(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/ftfstype.c",
"src/base/ftgasp.c",
"src/base/ftglyph.c",
"src/base/ftinit.c",
"src/base/ftmm.c",
"src/base/ftstroke.c",
"src/base/ftsystem.c",
"src/base/fttype1.c",
"src/base/ftsynth.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
]
# TODO(46923): UBSan has found an instance of undefined behavior in this target.
# Disable UBSan for this target temporarily until it is migrated into CI/CQ.
configs += [ "//build/config:temporarily_disable_ubsan_do_not_use" ]
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" ]
}
if (!rust_host) {
defines += [ "FT_CONFIG_OPTION_USE_PNG" ]
}
public_configs = [ ":freetype_config" ]
if (rust_host) {
public_configs += [":freetype_config_for_rust_host"]
}
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
}