Exemplo n.º 1
0
Arquivo: main.go Projeto: Xslxy/e8vm
func main() {
	flag.Parse()

	home := home8.NewDirHome(*homeDir, "")
	b := build8.NewBuilder(home, home)
	b.Verbose = true
	b.InitPC = arch8.InitPC
	b.RunTests = *runTests

	pkgs, err := build8.SelectPkgs(home, *pkg)
	if err != nil {
		fmt.Println(err)
		os.Exit(-1)
	}

	if !*plan {
		handleErrs(b.BuildPkgs(pkgs))
	} else {
		buildOrder, errs := b.Plan(pkgs)
		handleErrs(errs)
		for _, p := range buildOrder {
			fmt.Println(p)
		}
	}
}
Exemplo n.º 2
0
func buildMainPkg(home *build8.MemHome) (
	image []byte, errs []*lex8.Error, log []byte,
) {
	b := build8.NewBuilder(home)
	if errs := b.BuildAll(); errs != nil {
		return nil, errs, nil
	}

	image = home.Bin("main")
	log = home.Log("main", "ir")
	if image == nil {
		err := errors.New("missing main() function, no binary created")
		return nil, lex8.SingleErr(err), log
	}

	return image, nil, log
}
Exemplo n.º 3
0
func main() {
	flag.Parse()
	if *cpuProfile != "" {
		f, err := os.Create(*cpuProfile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	checkInitPC()

	lang := g8.Lang(*golike)
	home := build8.NewDirHome(*homeDir, lang)
	home.AddLang("asm", asm8.Lang())
	home.AddLang("bare", g8.BareFunc())

	b := build8.NewBuilder(home, home)
	b.Verbose = true
	b.InitPC = uint32(*initPC)
	b.RunTests = *runTests
	b.StaticOnly = *staticOnly

	var es []*lex8.Error
	if *pkg == "" {
		es = b.BuildAll()
	} else if strings.HasSuffix(*pkg, "...") {
		prefix := strings.TrimSuffix(*pkg, "...")
		b.BuildPrefix(prefix)
	} else {
		es = b.Build(*pkg)
	}

	if es != nil {
		for _, e := range es {
			fmt.Println(e)
		}
		os.Exit(-1)
	}
}
Exemplo n.º 4
0
func main() {
	flag.Parse()
	if *cpuProfile != "" {
		f, err := os.Create(*cpuProfile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	checkInitPC()

	var lang build8.Lang
	if !*golike {
		lang = g8.Lang()
	} else {
		lang = g8.LangGolike()
	}

	home := build8.NewDirHome(".", lang)
	home.AddLang("asm", asm8.Lang())
	home.AddLang("bare", g8.BareFunc())

	b := build8.NewBuilder(home)
	b.Verbose = true
	b.InitPC = uint32(*initPC)
	b.RunTests = *runTests

	es := b.BuildAll()
	if es != nil {
		for _, e := range es {
			fmt.Println(e)
		}
		os.Exit(-1)
	}
}