Building without a Makefile (on Windows)

Main changes:

- Switched to using `go-bindata` in place of `scripts/embed-static.sh`.
- Support for building Prometheus without a `Makefile`.
- Minor typo fix to make Prometheus build on Windows (without Makefiles).

Please note that this does not mean that prometheus will work on Windows.
There are still failing tests!
This commit is contained in:
Sindre Myren 2015-06-08 23:37:25 +00:00 committed by Sindre Røkenes Myren
parent db4df06414
commit a081c9436b
45 changed files with 1143 additions and 62 deletions

View file

@ -55,7 +55,6 @@ benchmark: dependencies tools web
clean:
$(MAKE) -C $(BUILD_PATH) clean
$(MAKE) -C tools clean
$(MAKE) -C web clean
rm -rf $(TEST_ARTIFACTS)
-rm $(ARCHIVE)
-find . -type f -name '*~' -exec rm '{}' ';'

View file

@ -1,36 +0,0 @@
#!/bin/sh
set -e
cat <<EOF
package blob
var files = map [string] map [string] []byte {
EOF
ORIGINAL_PWD=${PWD}
for dir in $@
do
cd "${dir}" > /dev/null
echo "\"$(basename ${dir})\": {"
# Do not embed map files and the non-minified bootstrap files.
# TODO(beorn7): There should be a better solution than hardcoding the
# exclusion here. We might want to switch to a less makeshift way of
# embedding files into the binary anyway...
find . -type f \! -name \*.map \! -name bootstrap.js \! -name bootstrap-theme.css \! -name bootstrap.css | while read file
do
name=$(echo "${file}"|sed 's|\.\/||')
# Using printf here instead of "echo -n" because the latter doesn't work on Mac OS X:
# http://hints.macworld.com/article.php?story=20071106192548833.
printf "\"$name\": []byte(\""
# The second newline deletion at the end is required for Mac OS X as well,
# as sed outputs a trailing newline there.
gzip -9 -c "${file}" | xxd -p | tr -d '\n' | sed 's/\(..\)/\\x\1/g' | tr -d '\n'
echo "\"),"
echo
done
echo "},"
cd "${ORIGINAL_PWD}"
done
echo '}'

View file

@ -19,5 +19,5 @@ func newLock(fileName string) (Releaser, error) {
if err != nil {
return nil, err
}
return &windowsFileLock{fd}, nil
return &windowsLock{fd}, nil
}

View file

@ -17,12 +17,10 @@ all: blob/files.go
SUFFIXES:
blob/files.go: $(shell find templates/ static/ -type f)
# Note that embed-static.sh excludes map files and the
# non-minified bootstrap files.
../scripts/embed-static.sh static templates | $(GOFMT) > $@
blob/files.go: go-bindata $(shell find blob/templates/ blob/static/ -type f)
$(GO) generate ./blob
clean:
-rm -f blob/files.go
go-bindata:
$(GO) get -u github.com/jteeuwen/go-bindata/...
.PHONY: clean
.PHONY: go-bindata

1
web/blob/.gitignore vendored
View file

@ -1,2 +1 @@
files.go
protocol_buffer.descriptor

View file

@ -1,8 +1,8 @@
package blob
//go:generate go-bindata -pkg blob -o files.go -ignore '(.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)' templates/... static/...
import (
"bytes"
"compress/gzip"
"fmt"
"io"
"net/http"
@ -27,21 +27,11 @@ var mimeMap = map[string]string{
// GetFile retrieves the content of an embedded file.
func GetFile(bucket string, name string) ([]byte, error) {
blob, ok := files[bucket][name]
if !ok {
return nil, fmt.Errorf("could not find %s/%s (missing or updated files.go?)", bucket, name)
}
reader := bytes.NewReader(blob)
gz, err := gzip.NewReader(reader)
data, err := Asset(fmt.Sprintf("%s/%s", bucket, name))
if err != nil {
return nil, err
}
var b bytes.Buffer
io.Copy(&b, gz)
gz.Close()
return b.Bytes(), nil
return data, nil
}
// Handler implements http.Handler.

1131
web/blob/files.go Normal file

File diff suppressed because one or more lines are too long

View file

Before

Width:  |  Height:  |  Size: 847 B

After

Width:  |  Height:  |  Size: 847 B

View file

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View file

@ -98,7 +98,7 @@ func NewWebService(o *WebServiceOptions) *WebService {
router.Get("/consoles/*filepath", instr("consoles", o.ConsolesHandler))
if *useLocalAssets {
router.Get("/static/*filepath", instr("static", route.FileServe("web/static")))
router.Get("/static/*filepath", instr("static", route.FileServe("web/blob/static")))
} else {
router.Get("/static/*filepath", instr("static", blob.Handler{}))
}
@ -136,7 +136,7 @@ func (ws *WebService) quitHandler(w http.ResponseWriter, r *http.Request) {
func getTemplateFile(name string) (string, error) {
if *useLocalAssets {
file, err := ioutil.ReadFile(fmt.Sprintf("web/templates/%s.html", name))
file, err := ioutil.ReadFile(fmt.Sprintf("web/blob/templates/%s.html", name))
if err != nil {
log.Errorf("Could not read %s template: %s", name, err)
return "", err