Skip to content

Commit ece0d6c

Browse files
authored
Merge pull request #25 from hillu/topic/go-mod
Switch from dep to Go modules
2 parents ec8bd4f + c882719 commit ece0d6c

File tree

6 files changed

+20
-137
lines changed

6 files changed

+20
-137
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ before_install:
77
- docker run --name build --rm --detach --interactive --mount type=bind,src=`pwd`,dst=/build debian:buster-slim /bin/sh
88
- docker ps -a
99
- docker exec -u root build apt-get -y update
10-
- docker exec -u root build apt-get --no-install-recommends -y install make gcc gcc-multilib gcc-mingw-w64 autoconf automake libtool pkg-config ca-certificates wget sed git-core golang-go moreutils zip go-dep
10+
- docker exec -u root build apt-get --no-install-recommends -y install make gcc gcc-multilib gcc-mingw-w64 autoconf automake libtool pkg-config ca-certificates wget sed git-core golang-go moreutils zip
1111
script:
1212
- travis_wait 40 docker exec build /build/.travis-make.sh make 3rdparty-all
1313
- docker exec build make -C /build unit-test

Gopkg.lock

Lines changed: 0 additions & 81 deletions
This file was deleted.

Gopkg.toml

Lines changed: 0 additions & 15 deletions
This file was deleted.

Makefile

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$(if $(filter 4.%,$(MAKE_VERSION)),,\
22
$(error GNU make 4.0 or above is required.))
33

4-
export GO111MODULE := off
4+
export GOPATH=$(CURDIR)/_gopath
55

66
all:
77

