mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-23 12:44:05 -08:00
Merge pull request #782 from smyrman/master
Make Prometheus build on Windows (without make).
This commit is contained in:
commit
92a0af37e4
1
Makefile
1
Makefile
|
@ -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 '{}' ';'
|
||||
|
|
|
@ -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 '}'
|
|
@ -19,5 +19,5 @@ func newLock(fileName string) (Releaser, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &windowsFileLock{fd}, nil
|
||||
return &windowsLock{fd}, nil
|
||||
}
|
||||
|
|
12
web/Makefile
12
web/Makefile
|
@ -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
1
web/blob/.gitignore
vendored
|
@ -1,2 +1 @@
|
|||
files.go
|
||||
protocol_buffer.descriptor
|
||||
|
|
|
@ -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
1131
web/blob/files.go
Normal file
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 847 B After Width: | Height: | Size: 847 B |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue