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