From 02dc7536dd625e0cdee23a96e66cb41b407cdba8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 23 Nov 2003 03:42:20 +0000 Subject: save about 35% of the time for "make idl" by processing multiple IDL files at once, which means less perl startup time. (This used to be commit 64b2c67e479ddc754d18f752d347ba22a6d77682) --- source4/build/pidl/pidl.pl | 130 +++++++++++++++++++++++++-------------------- 1 file changed, 72 insertions(+), 58 deletions(-) (limited to 'source4/build/pidl/pidl.pl') diff --git a/source4/build/pidl/pidl.pl b/source4/build/pidl/pidl.pl index b4710e5756..b8802ebe23 100755 --- a/source4/build/pidl/pidl.pl +++ b/source4/build/pidl/pidl.pl @@ -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); } -- cgit