diff --git a/cmd/gomobile/build.go b/cmd/gomobile/build.go index 9584ea5..a1e308b 100644 --- a/cmd/gomobile/build.go +++ b/cmd/gomobile/build.go @@ -253,6 +253,8 @@ func init() { addBuildFlags(cmdBind) addBuildFlagsNVXWork(cmdBind) + + addBuildFlagsNVXWork(cmdClean) } func goBuild(src string, env []string, args ...string) error { diff --git a/cmd/gomobile/clean.go b/cmd/gomobile/clean.go new file mode 100644 index 0000000..1c0e348 --- /dev/null +++ b/cmd/gomobile/clean.go @@ -0,0 +1,32 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "fmt" + "path/filepath" +) + +var cmdClean = &command{ + run: runClean, + Name: "clean", + Usage: "", + Short: "remove object files and cached gomobile files", + Long: ` +Clean removes object files and cached NDK files downloaded by gomobile init +`, +} + +func runClean(cmd *command) (err error) { + gopaths := filepath.SplitList(goEnv("GOPATH")) + if len(gopaths) == 0 { + return fmt.Errorf("GOPATH is not set") + } + gomobilepath = filepath.Join(gopaths[0], "pkg/gomobile") + if buildX { + fmt.Fprintln(xout, "GOMOBILE="+gomobilepath) + } + return removeAll(gomobilepath) +} diff --git a/cmd/gomobile/init.go b/cmd/gomobile/init.go index ef52e19..94fa759 100644 --- a/cmd/gomobile/init.go +++ b/cmd/gomobile/init.go @@ -566,7 +566,7 @@ func fetch(url string) (dst string, err error) { } hash := hex.EncodeToString(hashw.Sum(nil)) if fetchHashes[name] != hash { - return "", fmt.Errorf("sha256 for %q: %v, want %v", name, hash, fetchHashes[name]) + return "", fmt.Errorf("sha256 for %q: %v, want %v. Try 'gomobile clean'", name, hash, fetchHashes[name]) } if err = os.Rename(f.Name(), dst); err != nil { return "", err diff --git a/cmd/gomobile/main.go b/cmd/gomobile/main.go index b17d93d..4e0e184 100644 --- a/cmd/gomobile/main.go +++ b/cmd/gomobile/main.go @@ -174,6 +174,7 @@ var commands = []*command{ // TODO(crawshaw): cmdRun cmdBind, cmdBuild, + cmdClean, cmdInit, cmdInstall, cmdVersion,