Skip to content

Commit

Permalink
Disable cgo in hid, delete old vendored usb library
Browse files Browse the repository at this point in the history
  • Loading branch information
prestonvanloon committed Aug 20, 2024
1 parent b7e326e commit d8b13a4
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 485 deletions.
8 changes: 5 additions & 3 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -871,9 +871,6 @@ def prysm_deps():
)
go_repository(
name = "com_github_ethereum_go_ethereum",
build_directives = [
"gazelle:resolve go github.com/karalabe/usb @prysm//third_party/usb:go_default_library",
],
importpath = "github.com/ethereum/go-ethereum",
patch_args = ["-p1"],
patches = [
Expand Down Expand Up @@ -1929,6 +1926,11 @@ def prysm_deps():
importpath = "github.com/karalabe/hid",
sum = "h1:msKODTL1m0wigztaqILOtla9HeW1ciscYG4xjLtvk5I=",
version = "v1.0.1-0.20240306101548-573246063e52",
patch_args = ["-p1"],
patches = [
# This patch disables the cgo aspects of this library.
"//third_party:com_github_karalabe_hid.patch",
],
)
go_repository(
name = "com_github_kataras_blocks",
Expand Down
77 changes: 77 additions & 0 deletions third_party/com_github_karalabe_hid.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
diff --git a/BUILD.bazel b/BUILD.bazel
index 9be80a1..0e78457 100755
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -8,58 +8,7 @@ go_library(
srcs = [
"hid.go",
"hid_disabled.go",
- "hid_enabled.go",
- "wchar.go",
],
- cgo = True,
- clinkopts = select({
- "@io_bazel_rules_go//go/platform:darwin": [
- "-framework CoreFoundation -framework IOKit -lobjc",
- ],
- "@io_bazel_rules_go//go/platform:freebsd": [
- "-lusb",
- ],
- "@io_bazel_rules_go//go/platform:linux": [
- "-lrt",
- ],
- "@io_bazel_rules_go//go/platform:windows": [
- "-lsetupapi",
- ],
- "//conditions:default": [],
- }),
- copts = select({
- "@io_bazel_rules_go//go/platform:android": [
- "-DDEFAULT_VISIBILITY=",
- "-DPOLL_NFDS_TYPE=int",
- "-Ihidapi/hidapi",
- "-Ilibusb/libusb -DOS_LINUX -D_GNU_SOURCE -DHAVE_SYS_TIME_H -DHAVE_CLOCK_GETTIME",
- ],
- "@io_bazel_rules_go//go/platform:darwin": [
- "-DDEFAULT_VISIBILITY=",
- "-DOS_DARWIN -DHAVE_SYS_TIME_H",
- "-DPOLL_NFDS_TYPE=int",
- "-Ihidapi/hidapi",
- ],
- "@io_bazel_rules_go//go/platform:freebsd": [
- "-DDEFAULT_VISIBILITY=",
- "-DOS_FREEBSD",
- "-DPOLL_NFDS_TYPE=int",
- "-Ihidapi/hidapi",
- ],
- "@io_bazel_rules_go//go/platform:linux": [
- "-DDEFAULT_VISIBILITY=",
- "-DPOLL_NFDS_TYPE=int",
- "-Ihidapi/hidapi",
- "-Ilibusb/libusb -DOS_LINUX -D_GNU_SOURCE -DHAVE_SYS_TIME_H -DHAVE_CLOCK_GETTIME",
- ],
- "@io_bazel_rules_go//go/platform:windows": [
- "-DDEFAULT_VISIBILITY=",
- "-DOS_WINDOWS",
- "-DPOLL_NFDS_TYPE=int",
- "-Ihidapi/hidapi",
- ],
- "//conditions:default": [],
- }),
importpath = "github.com/karalabe/hid",
visibility = ["//visibility:public"],
)
diff --git a/hid_disabled.go b/hid_disabled.go
index fa2c504..0091853 100644
--- a/hid_disabled.go
+++ b/hid_disabled.go
@@ -4,9 +4,6 @@
// This file is released under the 3-clause BSD license. Note however that Linux
// support depends on libusb, released under GNU LGPL 2.1 or later.

-//go:build (!freebsd && !linux && !darwin && !windows) || ios || !cgo
-// +build !freebsd,!linux,!darwin,!windows ios !cgo
-
package hid

// Supported returns whether this platform is supported by the HID library or not.
7 changes: 0 additions & 7 deletions third_party/usb/AUTHORS

This file was deleted.

21 changes: 0 additions & 21 deletions third_party/usb/BUILD.bazel

This file was deleted.

165 changes: 0 additions & 165 deletions third_party/usb/LICENSE

This file was deleted.

6 changes: 0 additions & 6 deletions third_party/usb/README.md

This file was deleted.

40 changes: 0 additions & 40 deletions third_party/usb/hid_disabled.go

This file was deleted.

40 changes: 0 additions & 40 deletions third_party/usb/raw_disabled.go

This file was deleted.

Loading

0 comments on commit d8b13a4

Please sign in to comment.