Exemplo n.º 1
0
//TODO rewrite the whole link stuff, make i run in parallel
func ForkLinkAll(pkgs []*dag.Package, up2date bool) {

	mainPkgs := make([]*dag.Package, 0)

	for i := 0; i < len(pkgs); i++ {
		if pkgs[i].ShortName == "main" {
			mainPkgs = append(mainPkgs, pkgs[i])
		}
	}

	if len(mainPkgs) == 0 {
		log.Fatal("[ERROR] (linking) no main package found\n")
	}

	handy.DirOrMkdir("bin")

	for i := 0; i < len(mainPkgs); i++ {
		toks := strings.Split(mainPkgs[i].Name, "/")
		// do this for main packages which are placed in directories
		// if toks < 2 this cannot be true, i.e. then the main package
		// lives under the src-root and cannot be filtered
		if len(toks) >= 2 {
			nameOfBinary := toks[len(toks)-2]
			pathToBinary := filepath.Join("bin", nameOfBinary)
			global.SetString("-main", nameOfBinary)
			ForkLink(pathToBinary, pkgs, nil, up2date)
		}
	}
}
Exemplo n.º 2
0
func CreateLibArgv(pkgs []*dag.Package) {

	ss := stringset.New()
	for i := range pkgs {
		if len(pkgs[i].Name) > len(pkgs[i].ShortName) {
			ss.Add(pkgs[i].Name[:(len(pkgs[i].Name) - len(pkgs[i].ShortName))])
		}
	}
	slice := ss.Slice()
	for i := 0; i < len(slice); i++ {
		slice[i] = filepath.Join(libroot, slice[i])
		handy.DirOrMkdir(slice[i])
	}

	CreateArgv(pkgs)

}
Exemplo n.º 3
0
Arquivo: dag.go Projeto: bjarneh/godag
// gorun like stuff
func ParseSingle(pathname string) (pkgs []*Package, name string) {

	tree := getSyntaxTreeOrDie(pathname, parser.ImportsOnly)
	shortname := tree.Name.String()

	if shortname != "main" {
		log.Fatalf("[ERROR] running a single file requires 'main' package\n")
	}

	p := newPackage()
	p.ShortName = shortname
	absPath, e := filepath.Abs(pathname)
	handy.Check(e)
	stub := filepath.Join(os.TempDir(), "godag")
	handy.DirOrMkdir(stub)
	name = filepath.Join(stub, handy.Sha1(absPath))
	p.Name = name
	p.Files = append(p.Files, pathname)

	pkgs = append(pkgs, p)

	return
}