[svn:parrot] r46981 - in trunk: compilers/opsc compilers/opsc/src/Ops config/gen/makefiles src/dynoplibs

cotto at svn.parrot.org cotto at svn.parrot.org
Tue May 25 02:49:38 UTC 2010


Author: cotto
Date: Tue May 25 02:49:37 2010
New Revision: 46981
URL: https://trac.parrot.org/parrot/changeset/46981

Log:
[opsc] add --quiet to ops2c to suppress extra output during the build

Modified:
   trunk/compilers/opsc/ops2c.nqp
   trunk/compilers/opsc/src/Ops/Emitter.pm
   trunk/compilers/opsc/src/Ops/File.pm
   trunk/compilers/opsc/src/Ops/OpLib.pm
   trunk/config/gen/makefiles/root.in
   trunk/src/dynoplibs/Rules.in

Modified: trunk/compilers/opsc/ops2c.nqp
==============================================================================
--- trunk/compilers/opsc/ops2c.nqp	Tue May 25 02:46:17 2010	(r46980)
+++ trunk/compilers/opsc/ops2c.nqp	Tue May 25 02:49:37 2010	(r46981)
@@ -11,31 +11,43 @@
 my $getopts := Q:PIR{ %r = new ['Getopt';'Obj'] };
 
 $getopts.notOptStop();
+
+# build core ops
 my $arg := $getopts.add();
 $arg.long('core');
 $arg.short('c');
 
+# build the dynops in one .ops file
 $arg := $getopts.add();
 $arg.long('dynamic');
 $arg.short('d');
 $arg.type('String');
 
+# don't write to any files
 $arg := $getopts.add();
 $arg.long('debug');
 $arg.short('g');
 
+# don't add line numbers to generated files (not implemented)
 $arg := $getopts.add();
 $arg.long('no-lines');
 $arg.short('n');
 
+# print anemic usage information and exit
 $arg := $getopts.add();
 $arg.long('help');
 $arg.short('h');
 
+# regenerate ops.num et. al. even if it's not necessary
 $arg := $getopts.add();
 $arg.long('force-regen');
 $arg.short('f');
 
+# suppress timing and debug output on stdout
+$arg := $getopts.add();
+$arg.long('quiet');
+$arg.short('q');
+
 my $opts := $getopts.get_options(pir::getinterp__p()[2]);
 
 if $opts<core> {
@@ -78,7 +90,8 @@
 
 my $trans := Ops::Trans::C.new();
 my $start_time := pir::time__N();
-my $debug :=  ?$opts<debug>;
+my $debug := ?$opts<debug>;
+my $quiet := ?$opts<quiet>;
 my $f;
 my $renum;
 
@@ -86,20 +99,21 @@
     my $lib := Ops::OpLib.new(
         :num_file('src/ops/ops.num'),
         :skip_file('src/ops/ops.skip'),
+        :quiet($quiet)
     );
-    $f := Ops::File.new(|@files, :oplib($lib), :core(1));
+    $f := Ops::File.new(|@files, :oplib($lib), :core(1), :quiet($quiet));
 }
 else {
-    $f := Ops::File.new(|@files, :core(0));
+    $f := Ops::File.new(|@files, :core(0), :quiet($quiet));
 }
 
