save about 35% of the time for "make idl" by processing multiple IDL
authorAndrew Tridgell <tridge@samba.org>
Sun, 23 Nov 2003 03:42:20 +0000 (03:42 +0000)
committerAndrew Tridgell <tridge@samba.org>
Sun, 23 Nov 2003 03:42:20 +0000 (03:42 +0000)
files at once, which means less perl startup time.
(This used to be commit 64b2c67e479ddc754d18f752d347ba22a6d77682)

source4/Makefile.in
source4/build/pidl/pidl.pl
source4/script/build_idl.sh

index b6e9ee0327a0285f52ed852bf8bf3d6933725565..e4d9dc6ce2cbf58ef52ddd17dc5cff1c69351920 100644 (file)
@@ -1088,11 +1088,9 @@ proto_exists: include/proto.h include/build_env.h \
                include/tdbsam2_parse_info.h
 
 delheaders:
-       @echo Removing prototype headers
        @/bin/rm -f $(srcdir)/include/proto.h $(srcdir)/include/build_env.h 
 
 include/proto.h:
-       @echo Building include/proto.h
        @cd $(srcdir) && $(SHELL) script/mkproto.sh $(PERL) \
          -h _PROTO_H_ $(builddir)/include/proto.h \
          $(PROTO_OBJ)
index b4710e5756e6fa8e1cdce6d9f67de40608183d7e..b8802ebe23bd578bea4b37da62294bce088049b0 100755 (executable)
@@ -12,6 +12,7 @@ use FindBin qw($RealBin);
 use lib "$RealBin";
 use lib "$RealBin/lib";
 use Getopt::Long;
+use File::Basename;
 use idl;
 use dump;
 use header;
@@ -98,65 +99,78 @@ if ($opt_help) {
     exit(0);
 }
 
