1# Copyright 2024 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import("//build/rust/rust_bindgen.gni") 6import("//build/rust/rust_executable.gni") 7import("//build/rust/rust_static_library.gni") 8 9source_set("c_lib_headers") { 10 sources = [ "lib.h" ] 11} 12 13component("c_lib") { 14 sources = [ "lib.c" ] 15 16 deps = [ ":c_lib_headers" ] 17 18 defines = [ "COMPONENT_IMPLEMENTATION" ] 19} 20 21rust_bindgen("c_lib_bindgen") { 22 header = "lib.h" 23 deps = [ ":c_lib_headers" ] 24 wrap_static_fns = true 25} 26 27rust_static_library("bindgen_static_fns_test_lib") { 28 allow_unsafe = true 29 deps = [ 30 ":c_lib", 31 ":c_lib_bindgen", 32 ":c_lib_bindgen_static_fns", 33 ] 34 sources = [ "src/lib.rs" ] 35 build_native_rust_unit_tests = true 36 crate_root = "src/lib.rs" 37 38 bindgen_output = get_target_outputs(":c_lib_bindgen") 39 inputs = bindgen_output 40 rustenv = [ "BINDGEN_RS_FILE=" + 41 rebase_path(bindgen_output[0], get_path_info(crate_root, "dir")) ] 42} 43 44rust_executable("bindgen_static_fns_test") { 45 deps = [ ":bindgen_static_fns_test_lib" ] 46 sources = [ "main.rs" ] 47 crate_root = "main.rs" 48} 49