build: Generate gui.files.go on the fly, remove from repo

This commit is contained in:
Jakob Borg 2016-03-28 10:03:13 +00:00
parent 68185dd93c
commit 6be4b49999
4 changed files with 42 additions and 147 deletions

1
.gitattributes vendored
View File

@ -5,5 +5,4 @@
vendor/** -text=auto vendor/** -text=auto
# Diffs on these files are meaningless # Diffs on these files are meaningless
gui.files.go -diff
*.svg -diff *.svg -diff

1
.gitignore vendored
View File

@ -14,3 +14,4 @@ coverage.xml
syncthing.sig syncthing.sig
RELEASE RELEASE
deb deb
lib/auto/gui.files.go

View File

@ -115,7 +115,7 @@ func main() {
bench("./lib/...", "./cmd/...") bench("./lib/...", "./cmd/...")
case "assets": case "assets":
assets() rebuildAssets()
case "xdr": case "xdr":
xdr() xdr()
@ -184,6 +184,8 @@ func setup() {
} }
func test(pkgs ...string) { func test(pkgs ...string) {
lazyRebuildAssets()
setBuildEnv() setBuildEnv()
useRace := runtime.GOARCH == "amd64" useRace := runtime.GOARCH == "amd64"
switch runtime.GOOS { switch runtime.GOOS {
@ -200,11 +202,15 @@ func test(pkgs ...string) {
} }
func bench(pkgs ...string) { func bench(pkgs ...string) {
lazyRebuildAssets()
setBuildEnv() setBuildEnv()
runPrint("go", append([]string{"test", "-run", "NONE", "-bench", "."}, pkgs...)...) runPrint("go", append([]string{"test", "-run", "NONE", "-bench", "."}, pkgs...)...)
} }
func install(pkg string, tags []string) { func install(pkg string, tags []string) {
lazyRebuildAssets()
cwd, err := os.Getwd() cwd, err := os.Getwd()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
@ -223,6 +229,8 @@ func install(pkg string, tags []string) {
} }
func build(pkg string, tags []string) { func build(pkg string, tags []string) {
lazyRebuildAssets()
binary := "syncthing" binary := "syncthing"
if goos == "windows" { if goos == "windows" {
binary += ".exe" binary += ".exe"
@ -406,11 +414,42 @@ func setBuildEnv() {
os.Setenv("GO15VENDOREXPERIMENT", "1") os.Setenv("GO15VENDOREXPERIMENT", "1")
} }
func assets() { func rebuildAssets() {
setBuildEnv() setBuildEnv()
runPipe("lib/auto/gui.files.go", "go", "run", "script/genassets.go", "gui") runPipe("lib/auto/gui.files.go", "go", "run", "script/genassets.go", "gui")
} }
func lazyRebuildAssets() {
if shouldRebuildAssets() {
rebuildAssets()
}
}
func shouldRebuildAssets() bool {
info, err := os.Stat("lib/auto/gui.files.go")
if err != nil {
// If the file doesn't exist, we must rebuild it
return true
}
// Check if any of the files in gui/ are newer than the asset file. If
// so we should rebuild it.
currentBuild := info.ModTime()
assetsAreNewer := false
filepath.Walk("gui", func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if assetsAreNewer {
return nil
}
assetsAreNewer = info.ModTime().After(currentBuild)
return nil
})
return assetsAreNewer
}
func xdr() { func xdr() {
runPrint("go", "generate", "./lib/discover", "./lib/db", "./lib/protocol", "./lib/relay/protocol") runPrint("go", "generate", "./lib/discover", "./lib/db", "./lib/protocol", "./lib/relay/protocol")
} }
@ -429,8 +468,6 @@ func translate() {
func transifex() { func transifex() {
os.Chdir("gui/default/assets/lang") os.Chdir("gui/default/assets/lang")
runPrint("go", "run", "../../../../script/transifexdl.go") runPrint("go", "run", "../../../../script/transifexdl.go")
os.Chdir("../../../..")
assets()
} }
func clean() { func clean() {

File diff suppressed because one or more lines are too long