Browse Source

improved localimport for build

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

29
cmd/build.go

@ -98,16 +98,21 @@ 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 !com.IsExist(newPath) { if !build.IsLocalImport(name) {
var t, ver string = doc.BRANCH, "" newPath = filepath.Join(installRepoPath, pkg.ImportPath)
node := doc.NewNode(pkg.ImportPath, pkg.ImportPath, t, ver, true) if !com.IsExist(newPath) {
//node := new(doc.Node) var t, ver string = doc.BRANCH, ""
//node.Pkg = *pkg node := doc.NewNode(pkg.ImportPath, pkg.ImportPath, t, ver, true)
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 {
@ -115,7 +120,7 @@ func getChildPkgs(cpath string, ppkg *doc.Pkg, cachePkgs map[string]*doc.Pkg) er
} }
} }
} }
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