1
0
mirror of https://git.zx2c4.com/wireguard-go synced 2024-11-15 01:05:15 +01:00

Adopt GOPATH

GOPATH is annoying, but the Go community pushing me to adopt it is even
more annoying.
This commit is contained in:
Jason A. Donenfeld 2018-05-23 03:17:51 +02:00
parent f70bd1fab3
commit 588b9f01ae
19 changed files with 88 additions and 44 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
wireguard-go wireguard-go
vendor vendor
.gopath
ireallywantobuildon_linux.go

32
Gopkg.lock generated
View File

@ -1,16 +1,42 @@
# This was generated by ./generate-vendor.sh # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "golang.org/x/crypto" name = "golang.org/x/crypto"
packages = [
"blake2s",
"chacha20poly1305",
"curve25519",
"internal/chacha20",
"poly1305"
]
revision = "1a580b3eff7814fc9b40602fd35256c63b50f491" revision = "1a580b3eff7814fc9b40602fd35256c63b50f491"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "golang.org/x/net" name = "golang.org/x/net"
revision = "8e0cdda24ed423affc8f35c241e5e9b16180338e" packages = [
"bpf",
"internal/iana",
"internal/socket",
"ipv4",
"ipv6"
]
revision = "9ef9f5bb98a1fdc41f8cf6c250a4404b4085e389"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "golang.org/x/sys" name = "golang.org/x/sys"
revision = "7f59abf37be6a6007f075af1bc7f16f137bc176b" packages = [
"cpu",
"unix"
]
revision = "88eb85aaee56831ad49eaf7aa80d73de9814cde2"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "d85ae9d2b4afafc3d7535505c46368cbbbec350cf876616302c1bcf44f6ec103"
solver-name = "gps-cdcl"
solver-version = 1

View File

@ -1,4 +1,3 @@
# This was generated by ./generate-vendor.sh
[[constraint]] [[constraint]]
branch = "master" branch = "master"
name = "golang.org/x/crypto" name = "golang.org/x/crypto"
@ -11,3 +10,6 @@
branch = "master" branch = "master"
name = "golang.org/x/sys" name = "golang.org/x/sys"
[prune]
go-tests = true
unused-packages = true

View File

@ -5,18 +5,39 @@ BINDIR ?= $(PREFIX)/bin
ifeq ($(shell go env GOOS),linux) ifeq ($(shell go env GOOS),linux)
ifeq ($(wildcard .git),) ifeq ($(wildcard .git),)
$(error Do not build this for Linux. Instead use the Linux kernel module. See wireguard.com/install/ for more info.) $(error Do not build this for Linux. Instead use the Linux kernel module. See wireguard.com/install/ for more info.)
else
$(shell printf 'package main\nconst UseTheKernelModuleInstead = 0xdeadbabe\n' > ireallywantobuildon_linux.go)
endif endif
endif endif
all: wireguard-go all: wireguard-go
wireguard-go: $(wildcard *.go) $(wildcard */*.go) export GOPATH := $(CURDIR)/.gopath
go build -v -o $@ export PATH := $(PATH):$(CURDIR)/.gopath/bin
GO_IMPORT_PATH := git.zx2c4.com/wireguard-go
.gopath/.created:
rm -rf .gopath
mkdir -p $(dir .gopath/src/$(GO_IMPORT_PATH))
ln -s ../../.. .gopath/src/$(GO_IMPORT_PATH)
touch $@
vendor/.created: Gopkg.toml Gopkg.lock .gopath/.created
command -v dep >/dev/null || go get -v github.com/golang/dep/cmd/dep
cd .gopath/src/$(GO_IMPORT_PATH) && dep ensure -vendor-only -v
touch $@
wireguard-go: $(wildcard *.go) $(wildcard */*.go) .gopath/.created vendor/.created
go build $(GO_BUILD_EXTRA_ARGS) -v $(GO_IMPORT_PATH)
install: wireguard-go install: wireguard-go
@install -v -d "$(DESTDIR)$(BINDIR)" && install -m 0755 -v wireguard-go "$(DESTDIR)$(BINDIR)/wireguard-go" @install -v -d "$(DESTDIR)$(BINDIR)" && install -v -m 0755 wireguard-go "$(DESTDIR)$(BINDIR)/wireguard-go"
clean: clean:
rm -f wireguard-go rm -f wireguard-go
.PHONY: clean install update-dep:
command -v dep >/dev/null || go get -v github.com/golang/dep/cmd/dep
cd .gopath/src/$(GO_IMPORT_PATH) && dep ensure -update -v
.PHONY: clean install update-dep

View File

