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# aint 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 $generator; 43my $defines; 44my $preprocessor; 45my $writeDependencies; 46 47GetOptions('include=s@' => \@idlDirectories, 48 'outputDir=s' => \$outputDirectory, 49 'generator=s' => \$generator, 50 'defines=s' => \$defines, 51 'preprocessor=s' => \$preprocessor, 52 'write-dependencies' => \$writeDependencies); 53 54my $idlFile = $ARGV[0]; 55 56die('Must specify input file.') unless defined($idlFile); 57die('Must specify IDL search path.') unless @idlDirectories; 58die('Must specify generator') unless defined($generator); 59die('Must specify output directory.') unless defined($outputDirectory); 60die('Must specify defines') unless defined($defines); 61 62$defines =~ s/^\s+|\s+$//g; # trim whitespace 63 64# Parse the given IDL file. 65my $parser = IDLParser->new(1); 66my $document = $parser->Parse($idlFile, $defines, $preprocessor); 67 68# Generate desired output for given IDL file. 69my $codeGen = CodeGenerator->new(\@idlDirectories, $generator, $outputDirectory, 0, $preprocessor, $writeDependencies); 70$codeGen->ProcessDocument($document, $defines); 71