1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! # Gmsh Rust Bindings
//!
//! Rust FFI bindings to the [Gmsh](https://gmsh.info/) SDK.
//!
//! ## 生成 `bindings.rs`
//!
//! 绑定文件由 [bindgen](https://github.com/rust-lang/rust-bindgen) 命令行工具从 Gmsh 的 C API 头文件生成。
//! **不要在构建时自动生成**,因为 Windows 下 bindgen 库可能无法正常运行,且头文件很少变动,手动生成即可。
//!
//! ### 前提
//!
//! - 已安装 bindgen 命令行工具:
//! ```bash
//! cargo install bindgen-cli@0.72
//! ```
//! - Gmsh SDK 已下载到 `external/<platform>/gmsh/`(运行 `cargo build` 会自动下载)。
//!
//! ### 命令
//!
//! ```bash
//! bindgen \
//! --allowlist-function "gmsh.*" \
//! --use-core \
//! --no-layout-tests \
//! --generate-inline-functions \
//! --blocklist-type "__int32|__int64|__int128" \
//! -o src/bindings.rs \
//! external/<platform>/gmsh/include/gmshc.h
//! ```
//!
//! 其中 `<platform>` 根据您的操作系统选择:
//! - Linux: `linux`
//! - Windows: `windows`
//! - macOS (Intel): `macos`
//! - macOS (Apple Silicon): `macos_arm`
//!
//! **Windows 示例:**
//! ```bash
//! bindgen ^
//! --allowlist-function "gmsh.*" ^
//! --use-core ^
//! --no-layout-tests ^
//! --generate-inline-functions ^
//! -o src\bindings.rs ^
//! external\windows\gmsh\include\gmshc.h
//! ```
//!
//! ### 注意事项
//!
//! - 绑定仅在安装有对应平台 Gmsh SDK 的开发机上生成一次,生成结果提交到版本管理,后续其他开发者直接使用。
//! - 如需升级 Gmsh SDK 版本,更新 `build.rs` 中的 `GMSH_VERSION` 常量后重新执行上述命令。