@ -48,13 +48,11 @@ This will run on OpenBSD. It does not yet support sticky sockets. Fwmark is mapp
## Building ## Building
You can satisfy dependencies with either `go get -d -v` or `dep ensure -vendor-only`. Then run `make`. As this is a Go project, a `GOPATH` is required. For example, wireguard-go can be built with: This requires an installation of [go](https://golang.org) and of [dep](https://github.com/golang/dep). If dep is not installed, it will be downloaded and built as part of the build process.
``` ```
$ git clone https://git.zx2c4.com/wireguard-go $ git clone https://git.zx2c4.com/wireguard-go
$ cd wireguard-go $ cd wireguard-go
$ export GOPATH="$PWD/gopath"
$ go get -d -v
$ make $ make
``` ```

View File

@ -18,7 +18,7 @@
package main package main
import ( import (
"./rwcancel" "git.zx2c4.com/wireguard-go/rwcancel"
"errors" "errors"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
"net" "net"

View File

@ -7,7 +7,7 @@
package main package main
import ( import (
"./xchacha20poly1305" "git.zx2c4.com/wireguard-go/xchacha20poly1305"
"crypto/hmac" "crypto/hmac"
"crypto/rand" "crypto/rand"
"golang.org/x/crypto/blake2s" "golang.org/x/crypto/blake2s"

View File

@ -7,8 +7,8 @@
package main package main
import ( import (
"./ratelimiter" "git.zx2c4.com/wireguard-go/ratelimiter"
"./tun" "git.zx2c4.com/wireguard-go/tun"
"runtime" "runtime"
"sync" "sync"
"sync/atomic" "sync/atomic"

15
donotuseon_linux.go Normal file
View File

@ -0,0 +1,15 @@
// +build !android
/* SPDX-License-Identifier: GPL-2.0
*
* Copyright (C) 2017-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
*/
package main
const DoNotUseThisProgramOnLinux = UseTheKernelModuleInstead
// --------------------------------------------------------
// Do not use this on Linux. Instead use the kernel module.
// See wireguard.com/install for more information.
// --------------------------------------------------------

View File

@ -1,20 +0,0 @@
#!/bin/bash
echo "# This was generated by ./generate-vendor.sh" > Gopkg.lock
echo "# This was generated by ./generate-vendor.sh" > Gopkg.toml
while read -r package; do
cat >> Gopkg.lock <<-_EOF
[[projects]]
branch = "master"
name = "$package"
revision = "$(< "$GOPATH/src/$package/.git/refs/heads/master")"
_EOF
cat >> Gopkg.toml <<-_EOF
[[constraint]]
branch = "master"
name = "$package"
_EOF
done < <(sed -n 's/.*"\(golang.org\/x\/[^/]\+\)\/\?.*".*/\1/p' *.go */*.go | sort | uniq)

View File

@ -7,7 +7,7 @@
package main package main
import ( import (
"./replay" "git.zx2c4.com/wireguard-go/replay"
"crypto/cipher" "crypto/cipher"
"sync" "sync"
"time" "time"

View File

@ -7,7 +7,7 @@
package main package main
import ( import (
"./tun" "git.zx2c4.com/wireguard-go/tun"
"fmt" "fmt"
"os" "os"
"os/signal" "os/signal"

View File

@ -7,7 +7,7 @@
package main package main
import ( import (
"./tai64n" "git.zx2c4.com/wireguard-go/tai64n"
"errors" "errors"
"golang.org/x/crypto/blake2s" "golang.org/x/crypto/blake2s"
"golang.org/x/crypto/chacha20poly1305" "golang.org/x/crypto/chacha20poly1305"

2
tun.go
View File

@ -7,7 +7,7 @@
package main package main
import ( import (
"./tun" "git.zx2c4.com/wireguard-go/tun"
"sync/atomic" "sync/atomic"
) )

View File

@ -7,7 +7,7 @@
package tun package tun
import ( import (
"../rwcancel" "git.zx2c4.com/wireguard-go/rwcancel"
"errors" "errors"
"fmt" "fmt"
"golang.org/x/net/ipv6" "golang.org/x/net/ipv6"

View File

@ -6,7 +6,7 @@
package tun package tun
import ( import (
"../rwcancel" "git.zx2c4.com/wireguard-go/rwcancel"
"bytes" "bytes"
"errors" "errors"
"fmt" "fmt"

View File

@ -12,7 +12,7 @@ package tun
*/ */
import ( import (
"../rwcancel" "git.zx2c4.com/wireguard-go/rwcancel"
"bytes" "bytes"
"errors" "errors"
"fmt" "fmt"

View File

@ -6,7 +6,7 @@
package tun package tun
import ( import (
"../rwcancel" "git.zx2c4.com/wireguard-go/rwcancel"
"errors" "errors"
"fmt" "fmt"
"golang.org/x/net/ipv6" "golang.org/x/net/ipv6"

View File

@ -7,7 +7,7 @@
package main package main
import ( import (
"./rwcancel" "git.zx2c4.com/wireguard-go/rwcancel"
"errors" "errors"
"fmt" "fmt"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"