Added option for reproducible build
This commit is contained in:
parent
cf04126d27
commit
10b96ec705
22
build.go
22
build.go
|
@ -3,23 +3,37 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var reproducible = flag.Bool("r", false, "If set, the build will remove local directories from the debug infos.")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
env := os.Environ()
|
env := os.Environ()
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
env = append(env, "GOPATH="+wd)
|
|
||||||
|
|
||||||
args := []string{"build"}
|
env = append(env, "GOPATH="+wd, "CGO_ENABLED=0")
|
||||||
|
|
||||||
if len(os.Args) == 2 {
|
args := []string{"build", "-ldflags=-s -w"}
|
||||||
target := os.Args[1]
|
|
||||||
|
if *reproducible {
|
||||||
|
args = append(args,
|
||||||
|
"-asmflags=all=-trimpath="+wd,
|
||||||
|
"-gcflags=all=-trimpath="+wd,
|
||||||
|
"-a",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(flag.Args()) == 1 {
|
||||||
|
target := flag.Arg(0)
|
||||||
targetParts := strings.Split(target, "/")
|
targetParts := strings.Split(target, "/")
|
||||||
if len(targetParts) != 2 {
|
if len(targetParts) != 2 {
|
||||||
println("Invalid target specification. Example: windows/386")
|
println("Invalid target specification. Example: windows/386")
|
||||||
|
|
Loading…
Reference in New Issue