Browse Source

improved localimport for build

pull/103/head
Lunny Xiao 11 years ago
parent
commit
2fa3a13176
  1. 17
      cmd/build.go

17
cmd/build.go

@ -98,24 +98,29 @@ func getChildPkgs(cpath string, ppkg *doc.Pkg, cachePkgs map[string]*doc.Pkg) er
} }
for name, pkg := range pkgs { for name, pkg := range pkgs {
if !pkgInCache(name, cachePkgs) { if !pkgInCache(name, cachePkgs) {
newPath := filepath.Join(installRepoPath, pkg.ImportPath) var newPath string
if !build.IsLocalImport(name) {
newPath = filepath.Join(installRepoPath, pkg.ImportPath)
if !com.IsExist(newPath) { if !com.IsExist(newPath) {
var t, ver string = doc.BRANCH, "" var t, ver string = doc.BRANCH, ""
node := doc.NewNode(pkg.ImportPath, pkg.ImportPath, t, ver, true) node := doc.NewNode(pkg.ImportPath, pkg.ImportPath, t, ver, true)
//node := new(doc.Node)
//node.Pkg = *pkg
nodes := []*doc.Node{node} nodes := []*doc.Node{node}
downloadPackages(nodes) downloadPackages(nodes)
// should handler download failed // should handler download failed
} }
} else {
newPath, err = filepath.Abs(name)
if err != nil {
return err
}
}
err = getChildPkgs(newPath, pkg, cachePkgs) err = getChildPkgs(newPath, pkg, cachePkgs)
if err != nil { if err != nil {
return err return err
} }
} }
} }
if ppkg != nil { if ppkg != nil && !build.IsLocalImport(ppkg.ImportPath) {
cachePkgs[ppkg.ImportPath] = ppkg cachePkgs[ppkg.ImportPath] = ppkg
} }
return nil return nil
@ -164,7 +169,7 @@ func runBuild(cmd *Command, args []string) {
if !isExistP { if !isExistP {
pName := filepath.Join(paths[:len(paths)-1]...) pName := filepath.Join(paths[:len(paths)-1]...)
newPPath := filepath.Join(newGoPathSrc, pName) newPPath := filepath.Join(newGoPathSrc, pName)
com.ColorLog("[TRAC] create dirs %v\n", newPPath) //com.ColorLog("[TRAC] create dirs %v\n", newPPath)
os.MkdirAll(newPPath, os.ModePerm) os.MkdirAll(newPPath, os.ModePerm)
com.ColorLog("[INFO] linked %v\n", name) com.ColorLog("[INFO] linked %v\n", name)

Loading…
Cancel
Save