Skip to content

Commit 0440211

Browse files
authored
Merge pull request #338 from joewalnes/gomod
Switch to go modules, preparing 0.3.1
2 parents 3deec03 + 31738ae commit 0440211

File tree

6 files changed

+64
-106
lines changed

6 files changed

+64
-106
lines changed

.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
websocketd
2-
*.swp
3-
*.swo
4-
go
5-
go-v*
6-
go-workspace
2+
go-*

CHANGES

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Version 0.3.1 (Jan 28, 2019)
2+
3+
* Minor improvements to websocketd itself
4+
* Use of go modules, gorilla websockets set to 1.4.0
5+
* Binaries build code switched to 1.11.5 (improving underlying protocol handlers)
6+
17
Version 0.3.0 (??, 2017)
28

39
* Migration of underlying websocket server to Gorilla Websocket lib.

Makefile

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,35 @@
1010
# To manually invoke the locally installed Go, use ./go
1111

1212
# Go installation config.
13-
#GO_VERSION=1.2.1.linux-amd64
14-
GO_VER=1.4
13+
GO_VER=1.11.5
1514
SYSTEM_NAME:=$(shell uname -s | tr '[:upper:]' '[:lower:]')
1615
SYSTEM_ARCH:=$(shell uname -m)
1716
GO_ARCH:=$(if $(filter x86_64, $(SYSTEM_ARCH)),amd64,386)
18-
GO_VERSION:=$(GO_VER).$(SYSTEM_NAME)-$(GO_ARCH)$(if $(filter darwin,$(SYSTEM_NAME)),-osx10.8)
19-
GO_DOWNLOAD_URL=http://golang.org/dl/go$(GO_VERSION).tar.gz
17+
GO_VERSION:=$(GO_VER).$(SYSTEM_NAME)-$(GO_ARCH)
18+
GO_DOWNLOAD_URL:=https://dl.google.com/go/go$(GO_VERSION).tar.gz
19+
GO_DIR:=go-$(GO_VER)
2020

