Exemplo n.º 1
0
func parseArgs() []string {
	flag.Usage = usage
	version := flag.Bool("version", false, "")

	flag.Parse()

	if *version {
		fmt.Printf("%s\n", Version())
		os.Exit(0)
	}

	var arg string

	if flag.NArg() == 0 {
		arg = "."
	} else {
		arg = flag.Arg(0)
	}

	targets := path.Expand(arg)
	if len(targets) == 0 {
		fmt.Fprintf(os.Stderr, "Missing target path.\n")
		os.Exit(1)
	}

	return targets
}
Exemplo n.º 2
0
func main() {
	targets := parseArgs()

	for _, targ := range targets {
		list := path.Expand(targ)
		if len(list) == 0 {
			continue
		}

		for _, imp := range list {
			var list []string

			if !findDeps(imp, &list) {
				continue
			}

			// First entry is target package itself.
			list = list[1:]

			fmt.Fprintln(os.Stdout, imp)
			for _, dep := range list {
				fmt.Fprintln(os.Stdout, "  "+dep)
			}
		}
	}
}
Exemplo n.º 3
0
func parseArgs() *cpu.CPU {
	flag.Usage = usage
	version := flag.Bool("version", false, "Display version information.")

	flag.Parse()

	if *version {
		fmt.Printf("%s\n", Version())
		os.Exit(0)
	}

	if *scale < 1 {
		*scale = 1
	}

	switch *display {
	case "lem1802", "sped3":
	default:
		fmt.Fprintf(os.Stderr, "Invalid display hardware name. Want: 'lem1802' or 'sped3'.\n")
		os.Exit(1)
	}

	var arg string

	if flag.NArg() == 0 {
		arg = "."
	} else {
		arg = flag.Arg(0)
	}

	targets := path.Expand(arg)
	if len(targets) == 0 {
		fmt.Fprintf(os.Stderr, "Invalid target path: %q\n", arg)
		os.Exit(1)
	}

	// Create the CPU.
	c := cpu.New()
	c.ClockSpeed = time.Millisecond / 100

	err := Build(targets[0], c)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Load binary: %s.\n", err)
		os.Exit(1)
	}

	// Bind all hardware.
	c.RegisterDevice(clock.New)
	c.RegisterDevice(lem1802.New)
	c.RegisterDevice(keyboard.New)
	c.RegisterDevice(m35fd.New)
	c.RegisterDevice(sped3.New)
	c.RegisterDevice(spc2000.New)
	c.RegisterDevice(etcp.New)

	// Load floppy disk if necessary.
	if len(*fdd) > 0 {
		err := insertFdd(c, *fdd, *fddReadOnly)

		if err != nil {
			fmt.Fprintf(os.Stderr, "%s\n", err)
			os.Exit(1)
		}
	}

	return c
}