~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to kdevprj2kdevelop

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl
2
 
 
3
 
if ($#ARGV != 0) {
4
 
        die "Need one argument";
5
 
}
6
 
 
7
 
$filename = $ARGV[0];
8
 
unless ($filename =~ /\.kdevprj/) {
9
 
        die "Not a .kdevprj file";
10
 
}
11
 
 
12
 
 
13
 
$ingeneral = 0;
14
 
$inlfvgroups = 0;
15
 
 
16
 
open(FILE, "<$filename") || die "File not found";
17
 
while (<FILE>) {
18
 
        if (/\[General\]/) {
19
 
                $ingeneral = 1;
20
 
                $inlfvgroups = 0;
21
 
                $inbin = 0;
22
 
        } elsif (/\[LFV Groups\]/) {
23
 
                $ingeneral = 0;
24
 
                $inlfvgroups = 1;
25
 
                $inbin = 0;
26
 
        } elsif (/\[Config for BinMakefileAm\]/) {
27
 
                $ingeneral = 0;
28
 
                $inlfvgroups = 0;
29
 
                $inbin = 1;
30
 
        } elsif (/\[(.*)\]/) {
31
 
                push(@sourcefiles, $1);
32
 
                $ingeneral = 0;
33
 
                $inlfvgroups = 0;
34
 
                $inbin = 0;
35
 
        }
36
 
 
37
 
        if ($ingeneral) {
38
 
                if (/^author=(.*)/) {
39
 
                        $author = $1;
40
 
                } elsif (/^configure_args=(.*)/) {
41
 
                        $configure_args = $1;
42
 
                } elsif (/^email=(.*)/) {
43
 
                        $email = $1;
44
 
                } elsif (/^make_options=(.*)/) {
45
 
                        $make_options = $1;
46
 
                        if ($makeoptions =~ /-n/) {
47
 
                                $dontact = "true";
48
 
                        }
49
 
                        if ($makeoptions =~ /-j([0-9]+)/) {
50
 
                                $numberofjobs = $1;
51
 
                        }
52
 
                        if ($makeoptions =~ /-f/) {
53
 
                                $abortonerror = "true";
54
 
                        }
55
 
                } elsif (/^project_name=(.*)/) {
56
 
                        $project_name = $1;
57
 
                } elsif (/^project_type=(.*)/) {
58
 
                        $project_type = $1;
59
 
                } elsif (/^sub_dir=([^\/]*)/) {
60
 
                        $subdir = $1;
61
 
                }
62
 
        }
63
 
 
64
 
        if ($inlfvgroups) {
65
 
                if (/^groups=(.*)/) {
66
 
                        $lfvgroups = $1;
67
 
                } elsif (/(.*)=(.*)/) {
68
 
                        $group = $1;
69
 
                        $pattern = $2;
70
 
                        $pattern =~ s/^(.*),$/$1/;
71
 
                        $lfvgrouppattern{$group} = $pattern;
72
 
                }
73
 
        }
74
 
 
75
 
        if ($inbin) {
76
 
                if (/^bin_program=(.*)/) {
77
 
                        $bin_program = $1;
78
 
                } elsif (/^path_to_bin_program=(.*)/) {
79
 
                        $path_to_bin_program = $1;
80
 
                        $path_to_bin_program =~ s#^\./(.*)$#$1#;
81
 
                        $path_to_bin_program =~ s#^(.*)/#$1#;
82
 
                        $path_to_bin_program = $path_to_bin_program . "/";
83
 
                } elsif (/^cflags=(.*)/) {
84
 
                        $cflags = $1;
85
 
                } elsif (/^cxxflags=(.*)/) {
86
 
                        $cxxflags = $1;
87
 
                }
88
 
        }
89
 
 
90
 
}
91
 
close FILE;
92
 
 
93
 
# Choose language support
94
 
$primarylanguage = "C++";
95
 
if ($project_type eq "normal_c" 
96
 
    || $project_type eq "normal_gnome") {
97
 
        $primarylanguage = "C";
98
 
}
99
 
 
100
 
# Choose project management
101
 
$projectmanagement = "KDevCustomProject";
102
 
