1
0
mirror of https://github.com/golang/go synced 2024-11-26 20:51:23 -07:00
go/usr/gri/gosrc/go.go

56 lines
1.3 KiB
Go
Raw Normal View History

2008-07-10 19:46:30 -06:00
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import Build "build"
import Globals "globals"
2008-07-15 20:59:00 -06:00
import Compilation "compilation"
2008-07-10 19:46:30 -06:00
// For now we are not using the flags package to minimize
// external dependencies, and because the requirements are
// very minimal at this point.
2008-07-10 19:46:30 -06:00
func PrintHelp() {
print "go in go (", Build.time, ")\n";
print "usage:\n";
print " go { flag | file }\n";
print " -d print debug information\n";
print " -p print export\n";
print " -s enable semantic checks\n";
print " -v verbose mode\n";
print " -vv very verbose mode\n";
print " -6g 6g compatibility mode\n";
2008-07-10 19:46:30 -06:00
}
func main() {
if sys.argc() <= 1 {
PrintHelp();
sys.exit(1);
}
// collect flags and files
flags := new(Globals.Flags);
files := Globals.NewList();
2008-07-10 19:46:30 -06:00
for i := 1; i < sys.argc(); i++ {
switch arg := sys.argv(i); arg {
case "-d": flags.debug = true;
case "-p": flags.print_export = true;
case "-s": flags.semantic_checks = true;
case "-v": flags.verbose = 1;
case "-vv": flags.verbose = 2;
case "-6g": flags.sixg = true;
default: files.AddStr(arg);
2008-07-10 19:46:30 -06:00
}
}
// compile files
for p := files.first; p != nil; p = p.next {
comp := Globals.NewCompilation(flags);
Compilation.Compile(comp, p.str);
2008-07-10 19:46:30 -06:00
}
}