Skip to content

Commit 43ec366

Browse files
committed
Refactor build script and cbindgen configuration
- Updated build.rs to use a variable for the header name and improved readability. - Modified cbindgen.toml to reorganize export settings and enforce naming conventions for types and functions. - Added Clippy lints in lib.rs to enhance code quality and prevent common pitfalls.
1 parent 168718a commit 43ec366

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

datadog-ffe-ffi/build.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// Copyright 2025-Present Datadog, Inc. https://www.datadoghq.com/
22
// SPDX-License-Identifier: Apache-2.0
3+
extern crate build_common;
34

4-
fn main() {
5-
println!("cargo:rerun-if-changed=build.rs");
5+
use build_common::generate_and_configure_header;
66

7-
build_common::generate_and_configure_header("datadog_ffe.h");
7+
fn main() {
8+
let header_name = "datadog_ffe.h";
9+
generate_and_configure_header(header_name);
810
}

datadog-ffe-ffi/cbindgen.toml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ header = """// Copyright 2025-Present Datadog, Inc. https://www.datadoghq.com/
1010
include_guard = "DDOG_FFE_H"
1111
style = "both"
1212
pragma_once = true
13+
1314
no_includes = true
1415
sys_includes = ["stdbool.h", "stddef.h", "stdint.h"]
1516
includes = ["common.h"]
1617

17-
[parse]
18-
parse_deps = true
19-
include = ["ddcommon-ffi", "datadog-ffe"]
20-
2118
[export]
2219
include = ["datadog-ffe-ffi"]
2320
prefix = "ddog_ffe_"
@@ -28,9 +25,16 @@ renaming_overrides_prefixing = true
2825
"Error" = "ddog_Error"
2926
"Vec_u8" = "ddog_Vec_U8"
3027

31-
[fn]
32-
must_use = "DDOG_CHECK_RETURN"
28+
[export.mangle]
29+
rename_types = "PascalCase"
3330

3431
[enum]
3532
prefix_with_name = true
3633
rename_variants = "ScreamingSnakeCase"
34+
35+
[fn]
36+
must_use = "DDOG_CHECK_RETURN"
37+
38+
[parse]
39+
parse_deps = true
40+
include = ["ddcommon-ffi", "datadog-ffe"]

datadog-ffe-ffi/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
// Copyright 2025-Present Datadog, Inc. https://www.datadoghq.com/
22
// SPDX-License-Identifier: Apache-2.0
33

4+
#![cfg_attr(not(test), deny(clippy::panic))]
5+
#![cfg_attr(not(test), deny(clippy::unwrap_used))]
6+
#![cfg_attr(not(test), deny(clippy::expect_used))]
7+
#![cfg_attr(not(test), deny(clippy::todo))]
8+
#![cfg_attr(not(test), deny(clippy::unimplemented))]
9+
410
mod assignment;
511
mod configuration;
612
mod error;

0 commit comments

Comments
 (0)