build: remove d2xx dependency for periph.io
This commit is contained in:
		
							
								
								
									
										6
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							@@ -16,11 +16,11 @@ github.com/golang/protobuf/ptypes/timestamp
 | 
			
		||||
# github.com/gorilla/websocket v1.4.2
 | 
			
		||||
## explicit; go 1.12
 | 
			
		||||
github.com/gorilla/websocket
 | 
			
		||||
# github.com/konsorten/go-windows-terminal-sequences v1.0.1
 | 
			
		||||
## explicit
 | 
			
		||||
# github.com/sirupsen/logrus v1.8.1
 | 
			
		||||
## explicit; go 1.13
 | 
			
		||||
github.com/sirupsen/logrus
 | 
			
		||||
# github.com/stretchr/testify v1.6.1
 | 
			
		||||
## explicit; go 1.13
 | 
			
		||||
# golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0
 | 
			
		||||
## explicit; go 1.11
 | 
			
		||||
golang.org/x/net/internal/socks
 | 
			
		||||
@@ -75,7 +75,7 @@ periph.io/x/conn/v3/pin
 | 
			
		||||
periph.io/x/conn/v3/pin/pinreg
 | 
			
		||||
periph.io/x/conn/v3/spi
 | 
			
		||||
periph.io/x/conn/v3/spi/spireg
 | 
			
		||||
# periph.io/x/d2xx v0.0.1
 | 
			
		||||
# periph.io/x/d2xx v0.0.3
 | 
			
		||||
## explicit; go 1.13
 | 
			
		||||
periph.io/x/d2xx
 | 
			
		||||
# periph.io/x/devices/v3 v3.6.11
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										34
									
								
								vendor/periph.io/x/d2xx/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										34
									
								
								vendor/periph.io/x/d2xx/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -3,9 +3,6 @@
 | 
			
		||||
Package d2xx is a thin Go wrapper for the Future Technology "D2XX" driver at
 | 
			
		||||
https://ftdichip.com/drivers/d2xx-drivers/.
 | 
			
		||||
 | 
			
		||||
See https://periph.io/device/ftdi/ for more details, and how to configure
 | 
			
		||||
the host to be able to use this driver.
 | 
			
		||||
 | 
			
		||||
This package is not Go idiomatic. You will want to use
 | 
			
		||||
https://periph.io/x/host/v3/ftdi (or later) instead.
 | 
			
		||||
 | 
			
		||||
@@ -14,3 +11,34 @@ But if you really want, here it goes:
 | 
			
		||||
 | 
			
		||||
This Go package includes third party software. See
 | 
			
		||||
[third_party/README.md](third_party/README.md).
 | 
			
		||||
 | 
			
		||||
## Configuration
 | 
			
		||||
 | 
			
		||||
See https://periph.io/device/ftdi/ to configure the host to be able to use this
 | 
			
		||||
driver.
 | 
			
		||||
 | 
			
		||||
## Availability
 | 
			
		||||
 | 
			
		||||
On darwin_amd64, linux_amd64 linux_arm (v6, v7 compatible) and linux_arm64 (v8),
 | 
			
		||||
cgo is required. If cgo is disabled (via `CGO_ENABLED=0`), all functions in this
 | 
			
		||||
