From 5fbf99bcc4d03f3001f42905d1217758c4aeac13 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Wed, 16 Nov 2011 16:06:07 -0600 Subject: Finish rename from prior commit --- kdevprj2tdevelop | 299 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 299 insertions(+) create mode 100755 kdevprj2tdevelop (limited to 'kdevprj2tdevelop') diff --git a/kdevprj2tdevelop b/kdevprj2tdevelop new file mode 100755 index 00000000..e9c27b3b --- /dev/null +++ b/kdevprj2tdevelop @@ -0,0 +1,299 @@ +#!/usr/bin/perl + +if ($#ARGV != 0) { + die "Need one argument"; +} + +$filename = $ARGV[0]; +unless ($filename =~ /\.kdevprj/) { + die "Not a .kdevprj file"; +} + + +$ingeneral = 0; +$inlfvgroups = 0; + +open(FILE, "<$filename") || die "File not found"; +while () { + if (/\[General\]/) { + $ingeneral = 1; + $inlfvgroups = 0; + $inbin = 0; + } elsif (/\[LFV Groups\]/) { + $ingeneral = 0; + $inlfvgroups = 1; + $inbin = 0; + } elsif (/\[Config for BinMakefileAm\]/) { + $ingeneral = 0; + $inlfvgroups = 0; + $inbin = 1; + } elsif (/\[(.*)\]/) { + push(@sourcefiles, $1); + $ingeneral = 0; + $inlfvgroups = 0; + $inbin = 0; + } + + if ($ingeneral) { + if (/^author=(.*)/) { + $author = $1; + } elsif (/^configure_args=(.*)/) { + $configure_args = $1; + } elsif (/^email=(.*)/) { + $email = $1; + } elsif (/^make_options=(.*)/) { + $make_options = $1; + if ($makeoptions =~ /-n/) { + $dontact = "true"; + } + if ($makeoptions =~ /-j([0-9]+)/) { + $numberofjobs = $1; + } + if ($makeoptions =~ /-f/) { + $abortonerror = "true"; + } + } elsif (/^project_name=(.*)/) { + $project_name = $1; + } elsif (/^project_type=(.*)/) { + $project_type = $1; + } elsif (/^sub_dir=([^\/]*)/) { + $subdir = $1; + } + } + + if ($inlfvgroups) { + if (/^groups=(.*)/) { + $lfvgroups = $1; + } elsif (/(.*)=(.*)/) { + $group = $1; + $pattern = $2; + $pattern =~ s/^(.*),$/$1/; + $lfvgrouppattern{$group} = $pattern; + } + } + + if ($inbin) { + if (/^bin_program=(.*)/) { + $bin_program = $1; + } elsif (/^path_to_bin_program=(.*)/) { + $path_to_bin_program = $1; + $path_to_bin_program =~ s#^\./(.*)$#$1#; + $path_to_bin_program =~ s#^(.*)/#$1#; + $path_to_bin_program = $path_to_bin_program . "/"; + } elsif (/^cflags=(.*)/) { + $cflags = $1; + } elsif (/^cxxflags=(.*)/) { + $cxxflags = $1; + } + } + +} +close FILE; + +# Choose language support +$primarylanguage = "C++"; +if ($project_type eq "normal_c" + || $project_type eq "normal_gnome") { + $primarylanguage = "C"; +} + +# Choose project management +$projectmanagement = "KDevCustomProject"; +if ($project_type =~ /normal_kde|mini_kde|normalogl_kde|normal_kde2|mini_kde2|mdi_kde2/ + || $project_type =~ /kde2_normal|kicker_app|kio_slave|kc_module|kpart_plugin|ktheme/) { + $projectmanagement = "KDevKDEAutoProject"; +} +if ($project_type =~ /normal_cpp/) { + $projectmanagement = "KDevAutoProject"; +} + +# Keywords +if ($project_type =~ /normal_kde|mini_kde|normalogl_kde|normal_kde2|mini_kde2|mdi_kde2/ + || $project_type =~ /kde2_normal|kicker_app|kio_slave|kc_module|kpart_plugin|ktheme/) { + $keywords = $keywords . ",KDE"; +} +if ($project_type =~ /normal_kde|mini_kde|normalogl_kde|normal_kde2|mini_kde2|mdi_kde2/ + || $project_type =~ /kde2_normal|kicker_app|kio_slave|kc_module|kpart_plugin|ktheme/ + || $project_type =~ /normal_qt|normal_qt2|mdi_qt2|mdi_qextmdi/) { + $keywords = $keywords . ",Qt"; +} + + +## +## Let's go: write project file +## + +$projectfilename = $filename; +$projectfilename =~ s/^(.*)\.kdevprj$/$1.tdevelop/; +open(FILE, ">$projectfilename"); + +print FILE < + + + $author + $email + $projectmanagement + $primarylanguage + +EOF + +foreach $key (split(/,/, $keywords)) { + next if ($key eq ""); + print FILE <$key +EOF +} + +print FILE < + +EOF + +# auto project specific + +if ($projectmanagement eq "KDevAutoProject" || $projectmanagement eq "KDevKDEAutoProject") { + print FILE < + + $path_to_bin_program$bin_program + + + $configure_args + + + $abortonerror + $numberofjobs + $dontact + + + + $cflags + $cxxflags + + +EOF +} + +if ($project_management eq "KDevCustomProject") { + print FILE < + + $path_to_bin_program/$bin_program + + + $abortonerror + $numberofjobs + $dontact + + + +EOF +} + + +# file view +print FILE < + +EOF + +for $group (split /,/, $lfvgroups) { + next if ($group eq ""); + $pattern = $lfvgrouppattern{$group}; + $pattern =~ s/,/;/g; + print FILE < +EOF +} + +print FILE < + + + + gtk + gnustep + python + php + perl + + +EOF + +if ($projectmanagement eq "KDevAutoProject" + || $projectmanagement eq "KDevKDEAutoProject") { + print FILE < + + libtool + + +EOF +} + +print FILE < +EOF +close FILE; + + +## +## Write file list +## + +if ($projectmanagement eq "KDevCustomProject") { + $filelistfilename = $filename; + $filelistfilename =~ s/^(.*).kdevprj$/$1.filelist/; + open(FILE, ">$filelistfilename"); + for $file (@sourcefiles) { + print FILE "$file\n"; + } + close FILE; +} + + +## +## Convert templates +## + +$projectdir = ""; +if ($filename =~ m#(.*/)[^/]*#) { + $projectdir = $1; +} + +$oldtemplatedir = "${projectdir}$subdir/templates"; + +if (open(FILE, "$oldtemplatedir/cpp_template")) { + mkdir "${projectdir}templates"; + if (open(OFILE, ">${projectdir}templates/cpp")) { + while() { + s/\|EMAIL\|/\$EMAIL\$/; + s/\|AUTHOR\|/\$AUTHOR\$/; + s/\|VERSION\|/\$VERSION\$/; + s/\|DATE\|/\$DATE\$/; + s/\|YEAR\|/\$YEAR\$/; + s/\|FILENAME\|/\$FILENAME\$/; + print OFILE $_; + } + close OFILE; + } + close FILE; +} + +if (open(FILE, "$oldtemplatedir/header_template")) { + mkdir "${projectdir}templates"; + if (open(OFILE, ">${projectdir}templates/h")) { + while() { + s/\|EMAIL\|/\$EMAIL\$/; + s/\|AUTHOR\|/\$AUTHOR\$/; + s/\|VERSION\|/\$VERSION\$/; + s/\|DATE\|/\$DATE\$/; + s/\|YEAR\|/\$YEAR\$/; + s/\|FILENAME\|/\$FILENAME\$/; + print OFILE $_; + } + close OFILE; + } + close FILE; +} -- cgit v1.2.1