From 8b9c0d28fe084e8c7912a55f29052052edcfdd6e Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Wed, 17 Jun 2015 15:33:10 +0900 Subject: Revert to .kdevelop files with entity name for project files. This resolves bug 2308. Signed-off-by: Michele Calgaro (cherry picked from commit e044c5463329652f28565dfc7de24ef8b0edaa6f) --- kdevprj2kdevelop | 299 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 299 insertions(+) create mode 100755 kdevprj2kdevelop (limited to 'kdevprj2kdevelop') diff --git a/kdevprj2kdevelop b/kdevprj2kdevelop new file mode 100755 index 00000000..c30628a9 --- /dev/null +++ b/kdevprj2kdevelop @@ -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|tdeio_slave|kc_module|kpart_plugin|ktheme/) { + $projectmanagement = "KDevTDEAutoProject"; +} +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|tdeio_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|tdeio_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.kdevelop/; +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 "KDevTDEAutoProject") { + 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 "KDevTDEAutoProject") { + 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