Skip to content

Commit

Permalink
hacky build script
Browse files Browse the repository at this point in the history
  • Loading branch information
briandowns committed Jun 12, 2017
1 parent 2bad801 commit 8b71d95
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 8 deletions.
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
LDFLAGS = -ldflags "-X main.gitSHA=$(shell git rev-parse HEAD)"

OS := $(shell uname)

build: clean
go build $(LDFLAGS) -o simple-httpd

Expand All @@ -13,5 +15,16 @@ clean:
go clean
rm -f simple-httpd

install: clean
go install
install: clean release
ifeq ($(OS),Darwin)
cp -f bin/simple-httpd-darwin /usr/local/bin/simple-httpd
endif
ifeq ($(OS),Linux)
cp -f bin/simple-httpd-linux /usr/local/bin/simple-httpd
endif

uninstall: clean
rm -f /usr/local/bin/simple-httpd*

release:
@./build.sh
43 changes: 38 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
#!/bin/sh

FREEBSD="freebsd"
LINUX="linux"
DARWIN="darwin"
WINDOWS="windows"

VERSION="0.1"
ARCHS="darwin linux freebsd windows"
ARCHS="${DARWIN} ${LINUX} ${FREEBSD} ${WINDOWS}"

if [ $1 == "release" ]; then
echo "Generating simple-httpd release binaries..."
for arch in ${ARCHS}; do
GOOS=${arch} GOARCH=amd64 go build -v -ldflags "-X main.gitSHA=$(git rev-parse HEAD)" -o bin/simple-httpd-${arch}
done
fi

echo "Generating simple-httpd release binaries..."
case "$1" in
"release")
echo "Building release..."
for arch in ${ARCHS}; do
GOOS=${arch} GOARCH=amd64 go build -v -ldflags "-X main.gitSHA=$(git rev-parse HEAD)" -o bin/simple-httpd-${arch}
done
;;
"freebsd")
echo "Building binary for FreeBSD"
GOOS=${FREEBSD} GOARCH=amd64 go build -v -ldflags "-X main.gitSHA=$(git rev-parse HEAD)" -o bin/simple-httpd-${FREEBSD}
;;
"darwin")
echo "Building binary for Darwin"
GOOS=${DARWIN} GOARCH=amd64 go build -v -ldflags "-X main.gitSHA=$(git rev-parse HEAD)" -o bin/simple-httpd-${DARWIN}
;;
"linux")
echo "Building binary for Linux"
GOOS=${LINUX} GOARCH=amd64 go build -v -ldflags "-X main.gitSHA=$(git rev-parse HEAD)" -o bin/simple-httpd-${LINUX}
;;
"windows")
echo "Building binary for Windows"
GOOS=${WINDOWS} GOARCH=amd64 go build -v -ldflags "-X main.gitSHA=$(git rev-parse HEAD)" -o bin/simple-httpd-${WINDOWS}
;;
esac

for arch in ${ARCHS}; do
GOOS=windows GOARCH=amd64 go build -v -ldflags "-X main.gitSHA=$(git rev-parse HEAD)" -o bin/simple-httpd-${arch}
done
exit 0
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (r requestData) String() string {
return string(b)
}

// setHeaders sets the base headers for all requests
func setHeaders(w http.ResponseWriter) {
w.Header().Set("Server", name+pathSeperator+version)
w.Header().Add("Date", time.Now().Format(time.RFC822))
Expand Down Expand Up @@ -332,6 +333,6 @@ const htmlTemplate = `
</body>
<hr>
<footer>
<p>simple-httpd {{.version}} / {{.goVersion}}</p>
<p>simple-httpd - {{.version}} / {{.goVersion}}</p>
</footer>
</html>`
Binary file removed simple-httpd
Binary file not shown.

0 comments on commit 8b71d95

Please sign in to comment.