gmsh_ffi 0.1.0

Safe Rust FFI bindings to the Gmsh SDK
  • Size
  • Source code size: 196.76 kB This is the summed size of all the files inside the crates.io package for this release.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Miao-hub1415
docs.rs failed to build gmsh_ffi-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

Gmsh Rust Bindings

本项目提供 Rust 对 Gmsh SDK 的 FFI 绑定。

生成 src/bindings.rs

绑定文件由 bindgen 命令行工具从 Gmsh 的 C API 头文件生成。不要在构建时自动生成,因为 Windows 下 bindgen 库可能无法正常运行,且头文件很少变动,手动生成即可。

前提

  • 已安装 bindgen 命令行工具:
    cargo install bindgen-cli@0.72
    
  • Gmsh SDK 已下载到 external/<platform>/gmsh/(运行 cargo build 会自动下载)。

命令

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 示例:

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 常量后重新执行上述命令。