1 #!/usr/bin/perl -w 2 # 3 # Copyright (C) 2005 Apple Computer, Inc. 4 # Copyright (C) 2006 Anders Carlsson <andersca (at] mac.com> 5 # 6 # This file is part of WebKit 7 # 8 # This library is free software; you can redistribute it and/or 9 # modify it under the terms of the GNU Library General Public 10 # License as published by the Free Software Foundation; either 11 # version 2 of the License, or (at your option) any later version. 12 # 13 # This library is distributed in the hope that it will be useful, 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 # Library General Public License for more details. 17 # 18 # You should have received a copy of the GNU Library General Public License 19 # along with this library; see the file COPYING.LIB. If not, write to 20 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 # Boston, MA 02110-1301, USA. 22 # 23 24 # This script is a temporary hack. 25 # Files are generated in the source directory, when they really should go 26 # to the DerivedSources directory. 27 # This should also eventually be a build rule driven off of .idl files 28 # however a build rule only solution is blocked by several radars: 29 # <rdar://problems/4251781&4251785> 30 31 use strict; 32 33 use File::Path; 34 use Getopt::Long; 35 use Cwd; 36 37 use IDLParser; 38 use CodeGenerator; 39 40 my @idlDirectories; 41 my $outputDirectory; 42 my $outputHeadersDirectory; 43 my $generator; 44 my $defines; 45 my $filename; 46 my $prefix; 47 my $preprocessor; 48 my $writeDependencies; 49 my $verbose; 50 51 GetOptions('include=s@' => \@idlDirectories, 52 'outputDir=s' => \$outputDirectory, 53 'outputHeadersDir=s' => \$outputHeadersDirectory, 54 'generator=s' => \$generator, 55 'defines=s' => \$defines, 56 'filename=s' => \$filename, 57 'prefix=s' => \$prefix, 58 'preprocessor=s' => \$preprocessor, 59 'verbose' => \$verbose, 60 'write-dependencies' => \$writeDependencies); 61 62 my $idlFile = $ARGV[0]; 63 64 die('Must specify input file.') unless defined($idlFile); 65 die('Must specify generator') unless defined($generator); 66 die('Must specify output directory.') unless defined($outputDirectory); 67 die('Must specify defines') unless defined($defines); 68 69 if (!$outputHeadersDirectory) { 70 $outputHeadersDirectory = $outputDirectory; 71 } 72 if ($verbose) { 73 print "$generator: $idlFile\n"; 74 } 75 $defines =~ s/^\s+|\s+$//g; # trim whitespace 76 77 # Parse the given IDL file. 78 my $parser = IDLParser->new(!$verbose); 79 my $document = $parser->Parse($idlFile, $defines, $preprocessor); 80 81 # Generate desired output for given IDL file. 82 my $codeGen = CodeGenerator->new(\@idlDirectories, $generator, $outputDirectory, $outputHeadersDirectory, 0, $preprocessor, $writeDependencies, $verbose); 83 $codeGen->ProcessDocument($document, $defines); 84