| OLD | NEW |
| 1 #!/usr/bin/perl -w | 1 #!/usr/bin/perl -w |
| 2 # | 2 # |
| 3 # Copyright (C) 2005 Apple Computer, Inc. | 3 # Copyright (C) 2005 Apple Computer, Inc. |
| 4 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> | 4 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> |
| 5 # | 5 # |
| 6 # This file is part of WebKit | 6 # This file is part of WebKit |
| 7 # | 7 # |
| 8 # This library is free software; you can redistribute it and/or | 8 # This library is free software; you can redistribute it and/or |
| 9 # modify it under the terms of the GNU Library General Public | 9 # modify it under the terms of the GNU Library General Public |
| 10 # License as published by the Free Software Foundation; either | 10 # License as published by the Free Software Foundation; either |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 use deprecated_idl_parser; | 32 use deprecated_idl_parser; |
| 33 use deprecated_code_generator_v8; | 33 use deprecated_code_generator_v8; |
| 34 use deprecated_idl_serializer; | 34 use deprecated_idl_serializer; |
| 35 | 35 |
| 36 my @idlDirectories; | 36 my @idlDirectories; |
| 37 my $outputDirectory; | 37 my $outputDirectory; |
| 38 my $preprocessor; | 38 my $preprocessor; |
| 39 my $verbose; | 39 my $verbose; |
| 40 my $interfaceDependenciesFile; | 40 my $interfaceDependenciesFile; |
| 41 my $testSupportInterfaceDependenciesFile; |
| 41 my $additionalIdlFiles; | 42 my $additionalIdlFiles; |
| 42 my $idlAttributesFile; | 43 my $idlAttributesFile; |
| 43 my $writeFileOnlyIfChanged; | 44 my $writeFileOnlyIfChanged; |
| 44 | 45 |
| 45 GetOptions('include=s@' => \@idlDirectories, | 46 GetOptions('include=s@' => \@idlDirectories, |
| 46 'outputDir=s' => \$outputDirectory, | 47 'outputDir=s' => \$outputDirectory, |
| 47 'preprocessor=s' => \$preprocessor, | 48 'preprocessor=s' => \$preprocessor, |
| 48 'verbose' => \$verbose, | 49 'verbose' => \$verbose, |
| 49 'interfaceDependenciesFile=s' => \$interfaceDependenciesFile, | 50 'interfaceDependenciesFile=s' => \$interfaceDependenciesFile, |
| 51 'testSupportInterfaceDependenciesFile=s' => \$testSupportInterfaceDep
endenciesFile, |
| 50 'additionalIdlFiles=s' => \$additionalIdlFiles, | 52 'additionalIdlFiles=s' => \$additionalIdlFiles, |
| 51 'idlAttributesFile=s' => \$idlAttributesFile, | 53 'idlAttributesFile=s' => \$idlAttributesFile, |
| 52 'write-file-only-if-changed=s' => \$writeFileOnlyIfChanged); | 54 'write-file-only-if-changed=s' => \$writeFileOnlyIfChanged); |
| 53 | 55 |
| 54 my $targetIdlFile = $ARGV[0]; | 56 my $targetIdlFile = $ARGV[0]; |
| 55 | 57 |
| 56 die('Must specify input file.') unless defined($targetIdlFile); | 58 die('Must specify input file.') unless defined($targetIdlFile); |
| 57 die('Must specify output directory.') unless defined($outputDirectory); | 59 die('Must specify output directory.') unless defined($outputDirectory); |
| 58 | 60 |
| 59 $targetIdlFile = Cwd::realpath($targetIdlFile); | 61 $targetIdlFile = Cwd::realpath($targetIdlFile); |
| 60 if ($verbose) { | 62 if ($verbose) { |
| 61 print "$targetIdlFile\n"; | 63 print "$targetIdlFile\n"; |
| 62 } | 64 } |
| 63 my $targetInterfaceName = fileparse(basename($targetIdlFile), ".idl"); | 65 my $targetInterfaceName = fileparse(basename($targetIdlFile), ".idl"); |
| 64 | 66 |
| 65 my $idlFound = 0; | 67 my $idlFound = 0; |
| 66 my @dependencyIdlFiles; | 68 my @dependencyIdlFiles; |
| 69 my @testSupportDependencyIdlfiles; |
| 67 if ($interfaceDependenciesFile) { | 70 if ($interfaceDependenciesFile) { |
| 68 # The format of the interface dependencies file: | 71 # The format of the interface dependencies file: |
| 69 # | 72 # |
| 70 # Window.idl P.idl Q.idl R.idl | 73 # Window.idl P.idl Q.idl R.idl |
| 71 # Document.idl S.idl | 74 # Document.idl S.idl |
| 72 # Event.idl | 75 # Event.idl |
| 73 # ... | 76 # ... |
| 74 # | 77 # |
| 75 # The above indicates that Window.idl depends on P.idl, Q.idl, and R.idl, | 78 # The above indicates that Window.idl depends on P.idl, Q.idl, and R.idl, |
| 76 # Document.idl depends on S.idl, and Event.idl depends on no IDLs. | 79 # Document.idl depends on S.idl, and Event.idl depends on no IDLs. |
| 77 # A dependency IDL file (one that is depended on by another IDL, e.g. P.idl | 80 # A dependency IDL file (one that is depended on by another IDL, e.g. P.idl |
| 78 # in the above) does not have its own entry in the dependency file. | 81 # in the above) does not have its own entry in the dependency file. |
| 79 open FH, "< $interfaceDependenciesFile" or die "Cannot open $interfaceDepend
enciesFile\n"; | 82 open FH, "< $interfaceDependenciesFile" or die "Cannot open $interfaceDepend
enciesFile\n"; |
| 80 while (my $line = <FH>) { | 83 while (my $line = <FH>) { |
| 81 my ($idlFile, @followingIdlFiles) = split(/\s+/, $line); | 84 my ($idlFile, @followingIdlFiles) = split(/\s+/, $line); |
| 82 if ($idlFile and basename($idlFile) eq basename($targetIdlFile)) { | 85 if ($idlFile and basename($idlFile) eq basename($targetIdlFile)) { |
| 83 $idlFound = 1; | 86 $idlFound = 1; |
| 84 # We sort the dependency IDL files so that the corresponding code is
generated | 87 # We sort the dependency IDL files so that the corresponding code is
generated |
| 85 # in a consistent order. This is important for the bindings tests. | 88 # in a consistent order. This is important for the bindings tests. |
| 86 @dependencyIdlFiles = sort @followingIdlFiles; | 89 @dependencyIdlFiles = sort @followingIdlFiles; |
| 87 } | 90 } |
| 88 } | 91 } |
| 89 close FH; | 92 close FH; |
| 90 | 93 |
| 94 if ($testSupportInterfaceDependenciesFile) { |
| 95 open FH, "< $testSupportInterfaceDependenciesFile" or die "Cannot open $
testSupportInterfaceDependenciesFile\n"; |
| 96 while (my $line = <FH>) { |
| 97 my ($idlFile, @followingIdlFiles) = split(/\s+/, $line); |
| 98 if ($idlFile and basename($idlFile) eq basename($targetIdlFile)) { |
| 99 $idlFound = 1; |
| 100 @testSupportDependencyIdlfiles = sort @followingIdlFiles; |
| 101 } |
| 102 } |
| 103 close FH; |
| 104 } |
| 105 |
| 91 # $additionalIdlFiles is list of IDL files which should not be included in | 106 # $additionalIdlFiles is list of IDL files which should not be included in |
| 92 # DerivedSources*.cpp (i.e. they are not described in the interface | 107 # DerivedSources*.cpp (i.e. they are not described in the interface |
| 93 # dependencies file) but should generate .h and .cpp files. | 108 # dependencies file) but should generate .h and .cpp files. |
| 94 if (!$idlFound and $additionalIdlFiles) { | 109 if (!$idlFound and $additionalIdlFiles) { |
| 95 my @idlFiles = shellwords($additionalIdlFiles); | 110 my @idlFiles = shellwords($additionalIdlFiles); |
| 96 $idlFound = grep { $_ and basename($_) eq basename($targetIdlFile) } @id
lFiles; | 111 $idlFound = grep { $_ and basename($_) eq basename($targetIdlFile) } @id
lFiles; |
| 97 } | 112 } |
| 98 | 113 |
| 99 if (!$idlFound) { | 114 if (!$idlFound) { |
| 100 # We generate empty .h and .cpp files just to tell build scripts that .h
and .cpp files are created. | 115 # We generate empty .h and .cpp files just to tell build scripts that .h
and .cpp files are created. |
| 101 generateEmptyHeaderAndCpp($targetInterfaceName, $outputDirectory); | 116 generateEmptyHeaderAndCpp($targetInterfaceName, $outputDirectory); |
| 102 exit 0; | 117 exit 0; |
| 103 } | 118 } |
| 104 } | 119 } |
| 105 | 120 |
| 106 # Parse the target IDL file. | 121 # Parse the target IDL file. |
| 107 my $targetParser = deprecated_idl_parser->new(!$verbose); | 122 my $targetParser = deprecated_idl_parser->new(!$verbose); |
| 108 my $targetDocument = $targetParser->Parse($targetIdlFile, $preprocessor); | 123 my $targetDocument = $targetParser->Parse($targetIdlFile, $preprocessor); |
| 109 | 124 |
| 110 if ($idlAttributesFile) { | 125 if ($idlAttributesFile) { |
| 111 my $idlAttributes = loadIDLAttributes($idlAttributesFile); | 126 my $idlAttributes = loadIDLAttributes($idlAttributesFile); |
| 112 checkIDLAttributes($idlAttributes, $targetDocument, basename($targetIdlFile)
); | 127 checkIDLAttributes($idlAttributes, $targetDocument, basename($targetIdlFile)
); |
| 113 } | 128 } |
| 114 | 129 |
| 130 push @dependencyIdlFiles, @testSupportDependencyIdlfiles; |
| 115 foreach my $idlFile (@dependencyIdlFiles) { | 131 foreach my $idlFile (@dependencyIdlFiles) { |
| 116 next if $idlFile eq $targetIdlFile; | 132 next if $idlFile eq $targetIdlFile; |
| 117 | 133 |
| 118 my $interfaceName = fileparse(basename($idlFile), ".idl"); | 134 my $interfaceName = fileparse(basename($idlFile), ".idl"); |
| 119 my $parser = deprecated_idl_parser->new(!$verbose); | 135 my $parser = deprecated_idl_parser->new(!$verbose); |
| 120 my $document = $parser->Parse($idlFile, $preprocessor); | 136 my $document = $parser->Parse($idlFile, $preprocessor); |
| 121 | 137 |
| 122 foreach my $interface (@{$document->interfaces}) { | 138 foreach my $interface (@{$document->interfaces}) { |
| 123 if (!$interface->isPartial || $interface->name eq $targetInterfaceName)
{ | 139 if (!$interface->isPartial || $interface->name eq $targetInterfaceName)
{ |
| 124 my $targetDataNode; | 140 my $targetDataNode; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 last OUTER; | 311 last OUTER; |
| 296 } | 312 } |
| 297 } | 313 } |
| 298 } | 314 } |
| 299 if ($error) { | 315 if ($error) { |
| 300 die "IDL ATTRIBUTE CHECKER ERROR: $error | 316 die "IDL ATTRIBUTE CHECKER ERROR: $error |
| 301 If you want to add a new IDL attribute, you need to add it to bindings/scripts/I
DLAttributes.txt and add explanations to the Blink IDL document (http://chromium
.org/blink/webidl). | 317 If you want to add a new IDL attribute, you need to add it to bindings/scripts/I
DLAttributes.txt and add explanations to the Blink IDL document (http://chromium
.org/blink/webidl). |
| 302 "; | 318 "; |
| 303 } | 319 } |
| 304 } | 320 } |
| OLD | NEW |