@@ -12,9 +12,8 @@ include 3rdparty.mk
1212
GOROOT ?= /usr/lib/go-$(lastword $(shell echo '$(foreach elem,\
1313
$(sort $(patsubst go-%,%,$(notdir $(wildcard /usr/lib/go-1.*)))),\
1414
$(elem)\n)' | sort --version-sort))
15-
NAMESPACE := github.com/spyre-project/spyre
15+
NAMESPACE := $(shell awk '/^module / {print $$2}' go.mod)
1616
GOFILES := $(shell find $(CURDIR) \
17-
-not -path '$(CURDIR)/vendor/*' \
1817
-not -path '$(CURDIR)/_*' \
1918
-type f -name '*.go')
2019
VERSION := $(shell < cmd/spyre/version.go sed -ne '/var version/{ s/.*"\(.*\)"/\1/;p }')
@@ -54,49 +53,31 @@ unit-test: private export GOARCH=amd64
5453

5554
$(EXE) unit-test: private export CGO_ENABLED=1
5655
$(EXE) unit-test: private export PATH := $(CURDIR)/_3rdparty/tgt/bin:$(PATH)
57-
$(EXE) vendor/.exists dep-% unit-test: private export GOPATH=$(CURDIR)/_gopath
58-
59-
# Set up vendor directory using github.com/golang/dep
60-
_gopath/.exists: Gopkg.lock Gopkg.toml
61-
rm -f $(@D)/src/$(NAMESPACE)
62-
mkdir -p $(dir $(@D)/src/$(NAMESPACE))
63-
ln -sf $(CURDIR) $(@D)/src/$(NAMESPACE)
64-
touch $@
65-
66-
# Set up GOPATH via symlink
67-
# (Technically, this does not need to be in the build directory.)
68-
vendor/.exists: _gopath/.exists
69-
$(info [+] Populating vendor/ directory...)
70-
mkdir -p vendor
71-
cd _gopath/src/$(NAMESPACE) && dep ensure -vendor-only -v
72-
touch $@
73-
74-
.PHONY: dep-ensure
75-
dep-ensure: _gopath/.exists
76-
cd _gopath/src/$(NAMESPACE) && dep ensure -v
77-
dep-ensure-update: _gopath/.exists
78-
cd _gopath/src/$(NAMESPACE) && dep ensure -update -v
7956

8057
# Build resource files
8158
%_resource_windows_amd64.syso: %.rc
8259
x86_64-w64-mingw32-windres --output-format coff -o $@ -i $<
8360
%_resource_windows_386.syso: %.rc
8461
i686-w64-mingw32-windres --output-format coff -o $@ -i $<
8562

63+
.PHONY: dump-go-dependencies
64+
dump-go-dependencies:
65+
go mod download -json | jq -r '[.Path,"=",.Version] | add'
66+
8667
.PHONY: unit-test
68+
unit-test: test_pathspec ?= $(NAMESPACE)/...
69+
unit-test: test_flags ?= -v
8770
unit-test:
8871
$(info [+] Running tests...)
72+
$(info [+] test_flags=$(test_flags) test_pathspec=$(test_pathspec))
8973
$(info [+] GOROOT=$(GOROOT) GOOS=$(GOOS) GOARCH=$(GOARCH) CC=$(CC))
9074
$(info [+] PKG_CONFIG_PATH=$(PKG_CONFIG_PATH))
91-
$(GOROOT)/bin/go test -v \
75+
$(GOROOT)/bin/go test $(test_flags) \
9276
-ldflags '-w -s -linkmode=external -extldflags "-static"' \
9377
-tags yara_static \
94-
$(patsubst %,$(NAMESPACE)/%,$(shell find -not -path '*/vendor/*' \
95-
-not -path '*/_gopath/*' \
96-
-type f -name '*_test.go' \
97-
| xargs dirname | sed -e 's/^\.//'))
78+
$(test_pathspec)
9879

99-
$(EXE) unit-test: $(GOFILES) $(RCFILES) Makefile 3rdparty.mk 3rdparty-all.stamp _gopath/.exists vendor/.exists
80+
$(EXE) unit-test: $(GOFILES) $(RCFILES) Makefile 3rdparty.mk 3rdparty-all.stamp
10081

10182
$(EXE):
10283
$(info [+] Building spyre...)
@@ -118,4 +99,3 @@ spyre-$(VERSION).zip: $(EXE)
11899
clean:
119100
rm -rf _build $(RCFILES) spyre-$(VERSION).zip
120101
distclean: clean 3rdparty-distclean
121-
rm -rf _gopath _vendor

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module github.com/spyre-project/spyre
22

3-
go 1.14
3+
go 1.11
44

55
require (
6+
github.com/hillu/go-archive-zip-crypto v0.0.0-20200712202847-bd5cf365dd44
67
github.com/hillu/go-yara v1.3.0
78
github.com/spf13/afero v1.3.2
89
github.com/spf13/pflag v1.0.5
9-
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae
10-
golang.org/x/text v0.3.3 // indirect
10+
golang.org/x/sys v0.0.0-20190412213103-97732733099d
1111
)

go.sum

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2+
github.com/hillu/go-archive-zip-crypto v0.0.0-20200712202847-bd5cf365dd44 h1:seZZ+imS3iv6i0op0cqgt9K6BETRkXwUV9e8inrF+ws=
3+
github.com/hillu/go-archive-zip-crypto v0.0.0-20200712202847-bd5cf365dd44/go.mod h1:xUc/S/HgVuP6lhDvD0Wqtu/Npwx93VSXzbdyEDbqBb8=
24
github.com/hillu/go-yara v1.3.0 h1:d9HklhWmCY9M/2dnFxYbNXDOFDid3HPGw53hdVk4Urg=
35
github.com/hillu/go-yara v1.3.0/go.mod h1:KLxCsvD3F8cgVK866UDHi961qbzP+twKjhNdDsuz/2M=
46
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
@@ -12,16 +14,13 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
1214
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
1315
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
1416
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
17+
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586 h1:7KByu05hhLed2MO29w7p1XfZvZ13m8mub3shuVftRs0=
1518
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
1619
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
1720
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
21+
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
1822
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
19-
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo=
20-
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
2123
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
2224
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
23-
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
24-
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
25-
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
2625
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2726
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

0 commit comments

Comments
 (0)