/platform/external/webkit/WebCore/bindings/scripts/generate-bindings.pl

https://github.com/aharish/totoro-gb-opensource-update2 · Perl · 70 lines · 29 code · 11 blank · 30 comment · 0 complexity · 1209daf88722372caf959f7b476dfe44 MD5 · raw file

  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. # This script is a temporary hack.
  24. # Files are generated in the source directory, when they really should go
  25. # to the DerivedSources directory.
  26. # This should also eventually be a build rule driven off of .idl files
  27. # however a build rule only solution is blocked by several radars:
  28. # <rdar://problems/4251781&4251785>
  29. use strict;
  30. use File::Path;
  31. use Getopt::Long;
  32. use Cwd;
  33. use IDLParser;
  34. use CodeGenerator;
  35. my @idlDirectories;
  36. my $outputDirectory;
  37. my $generator;
  38. my $defines;
  39. my $preprocessor;
  40. my $writeDependencies;
  41. GetOptions('include=s@' => \@idlDirectories,
  42. 'outputDir=s' => \$outputDirectory,
  43. 'generator=s' => \$generator,
  44. 'defines=s' => \$defines,
  45. 'preprocessor=s' => \$preprocessor,
  46. 'write-dependencies' => \$writeDependencies);
  47. my $idlFile = $ARGV[0];
  48. die('Must specify input file.') unless defined($idlFile);
  49. die('Must specify IDL search path.') unless @idlDirectories;
  50. die('Must specify generator') unless defined($generator);
  51. die('Must specify output directory.') unless defined($outputDirectory);
  52. die('Must specify defines') unless defined($defines);
  53. $defines =~ s/^\s+|\s+$//g; # trim whitespace
  54. # Parse the given IDL file.
  55. my $parser = IDLParser->new(1);
  56. my $document = $parser->Parse($idlFile, $defines, $preprocessor);
  57. # Generate desired output for given IDL file.
  58. my $codeGen = CodeGenerator->new(\@idlDirectories, $generator, $outputDirectory, 0, $preprocessor, $writeDependencies);
  59. $codeGen->ProcessDocument($document, $defines);