driver return error [NoCGO](https://periph.io/x/d2xx#NoCGO).
 | 
			
		||||
 | 
			
		||||
On Windows, cgo is not required. If the dynamic library is not found at runtime,
 | 
			
		||||
[Missing](https://periph.io/x/d2xx#Missing) is returned.
 | 
			
		||||
 | 
			
		||||
## bcm2385
 | 
			
		||||
 | 
			
		||||
On linux_arm (v6), hard-float is required. For cross compilation, this
 | 
			
		||||
means arm-linux-gnueabihf-gcc is preferred to arm-linux-gnueabi-gcc. Using
 | 
			
		||||
hardfloat causes a segfault on Raspberry Pi 1, Zero and Zero Wireless. It is
 | 
			
		||||
recommended to disable this driver if targeting these hosts, see below.
 | 
			
		||||
 | 
			
		||||
## Disabling
 | 
			
		||||
 | 
			
		||||
To disable this driver, build with tag `no_d2xx`, e.g.
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
go install -tags no_d2xx periph.io/x/cmd/gpio-list@latest
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
This will behave has if cgo was disabled, even on Windows.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										19
									
								
								vendor/periph.io/x/d2xx/d2xx.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								vendor/periph.io/x/d2xx/d2xx.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -14,9 +14,8 @@ type Err int
 | 
			
		||||
// These are additional synthetic error codes.
 | 
			
		||||
const (
 | 
			
		||||
	// NoCGO is returned when the package was compiled without cgo, thus the d2xx
 | 
			
		||||
	// library is unavailable.
 | 
			
		||||
	//
 | 
			
		||||
	// This is never returned on Windows.
 | 
			
		||||
	// library is unavailable or the library was disabled via the `no_d2xx` build
 | 
			
		||||
	// tag.
 | 
			
		||||
	NoCGO Err = -2
 | 
			
		||||
	// Missing is returned when the dynamic library is not available.
 | 
			
		||||
	Missing Err = -1
 | 
			
		||||
@@ -117,16 +116,30 @@ type Handle interface {
 | 
			
		||||
var _ Handle = handle(0)
 | 
			
		||||
 | 
			
		||||
// Version returns the library's version.
 | 
			
		||||
//
 | 
			
		||||
// 0, 0, 0 is returned if the library is unavailable.
 | 
			
		||||
func Version() (uint8, uint8, uint8) {
 | 
			
		||||
	return version()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateDeviceInfoList discovers the currently found devices.
 | 
			
		||||
//
 | 
			
		||||
// If the driver is disabled via build tag `no_d2xx`, or on posix
 | 
			
		||||
// `CGO_ENABLED=0` environment variable, NoCGO is returned.
 | 
			
		||||
//
 | 
			
		||||
// On Windows, Missing is returned if the dynamic library is not found at
 | 
			
		||||
// runtime.
 | 
			
		||||
func CreateDeviceInfoList() (int, Err) {
 | 
			
		||||
	return createDeviceInfoList()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Open opens the ith device discovered.
 | 
			
		||||
//
 | 
			
		||||
// If the driver is disabled via build tag `no_d2xx`, or on posix
 | 
			
		||||
// `CGO_ENABLED=0` environment variable, NoCGO is returned.
 | 
			
		||||
//
 | 
			
		||||
// On Windows, Missing is returned if the dynamic library is not found at
 | 
			
		||||
// runtime.
 | 
			
		||||
func Open(i int) (Handle, Err) {
 | 
			
		||||
	return open(i)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								vendor/periph.io/x/d2xx/d2xx_darwin_amd64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/periph.io/x/d2xx/d2xx_darwin_amd64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -3,6 +3,7 @@
 | 
			
		||||
// that can be found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
// +build cgo
 | 
			
		||||
// +build !no_d2xx
 | 
			
		||||
 | 
			
		||||
package d2xx
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								vendor/periph.io/x/d2xx/d2xx_linux_amd64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/periph.io/x/d2xx/d2xx_linux_amd64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -3,10 +3,11 @@
 | 
			
		||||
// that can be found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
// +build cgo
 | 
			
		||||
// +build !no_d2xx
 | 
			
		||||
 | 
			
		||||
package d2xx
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
#cgo LDFLAGS: ${SRCDIR}/third_party/libftd2xx_linux_amd64_v1.4.6.a
 | 
			
		||||
#cgo LDFLAGS: ${SRCDIR}/third_party/libftd2xx_linux_amd64_v1.4.24.a
 | 
			
		||||
*/
 | 
			
		||||
import "C"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								vendor/periph.io/x/d2xx/d2xx_linux_arm.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/periph.io/x/d2xx/d2xx_linux_arm.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -3,6 +3,7 @@
 | 
			
		||||
// that can be found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
// +build cgo
 | 
			
		||||
// +build !no_d2xx
 | 
			
		||||
 | 
			
		||||
package d2xx
 | 
			
		||||
 | 
			
		||||
@@ -10,6 +11,6 @@ package d2xx
 | 
			
		||||
// optimal ARM architecture.
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
#cgo LDFLAGS: ${SRCDIR}/third_party/libftd2xx_linux_arm6hf_v1.4.6.a
 | 
			
		||||
#cgo LDFLAGS: ${SRCDIR}/third_party/libftd2xx_linux_arm6hf_v1.4.24.a
 | 
			
		||||
*/
 | 
			
		||||
import "C"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										13
									
								
								vendor/periph.io/x/d2xx/d2xx_linux_arm64.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								vendor/periph.io/x/d2xx/d2xx_linux_arm64.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
// Copyright 2021 The Periph Authors. All rights reserved.
 | 
			
		||||
// Use of this source code is governed under the Apache License, Version 2.0
 | 
			
		||||
// that can be found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
// +build cgo
 | 
			
		||||
// +build !no_d2xx
 | 
			
		||||
 | 
			
		||||
package d2xx
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
#cgo LDFLAGS: ${SRCDIR}/third_party/libftd2xx_linux_arm64_v1.4.24.a
 | 
			
		||||
*/
 | 
			
		||||
import "C"
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/periph.io/x/d2xx/d2xx_posix.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/periph.io/x/d2xx/d2xx_posix.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -2,7 +2,9 @@
 | 
			
		||||
// Use of this source code is governed under the Apache License, Version 2.0
 | 
			
		||||
// that can be found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
// +build cgo
 | 
			
		||||
// +build !windows
 | 
			
		||||
// +build !no_d2xx
 | 
			
		||||
 | 
			
		||||
package d2xx
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								vendor/periph.io/x/d2xx/d2xx_posix_no_cgo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/periph.io/x/d2xx/d2xx_posix_no_cgo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -2,8 +2,8 @@
 | 
			
		||||
// Use of this source code is governed under the Apache License, Version 2.0
 | 
			
		||||
// that can be found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
// +build !cgo
 | 
			
		||||
// +build !windows
 | 
			
		||||
// +build !cgo no_d2xx
 | 
			
		||||
// +build !windows no_d2xx
 | 
			
		||||
 | 
			
		||||
package d2xx
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								vendor/periph.io/x/d2xx/d2xx_posix_other.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/periph.io/x/d2xx/d2xx_posix_other.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -7,9 +7,12 @@
 | 
			
		||||
// +build !linux,!amd64
 | 
			
		||||
// +build !linux,!arm
 | 
			
		||||
// +build !windows
 | 
			
		||||
// +build !no_d2xx
 | 
			
		||||
 | 
			
		||||
package d2xx
 | 
			
		||||
 | 
			
		||||
// This assumes the library is installed and available for linking.
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
#cgo LDFLAGS: -lftd2xx
 | 
			
		||||
*/
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										18
									
								
								vendor/periph.io/x/d2xx/d2xx_windows.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								vendor/periph.io/x/d2xx/d2xx_windows.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -2,6 +2,8 @@
 | 
			
		||||
// Use of this source code is governed under the Apache License, Version 2.0
 | 
			
		||||
// that can be found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
// +build !no_d2xx
 | 
			
		||||
 | 
			
		||||
package d2xx
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
@@ -22,15 +24,21 @@ func version() (uint8, uint8, uint8) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func createDeviceInfoList() (int, Err) {
 | 
			
		||||
	var num uint32
 | 
			
		||||
	r1, _, _ := pCreateDeviceInfoList.Call(uintptr(unsafe.Pointer(&num)))
 | 
			
		||||
	return int(num), Err(r1)
 | 
			
		||||
	if pCreateDeviceInfoList != nil {
 | 
			
		||||
		var num uint32
 | 
			
		||||
		r1, _, _ := pCreateDeviceInfoList.Call(uintptr(unsafe.Pointer(&num)))
 | 
			
		||||
		return int(num), Err(r1)
 | 
			
		||||
	}
 | 
			
		||||
	return 0, Missing
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func open(i int) (Handle, Err) {
 | 
			
		||||
	var h handle
 | 
			
		||||
	r1, _, _ := pOpen.Call(uintptr(i), uintptr(unsafe.Pointer(&h)))
 | 
			
		||||
	return h, Err(r1)
 | 
			
		||||
	if pOpen != nil {
 | 
			
		||||
		r1, _, _ := pOpen.Call(uintptr(i), uintptr(unsafe.Pointer(&h)))
 | 
			
		||||
		return h, Err(r1)
 | 
			
		||||
	}
 | 
			
		||||
	return h, Missing
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (h handle) Close() Err {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										7
									
								
								vendor/periph.io/x/d2xx/doc.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								vendor/periph.io/x/d2xx/doc.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -5,9 +5,9 @@
 | 
			
		||||
// Package d2xx is a thin Go wrapper for the Future Technology "D2XX" driver.
 | 
			
		||||
//
 | 
			
		||||
// This package is not Go idiomatic. You want to use
 | 
			
		||||
// https://periph.io/x/host/v3/ftdi instead.
 | 
			
		||||
// https://periph.io/x/host/v3/ftdi (or later) instead.
 | 
			
		||||
//
 | 
			
		||||
// A binary copy of the d2xx driver is included for linux and macOS. They are
 | 
			
		||||
// A static library of the d2xx driver is included for linux and macOS. They are
 | 
			
		||||
// from https://ftdichip.com/drivers/d2xx-drivers/. See third_party/README.md
 | 
			
		||||
// for more details.
 | 
			
		||||
//
 | 
			
		||||
@@ -15,7 +15,4 @@
 | 
			
		||||
//
 | 
			
		||||
// See https://periph.io/device/ftdi/ for more details, and how to configure
 | 
			
		||||
// the host to be able to use this driver.
 | 
			
		||||
//
 | 
			
		||||
// Windows 10 automatically fetches the driver from Windows Update upon
 | 
			
		||||
// connecting a FTDI device on the firt time, so no need to download a driver.
 | 
			
		||||
package d2xx
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										32
									
								
								vendor/periph.io/x/d2xx/test.sh
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										32
									
								
								vendor/periph.io/x/d2xx/test.sh
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -4,8 +4,6 @@
 | 
			
		||||
# that can be found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
# Builds the package on multiple OSes to confirm it builds fine.
 | 
			
		||||
#
 | 
			
		||||
# It is recommended to use the -i flag so subsequent runs are much faster.
 | 
			
		||||
 | 
			
		||||
set -eu
 | 
			
		||||
 | 
			
		||||
@@ -13,13 +11,33 @@ cd `dirname $0`
 | 
			
		||||
 | 
			
		||||
OPT=$*
 | 
			
		||||
 | 
			
		||||
# Do not set CGO_ENABLED, as we want the default behavior when cross compiling,
 | 
			
		||||
# which is different from when CGO_ENABLED=1.
 | 
			
		||||
export -n CGO_ENABLED
 | 
			
		||||
 | 
			
		||||
# Cleanup.
 | 
			
		||||
export -n GOOS
 | 
			
		||||
export -n GOARCH
 | 
			
		||||
 | 
			
		||||
function build {
 | 
			
		||||
  echo "Testing on $1/$2"
 | 
			
		||||
  GOOS=$1 GOARCH=$2 go build $OPT
 | 
			
		||||
  export GOOS=$1
 | 
			
		||||
  export GOARCH=$2
 | 
			
		||||
  echo "Building on $GOOS/$GOARCH"
 | 
			
		||||
  go build $OPT
 | 
			
		||||
  echo "Building on $GOOS/$GOARCH - no_d2xx"
 | 
			
		||||
  go build -tags no_d2xx $OPT
 | 
			
		||||
  echo "Building on $GOOS/$GOARCH - no cgo"
 | 
			
		||||
  CGO_ENABLED=0 go build $OPT
 | 
			
		||||
  echo "Building on $GOOS/$GOARCH - no cgo, no_d2xx"
 | 
			
		||||
  CGO_ENABLED=0 go build -tags no_d2xx $OPT
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
build darwin amd64
 | 
			
		||||
build linux amd64
 | 
			
		||||
build linux arm
 | 
			
		||||
CGO_ENABLED=1 CC=x86_64-linux-gnu-gcc build linux amd64
 | 
			
		||||
# Requires: sudo apt install gcc-arm-linux-gnueabihf
 | 
			
		||||
CGO_ENABLED=1 CC=arm-linux-gnueabihf-gcc build linux arm
 | 
			
		||||
# Requires: sudo apt install gcc-aarch64-linux-gnu
 | 
			
		||||
CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc build linux arm64
 | 
			
		||||
 | 
			
		||||
build linux 386
 | 
			
		||||
build windows amd64
 | 
			
		||||
build darwin amd64
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user