diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-11-23 03:42:20 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-11-23 03:42:20 +0000 |
commit | 02dc7536dd625e0cdee23a96e66cb41b407cdba8 (patch) | |
tree | 07abe233e81ee3a945361a5ce4cc694754b77f8b /source4/build/pidl | |
parent | 231ae2430ee4f762035803ee0c7c00823fba6bfb (diff) | |
download | samba-02dc7536dd625e0cdee23a96e66cb41b407cdba8.tar.gz samba-02dc7536dd625e0cdee23a96e66cb41b407cdba8.tar.bz2 samba-02dc7536dd625e0cdee23a96e66cb41b407cdba8.zip |
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)
Diffstat (limited to 'source4/build/pidl')
-rwxr-xr-x | source4/build/pidl/pidl.pl | 130 |
1 files changed, 72 insertions, 58 deletions
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); } |