2
0
mirror of synced 2025-02-24 15:28:28 +00:00
mobile/cmd/gomobile/clean.go
Hana Kim 6837d85185 cmd/gomobile: introduce the 'clean' command
The command deletes all files under $GOPATH/pkg/gomobile dir
that keeps downloaded files and precompiled objects during the
last gomobile init run.

'gomobile clean' will be suggested in case of gomobile init
failures due to downloaded file hash mismatch.

For golang/go#15973

Change-Id: Ie9d3cfa7aef9d68931fd68f7b58d1a18c9d4b3b8
Reviewed-on: https://go-review.googlesource.com/24074
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-14 16:05:07 +00:00

33 lines
744 B
Go

// 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)
}