Skip to content

Commit

Permalink
Add BUILD rules to support using libhoth with external tools
Browse files Browse the repository at this point in the history
- Expose USB and SPI devices as separate build targets
- Add library targets (header and lib) for API use
  • Loading branch information
nnooney authored and cjevans-google committed Dec 12, 2023
1 parent 0ddfb27 commit 8793529
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 17 deletions.
68 changes: 51 additions & 17 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,8 @@ package(default_visibility = ["//visibility:public"])

cc_library(
name = "libhoth",
srcs = [
"libhoth.c",
"libhoth_mtd.c",
"libhoth_spi.c",
"libhoth_usb.c",
"libhoth_usb_fifo.c",
"libhoth_usb_mailbox.c",
],
hdrs = [
"libhoth.h",
"libhoth_ec.h",
"libhoth_mtd.h",
"libhoth_spi.h",
"libhoth_usb.h",
"libhoth_usb_device.h",
],
deps = ["@libusb//:libusb"],
srcs = ["libhoth.c"],
hdrs = ["libhoth.h"],
)

cc_library(
Expand All @@ -34,3 +19,52 @@ genrule(
stamp = 1,
)

cc_library(
name = "libhoth_ec",
hdrs = ["libhoth_ec.h"],
)

cc_library(
name = "libhoth_mtd",
srcs = ["libhoth_mtd.c"],
hdrs = ["libhoth_mtd.h"],
deps = [
":libhoth",
":libhoth_ec",
],
)

cc_library(
name = "libhoth_spi",
srcs = ["libhoth_spi.c"],
hdrs = ["libhoth_spi.h"],
deps = [
":libhoth",
":libhoth_ec",
],
)

cc_library(
name = "libhoth_usb",
srcs = ["libhoth_usb.c"],
hdrs = ["libhoth_usb.h"],
deps = [
":libhoth",
":libhoth_usb_device",
"@libusb//:libusb",
],
)

cc_library(
name = "libhoth_usb_device",
srcs = [
"libhoth_usb_fifo.c",
"libhoth_usb_mailbox.c",
],
hdrs = ["libhoth_usb_device.h"],
deps = [
":libhoth",
":libhoth_ec",
"@libusb//:libusb",
],
)
3 changes: 3 additions & 0 deletions examples/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ cc_binary(
":host_commands",
"//:git_version",
"//:libhoth",
"//:libhoth_mtd",
"//:libhoth_spi",
"//:libhoth_usb",
"@libusb//:libusb",
],
)

0 comments on commit 8793529

Please sign in to comment.