| # Copyright 2019 The Fuchsia Authors |
| # |
| # Use of this source code is governed by a MIT-style |
| # license that can be found in the LICENSE file or at |
| # https://opensource.org/licenses/MIT |
| |
| import("//build/cpp/library_headers.gni") |
| import("//build/toolchain/toolchain_environment.gni") |
| |
| library_headers("headers") { |
| headers = [] |
| public_deps = [ |
| # <stdio.h> has #include <ktl/string_view.h>. |
| "//zircon/kernel/lib/ktl:headers", |
| ] |
| |
| public_configs = [ ":headers.after" ] |
| } |
| |
| static_library("libc") { |
| public_deps = [ ":headers" ] |
| |
| sources = [ |
| "abort.cc", |
| "atomic.cc", |
| "cxa_atexit.cc", |
| "cxa_pure_virtual.cc", |
| "fprintf.cc", |
| "printf.cc", |
| "rand.cc", |
| "snprintf.cc", |
| "string-file.cc", |
| "strtol.cc", |
| "strtoul.cc", |
| ] |
| deps = [ |
| ":ctype", |
| "string", |
| "//zircon/system/ulib/zircon-internal", |
| ] |
| |
| if (toolchain_environment == "kernel") { |
| deps += [ "//zircon/kernel/lib/heap" ] |
| } |
| } |
| |
| config("headers.after") { |
| visibility = [ |
| ":*", |
| "//zircon/kernel:headers", |
| ] |
| |
| # libc/include is before toolchain headers because it needs to be able to |
| # override some libc++ headers that won't work in the kernel context. |
| # However, libc/include/limits.h punts to the toolchain via #include_next |
| # <limits.h> and the toolchain's limits.h does the same to get the "system" |
| # libc <limits.h>, so we need another include directory after the toolchain |
| # headers that has a limits.h for that to find, even though in the kernel |
| # there is nothing to add to the toolchain's <limits.h> content. |
| cflags = [ |
| "-idirafter", |
| rebase_path("include-after", root_build_dir), |
| ] |
| |
| # This is propagated by :headers, but that's not used directly by the kernel |
| # toolchain. It explicitly uses this config, so propagate it separately that |
| # way. |
| configs = [ "//zircon/kernel/lib/ktl:headers.after" ] |
| } |
| |
| source_set("ctype") { |
| sources = [ "ctype.cc" ] |
| deps = [ ":headers" ] |
| } |
| |
| source_set("tests") { |
| # TODO: testonly = true |
| if (toolchain_environment == "kernel") { |
| sources = [ "atomic_tests.cc" ] |
| deps = [ |
| "//zircon/kernel/lib/ktl:headers", |
| "//zircon/kernel/lib/unittest", |
| ] |
| } |
| } |