-my($idl_file) = shift;
-die "ERROR: You must specify an idl file to process" unless ($idl_file);
-
-if (!defined($opt_output)) {
-       $opt_output = $idl_file;
-}
-
-my($pidl_file) = util::ChangeExtension($opt_output, "pidl");
-
-if ($opt_parse) {
-    print "Generating $pidl_file from $idl_file\n";
-    my($idl) = IdlParse($idl_file);
-    defined $idl || die "Failed to parse $idl_file";
-    util::SaveStructure($pidl_file, $idl) || die "Failed to save $pidl_file";
-
-    IdlValidator::Validate($idl);
-}
-
-if ($opt_dump) {
-    my($idl) = util::LoadStructure($pidl_file);
-    print IdlDump::Dump($idl);
-}
-
-if ($opt_header) {
-    my($idl) = util::LoadStructure($pidl_file);
-    my($header) = util::ChangeExtension($opt_output, "h");
-    print "Generating $header\n";
-    util::FileSave($header, IdlHeader::Parse($idl));
-}
-
-if ($opt_parser) {
-    my($idl) = util::LoadStructure($pidl_file);
-    my($parser) = util::ChangeExtension($opt_output, "c");
-    print "Generating $parser\n";
-    IdlParser::Parse($idl, $parser);
-}
-
-if ($opt_eparser) {
-    my($idl) = util::LoadStructure($pidl_file);
-    my($parser) = util::ChangeExtension($opt_output, "c");
-    print "Generating $parser for ethereal\n";
-    util::FileSave($parser, IdlEParser::Parse($idl));
-}
-
-if ($opt_client) {
-    my($idl) = util::LoadStructure($pidl_file);
-    my($client) = util::ChangeExtension($opt_client, "c");
-    print "Generating $client client calls\n";
-    util::FileSave($client, IdlClient::Parse($idl));
+sub process_file($)
+{
+       my $idl_file = shift;
+       my $output;
+
+       my $basename = basename($idl_file, ".idl");
+
+       if (!defined($opt_output)) {
+               $output = $idl_file;
+       } else {
+               $output = $opt_output . $basename;
+       }
+
+       my($pidl_file) = util::ChangeExtension($output, "pidl");
+
+       if ($opt_parse) {
+               print "Generating $pidl_file from $idl_file\n";
+               my($idl) = IdlParse($idl_file);
+               defined $idl || die "Failed to parse $idl_file";
+               util::SaveStructure($pidl_file, $idl) || die "Failed to save $pidl_file";
+               
+               IdlValidator::Validate($idl);
+       }
+       
+       if ($opt_dump) {
+               my($idl) = util::LoadStructure($pidl_file);
+               print IdlDump::Dump($idl);
+       }
+       
+       if ($opt_header) {
+               my($idl) = util::LoadStructure($pidl_file);
+               my($header) = util::ChangeExtension($output, "h");
+               print "Generating $header\n";
+               util::FileSave($header, IdlHeader::Parse($idl));
+       }
+       
+       if ($opt_parser) {
+               my($idl) = util::LoadStructure($pidl_file);
+               my($parser) = util::ChangeExtension($output, "c");
+               print "Generating $parser\n";
+               IdlParser::Parse($idl, $parser);
+       }
+       
+       if ($opt_eparser) {
+               my($idl) = util::LoadStructure($pidl_file);
+               my($parser) = util::ChangeExtension($output, "c");
+               print "Generating $parser for ethereal\n";
+               util::FileSave($parser, IdlEParser::Parse($idl));
+       }
+       
+       if ($opt_client) {
+               my($idl) = util::LoadStructure($pidl_file);
+               my($client) = $opt_client . $basename;
+               $client = util::ChangeExtension($client, "c");
+               print "Generating $client client calls\n";
+               util::FileSave($client, IdlClient::Parse($idl));
+       }
+       
+       if ($opt_diff) {
+               my($idl) = util::LoadStructure($pidl_file);
+               my($tempfile) = util::ChangeExtension($output, "tmp");
+               util::FileSave($tempfile, IdlDump::Dump($idl));
+               system("diff -wu $idl_file $tempfile");
+               unlink($tempfile);
+       }
+       
+       if (!$opt_keep) {
+               system("rm -f $pidl_file");
+       }
 }
 
-if ($opt_diff) {
-    my($idl) = util::LoadStructure($pidl_file);
-    my($tempfile) = util::ChangeExtension($opt_output, "tmp");
-    util::FileSave($tempfile, IdlDump::Dump($idl));
-    system("diff -wu $idl_file $tempfile");
-    unlink($tempfile);
-}
 
-if (!$opt_keep) {
-       system("rm -f $pidl_file");
+foreach my $filename (@ARGV) {
+       process_file($filename);
 }
index 569dd7dd31a55b8426788a270bec99bc04b6beb7..9ad9391ee050f6a709f584e15a92df9381d6d564 100755 (executable)
@@ -7,13 +7,25 @@ FULLBUILD=$1
 
 ( cd build/pidl && make ) || exit 1
 
+PIDL="build/pidl/pidl.pl --output librpc/gen_ndr/ndr_ --parse --header --parser --client librpc/gen_rpc/rpc_"
+
+if [ x$FULLBUILD = xFULL ]; then
+      echo Rebuilding all idl files in librpc/idl
+      $PIDL librpc/idl/*.idl || exit 1
+      exit 0
+fi
+
+list=""
+
 for f in librpc/idl/*.idl; do
-    base=`basename $f .idl`
-    ndr=librpc/gen_ndr/ndr_$base
-    if [ x$FULLBUILD = xFULL -o "$f" -nt $ndr.c ]; then
-      echo Processing $f
-      build/pidl/pidl.pl --output $ndr --parse --header --parser --client librpc/gen_rpc/rpc_$base.c $f || exit 1
+    basename=`basename $f .idl`
+    if [ "$f" -nt librpc/gen_ndr/ndr_$basename.c ]; then
+       list="$list $f"
     fi
 done
 
+if [ "x$list" != x ]; then
+    $PIDL $list || exit 1
+fi
+
 exit 0