2121
# Build websocketd binary
22-
websocketd: go $(wildcard *.go) $(wildcard libwebsocketd/*.go) go-workspace/src/github.com/joewalnes/websocketd
23-
./go get ./go-workspace/src/github.com/joewalnes/websocketd
24-
./go fmt github.com/joewalnes/websocketd/libwebsocketd github.com/joewalnes/websocketd
25-
./go build
26-
27-
# Create local go workspace and symlink websocketd into the right location.
28-
go-workspace/src/github.com/joewalnes/websocketd:
29-
mkdir -p go-workspace/src/github.com/joewalnes
30-
ln -s ../../../../ go-workspace/src/github.com/joewalnes/websocketd
31-
32-
# Setup ./go wrapper to use local GOPATH/GOROOT.
33-
# Need to set PATH for gofmt.
34-
go: go-v$(GO_VERSION)/.done
35-
@echo '#!/bin/sh' > $@
36-
@echo export PATH=$(abspath go-v$(GO_VERSION)/bin):$(PATH) >> $@
37-
@echo mkdir -p $(abspath go-workspace) >> $@
38-
@echo GOPATH=$(abspath go-workspace) GOROOT=$(abspath go-v$(GO_VERSION)) $(abspath go-v$(GO_VERSION)/bin/go) \$$@ >> $@
39-
chmod +x $@
40-
@echo 'Created ./$@ wrapper'
22+
websocketd: $(GO_DIR)/bin/go $(wildcard *.go) $(wildcard libwebsocketd/*.go)
23+
$(GO_DIR)/bin/go build
24+
25+
localgo: $(GO_DIR)/bin/go
4126

4227
# Download and unpack Go distribution.
43-
go-v$(GO_VERSION)/.done:
44-
mkdir -p $(dir $@)
28+
$(GO_DIR)/bin/go:
29+
mkdir -p $(GO_DIR)
4530
rm -f $@
46-
@echo Downloading and unpacking Go $(GO_VERSION) to $(dir $@)
47-
wget -q -O - $(GO_DOWNLOAD_URL) | tar xzf - --strip-components=1 -C $(dir $@)
48-
touch $@
31+
@echo Downloading and unpacking Go $(GO_VERSION) to $(GO_DIR)
32+
curl -s $(GO_DOWNLOAD_URL) | tar xf - --strip-components=1 -C $(GO_DIR)
4933

5034
# Clean up binary
5135
clean:
52-
rm -rf websocketd go-workspace
36+
rm -rf websocketd
37+
5338
.PHONY: clean
5439

5540
# Also clean up downloaded Go
5641
clobber: clean
57-
rm -rf go $(wildcard go-v*)
42+
rm -rf $(wildcard go-v*)
43+
5844
.PHONY: clobber

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/joewalnes/websocketd
2+
3+
require github.com/gorilla/websocket v1.4.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
2+
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=

release/Makefile

Lines changed: 36 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2013 Joe Walnes and the websocketd team.
1+
# Copyright 2013-2019 Joe Walnes and the websocketd team.
22
# All rights reserved.
33
# Use of this source code is governed by a BSD-style
44
# license that can be found in the LICENSE file.
@@ -16,10 +16,12 @@ LAST_PATCH_VERSION:=$(shell git ls-remote [email protected]:joewalnes/websocketd.gi
1616
| sort -n \
1717
| tail -n 1)
1818

19-
VERSION_PATCH:=$(if $(LAST_PATCH_VERSION),$(shell expr $(LAST_PATCH_VERSION)),0)
19+
20+
21+
VERSION_PATCH:=$(shell expr $$(( $(or $(LAST_PATCH_VERSION),-1) + 1 )))
2022
RELEASE_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
2123

22-
GO_VERSION=1.9.2
24+
GO_VERSION=1.11.5
2325
PLATFORMS=linux_amd64 linux_386 linux_arm linux_arm64 darwin_amd64 freebsd_amd64 freebsd_386 windows_386 windows_amd64 openbsd_386 openbsd_amd64 solaris_amd64
2426

2527

@@ -41,73 +43,47 @@ endif
4143

4244

4345

44-
GO_SRC_URL=https://storage.googleapis.com/golang/go$(GO_VERSION).$(UNAME_SYS)-$(UNAME_ARCH).tar.gz
45-
GO_DOWNLOAD=go-local/$(GO_VERSION).tgz
46-
GO_DIR=go-local/$(GO_VERSION)
47-
GO_UNPACKED=$(GO_DIR)/.unpacked
46+
GO_DOWNLOAD_URL=https://dl.google.com/go/go$(GO_VERSION).$(UNAME_SYS)-$(UNAME_ARCH).tar.gz
47+
GO_DIR=../go-$(GO_VERSION)
4848

4949
# Prevent any global environment polluting the builds
50-
GOROOT=$(shell readlink -f $(GO_DIR))/go
51-
GOPATH=$(shell readlink -f go-path)
52-
53-
FLAGS_all = GOROOT=$(GOROOT) GOPATH=$(GOPATH)
54-
FLAGS_linux_amd64 = $(FLAGS_all) GOOS=linux GOARCH=amd64
55-
FLAGS_linux_386 = $(FLAGS_all) GOOS=linux GOARCH=386
56-
FLAGS_linux_arm = $(FLAGS_all) GOOS=linux GOARCH=arm GOARM=5 # ARM5 support for Raspberry Pi
57-
FLAGS_linux_arm64 = $(FLAGS_all) GOOS=linux GOARCH=arm64 # no need for GOARM= (which is technically 8)
58-
FLAGS_darwin_amd64 = $(FLAGS_all) GOOS=darwin GOARCH=amd64 CGO_ENABLED=0
59-
FLAGS_darwin_386 = $(FLAGS_all) GOOS=darwin GOARCH=386 CGO_ENABLED=0
60-
FLAGS_freebsd_amd64 = $(FLAGS_all) GOOS=freebsd GOARCH=amd64 CGO_ENABLED=0
61-
FLAGS_freebsd_386 = $(FLAGS_all) GOOS=freebsd GOARCH=386 CGO_ENABLED=0
62-
FLAGS_windows_386 = $(FLAGS_all) GOOS=windows GOARCH=386 CGO_ENABLED=0
63-
FLAGS_windows_amd64 = $(FLAGS_all) GOOS=windows GOARCH=amd64 CGO_ENABLED=0
64-
FLAGS_openbsd_386 = $(FLAGS_all) GOOS=openbsd GOARCH=386 CGO_ENABLED=0
65-
FLAGS_openbsd_amd64 = $(FLAGS_all) GOOS=openbsd GOARCH=amd64 CGO_ENABLED=0
66-
FLAGS_solaris_amd64 = $(FLAGS_all) GOOS=solaris GOARCH=amd64 CGO_ENABLED=0
67-
68-
EXTENSION_windows_386=.exe
69-
EXTENSION_windows_amd64=.exe
50+
FLAGS_linux_amd64 = GOOS=linux GOARCH=amd64
51+
FLAGS_linux_386 = GOOS=linux GOARCH=386
52+
FLAGS_linux_arm = GOOS=linux GOARCH=arm GOARM=5 # ARM5 support for Raspberry Pi
53+
FLAGS_linux_arm64 = GOOS=linux GOARCH=arm64 # no need for GOARM= (which is technically 8)
54+
FLAGS_darwin_amd64 = GOOS=darwin GOARCH=amd64 CGO_ENABLED=0
55+
FLAGS_darwin_386 = GOOS=darwin GOARCH=386 CGO_ENABLED=0
56+
FLAGS_freebsd_amd64 = GOOS=freebsd GOARCH=amd64 CGO_ENABLED=0
57+
FLAGS_freebsd_386 = GOOS=freebsd GOARCH=386 CGO_ENABLED=0
58+
FLAGS_windows_386 = GOOS=windows GOARCH=386 CGO_ENABLED=0
59+
FLAGS_windows_amd64 = GOOS=windows GOARCH=amd64 CGO_ENABLED=0
60+
FLAGS_openbsd_386 = GOOS=openbsd GOARCH=386 CGO_ENABLED=0
61+
FLAGS_openbsd_amd64 = GOOS=openbsd GOARCH=amd64 CGO_ENABLED=0
62+
FLAGS_solaris_amd64 = GOOS=solaris GOARCH=amd64 CGO_ENABLED=0
7063

7164
all: build
72-
.PHONY: all
73-
74-
go-path/src/github.com/joewalnes/websocketd: ../*.go ../libwebsocketd/*.go
75-
rm -f $@
76-
mkdir -p go-path/src/github.com/joewalnes
77-
cd go-path/src/github.com/joewalnes && ln -s ../../../../../ websocketd
78-
79-
80-
# Download Go source code
81-
$(GO_DOWNLOAD):
82-
$(call msg,"Dowloading Go $(GO_VERSION)")
83-
mkdir -p $(dir $@)
84-
curl --silent --fail --output $@ $(GO_SRC_URL)
8565

86-
go-download: $(GO_DOWNLOAD)
87-
.PHONY: go-download
66+
localgo: $(GO_DIR)/bin/go
8867

89-
# Unpack Go source code
90-
$(GO_UNPACKED): $(GO_DOWNLOAD)
91-
$(call msg,"Unpacking Go $(GO_VERSION)")
92-
rm -f $(GO_UNPACKED)
68+
$(GO_DIR)/bin/go:
9369
mkdir -p $(GO_DIR)
94-
tar xzf $(GO_DOWNLOAD) -C $(GO_DIR)
95-
touch $(GO_UNPACKED)
96-
97-
go-unpack: $(GO_UNPACKED)
98-
.PHONY: go-unpack
70+
rm -f $@
71+
@echo Downloading and unpacking Go $(GO_VERSION) to $(GO_DIR)
72+
curl -s $(GO_DOWNLOAD_URL) | tar xzf - --strip-components=1 -C $(GO_DIR)
9973

10074

10175
# Cross-compile final applications
102-
out/$(RELEASE_VERSION)/%/websocketd out/$(RELEASE_VERSION)/%/websocketd.exe: $(GO_UNPACKED) $(wildcard ../*.go) go-path/src/github.com/joewalnes/websocketd
103-
$(call msg,"Compiling release for $*")
76+
out/$(RELEASE_VERSION)/%/websocketd: ../*.go ../libwebsocketd/*.go $(GO_DIR)/bin/go
77+
rm -f $@
78+
mkdir -p $(dir $@)
79+
$(FLAGS_$*) $(GO_DIR)/bin/go build -ldflags "-X main.version=$(RELEASE_VERSION)" -o out/$(RELEASE_VERSION)/$*/websocketd ..
80+
81+
out/$(RELEASE_VERSION)/%/websocketd.exe: ../*.go ../libwebsocketd/*.go $(GO_DIR)/bin/go
10482
rm -f $@
10583
mkdir -p $(dir $@)
106-
$(FLAGS_$*) $(GO_DIR)/go/bin/go get github.com/gorilla/websocket
107-
$(FLAGS_$*) $(GO_DIR)/go/bin/go build -ldflags "-X main.version=$(RELEASE_VERSION)" -o out/$(RELEASE_VERSION)/$*/websocketd$(EXTENSION_$*) $(wildcard ../*.go)
108-
touch $@
84+
$(FLAGS_$*) $(GO_DIR)/bin/go build -ldflags "-X main.version=$(RELEASE_VERSION)" -o out/$(RELEASE_VERSION)/$*/websocketd.exe ..
10985

110-
out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)-%.zip: out/$(RELEASE_VERSION)/%/websocketd $(wildcard ../*.go) go-path/src/github.com/joewalnes/websocketd
86+
out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)-%.zip: out/$(RELEASE_VERSION)/%/websocketd
11187
rm -f $@
11288
zip -j $@ out/$(RELEASE_VERSION)/$*/* ../{README.md,LICENSE,CHANGES}
11389

@@ -118,10 +94,8 @@ DEBS = out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_i386.deb out/$(RELEA
11894
RPMS = out/$(RELEASE_VERSION)/websocketd.$(RELEASE_VERSION).i386.rpm out/$(RELEASE_VERSION)/websocketd.$(RELEASE_VERSION).x86_64.rpm
11995

12096
binaries: $(BINARIES)
121-
.PHONY: websocketd
12297

12398
build: out/$(RELEASE_VERSION)/CHECKSUMS
124-
.PHONY: build
12599

126100
out/$(RELEASE_VERSION)/CHECKSUMS: $(BINARIES) $(ZIPS) $(DEBS) $(RPMS)
127101
sha256sum $^ | sed -e 's/out\/$(RELEASE_VERSION)\///' >$@
@@ -134,10 +108,8 @@ DEBFPM=""
134108
RPMFPM=--rpm-os linux
135109

136110
deb: $(DEBS)
137-
.PHONY: deb
138111

139112
rpm: $(RPMS)
140-
.PHONY: rpm
141113

142114

143115
out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_i386.deb: $(GO_UNPACKED) out/$(RELEASE_VERSION)/linux_386/websocketd
@@ -175,17 +147,10 @@ out/$(RELEASE_VERSION)/websocketd.$(RELEASE_VERSION).i386.rpm: $(GO_UNPACKED) ou
175147

176148
# Clean up
177149
clobber: clean
178-
.PHONY: clobber
179-
180-
clean: clean-go clean-out
181-
.PHONY: clean
150+
rm -rf $(GO_DIR)
182151

183-
clean-go:
184-
rm -rf go-local
185-
rm -rf go-path
186-
.PHONY: clean-go
187152

188-
clean-out:
153+
clean:
189154
rm -rf out
190-
.PHONY: clean-out
191155

156+
.PHONY: all build deb rpm localgo clobber clean

0 commit comments

Comments
 (0)