blob: 99e16dfe529878998fb70f1d96242a4d5ec12d53 [file] [log] [blame]
# Copyright 2023 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("../../libc.gni")
llvm_libc_source_set("printf_core") {
visibility = [ "../*" ]
public = [
"printf_main.h",
"writer.h",
]
public_configs = [ ":printf-options" ]
functions = []
# The implementation is entirely in headers, but they are all used only via
# the single printf_main.h header.
sources = [
"converter.h",
"core_structs.h",
"parser.h",
]
# Each implementation pieces has its own tests.
test_sources = [
"converter_test.cpp",
"writer_test.cpp",
# TODO(https://fxbug.dev/42141211): This test code requires the fancier
# test machinery that we don't yet support since zxtest doesn't have the
# features.
#"parser_test.cpp",
]
}
config("printf-options") {
visibility = [ ":*" ]
defines = [
# Never support %n.
"LIBC_COPT_PRINTF_DISABLE_WRITE_INT",
# Don't support %m since it uses problematic llvm-libc internals.
"LIBC_COPT_PRINTF_DISABLE_STRERROR",
]
# Don't support FP types if the toolchain doesn't.
_no_floating_point = toolchain_variant.tags + [ "no-floating-point" ] -
[ "no-floating-point" ] != toolchain_variant.tags
if (_no_floating_point) {
defines += [ "LIBC_COPT_PRINTF_DISABLE_FLOAT" ]
}
}
libc_source_set("wrapper") {
visibility = [ "//sdk/lib/ld/*" ]
public = [ "wrapper.h" ]
public_configs = [ ":wrapper.config" ]
sources = [ "wrapper.cc" ]
configs = [ ":printf-options" ]
deps = [ ":printf_core" ]
}
config("wrapper.config") {
visibility = [ ":*" ]
defines = [ "LIBC_NAMESPACE=$libc_namespace" ]
include_dirs = [ libc ]
}