Skip to content

htool: add macos build - #305

Open
mfield4 wants to merge 3 commits into
google:mainfrom
mfield4:macos-build
Open

mfield4 wants to merge 3 commits into
google:mainfrom
mfield4:macos-build

Conversation

@mfield4

@mfield4 mfield4 commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

This lets htool build and run on macOS with Bazel, using the USB transport. It also adds a macOS job to CI. Linux only transports are not ported, and choosing one on mac exits with a printed warning and a non-zero exit code.

Tested on real hardware from an Apple Silicon Mac:

$ ./bazel-bin/examples/htool --usb_loc 0-1.3 hello
output: 0x01020304

$ ./bazel-bin/examples/htool --usb_loc 0-1.3 show chipinfo
Chip Info:
...

Known limitations / follow-ups

  • No -Werror on macOS yet. Format strings like %lx for uint64_t/libhoth_error warn on macOS, where those are unsigned long long. Switching to PRIx64 would fix it. libusb's upstream darwin_usb.c also has unused-variable warnings.
  • The fully_static_link_target feature on htool has no effect on macOS. macOS doesn't support fully static binaries, so the result links against system libraries and frameworks dynamically.
  • The linker prints ld: warning: ignoring duplicate libraries: '-lobjc'. It's harmless, because the macOS toolchain already links libobjc.

@mfield4 mfield4 changed the title Macos build htool: add macos build Sep 24, 2026
Configure MTD and SPI transports with target_compatible_with and Bazel config_setting rules matching the D-Bus backend pattern, enabled by default on Linux via .bazelrc.

Signed-off-by: Michael Field <michaelfield@google.com>
Configure libusb for Darwin, use POSIX getentropy() for DFU nonce generation, and set minimum macOS version in .bazelrc.

Signed-off-by: Michael Field <michaelfield@google.com>
Add build-macos GitHub Actions job to build and run Bazel tests on macOS.

Signed-off-by: Michael Field <michaelfield@google.com>
@mfield4
mfield4 marked this pull request as ready for review September 25, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant