| OLD | NEW |
| 1 #!/usr/bin/perl -w | 1 #!/usr/bin/perl -w |
| 2 | 2 |
| 3 # Copyright (C) 2011 Adam Barth <abarth@webkit.org> | 3 # Copyright (C) 2011 Adam Barth <abarth@webkit.org> |
| 4 # | 4 # |
| 5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
| 6 # modification, are permitted provided that the following conditions | 6 # modification, are permitted provided that the following conditions |
| 7 # are met: | 7 # are met: |
| 8 # 1. Redistributions of source code must retain the above copyright | 8 # 1. Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # 2. Redistributions in binary form must reproduce the above copyright | 10 # 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 # | 25 # |
| 26 | 26 |
| 27 use strict; | 27 use strict; |
| 28 | 28 |
| 29 use Config; | 29 use Config; |
| 30 use Getopt::Long; | 30 use Getopt::Long; |
| 31 use File::Path; | 31 use File::Path; |
| 32 use File::Spec; | 32 use File::Spec; |
| 33 use IO::File; | 33 use IO::File; |
| 34 use InFilesParser; | 34 use InFilesParser; |
| 35 use idltopath; |
| 35 | 36 |
| 36 require Config; | 37 require Config; |
| 37 | 38 |
| 38 package InFilesCompiler; | 39 package InFilesCompiler; |
| 39 | 40 |
| 40 my $inputFile = ""; | 41 my $inputFile = ""; |
| 41 my $outputDir = "."; | 42 my $outputDir = "."; |
| 43 my $idlToPathFile = ""; |
| 42 my $defaultItemFactory; | 44 my $defaultItemFactory; |
| 43 | 45 |
| 44 my %parsedItems; | 46 my %parsedItems; |
| 45 my %parsedItemPaths; | 47 my %parsedItemPaths; |
| 46 my %parsedParameters; | 48 my %parsedParameters; |
| 47 | 49 |
| 48 sub itemHandler($$$) | 50 sub itemHandler($$$) |
| 49 { | 51 { |
| 50 my ($itemName, $property, $value) = @_; | 52 my ($itemName, $property, $value) = @_; |
| 51 | 53 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 86 |
| 85 bless($reference, $object); | 87 bless($reference, $object); |
| 86 return $reference; | 88 return $reference; |
| 87 } | 89 } |
| 88 | 90 |
| 89 sub initializeFromCommandLine() | 91 sub initializeFromCommandLine() |
| 90 { | 92 { |
| 91 ::GetOptions( | 93 ::GetOptions( |
| 92 'input=s' => \$inputFile, | 94 'input=s' => \$inputFile, |
| 93 'outputDir=s' => \$outputDir, | 95 'outputDir=s' => \$outputDir, |
| 96 'idltopathfile=s' => \$idlToPathFile, |
| 94 ); | 97 ); |
| 95 | 98 |
| 96 die "You must specify --input <file>" unless length($inputFile); | 99 die "You must specify --input <file>" unless length($inputFile); |
| 97 | 100 |
| 101 die "You must specify --idltopathfile" unless length($idlToPathFile); |
| 102 |
| 103 idltopath::initIdlToPath($idlToPathFile); |
| 98 ::mkpath($outputDir); | 104 ::mkpath($outputDir); |
| 99 | 105 |
| 100 # FIXME: Should we provide outputDir via an accessor? | 106 # FIXME: Should we provide outputDir via an accessor? |
| 101 return $outputDir; | 107 return $outputDir; |
| 102 } | 108 } |
| 103 | 109 |
| 104 sub compile() | 110 sub compile() |
| 105 { | 111 { |
| 106 my $object = shift; | 112 my $object = shift; |
| 107 my $generateCode = shift; | 113 my $generateCode = shift; |
| 108 | 114 |
| 109 my $file = new IO::File; | 115 my $file = new IO::File; |
| 110 open($file, $inputFile) or die "Failed to open file: $!"; | 116 open($file, $inputFile) or die "Failed to open file: $!"; |
| 111 | 117 |
| 112 my $InParser = InFilesParser->new(); | 118 my $InParser = InFilesParser->new(); |
| 113 $InParser->parse($file, \¶meterHandler, \&itemHandler); | 119 $InParser->parse($file, \¶meterHandler, \&itemHandler); |
| 114 | 120 |
| 115 close($file); | 121 close($file); |
| 116 die "Failed to read from file: $inputFile" if (keys %parsedItems == 0); | 122 die "Failed to read from file: $inputFile" if (keys %parsedItems == 0); |
| 117 | 123 |
| 118 &$generateCode(\%parsedParameters, \%parsedItems, \%parsedItemPaths); | 124 &$generateCode(\%parsedParameters, \%parsedItems, \%parsedItemPaths); |
| 119 } | 125 } |
| 120 | 126 |
| 121 sub license() | 127 sub license() |
| 122 { | 128 { |
| 123 return "/* | 129 return "/* |
| 124 * THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT EDIT. | 130 * THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT EDIT. |
| 125 * | 131 * |
| 132 * This file was generated by the make_names.pl/InFilesCompiler.pm script. |
| 133 * |
| 126 * Copyright (C) 2011 Google Inc. All rights reserved. | 134 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 127 * | 135 * |
| 128 * Redistribution and use in source and binary forms, with or without | 136 * Redistribution and use in source and binary forms, with or without |
| 129 * modification, are permitted provided that the following conditions | 137 * modification, are permitted provided that the following conditions |
| 130 * are met: | 138 * are met: |
| 131 * 1. Redistributions of source code must retain the above copyright | 139 * 1. Redistributions of source code must retain the above copyright |
| 132 * notice, this list of conditions and the following disclaimer. | 140 * notice, this list of conditions and the following disclaimer. |
| 133 * 2. Redistributions in binary form must reproduce the above copyright | 141 * 2. Redistributions in binary form must reproduce the above copyright |
| 134 * notice, this list of conditions and the following disclaimer in the | 142 * notice, this list of conditions and the following disclaimer in the |
| 135 * documentation and/or other materials provided with the distribution. | 143 * documentation and/or other materials provided with the distribution. |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 287 |
| 280 for my $itemName (sort keys %parsedItems) { | 288 for my $itemName (sort keys %parsedItems) { |
| 281 my $conditional = $parsedItems{$itemName}{"conditional"}; | 289 my $conditional = $parsedItems{$itemName}{"conditional"}; |
| 282 my $interfaceName = $object->interfaceForItem($itemName); | 290 my $interfaceName = $object->interfaceForItem($itemName); |
| 283 | 291 |
| 284 next if defined($includedInterfaces{$interfaceName}); | 292 next if defined($includedInterfaces{$interfaceName}); |
| 285 $includedInterfaces{$interfaceName} = 1; | 293 $includedInterfaces{$interfaceName} = 1; |
| 286 | 294 |
| 287 print F "#if " . $object->conditionalStringFromAttributeValue($condition
al) . "\n" if $conditional; | 295 print F "#if " . $object->conditionalStringFromAttributeValue($condition
al) . "\n" if $conditional; |
| 288 my $path = "$interfaceName.h"; | 296 my $path = "$interfaceName.h"; |
| 297 if (!defined($parsedItemPaths{$itemName})) { |
| 298 print("Warning: Missing path for interface headers for " . $itemName
. " in InFilesCompiler.pm\n"); |
| 299 my $path = idltopath::idlToPath($itemName); |
| 300 # Removing trailing '/' since we'll add it again here. |
| 301 chop($path); |
| 302 $parsedItemPaths{$itemName} = $path; |
| 303 } |
| 304 # die "Unknown idl path for " . $itemName unless defined($parsedItemPaths
{$itemName}); |
| 289 $path = $parsedItemPaths{$itemName} . "/" . $path if defined($parsedItem
Paths{$itemName}); | 305 $path = $parsedItemPaths{$itemName} . "/" . $path if defined($parsedItem
Paths{$itemName}); |
| 290 print F "#include \"$path\"\n"; | 306 print F "#include \"./$path\"\n"; |
| 291 print F "#include \"V8$interfaceName.h\"\n"; | 307 print F "#include \"V8$interfaceName.h\"\n"; |
| 292 print F "#endif\n" if $conditional; | 308 print F "#endif\n" if $conditional; |
| 293 } | 309 } |
| 294 | 310 |
| 295 print F "\n"; | 311 print F "\n"; |
| 296 print F "#endif // ${namespace}Headers_h\n"; | 312 print F "#endif // ${namespace}Headers_h\n"; |
| 297 | 313 |
| 298 close F; | 314 close F; |
| 299 } | 315 } |
| 300 | 316 |
| 301 1; | 317 1; |
| OLD | NEW |