1#!/usr/bin/perl -w 2# 3# Copyright (C) 2005 Apple Computer, Inc. 4# Copyright (C) 2006 Anders Carlsson <andersca@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 31use strict; 32 33use File::Path; 34use Getopt::Long; 35use Cwd; 36 37use IDLParser; 38use CodeGenerator; 39 40my @idlDirectories; 41my $outputDirectory; 42my $outputHeadersDirectory; 43my $generator; 44my $defines; 45my $filename; 46my $prefix; 47my $preprocessor; 48my $writeDependencies; 49my $verbose; 50 51GetOptions('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 62my $idlFile = $ARGV[0]; 63 64die('Must specify input file.') unless defined($idlFile); 65die('Must specify generator') unless defined($generator); 66die('Must specify output directory.') unless defined($outputDirectory); 67die('Must specify defines') unless defined($defines); 68 69if (!$outputHeadersDirectory) { 70 $outputHeadersDirectory = $outputDirectory; 71} 72if ($verbose) { 73 print "$generator: $idlFile\n"; 74} 75$defines =~ s/^\s+|\s+$//g; # trim whitespace 76 77# Parse the given IDL file. 78my $parser = IDLParser->new(!$verbose); 79my $document = $parser->Parse($idlFile, $defines, $preprocessor); 80 81# Generate desired output for given IDL file. 82my $codeGen = CodeGenerator->new(\@idlDirectories, $generator, $outputDirectory, $outputHeadersDirectory, 0, $preprocessor, $writeDependencies, $verbose); 83$codeGen->ProcessDocument($document, $defines); 84