devcam: bugfix; do not fail when binary does not exist

http://camlistore.org/issue/213

Change-Id: I432a8ec04cb02c4c5241bd38361fad3d6d39ee02
This commit is contained in:
mpl 2013-08-26 15:09:57 +02:00
parent 500ba50b97
commit 6bc558910d
2 changed files with 11 additions and 5 deletions

View File

@ -130,16 +130,21 @@ func (c *serverCmd) build(name string) error {
return fmt.Errorf("Could not build, invalid target: %v", name) return fmt.Errorf("Could not build, invalid target: %v", name)
} }
binPath := filepath.Join(c.camliSrcRoot, "bin", name) binPath := filepath.Join(c.camliSrcRoot, "bin", name)
var modtime int64
fi, err := os.Stat(binPath) fi, err := os.Stat(binPath)
if err != nil { if err != nil {
if !os.IsNotExist(err) {
return fmt.Errorf("Could not stat %v: %v", binPath, err) return fmt.Errorf("Could not stat %v: %v", binPath, err)
} }
} else {
modtime = fi.ModTime().Unix()
}
args := []string{ args := []string{
"run", "make.go", "run", "make.go",
"--quiet", "--quiet",
"--embed_static=false", "--embed_static=false",
"--sqlite=false", "--sqlite=false",
fmt.Sprintf("--if_mods_since=%d", fi.ModTime().Unix()), fmt.Sprintf("--if_mods_since=%d", modtime),
"--targets=" + target, "--targets=" + target,
} }
cmd := exec.Command("go", args...) cmd := exec.Command("go", args...)

View File

@ -50,6 +50,7 @@ var (
verbose = flag.Bool("v", false, "Verbose mode") verbose = flag.Bool("v", false, "Verbose mode")
targets = flag.String("targets", "", "Optional comma-separated list of targets (i.e go packages) to build and install. Empty means all. Example: camlistore.org/server/camlistored,camlistore.org/cmd/camput") targets = flag.String("targets", "", "Optional comma-separated list of targets (i.e go packages) to build and install. Empty means all. Example: camlistore.org/server/camlistored,camlistore.org/cmd/camput")
quiet = flag.Bool("quiet", false, "Don't print anything unless there's a failure.") quiet = flag.Bool("quiet", false, "Don't print anything unless there's a failure.")
// TODO(mpl): looks like ifModsSince is not used anywhere?
ifModsSince = flag.Int64("if_mods_since", 0, "If non-zero return immediately without building if there aren't any filesystem modifications past this time (in unix seconds)") ifModsSince = flag.Int64("if_mods_since", 0, "If non-zero return immediately without building if there aren't any filesystem modifications past this time (in unix seconds)")
buildARCH = flag.String("arch", runtime.GOARCH, "Architecture to build for.") buildARCH = flag.String("arch", runtime.GOARCH, "Architecture to build for.")
buildOS = flag.String("os", runtime.GOOS, "Operating system to build for.") buildOS = flag.String("os", runtime.GOOS, "Operating system to build for.")