File indexing completed on 2024-05-12 15:37:27

0001 #!/usr/bin/perl -w
0002 #
0003 # Copyright (C) 2005 Apple Computer, Inc.
0004 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
0005 # 
0006 # This library is free software; you can redistribute it and/or
0007 # modify it under the terms of the GNU Library General Public
0008 # License as published by the Free Software Foundation; either
0009 # version 2 of the License, or (at your option) any later version.
0010 # 
0011 # This library is distributed in the hope that it will be useful,
0012 # but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014 # Library General Public License for more details.
0015 # 
0016 # You should have received a copy of the GNU Library General Public License
0017 # aint with this library; see the file COPYING.LIB.  If not, write to
0018 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019 # Boston, MA 02110-1301, USA.
0020 # 
0021 
0022 # This script is a temporary hack. 
0023 # Files are generated in the source directory, when they really should go
0024 # to the DerivedSources directory.
0025 # This should also eventually be a build rule driven off of .idl files
0026 # however a build rule only solution is blocked by several radars:
0027 # <rdar://problems/4251781&4251785>
0028 
0029 use strict;
0030 
0031 use File::Path;
0032 use Getopt::Long;
0033 use Cwd;
0034 
0035 use IDLParser;
0036 use CodeGenerator;
0037 
0038 my @idlDirectories;
0039 my $outputDirectory;
0040 my $generator;
0041 my $defines;
0042 my $preprocessor;
0043 
0044 GetOptions('include=s@' => \@idlDirectories,
0045            'outputdir=s' => \$outputDirectory,
0046            'generator=s' => \$generator,
0047            'defines=s' => \$defines,
0048            'preprocessor=s' => \$preprocessor);
0049 
0050 my $idlFile = $ARGV[0];
0051 
0052 die('Must specify input file.') unless defined($idlFile);
0053 die('Must specify IDL search path.') unless @idlDirectories;
0054 die('Must specify generator') unless defined($generator);
0055 die('Must specify input file.') unless defined($idlFile);
0056 die('Must specify output directory.') unless defined($outputDirectory);
0057 die('Must specify defines') unless defined($defines);
0058 
0059 $defines =~ s/^\s+|\s+$//g; # trim whitespace
0060 
0061 # Parse the given IDL file.
0062 my $parser = IDLParser->new(1);
0063 my $document = $parser->Parse($idlFile, $defines, $preprocessor);
0064 
0065 # Generate desired output for given IDL file.
0066 my $codeGen = CodeGenerator->new(\@idlDirectories, $generator, $outputDirectory, 0, $preprocessor);
0067 $codeGen->ProcessDocument($document, $defines);