Skip to content
Permalink
Browse files
Beginnings of cleanups for plugin builder for 0.8 release.
Tidy up messages with better clarification of how vars will be used.
Add PluginLCaseName - a lower cased version of the plugin name so that
we can rename the file names of .cpp and .h files to ones matching
their contained class definitions.


git-svn-id: http://svn.osgeo.org/qgis/trunk@4904 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Feb 23, 2006
1 parent 9e7c45f commit c3c1ab30e1f39f6c477151d61ec9c0edb5bfd111
Showing with 26 additions and 7 deletions.
  1. +26 −7 src/plugins/plugin_builder.pl
@@ -9,20 +9,30 @@
# $Id$ #

# get the needed information from the user
print "\n\nEnter the directory name under qgis/plugins/ where your new plugin will be created.\n";
print "\n\nEnter the directory name under qgis/src/plugins/ where your new plugin will be created.\n";
print "We suggest using a lowercase underscore separated name e.g. clever_plugin\n";
print "Directory for the new plugin:";
$pluginDir =<STDIN>;
chop $pluginDir;

print "\n\nEnter the name that will be used when creating the plugin library and should be\n";
print "entered as a mixed case name with no spaces. e.g. CleverPlugin\n";
print "\n\nEnter the name that will be used when creating the plugin library.\n";
print "The name should be entered as a mixed case name with no spaces. e.g. CleverTool\n";
print "The plugin name will be used in the following ways:\n";
print "1) it will be 'lower cased' and used as the root of the generated lib name \n";
print " e.g. libqgis_plugin_clevertool\n";
print "2) in its upper cased form it will be used as the basis for class names, in particular\n";
print " CleverToolGuiBase <- The base class for the plugins configuration dialog / gui generated by uic\n";
print " CleverToolGui <- The concrete class for the plugins configuration dialog\n";
print "3) CleverTool <- The class that includes the plugin loader instructions and\n";
print " and calls to your custom application logic\n";
print "4) clevertool.h, clevertool.cpp etc. <- the filenames used to hold the above derived classes\n";
print "Plugin name: " ;
$pluginName = <STDIN>;
chop $pluginName;
$pluginLCaseName = $pluginName; #todo convert to lower case

print "\n\nEnter a short description (typically one line)\n";
print "e.g. The clever plugin does clever stuff in qgis\n";
print "e.g. The clever plugin does clever stuff in QGIS\n";
print "Plugin description: " ;
$pluginDescription = <STDIN>;
chop $pluginDescription;
@@ -46,12 +56,13 @@
---------------------------------------------
Plugin directory $pluginDir
Name of the plugin: $pluginName
Library name of the plugin: libqgis_plugin_$pluginLCaseName
Description of the plugin: $pluginDescription
Menu name: $menuName
Menu item name: $menuItemName
Warning - Proceeding will make changes to Makefile.am in this directory,
as well as ../configure.in. Please use caution.
as well as ../../configure.in. Please use caution.
EOF
# ask if we should proceed
print "Create the plugin? [y/n]: ";
@@ -64,12 +75,20 @@
#
# create the new plugin directory
system("cp -r plugin_template $pluginDir");
# remove the CVS directory
system("rm -rf $pluginDir/CVS");
# remove the subversion directory
system("rm -rf $pluginDir/.svn");
# copy files to appropriate names
system("cp $pluginDir/plugin.cpp $pluginDir/$pluginLCaseName.cpp");
system("cp $pluginDir/plugin.h $pluginDir/$pluginLCaseName.h");
#todo sort out copying these next items properly
system("cp $pluginDir/pluginbase.cpp $pluginDir/$pluginLCaseName.cpp");
system("cp $pluginDir/plugin.cpp $pluginDir/$pluginLCaseName.cpp");

# Substitute the plugin specific vars in the various files
# This is a brute force approach but its quick and dirty :)
#
# replace [pluginlcasename] in template with the new plugin name
system("perl -pi -e 's/\\\[pluginlcasename\\\]/$pluginLCaseName/g' $pluginDir/*.cpp $pluginDir/*.h $pluginDir/*.am $pluginDir/*.ui");
# replace [pluginname] in template with the new plugin name
system("perl -pi -e 's/\\\[pluginname\\\]/$pluginName/g' $pluginDir/*.cpp $pluginDir/*.h $pluginDir/*.am $pluginDir/*.ui");
# replace [plugindescription] in template with the description

0 comments on commit c3c1ab3

Please sign in to comment.