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: clean:
$(MAKE) -C $(BUILD_PATH) clean $(MAKE) -C $(BUILD_PATH) clean
$(MAKE) -C tools clean $(MAKE) -C tools clean
$(MAKE) -C web clean
rm -rf $(TEST_ARTIFACTS) rm -rf $(TEST_ARTIFACTS)
-rm $(ARCHIVE) -rm $(ARCHIVE)
-find . -type f -name '*~' -exec rm '{}' ';' -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 { if err != nil {
return nil, err return nil, err
} }
return &windowsFileLock{fd}, nil return &windowsLock{fd}, nil
} }

View file

@ -17,12 +17,10 @@ all: blob/files.go
SUFFIXES: SUFFIXES:
blob/files.go: $(shell find templates/ static/ -type f) blob/files.go: go-bindata $(shell find blob/templates/ blob/static/ -type f)
# Note that embed-static.sh excludes map files and the $(GO) generate ./blob
# non-minified bootstrap files.
../scripts/embed-static.sh static templates | $(GOFMT) > $@
clean: go-bindata:
-rm -f blob/files.go $(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 protocol_buffer.descriptor

View file

@ -1,8 +1,8 @@
package blob package blob
//go:generate go-bindata -pkg blob -o files.go -ignore '(.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)' templates/... static/...
import ( import (
"bytes"
"compress/gzip"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
@ -27,21 +27,11 @@ var mimeMap = map[string]string{
// GetFile retrieves the content of an embedded file. // GetFile retrieves the content of an embedded file.
func GetFile(bucket string, name string) ([]byte, error) { func GetFile(bucket string, name string) ([]byte, error) {
blob, ok := files[bucket][name] data, err := Asset(fmt.Sprintf("%s/%s", 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)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return data, nil
var b bytes.Buffer
io.Copy(&b, gz)
gz.Close()
return b.Bytes(), nil
} }
// Handler implements http.Handler. // 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)) router.Get("/consoles/*filepath", instr("consoles", o.ConsolesHandler))
if *useLocalAssets { if *useLocalAssets {
router.Get("/static/*filepath", instr("static", route.FileServe("web/static"))) router.Get("/static/*filepath", instr("static", route.FileServe("web/blob/static")))
} else { } else {
router.Get("/static/*filepath", instr("static", blob.Handler{})) 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) { func getTemplateFile(name string) (string, error) {
if *useLocalAssets { 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 { if err != nil {
log.Errorf("Could not read %s template: %s", name, err) log.Errorf("Could not read %s template: %s", name, err)
return "", err return "", err