clean.go 744 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package main
  5. import (
  6. "fmt"
  7. "path/filepath"
  8. )
  9. var cmdClean = &command{
  10. run: runClean,
  11. Name: "clean",
  12. Usage: "",
  13. Short: "remove object files and cached gomobile files",
  14. Long: `
  15. Clean removes object files and cached NDK files downloaded by gomobile init
  16. `,
  17. }
  18. func runClean(cmd *command) (err error) {
  19. gopaths := filepath.SplitList(goEnv("GOPATH"))
  20. if len(gopaths) == 0 {
  21. return fmt.Errorf("GOPATH is not set")
  22. }
  23. gomobilepath = filepath.Join(gopaths[0], "pkg/gomobile")
  24. if buildX {
  25. fmt.Fprintln(xout, "GOMOBILE="+gomobilepath)
  26. }
  27. return removeAll(gomobilepath)
  28. }