1# Copyright (C) 2023 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15load("@gbl//toolchain:gbl_toolchain.bzl", "link_static_cc_library") 16load("@gbl//toolchain:gbl_workspace_util.bzl", "ANDROID_RUST_LINTS") 17load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") 18load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test") 19 20package( 21 default_visibility = ["//visibility:public"], 22) 23 24rust_library( 25 name = "libc", 26 srcs = glob(["src/*.rs"]), 27 edition = "2021", 28 rustc_flags = ANDROID_RUST_LINTS, 29 deps = [ 30 ":libc_c_staticlib", 31 "@gbl//libsafemath", 32 ], 33) 34 35rust_test( 36 name = "libc_test", 37 crate = ":libc", 38 rustc_flags = ANDROID_RUST_LINTS, 39) 40 41rust_library( 42 name = "libc_deps_posix", 43 srcs = ["deps/posix.rs"], 44 edition = "2021", 45 rustc_flags = ANDROID_RUST_LINTS, 46) 47 48cc_library( 49 name = "headers", 50 hdrs = [ 51 "include/debug.h", 52 "include/gbl/print.h", 53 "include/inttypes.h", 54 "include/limits.h", 55 "include/stdio.h", 56 "include/stdlib.h", 57 "include/string.h", 58 "include/sys/types.h", 59 ], 60 includes = ["include"], 61) 62 63cc_library( 64 name = "libc_c", 65 srcs = [ 66 "src/format.c", 67 ], 68 deps = [ 69 ":headers", 70 ], 71) 72 73cc_test( 74 name = "libc_c_test", 75 srcs = ["src/format_test.cpp"], 76 target_compatible_with = [ 77 "@platforms//os:linux", 78 ], 79 deps = [ 80 ":libc_c", 81 "@googletest//:gtest_main", 82 ], 83) 84 85link_static_cc_library( 86 name = "libc_c_staticlib", 87 cc_library = ":libc_c", 88) 89