mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
build: Let "go generate" create assets
This commit is contained in:
parent
406b394704
commit
ef5ca0c218
5
build.go
5
build.go
@ -738,12 +738,11 @@ func listFiles(dir string) []string {
|
|||||||
|
|
||||||
func rebuildAssets() {
|
func rebuildAssets() {
|
||||||
os.Setenv("SOURCE_DATE_EPOCH", fmt.Sprint(buildStamp()))
|
os.Setenv("SOURCE_DATE_EPOCH", fmt.Sprint(buildStamp()))
|
||||||
runPipe("lib/auto/gui.files.go", "go", "run", "script/genassets.go", "gui")
|
runPrint("go", "generate", "github.com/syncthing/syncthing/lib/auto", "github.com/syncthing/syncthing/cmd/strelaypoolsrv/auto")
|
||||||
runPipe("cmd/strelaypoolsrv/auto/gui.go", "go", "run", "script/genassets.go", "cmd/strelaypoolsrv/gui")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func lazyRebuildAssets() {
|
func lazyRebuildAssets() {
|
||||||
if shouldRebuildAssets("lib/auto/gui.files.go", "gui") || shouldRebuildAssets("cmd/strelaypoolsrv/auto/gui.go", "cmd/strelaypoolsrv/auto/gui") {
|
if shouldRebuildAssets("lib/auto/gui.files.go", "gui") || shouldRebuildAssets("cmd/strelaypoolsrv/auto/gui.files.go", "cmd/strelaypoolsrv/auto/gui") {
|
||||||
rebuildAssets()
|
rebuildAssets()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
cmd/strelaypoolsrv/auto/.gitignore
vendored
2
cmd/strelaypoolsrv/auto/.gitignore
vendored
@ -1 +1 @@
|
|||||||
gui.go
|
gui.files.go
|
||||||
|
10
cmd/strelaypoolsrv/auto/doc.go
Normal file
10
cmd/strelaypoolsrv/auto/doc.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// Copyright (C) 2018 The Syncthing Authors.
|
||||||
|
//
|
||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
//go:generate go run ../../../script/genassets.go -o gui.files.go ../gui
|
||||||
|
|
||||||
|
// Package auto contains auto generated files for web assets.
|
||||||
|
package auto
|
@ -4,5 +4,7 @@
|
|||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
//go:generate go run ../../script/genassets.go -o gui.files.go ../../gui
|
||||||
|
|
||||||
// Package auto contains auto generated files for web assets.
|
// Package auto contains auto generated files for web assets.
|
||||||
package auto
|
package auto
|
||||||
|
@ -86,6 +86,7 @@ type templateVars struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
outfile := flag.String("o", "", "Name of output file (default stdout)")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
filepath.Walk(flag.Arg(0), walkerFor(flag.Arg(0)))
|
filepath.Walk(flag.Arg(0), walkerFor(flag.Arg(0)))
|
||||||
@ -104,7 +105,17 @@ func main() {
|
|||||||
})
|
})
|
||||||
bs, err := format.Source(buf.Bytes())
|
bs, err := format.Source(buf.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
os.Stdout.Write(bs)
|
|
||||||
|
out := io.Writer(os.Stdout)
|
||||||
|
if *outfile != "" {
|
||||||
|
out, err = os.Create(*outfile)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.Write(bs)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user