|
1 #!/usr/bin/perl |
|
2 ############################################################################# |
|
3 ## |
|
4 ## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
5 ## All rights reserved. |
|
6 ## Contact: Nokia Corporation (qt-info@nokia.com) |
|
7 ## |
|
8 ## This file is part of the Qt Mobility Components. |
|
9 ## |
|
10 ## $QT_BEGIN_LICENSE:LGPL$ |
|
11 ## No Commercial Usage |
|
12 ## This file contains pre-release code and may not be distributed. |
|
13 ## You may use this file in accordance with the terms and conditions |
|
14 ## contained in the Technology Preview License Agreement accompanying |
|
15 ## this package. |
|
16 ## |
|
17 ## GNU Lesser General Public License Usage |
|
18 ## Alternatively, this file may be used under the terms of the GNU Lesser |
|
19 ## General Public License version 2.1 as published by the Free Software |
|
20 ## Foundation and appearing in the file LICENSE.LGPL included in the |
|
21 ## packaging of this file. Please review the following information to |
|
22 ## ensure the GNU Lesser General Public License version 2.1 requirements |
|
23 ## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
24 ## |
|
25 ## In addition, as a special exception, Nokia gives you certain additional |
|
26 ## rights. These rights are described in the Nokia Qt LGPL Exception |
|
27 ## version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
28 ## |
|
29 ## If you have questions regarding the use of this file, please contact |
|
30 ## Nokia at qt-info@nokia.com. |
|
31 ## |
|
32 ## |
|
33 ## |
|
34 ## |
|
35 ## |
|
36 ## |
|
37 ## |
|
38 ## |
|
39 ## $QT_END_LICENSE$ |
|
40 ## |
|
41 ############################################################################# |
|
42 |
|
43 use strict; |
|
44 use warnings; |
|
45 |
|
46 use File::Basename; |
|
47 use File::stat; |
|
48 use File::Path; |
|
49 |
|
50 my $allow_non_exported = 1; |
|
51 if ( @ARGV && $ARGV[0] eq "-needs-export" ) { |
|
52 shift(@ARGV); |
|
53 $allow_non_exported = 0; |
|
54 } |
|
55 |
|
56 my $outdir = shift(@ARGV) or usage(); |
|
57 mkpath($outdir); |
|
58 |
|
59 my $indir = shift(@ARGV) or usage(); |
|
60 processFile($indir); |
|
61 |
|
62 exit 0; |
|
63 |
|
64 sub usage |
|
65 { |
|
66 print "Usage: syncheaders [-needs-export] outdir indir\n"; |
|
67 print " Processes all public header files <indir>\n"; |
|
68 exit 2; |
|
69 } |
|
70 |
|
71 sub processFile |
|
72 { |
|
73 my ( $read_dir ) = @_; |
|
74 my @allFiles; |
|
75 my $filename; |
|
76 |
|
77 opendir( THISDIR, $read_dir) or die "Can't read $read_dir"; |
|
78 #process all header files |
|
79 @allFiles = grep /\.h/, readdir THISDIR; |
|
80 #don't include private headers |
|
81 @allFiles = grep !/_p\.h/, @allFiles; |
|
82 |
|
83 for $filename (@allFiles) { |
|
84 open INPUT, "$indir/$filename" or die "Can't read $filename"; |
|
85 |
|
86 my $src_s = stat("$indir/$filename"); |
|
87 my $now = $src_s->mtime; |
|
88 |
|
89 while (<INPUT>) { |
|
90 if ( /^\s*class\s+.*_EXPORT\s+([^\s:]+)/ || |
|
91 ($allow_non_exported && /^\s*class\s+([^\s:<]+)/ && index($_, ";") == -1) || |
|
92 /syncqtopia\s+header\s+([^\s:]+)/ ) |
|
93 { |
|
94 # Skip preprocessor-related items |
|
95 next if ( $1 =~ /#/ ); |
|
96 |
|
97 my $outfile = "$outdir/$1"; |
|
98 |
|
99 print "Create header $outfile\n"; |
|
100 |
|
101 #system("install", "-m", "0644", $filename, $outfile); |
|
102 open OUT, ">$outfile" or die "Can't write $outfile"; |
|
103 print OUT "#include \"".basename($filename)."\"\n"; |
|
104 close OUT; |
|
105 } |
|
106 } |
|
107 close INPUT; |
|
108 } |
|
109 } |
|
110 |