Split "all" build target, add package name as a tag
This commit is contained in:
@@ -60,7 +60,7 @@ type target struct {
|
|||||||
debpre string
|
debpre string
|
||||||
debpost string
|
debpost string
|
||||||
description string
|
description string
|
||||||
buildPkgs []string
|
buildPkg string
|
||||||
binaryName string
|
binaryName string
|
||||||
archiveFiles []archiveFile
|
archiveFiles []archiveFile
|
||||||
systemdServices []string
|
systemdServices []string
|
||||||
@@ -74,20 +74,21 @@ type archiveFile struct {
|
|||||||
perm os.FileMode
|
perm os.FileMode
|
||||||
}
|
}
|
||||||
|
|
||||||
var targets = map[string]target{
|
var targets = map[string][]target{
|
||||||
"all": {
|
"all": {
|
||||||
// Only valid for the "build" and "install" commands as it lacks all
|
// Only valid for the "build" and "install" commands as it lacks all
|
||||||
// the archive creation stuff. buildPkgs gets filled out in init()
|
// the archive creation stuff. buildPkgs gets filled out in init()
|
||||||
tags: []string{"purego"},
|
|
||||||
},
|
},
|
||||||
"syncthing": {
|
"syncthing": {
|
||||||
|
|
||||||
|
{
|
||||||
// The default target for "build", "install", "tar", "zip", "deb", etc.
|
// The default target for "build", "install", "tar", "zip", "deb", etc.
|
||||||
name: "syncthing",
|
name: "syncthing",
|
||||||
debname: "syncthing",
|
debname: "syncthing",
|
||||||
debdeps: []string{"libc6", "procps"},
|
debdeps: []string{"libc6", "procps"},
|
||||||
debpost: "script/post-upgrade",
|
debpost: "script/post-upgrade",
|
||||||
description: "Open Source Continuous File Synchronization",
|
description: "Open Source Continuous File Synchronization",
|
||||||
buildPkgs: []string{"github.com/syncthing/syncthing/cmd/syncthing"},
|
buildPkg: "github.com/syncthing/syncthing/cmd/syncthing",
|
||||||
binaryName: "syncthing", // .exe will be added automatically for Windows builds
|
binaryName: "syncthing", // .exe will be added automatically for Windows builds
|
||||||
archiveFiles: []archiveFile{
|
archiveFiles: []archiveFile{
|
||||||
{src: "{{binary}}", dst: "{{binary}}", perm: 0755},
|
{src: "{{binary}}", dst: "{{binary}}", perm: 0755},
|
||||||
@@ -125,13 +126,15 @@ var targets = map[string]target{
|
|||||||
{src: "assets/logo-only.svg", dst: "deb/usr/share/icons/hicolor/scalable/apps/syncthing.svg", perm: 0644},
|
{src: "assets/logo-only.svg", dst: "deb/usr/share/icons/hicolor/scalable/apps/syncthing.svg", perm: 0644},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
"stdiscosrv": {
|
"stdiscosrv": {
|
||||||
|
{
|
||||||
name: "stdiscosrv",
|
name: "stdiscosrv",
|
||||||
debname: "syncthing-discosrv",
|
debname: "syncthing-discosrv",
|
||||||
debdeps: []string{"libc6"},
|
debdeps: []string{"libc6"},
|
||||||
debpre: "cmd/stdiscosrv/scripts/preinst",
|
debpre: "cmd/stdiscosrv/scripts/preinst",
|
||||||
description: "Syncthing Discovery Server",
|
description: "Syncthing Discovery Server",
|
||||||
buildPkgs: []string{"github.com/syncthing/syncthing/cmd/stdiscosrv"},
|
buildPkg: "github.com/syncthing/syncthing/cmd/stdiscosrv",
|
||||||
binaryName: "stdiscosrv", // .exe will be added automatically for Windows builds
|
binaryName: "stdiscosrv", // .exe will be added automatically for Windows builds
|
||||||
archiveFiles: []archiveFile{
|
archiveFiles: []archiveFile{
|
||||||
{src: "{{binary}}", dst: "{{binary}}", perm: 0755},
|
{src: "{{binary}}", dst: "{{binary}}", perm: 0755},
|
||||||
@@ -153,13 +156,15 @@ var targets = map[string]target{
|
|||||||
},
|
},
|
||||||
tags: []string{"purego"},
|
tags: []string{"purego"},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
"strelaysrv": {
|
"strelaysrv": {
|
||||||
|
{
|
||||||
name: "strelaysrv",
|
name: "strelaysrv",
|
||||||
debname: "syncthing-relaysrv",
|
debname: "syncthing-relaysrv",
|
||||||
debdeps: []string{"libc6"},
|
debdeps: []string{"libc6"},
|
||||||
debpre: "cmd/strelaysrv/scripts/preinst",
|
debpre: "cmd/strelaysrv/scripts/preinst",
|
||||||
description: "Syncthing Relay Server",
|
description: "Syncthing Relay Server",
|
||||||
buildPkgs: []string{"github.com/syncthing/syncthing/cmd/strelaysrv"},
|
buildPkg: "github.com/syncthing/syncthing/cmd/strelaysrv",
|
||||||
binaryName: "strelaysrv", // .exe will be added automatically for Windows builds
|
binaryName: "strelaysrv", // .exe will be added automatically for Windows builds
|
||||||
archiveFiles: []archiveFile{
|
archiveFiles: []archiveFile{
|
||||||
{src: "{{binary}}", dst: "{{binary}}", perm: 0755},
|
{src: "{{binary}}", dst: "{{binary}}", perm: 0755},
|
||||||
@@ -182,12 +187,14 @@ var targets = map[string]target{
|
|||||||
{src: "cmd/strelaysrv/etc/firewall-ufw/strelaysrv", dst: "deb/etc/ufw/applications.d/strelaysrv", perm: 0644},
|
{src: "cmd/strelaysrv/etc/firewall-ufw/strelaysrv", dst: "deb/etc/ufw/applications.d/strelaysrv", perm: 0644},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
"strelaypoolsrv": {
|
"strelaypoolsrv": {
|
||||||
|
{
|
||||||
name: "strelaypoolsrv",
|
name: "strelaypoolsrv",
|
||||||
debname: "syncthing-relaypoolsrv",
|
debname: "syncthing-relaypoolsrv",
|
||||||
debdeps: []string{"libc6"},
|
debdeps: []string{"libc6"},
|
||||||
description: "Syncthing Relay Pool Server",
|
description: "Syncthing Relay Pool Server",
|
||||||
buildPkgs: []string{"github.com/syncthing/syncthing/cmd/strelaypoolsrv"},
|
buildPkg: "github.com/syncthing/syncthing/cmd/strelaypoolsrv",
|
||||||
binaryName: "strelaypoolsrv", // .exe will be added automatically for Windows builds
|
binaryName: "strelaypoolsrv", // .exe will be added automatically for Windows builds
|
||||||
archiveFiles: []archiveFile{
|
archiveFiles: []archiveFile{
|
||||||
{src: "{{binary}}", dst: "{{binary}}", perm: 0755},
|
{src: "{{binary}}", dst: "{{binary}}", perm: 0755},
|
||||||
@@ -202,6 +209,7 @@ var targets = map[string]target{
|
|||||||
{src: "AUTHORS", dst: "deb/usr/share/doc/syncthing-relaypoolsrv/AUTHORS.txt", perm: 0644},
|
{src: "AUTHORS", dst: "deb/usr/share/doc/syncthing-relaypoolsrv/AUTHORS.txt", perm: 0644},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// These are repos we need to clone to run "go generate"
|
// These are repos we need to clone to run "go generate"
|
||||||
@@ -225,13 +233,18 @@ func init() {
|
|||||||
// ignore dotfiles
|
// ignore dotfiles
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
all.buildPkgs = append(all.buildPkgs, fmt.Sprintf("github.com/syncthing/syncthing/cmd/%s", pkg))
|
all = append(all, target{
|
||||||
|
name: pkg,
|
||||||
|
buildPkg: fmt.Sprintf("github.com/syncthing/syncthing/cmd/%s", pkg),
|
||||||
|
binaryName: pkg,
|
||||||
|
tags: []string{"purego"},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
targets["all"] = all
|
targets["all"] = all
|
||||||
|
|
||||||
// The "syncthing" target includes a few more files found in the "etc"
|
// The "syncthing" target includes a few more files found in the "etc"
|
||||||
// and "extra" dirs.
|
// and "extra" dirs.
|
||||||
syncthingPkg := targets["syncthing"]
|
for i, syncthingPkg := range targets["syncthing"] {
|
||||||
for _, file := range listFiles("etc") {
|
for _, file := range listFiles("etc") {
|
||||||
syncthingPkg.archiveFiles = append(syncthingPkg.archiveFiles, archiveFile{src: file, dst: file, perm: 0644})
|
syncthingPkg.archiveFiles = append(syncthingPkg.archiveFiles, archiveFile{src: file, dst: file, perm: 0644})
|
||||||
}
|
}
|
||||||
@@ -241,7 +254,8 @@ func init() {
|
|||||||
for _, file := range listFiles("extra") {
|
for _, file := range listFiles("extra") {
|
||||||
syncthingPkg.installationFiles = append(syncthingPkg.installationFiles, archiveFile{src: file, dst: "deb/usr/share/doc/syncthing/" + filepath.Base(file), perm: 0644})
|
syncthingPkg.installationFiles = append(syncthingPkg.installationFiles, archiveFile{src: file, dst: "deb/usr/share/doc/syncthing/" + filepath.Base(file), perm: 0644})
|
||||||
}
|
}
|
||||||
targets["syncthing"] = syncthingPkg
|
targets["syncthing"][i] = syncthingPkg
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -277,7 +291,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func runCommand(cmd string, target target) {
|
func runCommand(cmd string, targets []target) {
|
||||||
switch cmd {
|
switch cmd {
|
||||||
case "install":
|
case "install":
|
||||||
var tags []string
|
var tags []string
|
||||||
@@ -285,7 +299,9 @@ func runCommand(cmd string, target target) {
|
|||||||
tags = []string{"noupgrade"}
|
tags = []string{"noupgrade"}
|
||||||
}
|
}
|
||||||
tags = append(tags, strings.Fields(extraTags)...)
|
tags = append(tags, strings.Fields(extraTags)...)
|
||||||
|
for _, target := range targets {
|
||||||
install(target, tags)
|
install(target, tags)
|
||||||
|
}
|
||||||
metalintShort()
|
metalintShort()
|
||||||
|
|
||||||
case "build":
|
case "build":
|
||||||
@@ -294,7 +310,9 @@ func runCommand(cmd string, target target) {
|
|||||||
tags = []string{"noupgrade"}
|
tags = []string{"noupgrade"}
|
||||||
}
|
}
|
||||||
tags = append(tags, strings.Fields(extraTags)...)
|
tags = append(tags, strings.Fields(extraTags)...)
|
||||||
|
for _, target := range targets {
|
||||||
build(target, tags)
|
build(target, tags)
|
||||||
|
}
|
||||||
|
|
||||||
case "test":
|
case "test":
|
||||||
test("github.com/syncthing/syncthing/lib/...", "github.com/syncthing/syncthing/cmd/...")
|
test("github.com/syncthing/syncthing/lib/...", "github.com/syncthing/syncthing/cmd/...")
|
||||||
@@ -321,13 +339,19 @@ func runCommand(cmd string, target target) {
|
|||||||
transifex()
|
transifex()
|
||||||
|
|
||||||
case "tar":
|
case "tar":
|
||||||
|
for _, target := range targets {
|
||||||
buildTar(target)
|
buildTar(target)
|
||||||
|
}
|
||||||
|
|
||||||
case "zip":
|
case "zip":
|
||||||
|
for _, target := range targets {
|
||||||
buildZip(target)
|
buildZip(target)
|
||||||
|
}
|
||||||
|
|
||||||
case "deb":
|
case "deb":
|
||||||
|
for _, target := range targets {
|
||||||
buildDeb(target)
|
buildDeb(target)
|
||||||
|
}
|
||||||
|
|
||||||
case "vet":
|
case "vet":
|
||||||
metalintShort()
|
metalintShort()
|
||||||
@@ -444,6 +468,7 @@ func install(target target, tags []string) {
|
|||||||
lazyRebuildAssets()
|
lazyRebuildAssets()
|
||||||
|
|
||||||
tags = append(target.tags, tags...)
|
tags = append(target.tags, tags...)
|
||||||
|
tags = append(tags, target.name)
|
||||||
|
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -467,13 +492,14 @@ func install(target target, tags []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args := []string{"install", "-v"}
|
args := []string{"install", "-v"}
|
||||||
args = appendParameters(args, tags, target.buildPkgs...)
|
args = appendParameters(args, tags, target.buildPkg)
|
||||||
runPrint(goCmd, args...)
|
runPrint(goCmd, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func build(target target, tags []string) {
|
func build(target target, tags []string) {
|
||||||
lazyRebuildAssets()
|
lazyRebuildAssets()
|
||||||
tags = append(target.tags, tags...)
|
tags = append(target.tags, tags...)
|
||||||
|
tags = append(tags, target.name)
|
||||||
|
|
||||||
rmr(target.BinaryName())
|
rmr(target.BinaryName())
|
||||||
|
|
||||||
@@ -497,7 +523,7 @@ func build(target target, tags []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args := []string{"build", "-v"}
|
args := []string{"build", "-v"}
|
||||||
args = appendParameters(args, tags, target.buildPkgs...)
|
args = appendParameters(args, tags, target.buildPkg)
|
||||||
runPrint(goCmd, args...)
|
runPrint(goCmd, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user