if ($project_type =~ /normal_kde|mini_kde|normalogl_kde|normal_kde2|mini_kde2|mdi_kde2/
103
 
    || $project_type =~ /kde2_normal|kicker_app|kio_slave|kc_module|kpart_plugin|ktheme/) {
104
 
        $projectmanagement = "KDevKDEAutoProject";
105
 
}
106
 
if ($project_type =~ /normal_cpp/) {
107
 
        $projectmanagement = "KDevAutoProject";
108
 
}
109
 
 
110
 
# Keywords
111
 
if ($project_type =~ /normal_kde|mini_kde|normalogl_kde|normal_kde2|mini_kde2|mdi_kde2/
112
 
    || $project_type =~ /kde2_normal|kicker_app|kio_slave|kc_module|kpart_plugin|ktheme/) {
113
 
        $keywords = $keywords . ",KDE";
114
 
}
115
 
if ($project_type =~ /normal_kde|mini_kde|normalogl_kde|normal_kde2|mini_kde2|mdi_kde2/
116
 
    || $project_type =~ /kde2_normal|kicker_app|kio_slave|kc_module|kpart_plugin|ktheme/
117
 
    || $project_type =~ /normal_qt|normal_qt2|mdi_qt2|mdi_qextmdi/) {
118
 
        $keywords = $keywords . ",Qt";
119
 
}
120
 
 
121
 
 
122
 
##
123
 
## Let's go: write project file
124
 
##
125
 
 
126
 
$projectfilename = $filename;
127
 
$projectfilename =~ s/^(.*)\.kdevprj$/$1.kdevelop/;
128
 
open(FILE, ">$projectfilename");
129
 
 
130
 
print FILE <<EOF;
131
 
<!DOCTYPE kdevelop>
132
 
<kdevelop>
133
 
 <general>
134
 
  <author>$author</author>
135
 
  <email>$email</email>
136
 
  <projectmanagement>$projectmanagement</projectmanagement>
137
 
  <primarylanguage>$primarylanguage</primarylanguage>
138
 
  <keywords>
139
 
EOF
140
 
 
141
 
foreach $key (split(/,/, $keywords)) {
142
 
        next if ($key eq "");
143
 
        print FILE <<EOF;
144
 
   <keyword>$key</keyword>
145
 
EOF
146
 
}
147
 
 
148
 
print FILE <<EOF;
149
 
  </keywords>
150
 
 </general>
151
 
EOF
152
 
 
153
 
# auto project specific
154
 
 
155
 
if ($projectmanagement eq "KDevAutoProject" || $projectmanagement eq "KDevKDEAutoProject") {
156
 
        print FILE <<EOF;
157
 
 <kdevautoproject>
158
 
  <general>
159
 
   <mainprogram>$path_to_bin_program$bin_program</mainprogram>
160
 
  </general>
161
 
  <configure>
162
 
   <configargs>$configure_args</configargs>
163
 
  </configure>
164
 
  <make>
165
 
   <abortonerror>$abortonerror</abortonerror>
166
 
   <numberofjobs>$numberofjobs</numberofjobs>
167
 
   <dontact>$dontact</dontact>
168
 
   <makebin/>
169
 
  </make>
170
 
  <compiler>
171
 
   <cflags>$cflags</cflags>
172
 
   <cxxflags>$cxxflags</cxxflags>
173
 
  </compiler>
174
 
 </kdevautoproject>
175
 
EOF
176
 
}
177
 
 
178
 
if ($project_management eq "KDevCustomProject") {
179
 
      print FILE <<EOF;
180
 
 <kdevcustomproject>
181
 
  <general>
182
 
   <mainprogram>$path_to_bin_program/$bin_program</mainprogram>
183
 
  </general>
184
 
  <make>
185
 
   <abortonerror>$abortonerror</abortonerror>
186
 
   <numberofjobs>$numberofjobs</numberofjobs>
187
 
   <dontact>$dontact</dontact>
188
 
   <makebin/>
189
 
  </make>
190
 
 </kdevcustomproject>
191
 
EOF
192
 
}
193
 
 
194
 
 
195
 
