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"
|
2008-07-30 18:36:03 -06:00
|
|
|
import Globals "globals"
|
2008-07-15 20:59:00 -06:00
|
|
|
import Compilation "compilation"
|
2008-07-10 19:46:30 -06:00
|
|
|
|
|
|
|
|
2008-07-30 18:36:03 -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";
|
2008-07-30 18:36:03 -06:00
|
|
|
print " go { flag | file }\n";
|
|
|
|
print " -d print debug information\n";
|
2008-07-30 22:26:15 -06:00
|
|
|
print " -p print export\n";
|
2008-07-30 18:36:03 -06:00
|
|
|
print " -s enable semantic checks\n";
|
|
|
|
print " -v verbose mode\n";
|
|
|
|
print " -vv very verbose mode\n";
|
2008-07-30 22:26:15 -06:00
|
|
|
print " -6g 6g compatibility mode\n";
|
2008-07-10 19:46:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
if sys.argc() <= 1 {
|
|
|
|
PrintHelp();
|
|
|
|
sys.exit(1);
|
|
|
|
}
|
|
|
|
|
2008-07-30 18:36:03 -06:00
|
|
|
// 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++ {
|
2008-07-30 18:36:03 -06:00
|
|
|
switch arg := sys.argv(i); arg {
|
|
|
|
case "-d": flags.debug = true;
|
2008-07-30 22:26:15 -06:00
|
|
|
case "-p": flags.print_export = true;
|
2008-07-30 18:36:03 -06:00
|
|
|
case "-s": flags.semantic_checks = true;
|
|
|
|
case "-v": flags.verbose = 1;
|
|
|
|
case "-vv": flags.verbose = 2;
|
2008-07-30 22:26:15 -06:00
|
|
|
case "-6g": flags.sixg = true;
|
2008-07-30 18:36:03 -06:00
|
|
|
default: files.AddStr(arg);
|
2008-07-10 19:46:30 -06:00
|
|
|
}
|
2008-07-30 18:36:03 -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
|
|
|
}
|
|
|
|
}
|