mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
Use simple script for asset embedding
This commit is contained in:
parent
5837277f8d
commit
d0863d495c
27
assets.sh
Executable file
27
assets.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
cat <<EOT
|
||||
package auto
|
||||
|
||||
import "compress/gzip"
|
||||
import "bytes"
|
||||
import "io/ioutil"
|
||||
|
||||
var Assets = make(map[string][]byte)
|
||||
|
||||
func init() {
|
||||
var data []byte
|
||||
var gr *gzip.Reader
|
||||
EOT
|
||||
|
||||
cd gui
|
||||
for f in $(find . -type f) ; do
|
||||
f="${f#./}"
|
||||
echo "gr, _ = gzip.NewReader(bytes.NewBuffer([]byte{"
|
||||
gzip -c $f | od -vt x1 | sed 's/^[0-9a-f]*//' | sed 's/\([0-9a-f][0-9a-f]\)/0x\1,/g'
|
||||
echo "}))"
|
||||
echo "data, _ = ioutil.ReadAll(gr)"
|
||||
echo "Assets[\"$f\"] = data"
|
||||
done
|
||||
echo "}"
|
||||
|
12944
auto/gui.files.go
12944
auto/gui.files.go
File diff suppressed because one or more lines are too long
4
build.sh
4
build.sh
@ -6,15 +6,13 @@ version=$(git describe --always)
|
||||
buildDir=dist
|
||||
|
||||
if [[ $fast != yes ]] ; then
|
||||
./assets.sh | gofmt > auto/gui.files.go
|
||||
go get -d
|
||||
go test ./...
|
||||
fi
|
||||
|
||||
if [[ -z $1 ]] ; then
|
||||
go build -ldflags "-X main.Version $version"
|
||||
elif [[ $1 == "embed" ]] ; then
|
||||
embedder auto gui > auto/gui.files.go \
|
||||
&& go build -ldflags "-X main.Version $version"
|
||||
elif [[ $1 == "tar" ]] ; then
|
||||
go build -ldflags "-X main.Version $version" \
|
||||
&& mkdir syncthing-dist \
|
||||
|
@ -11,15 +11,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/calmh/syncthing/auto"
|
||||
"github.com/cratonica/embed"
|
||||
)
|
||||
|
||||
func embeddedStatic() interface{} {
|
||||
fs, err := embed.Unpack(auto.Resources)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var modt = time.Now().UTC().Format(http.TimeFormat)
|
||||
|
||||
return func(res http.ResponseWriter, req *http.Request, log *log.Logger) {
|
||||
@ -29,7 +23,7 @@ func embeddedStatic() interface{} {
|
||||
file = file[1:]
|
||||
}
|
||||
|
||||
bs, ok := fs[file]
|
||||
bs, ok := auto.Assets[file]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user