From 722ce1efbac31c61b1d4b13f7e075c9f311e3e73 Mon Sep 17 00:00:00 2001 From: Darrell Anderson Date: Sun, 2 Mar 2014 20:05:33 +0100 Subject: Finish renaming tdevelop components --- tdevprj2tdevelop | 299 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 299 insertions(+) create mode 100644 tdevprj2tdevelop (limited to 'tdevprj2tdevelop') diff --git a/tdevprj2tdevelop b/tdevprj2tdevelop new file mode 100644 index 00000000..79966df0 --- /dev/null +++ b/tdevprj2tdevelop @@ -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 = "TDevCustomProject"; +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.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 "KDevTDEAutoProject") { + print FILE < + + $path_to_bin_program$bin_program + + + $configure_args + + + $abortonerror + $numberofjobs + $dontact + + + + $cflags + $cxxflags + + +EOF +} + +if ($project_management eq "TDevCustomProject") { + 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 "TDevCustomProject") { + $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