# file view
196
 
print FILE <<EOF;
197
 
 <kdevfileview>
198
 
  <groups>
199
 
EOF
200
 
 
201
 
for $group (split /,/, $lfvgroups) { 
202
 
        next if ($group eq "");
203
 
        $pattern = $lfvgrouppattern{$group};
204
 
        $pattern =~ s/,/;/g;
205
 
        print FILE <<EOF;
206
 
   <group pattern="$pattern" name="$group" />
207
 
EOF
208
 
}
209
 
 
210
 
print FILE <<EOF;
211
 
  </groups>
212
 
 </kdevfileview>
213
 
 <kdevdoctreeview>
214
 
  <ignoretocs>
215
 
   <toc>gtk</toc>
216
 
   <toc>gnustep</toc>
217
 
   <toc>python</toc>
218
 
   <toc>php</toc>
219
 
   <toc>perl</toc>
220
 
  </ignoretocs>
221
 
 </kdevdoctreeview>
222
 
EOF
223
 
 
224
 
if ($projectmanagement eq "KDevAutoProject"
225
 
    || $projectmanagement eq "KDevKDEAutoProject") {
226
 
        print FILE <<EOF;
227
 
 <kdevdebugger>
228
 
  <general>
229
 
   <dbgshell>libtool</dbgshell>
230
 
  </general>
231
 
 </kdevdebugger>
232
 
EOF
233
 
}
234
 
 
235
 
print FILE <<EOF;
236
 
</kdevelop>
237
 
EOF
238
 
close FILE;
239
 
 
240
 
 
241
 
##
242
 
## Write file list
243
 
##
244
 
 
245
 
if ($projectmanagement eq "KDevCustomProject") {
246
 
        $filelistfilename = $filename;
247
 
        $filelistfilename =~ s/^(.*).kdevprj$/$1.filelist/;
248
 
        open(FILE, ">$filelistfilename");
249
 
        for $file (@sourcefiles) {
250
 
                print FILE "$file\n";
251
 
        }
252
 
        close FILE;
253
 
}
254
 
 
255
 
 
256
 
##
257
 
## Convert templates
258
 
##
259
 
 
260
 
$projectdir = "";
261
 
if ($filename =~ m#(.*/)[^/]*#) {
262
 
        $projectdir = $1;
263
 
}
264
 
 
265
 
$oldtemplatedir = "${projectdir}$subdir/templates";
266
 
 
267
 
if (open(FILE, "$oldtemplatedir/cpp_template")) {
268
 
        mkdir "${projectdir}templates";
269
 
        if (open(OFILE, ">${projectdir}templates/cpp")) {
270
 
                  while(<FILE>) {
271
 
                          s/\|EMAIL\|/\$EMAIL\$/;
272
 
                          s/\|AUTHOR\|/\$AUTHOR\$/;
273
 
                          s/\|VERSION\|/\$VERSION\$/;
274
 
                          s/\|DATE\|/\$DATE\$/;
275
 
                          s/\|YEAR\|/\$YEAR\$/;
276
 
                          s/\|FILENAME\|/\$FILENAME\$/;
277
 
                          print OFILE $_;
278
 
                  }
279
 
                  close OFILE;
280
 
        }
281
 
        close FILE;
282
 
}
283
 
 
284
 
if (open(FILE, "$oldtemplatedir/header_template")) {
285
 
        mkdir "${projectdir}templates";
286
 
        if (open(OFILE, ">${projectdir}templates/h")) {
287
 
                  while(<FILE>) {
288
 
                          s/\|EMAIL\|/\$EMAIL\$/;
289
 
                          s/\|AUTHOR\|/\$AUTHOR\$/;
290
 
                          s/\|VERSION\|/\$VERSION\$/;
291
 
                          s/\|DATE\|/\$DATE\$/;
292
 
                          s/\|YEAR\|/\$YEAR\$/;
293
 
                          s/\|FILENAME\|/\$FILENAME\$/;
294
 
                          print OFILE $_;
295
 
                  }
296
 
                  close OFILE;
297
 
        }
298
 
        close FILE;
299
 
}