fix: simplify macOS sleep inhibitor FFI (#12340)

Summary
- simplify the macOS sleep inhibitor FFI by replacing `dlopen` / `dlsym`
/ `transmute` with normal IOKit extern calls and `SAFETY` comments
- switch to cfg-selected platform implementations
(`imp::SleepInhibitor`) instead of `Box<dyn ...>`
- check in minimal IOKit bindings generated with `bindgen` and include
them from the macOS backend
- enable direct IOKit linkage in Bazel macOS builds by registering
`IOKit` in the Bazel `osx.framework(...)` toolchain extension list
- update `Cargo.lock` and `MODULE.bazel.lock` after removing the
build-time `bindgen` dependency path

Testing
- `just fmt`
- `cargo clippy -p codex-utils-sleep-inhibitor --all-targets -- -D
warnings`
- `cargo test -p codex-utils-sleep-inhibitor`
- `bazel test //codex-rs/utils/sleep-inhibitor:all --test_output=errors`
- `just bazel-lock-update`
- `just bazel-lock-check`

Context
- follow-up to #11711 addressing Ryan's review comments
- `bindgen` is used to generate the checked-in bindings file, but not at
build time
This commit is contained in:
Yaroslav Volovich
2026-02-20 17:52:21 +00:00
committed by GitHub
parent fd67aba114
commit 5b71246001
8 changed files with 159 additions and 227 deletions

View File

@@ -9,5 +9,4 @@ workspace = true
[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = "0.9"
libc = { workspace = true }
tracing = { workspace = true }