-#pir::sprintf(my $time, "%.3f", [pir::time__N() - $start_time] );
-#say("# Ops parsed in $time seconds.");
+pir::sprintf(my $time, "%.3f", [pir::time__N() - $start_time] );
+$quiet || say("# Ops parsed in $time seconds.");
 
 my $emitter := Ops::Emitter.new(
     :ops_file($f), :trans($trans),
     :script('ops2c.nqp'), :file(@files[0]),
-    :flags( hash( core => $core ) ),
+    :flags( hash( core => $core, quiet => $quiet ) ),
 );
 
 unless $debug {

Modified: trunk/compilers/opsc/src/Ops/Emitter.pm
==============================================================================
--- trunk/compilers/opsc/src/Ops/Emitter.pm	Tue May 25 02:46:17 2010	(r46980)
+++ trunk/compilers/opsc/src/Ops/Emitter.pm	Tue May 25 02:49:37 2010	(r46981)
@@ -16,6 +16,7 @@
     self<script>    := $script;
     self<file>      := $file;
     self<flags>     := %flags;
+    self<quiet>     := %flags<quiet> // 0;
 
     # Preparing various bits.
     my $suffix := $trans.suffix();
@@ -195,6 +196,7 @@
     my $found_dynamic      := 0;
     self<max_fixed_op_num> := 0;
     self<ops_num_start>    := list();
+    self<max_op_num>       := 0;
 
     #record which ones have fixed numbers and which just need to be somewhere in ops.num
     for self.ops_file.oplib.num_file_lines -> $line {
@@ -207,13 +209,14 @@
         if $line<op> {
             if $found_dynamic {
                 self<numbered_ops>{ $line<op><name> } := 1;
-                #say("# added '"~$line<op><name> ~" to numered ops");
+                self<quiet> || say("# added '"~$line<op><name> ~" to numered ops");
             }
             else {
                 #don't need to keep track of fixed ops
                 self<max_fixed_op_num> := +$line<op><number>;
-                #say("# added '"~$line<op><name> ~" to fixed ops");
+                self<quiet> || say("# added '"~$line<op><name> ~" to fixed ops");
             }
+            self<max_op_num>++;
         }
         elsif $line<dynamic> {
             $found_dynamic := 1;

Modified: trunk/compilers/opsc/src/Ops/File.pm
==============================================================================
--- trunk/compilers/opsc/src/Ops/File.pm	Tue May 25 02:46:17 2010	(r46980)
+++ trunk/compilers/opsc/src/Ops/File.pm	Tue May 25 02:49:37 2010	(r46981)
@@ -182,7 +182,7 @@
 
 =end
 
-method new(*@files, :$oplib, :$core!, :$nolines) {
+method new(*@files, :$oplib, :$core!, :$nolines, :$quiet? = 0) {
     self<files>   := @files;
     self<core>    := $core;
     self<ops>     := list(); # Ops
@@ -190,6 +190,7 @@
     self<compiler>:= pir::compreg__Ps('Ops');
     self<op_order>:= 0;
     self<renum>   := Ops::Renumberer.new( :ops_file(self) );
+    self<quiet>   := $quiet;
 
     if $core {
         self<oplib> := $oplib;
@@ -243,12 +244,12 @@
 method read_ops($file, $nolines) {
     $Ops::Compiler::Actions::OPLIB := self<oplib>;
 
-    #say("# Parsing $file...");
+    self<quiet> || say("# Parsing $file...");
     my $start_time := pir::time__N();
     my $buffer     := slurp($file);
     self.compile_ops($buffer, :experimental( $file ~~ /experimental\.ops/));
-    #pir::sprintf(my $time, "%.3f", [pir::time__N() - $start_time] );
-    #say("# Parsed $file in $time seconds.");
+    pir::sprintf(my $time, "%.3f", [pir::time__N() - $start_time] );
+    self<quiet> || say("# Parsed $file in $time seconds.");
 }
 
 method compile_ops($str, :$experimental? = 0) {
@@ -301,7 +302,7 @@
             #ops not explicitly listed but not skipped are experimental
             else {
                 $op<code> := $code++;
-                say("# Experimental op " ~ $op.full_name ~ " is not in ops.num.");
+                self<quiet> || say("# Experimental op " ~ $op.full_name ~ " is not in ops.num.");
             }
         }
         #if there's no oplib, we're compiling dynops and ops aren't experimental

Modified: trunk/compilers/opsc/src/Ops/OpLib.pm
==============================================================================
--- trunk/compilers/opsc/src/Ops/OpLib.pm	Tue May 25 02:46:17 2010	(r46980)
+++ trunk/compilers/opsc/src/Ops/OpLib.pm	Tue May 25 02:49:37 2010	(r46981)
@@ -93,9 +93,10 @@
 
 =end METHODS
 
-method new(:$num_file, :$skip_file) {
+method new(:$num_file, :$skip_file, :$quiet? = 0) {
     self<num_file>   := $num_file  // './src/ops/ops.num';
     self<skip_file>  := $skip_file // './src/ops/ops.skip';
+    self<quiet>      := $quiet;
 
     # Initialize self.
     self<max_op_num>    := 0;
@@ -155,11 +156,11 @@
             if (+$number) eq $number {
                 if ($prev + 1 != $number) {
                     self<regen_ops_num> := 1;
-                    say("# hole in ops.num before #$number: will regenerate ops.num");
+                    self<quiet> || say("# hole in ops.num before #$number: will regenerate ops.num");
                 }
                 if self<op_num_table>.exists($name) {
                     self<regen_ops_num> := 1;
-                    say("# duplicate opcode $name and $number: will regenerate ops.num");
+                    self<quiet> || say("# duplicate opcode $name and $number: will regenerate ops.num");
                 }
 
                 $prev := $number;

Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in	Tue May 25 02:46:17 2010	(r46980)
+++ trunk/config/gen/makefiles/root.in	Tue May 25 02:49:37 2010	(r46981)
@@ -798,7 +798,7 @@
 installable: all $(INSTALLABLEPARROT) $(INSTALLABLEPDUMP) $(INSTALLABLEDIS) $(INSTALLABLEPDB) $(INSTALLABLEPBC_MERGE) $(INSTALLABLEPBCTOEXE) $(INSTALLABLECONFIG) $(INSTALLABLENQP) $(INSTALLABLENCITHUNKGEN) $(INSTALLABLEPROVE) $(INSTALLABLEOPS2C)
 
 bootstrap-ops : $(OPS2C)
-	$(OPS2C) --core
+	$(OPS2C) --core --quiet
 	$(MAKE) .
 
 runtime/parrot/include/parrotlib.pbc: runtime/parrot/library/parrotlib.pir $(PARROT) $(GEN_PASM_INCLUDES)

Modified: trunk/src/dynoplibs/Rules.in
==============================================================================
--- trunk/src/dynoplibs/Rules.in	Tue May 25 02:46:17 2010	(r46980)
+++ trunk/src/dynoplibs/Rules.in	Tue May 25 02:49:37 2010	(r46981)
@@ -18,7 +18,7 @@
 src/dynoplibs/obscure_ops.h: src/dynoplibs/obscure_ops.c
 
 src/dynoplibs/obscure_ops.c: src/dynoplibs/obscure.ops $(OPS2C)
-	$(OPS2C) --dynamic src/dynoplibs/obscure.ops
+	$(OPS2C) --dynamic src/dynoplibs/obscure.ops --quiet
 
 
 $(DYNEXT_DIR)/math_ops$(LOAD_EXT): src/dynoplibs/math_ops$(O) $(LIBPARROT)
@@ -27,7 +27,7 @@
 #IF(cygwin or hpux):	$(CHMOD) 0775 $@
 
 src/dynoplibs/math_ops.c: src/dynoplibs/math.ops $(OPS2C)
-	$(OPS2C) --dynamic src/dynoplibs/math.ops
+	$(OPS2C) --dynamic src/dynoplibs/math.ops --quiet
 
 src/dynoplibs/math_ops$(O): $(DYNOP_O_DEPS) \
     src/dynoplibs/math_ops.c src/dynoplibs/math_ops.h
@@ -46,4 +46,4 @@
 src/dynoplibs/deprecated_ops.h: src/dynoplibs/deprecated_ops.c
 
 src/dynoplibs/deprecated_ops.c: src/dynoplibs/deprecated.ops $(OPS2C)
-	$(OPS2C) --dynamic src/dynoplibs/deprecated.ops
+	$(OPS2C) --dynamic src/dynoplibs/deprecated.ops --quiet


More information about the parrot-commits mailing list