2016-03-01 15:57:46 -07:00
|
|
|
// Copyright 2012 The Go Authors. All rights reserved.
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2015-01-07 09:38:00 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2015-04-20 09:41:31 -06:00
|
|
|
"bytes"
|
2017-08-31 05:00:19 -06:00
|
|
|
"flag"
|
2015-01-07 09:38:00 -07:00
|
|
|
"fmt"
|
2016-04-07 14:03:53 -06:00
|
|
|
"io"
|
2015-01-07 09:38:00 -07:00
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"path/filepath"
|
|
|
|
"sort"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// pathf is fmt.Sprintf for generating paths
|
|
|
|
// (on windows it turns / into \ after the printf).
|
|
|
|
func pathf(format string, args ...interface{}) string {
|
|
|
|
return filepath.Clean(fmt.Sprintf(format, args...))
|
|
|
|
}
|
|
|
|
|
|
|
|
// filter returns a slice containing the elements x from list for which f(x) == true.
|
|
|
|
func filter(list []string, f func(string) bool) []string {
|
|
|
|
var out []string
|
|
|
|
for _, x := range list {
|
|
|
|
if f(x) {
|
|
|
|
out = append(out, x)
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
2015-01-07 09:38:00 -07:00
|
|
|
}
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
// uniq returns a sorted slice containing the unique elements of list.
|
|
|
|
func uniq(list []string) []string {
|
|
|
|
out := make([]string, len(list))
|
|
|
|
copy(out, list)
|
|
|
|
sort.Strings(out)
|
|
|
|
keep := out[:0]
|
|
|
|
for _, x := range out {
|
|
|
|
if len(keep) == 0 || keep[len(keep)-1] != x {
|
|
|
|
keep = append(keep, x)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return keep
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
CheckExit = 1 << iota
|
|
|
|
ShowOutput
|
|
|
|
Background
|
|
|
|
)
|
|
|
|
|
|
|
|
var outputLock sync.Mutex
|
|
|
|
|
|
|
|
// run runs the command line cmd in dir.
|
2015-12-30 09:10:47 -07:00
|
|
|
// If mode has ShowOutput set and Background unset, run passes cmd's output to
|
|
|
|
// stdout/stderr directly. Otherwise, run returns cmd's output as a string.
|
2015-01-07 09:38:00 -07:00
|
|
|
// If mode has CheckExit set and the command fails, run calls fatal.
|
|
|
|
// If mode has Background set, this command is being run as a
|
|
|
|
// Background job. Only bgrun should use the Background mode,
|
|
|
|
// not other callers.
|
|
|
|
func run(dir string, mode int, cmd ...string) string {
|
|
|
|
if vflag > 1 {
|
|
|
|
errprintf("run: %s\n", strings.Join(cmd, " "))
|
|
|
|
}
|
|
|
|
|
|
|
|
xcmd := exec.Command(cmd[0], cmd[1:]...)
|
|
|
|
xcmd.Dir = dir
|
2015-01-23 09:08:51 -07:00
|
|
|
var data []byte
|
2015-01-07 09:38:00 -07:00
|
|
|
var err error
|
2015-01-23 09:08:51 -07:00
|
|
|
|
|
|
|
// If we want to show command output and this is not
|
|
|
|
// a background command, assume it's the only thing
|
|
|
|
// running, so we can just let it write directly stdout/stderr
|
|
|
|
// as it runs without fear of mixing the output with some
|
|
|
|
// other command's output. Not buffering lets the output
|
|
|
|
// appear as it is printed instead of once the command exits.
|
|
|
|
// This is most important for the invocation of 'go1.4 build -v bootstrap/...'.
|
|
|
|
if mode&(Background|ShowOutput) == ShowOutput {
|
|
|
|
xcmd.Stdout = os.Stdout
|
|
|
|
xcmd.Stderr = os.Stderr
|
|
|
|
err = xcmd.Run()
|
|
|
|
} else {
|
|
|
|
data, err = xcmd.CombinedOutput()
|
|
|
|
}
|
2015-01-07 09:38:00 -07:00
|
|
|
if err != nil && mode&CheckExit != 0 {
|
|
|
|
outputLock.Lock()
|
|
|
|
if len(data) > 0 {
|
|
|
|
xprintf("%s\n", data)
|
|
|
|
}
|
|
|
|
outputLock.Unlock()
|
|
|
|
if mode&Background != 0 {
|
2015-08-28 15:08:51 -06:00
|
|
|
// Prevent fatal from waiting on our own goroutine's
|
|
|
|
// bghelper to exit:
|
|
|
|
bghelpers.Done()
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
2015-03-08 11:33:39 -06:00
|
|
|
fatal("FAILED: %v: %v", strings.Join(cmd, " "), err)
|
2015-01-07 09:38:00 -07:00
|
|
|
}
|
|
|
|
if mode&ShowOutput != 0 {
|
2015-01-16 20:12:41 -07:00
|
|
|
outputLock.Lock()
|
2015-01-07 09:38:00 -07:00
|
|
|
os.Stdout.Write(data)
|
2015-01-16 20:12:41 -07:00
|
|
|
outputLock.Unlock()
|
|
|
|
}
|
|
|
|
if vflag > 2 {
|
|
|
|
errprintf("run: %s DONE\n", strings.Join(cmd, " "))
|
2015-01-07 09:38:00 -07:00
|
|
|
}
|
|
|
|
return string(data)
|
|
|
|
}
|
|
|
|
|
|
|
|
var maxbg = 4 /* maximum number of jobs to run at once */
|
|
|
|
|
|
|
|
var (
|
2015-01-16 20:12:41 -07:00
|
|
|
bgwork = make(chan func(), 1e5)
|
|
|
|
|
2015-08-28 15:08:51 -06:00
|
|
|
bghelpers sync.WaitGroup
|
2015-01-16 20:12:41 -07:00
|
|
|
|
2015-08-28 15:08:51 -06:00
|
|
|
dieOnce sync.Once // guards close of dying
|
|
|
|
dying = make(chan struct{})
|
2015-01-07 09:38:00 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func bginit() {
|
2015-08-28 15:08:51 -06:00
|
|
|
bghelpers.Add(maxbg)
|
2015-01-07 09:38:00 -07:00
|
|
|
for i := 0; i < maxbg; i++ {
|
|
|
|
go bghelper()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func bghelper() {
|
2015-08-28 15:08:51 -06:00
|
|
|
defer bghelpers.Done()
|
2015-01-07 09:38:00 -07:00
|
|
|
for {
|
2015-08-28 15:08:51 -06:00
|
|
|
select {
|
|
|
|
case <-dying:
|
2015-01-16 20:12:41 -07:00
|
|
|
return
|
2015-08-28 15:08:51 -06:00
|
|
|
case w := <-bgwork:
|
|
|
|
// Dying takes precedence over doing more work.
|
|
|
|
select {
|
|
|
|
case <-dying:
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
w()
|
|
|
|
}
|
2015-01-16 20:12:41 -07:00
|
|
|
}
|
2015-01-07 09:38:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// bgrun is like run but runs the command in the background.
|
|
|
|
// CheckExit|ShowOutput mode is implied (since output cannot be returned).
|
2015-08-28 15:08:51 -06:00
|
|
|
// bgrun adds 1 to wg immediately, and calls Done when the work completes.
|
|
|
|
func bgrun(wg *sync.WaitGroup, dir string, cmd ...string) {
|
|
|
|
wg.Add(1)
|
2015-01-07 09:38:00 -07:00
|
|
|
bgwork <- func() {
|
2015-08-28 15:08:51 -06:00
|
|
|
defer wg.Done()
|
2015-01-07 09:38:00 -07:00
|
|
|
run(dir, CheckExit|ShowOutput|Background, cmd...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// bgwait waits for pending bgruns to finish.
|
2015-01-16 20:12:41 -07:00
|
|
|
// bgwait must be called from only a single goroutine at a time.
|
2015-08-28 15:08:51 -06:00
|
|
|
func bgwait(wg *sync.WaitGroup) {
|
|
|
|
done := make(chan struct{})
|
|
|
|
go func() {
|
|
|
|
wg.Wait()
|
|
|
|
close(done)
|
|
|
|
}()
|
|
|
|
select {
|
|
|
|
case <-done:
|
|
|
|
case <-dying:
|
2015-01-07 09:38:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// xgetwd returns the current directory.
|
|
|
|
func xgetwd() string {
|
|
|
|
wd, err := os.Getwd()
|
|
|
|
if err != nil {
|
|
|
|
fatal("%s", err)
|
|
|
|
}
|
|
|
|
return wd
|
|
|
|
}
|
|
|
|
|
|
|
|
// xrealwd returns the 'real' name for the given path.
|
|
|
|
// real is defined as what xgetwd returns in that directory.
|
|
|
|
func xrealwd(path string) string {
|
|
|
|
old := xgetwd()
|
|
|
|
if err := os.Chdir(path); err != nil {
|
|
|
|
fatal("chdir %s: %v", path, err)
|
|
|
|
}
|
|
|
|
real := xgetwd()
|
|
|
|
if err := os.Chdir(old); err != nil {
|
|
|
|
fatal("chdir %s: %v", old, err)
|
|
|
|
}
|
|
|
|
return real
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// isdir reports whether p names an existing directory.
|
2015-01-07 09:38:00 -07:00
|
|
|
func isdir(p string) bool {
|
|
|
|
fi, err := os.Stat(p)
|
|
|
|
return err == nil && fi.IsDir()
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// isfile reports whether p names an existing file.
|
2015-01-07 09:38:00 -07:00
|
|
|
func isfile(p string) bool {
|
|
|
|
fi, err := os.Stat(p)
|
|
|
|
return err == nil && fi.Mode().IsRegular()
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// mtime returns the modification time of the file p.
|
2015-01-07 09:38:00 -07:00
|
|
|
func mtime(p string) time.Time {
|
|
|
|
fi, err := os.Stat(p)
|
|
|
|
if err != nil {
|
|
|
|
return time.Time{}
|
|
|
|
}
|
|
|
|
return fi.ModTime()
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
|
2015-01-07 09:38:00 -07:00
|
|
|
// readfile returns the content of the named file.
|
|
|
|
func readfile(file string) string {
|
|
|
|
data, err := ioutil.ReadFile(file)
|
|
|
|
if err != nil {
|
|
|
|
fatal("%v", err)
|
|
|
|
}
|
|
|
|
return string(data)
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
|
2015-04-20 09:41:31 -06:00
|
|
|
const (
|
|
|
|
writeExec = 1 << iota
|
|
|
|
writeSkipSame
|
|
|
|
)
|
|
|
|
|
|
|
|
// writefile writes b to the named file, creating it if needed.
|
|
|
|
// if exec is non-zero, marks the file as executable.
|
|
|
|
// If the file already exists and has the expected content,
|
|
|
|
// it is not rewritten, to avoid changing the time stamp.
|
|
|
|
func writefile(b, file string, flag int) {
|
|
|
|
new := []byte(b)
|
|
|
|
if flag&writeSkipSame != 0 {
|
|
|
|
old, err := ioutil.ReadFile(file)
|
|
|
|
if err == nil && bytes.Equal(old, new) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2015-01-07 09:38:00 -07:00
|
|
|
mode := os.FileMode(0666)
|
2015-04-20 09:41:31 -06:00
|
|
|
if flag&writeExec != 0 {
|
2015-01-07 09:38:00 -07:00
|
|
|
mode = 0777
|
|
|
|
}
|
2015-04-20 09:41:31 -06:00
|
|
|
err := ioutil.WriteFile(file, new, mode)
|
2015-01-07 09:38:00 -07:00
|
|
|
if err != nil {
|
|
|
|
fatal("%v", err)
|
|
|
|
}
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
2012-02-21 14:49:30 -07:00
|
|
|
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
// xmkdir creates the directory p.
|
2015-01-07 09:38:00 -07:00
|
|
|
func xmkdir(p string) {
|
|
|
|
err := os.Mkdir(p, 0777)
|
|
|
|
if err != nil {
|
|
|
|
fatal("%v", err)
|
|
|
|
}
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// xmkdirall creates the directory p and its parents, as needed.
|
2015-01-07 09:38:00 -07:00
|
|
|
func xmkdirall(p string) {
|
|
|
|
err := os.MkdirAll(p, 0777)
|
|
|
|
if err != nil {
|
|
|
|
fatal("%v", err)
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// xremove removes the file p.
|
2015-01-07 09:38:00 -07:00
|
|
|
func xremove(p string) {
|
|
|
|
if vflag > 2 {
|
|
|
|
errprintf("rm %s\n", p)
|
|
|
|
}
|
|
|
|
os.Remove(p)
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// xremoveall removes the file or directory tree rooted at p.
|
2015-01-07 09:38:00 -07:00
|
|
|
func xremoveall(p string) {
|
|
|
|
if vflag > 2 {
|
|
|
|
errprintf("rm -r %s\n", p)
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
2015-01-07 09:38:00 -07:00
|
|
|
os.RemoveAll(p)
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
|
2015-01-19 10:57:35 -07:00
|
|
|
// xreaddir replaces dst with a list of the names of the files and subdirectories in dir.
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
// The names are relative to dir; they are not full paths.
|
2015-01-07 09:38:00 -07:00
|
|
|
func xreaddir(dir string) []string {
|
|
|
|
f, err := os.Open(dir)
|
|
|
|
if err != nil {
|
|
|
|
fatal("%v", err)
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
2015-01-07 09:38:00 -07:00
|
|
|
defer f.Close()
|
|
|
|
names, err := f.Readdirnames(-1)
|
|
|
|
if err != nil {
|
|
|
|
fatal("reading %s: %v", dir, err)
|
|
|
|
}
|
|
|
|
return names
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
|
2015-01-19 10:57:35 -07:00
|
|
|
// xreaddir replaces dst with a list of the names of the files in dir.
|
|
|
|
// The names are relative to dir; they are not full paths.
|
|
|
|
func xreaddirfiles(dir string) []string {
|
|
|
|
f, err := os.Open(dir)
|
|
|
|
if err != nil {
|
|
|
|
fatal("%v", err)
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
infos, err := f.Readdir(-1)
|
|
|
|
if err != nil {
|
|
|
|
fatal("reading %s: %v", dir, err)
|
|
|
|
}
|
|
|
|
var names []string
|
|
|
|
for _, fi := range infos {
|
|
|
|
if !fi.IsDir() {
|
|
|
|
names = append(names, fi.Name())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return names
|
|
|
|
}
|
|
|
|
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
// xworkdir creates a new temporary directory to hold object files
|
|
|
|
// and returns the name of that directory.
|
2015-01-07 09:38:00 -07:00
|
|
|
func xworkdir() string {
|
|
|
|
name, err := ioutil.TempDir("", "go-tool-dist-")
|
|
|
|
if err != nil {
|
|
|
|
fatal("%v", err)
|
|
|
|
}
|
|
|
|
return name
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// fatal prints an error message to standard error and exits.
|
2015-01-07 09:38:00 -07:00
|
|
|
func fatal(format string, args ...interface{}) {
|
|
|
|
fmt.Fprintf(os.Stderr, "go tool dist: %s\n", fmt.Sprintf(format, args...))
|
2015-01-16 20:12:41 -07:00
|
|
|
|
2015-08-28 15:08:51 -06:00
|
|
|
dieOnce.Do(func() { close(dying) })
|
|
|
|
|
2015-01-16 20:12:41 -07:00
|
|
|
// Wait for background goroutines to finish,
|
|
|
|
// so that exit handler that removes the work directory
|
|
|
|
// is not fighting with active writes or open files.
|
2015-08-28 15:08:51 -06:00
|
|
|
bghelpers.Wait()
|
2015-01-16 20:12:41 -07:00
|
|
|
|
2015-01-07 09:38:00 -07:00
|
|
|
xexit(2)
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
|
2015-01-07 09:38:00 -07:00
|
|
|
var atexits []func()
|
|
|
|
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
// xexit exits the process with return code n.
|
2015-01-07 09:38:00 -07:00
|
|
|
func xexit(n int) {
|
|
|
|
for i := len(atexits) - 1; i >= 0; i-- {
|
|
|
|
atexits[i]()
|
|
|
|
}
|
|
|
|
os.Exit(n)
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// xatexit schedules the exit-handler f to be run when the program exits.
|
2015-01-07 09:38:00 -07:00
|
|
|
func xatexit(f func()) {
|
|
|
|
atexits = append(atexits, f)
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// xprintf prints a message to standard output.
|
2015-01-07 09:38:00 -07:00
|
|
|
func xprintf(format string, args ...interface{}) {
|
|
|
|
fmt.Printf(format, args...)
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
|
2012-07-05 23:00:18 -06:00
|
|
|
// errprintf prints a message to standard output.
|
2015-01-07 09:38:00 -07:00
|
|
|
func errprintf(format string, args ...interface{}) {
|
|
|
|
fmt.Fprintf(os.Stderr, format, args...)
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
|
2015-01-07 09:38:00 -07:00
|
|
|
// xsamefile reports whether f1 and f2 are the same file (or dir)
|
|
|
|
func xsamefile(f1, f2 string) bool {
|
|
|
|
fi1, err1 := os.Stat(f1)
|
|
|
|
fi2, err2 := os.Stat(f2)
|
|
|
|
if err1 != nil || err2 != nil {
|
|
|
|
return f1 == f2
|
|
|
|
}
|
|
|
|
return os.SameFile(fi1, fi2)
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
|
|
|
|
2015-01-07 09:38:00 -07:00
|
|
|
func xgetgoarm() string {
|
|
|
|
if goos == "nacl" {
|
|
|
|
// NaCl guarantees VFPv3 and is always cross-compiled.
|
|
|
|
return "7"
|
|
|
|
}
|
2014-12-25 23:22:41 -07:00
|
|
|
if goos == "darwin" {
|
|
|
|
// Assume all darwin/arm devices are have VFPv3. This
|
|
|
|
// port is also mostly cross-compiled, so it makes little
|
|
|
|
// sense to auto-detect the setting.
|
|
|
|
return "7"
|
|
|
|
}
|
2015-01-07 09:38:00 -07:00
|
|
|
if gohostarch != "arm" || goos != gohostos {
|
|
|
|
// Conservative default for cross-compilation.
|
|
|
|
return "5"
|
|
|
|
}
|
2015-03-15 00:38:05 -06:00
|
|
|
if goos == "freebsd" || goos == "openbsd" {
|
2015-01-07 09:38:00 -07:00
|
|
|
// FreeBSD has broken VFP support.
|
2015-03-15 00:38:05 -06:00
|
|
|
// OpenBSD currently only supports softfloat.
|
2015-01-07 09:38:00 -07:00
|
|
|
return "5"
|
|
|
|
}
|
2015-09-09 20:56:26 -06:00
|
|
|
|
|
|
|
// Try to exec ourselves in a mode to detect VFP support.
|
|
|
|
// Seeing how far it gets determines which instructions failed.
|
|
|
|
// The test is OS-agnostic.
|
|
|
|
out := run("", 0, os.Args[0], "-check-goarm")
|
|
|
|
v1ok := strings.Contains(out, "VFPv1 OK.")
|
|
|
|
v3ok := strings.Contains(out, "VFPv3 OK.")
|
|
|
|
|
|
|
|
if v1ok && v3ok {
|
2015-01-07 09:38:00 -07:00
|
|
|
return "7"
|
|
|
|
}
|
2015-09-09 20:56:26 -06:00
|
|
|
if v1ok {
|
|
|
|
return "6"
|
2015-01-07 09:38:00 -07:00
|
|
|
}
|
2015-09-09 20:56:26 -06:00
|
|
|
return "5"
|
cmd/dist: new command
dist is short for distribution. This is the new Go distribution tool.
The plan is to replace the Makefiles with what amounts to
'go tool dist bootstrap', although it cannot be invoked like
that since it is in charge of getting us to the point where we
can build the go command.
It will also add additional commands to replace bash scripts
like test/run (go tool dist testrun), eventually eliminating our
dependence on not just bash but all the Unix tools and all
of cygwin.
This is strong enough to build (cc *.c) and run (a.out bootstrap)
to build not just the C libraries and tools but also the basic
Go packages up to the bootstrap form of the go command
(go_bootstrap). I've run it successfully on both Linux and Windows.
This means that once we've switched to this tool in the build,
we can delete the buildscripts.
This tool is not nearly as nice as the go tool. There are many
special cases that turn into simple if statements or tables in
the code. Please forgive that. C does not enjoy the benefits
that we designed into Go.
I was planning to wait to do this until after Go 1, but the
Windows builders are both broken due to a bug in either
make or bash or both involving the parsing of quoted command
arguments. Make thinks it is invoking
quietgcc -fno-common -I"c:/go/include" -ggdb -O2 -c foo.c
but bash (quietgcc is a bash script) thinks it is being invoked as
quietgcc -fno-common '-Ic:/go/include -ggdb' -O2 -c foo.c
which obviously does not have the desired effect. Rather than fight
these clumsy ports, I accelerated the schedule for the new tool.
We should be completely off cygwin (using just the mingw gcc port,
which is much more standalone) before Go 1.
It is big for a single CL, and for that I apologize. I can cut it into
separate CLs along file boundaries if people would prefer that.
R=golang-dev, adg, gri, bradfitz, alex.brainman, dsymonds, iant, ality, hcwfrichter
CC=golang-dev
https://golang.org/cl/5620045
2012-02-02 17:41:39 -07:00
|
|
|
}
|
2015-02-24 16:59:20 -07:00
|
|
|
|
|
|
|
func min(a, b int) int {
|
|
|
|
if a < b {
|
|
|
|
return a
|
|
|
|
}
|
|
|
|
return b
|
|
|
|
}
|
2016-04-07 14:03:53 -06:00
|
|
|
|
|
|
|
// elfIsLittleEndian detects if the ELF file is little endian.
|
|
|
|
func elfIsLittleEndian(fn string) bool {
|
|
|
|
// read the ELF file header to determine the endianness without using the
|
|
|
|
// debug/elf package.
|
|
|
|
file, err := os.Open(fn)
|
|
|
|
if err != nil {
|
|
|
|
fatal("failed to open file to determine endianness: %v", err)
|
|
|
|
}
|
|
|
|
defer file.Close()
|
|
|
|
var hdr [16]byte
|
|
|
|
if _, err := io.ReadFull(file, hdr[:]); err != nil {
|
|
|
|
fatal("failed to read ELF header to determine endianness: %v", err)
|
|
|
|
}
|
|
|
|
// hdr[5] is EI_DATA byte, 1 is ELFDATA2LSB and 2 is ELFDATA2MSB
|
|
|
|
switch hdr[5] {
|
|
|
|
default:
|
|
|
|
fatal("unknown ELF endianness of %s: EI_DATA = %d", fn, hdr[5])
|
|
|
|
case 1:
|
|
|
|
return true
|
|
|
|
case 2:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
panic("unreachable")
|
|
|
|
}
|
2017-08-31 05:00:19 -06:00
|
|
|
|
|
|
|
// count is a flag.Value that is like a flag.Bool and a flag.Int.
|
|
|
|
// If used as -name, it increments the count, but -name=x sets the count.
|
|
|
|
// Used for verbose flag -v.
|
|
|
|
type count int
|
|
|
|
|
|
|
|
func (c *count) String() string {
|
|
|
|
return fmt.Sprint(int(*c))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *count) Set(s string) error {
|
|
|
|
switch s {
|
|
|
|
case "true":
|
|
|
|
*c++
|
|
|
|
case "false":
|
|
|
|
*c = 0
|
|
|
|
default:
|
|
|
|
n, err := strconv.Atoi(s)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("invalid count %q", s)
|
|
|
|
}
|
|
|
|
*c = count(n)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *count) IsBoolFlag() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func xflagparse(maxargs int) {
|
|
|
|
flag.Var((*count)(&vflag), "v", "verbosity")
|
|
|
|
flag.Parse()
|
|
|
|
if maxargs >= 0 && flag.NArg() > maxargs {
|
|
|
|
flag.Usage()
|
|
|
|
}
|
|
|
|
}
|