Skip to content

Commit c3c1ab3

Browse files
author
timlinux
committed
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
1 parent 9e7c45f commit c3c1ab3

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

src/plugins/plugin_builder.pl

+26-7
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,30 @@
99
# $Id$ #
1010

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

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

2434
print "\n\nEnter a short description (typically one line)\n";
25-
print "e.g. The clever plugin does clever stuff in qgis\n";
35+
print "e.g. The clever plugin does clever stuff in QGIS\n";
2636
print "Plugin description: " ;
2737
$pluginDescription = <STDIN>;
2838
chop $pluginDescription;
@@ -46,12 +56,13 @@
4656
---------------------------------------------
4757
Plugin directory $pluginDir
4858
Name of the plugin: $pluginName
59+
Library name of the plugin: libqgis_plugin_$pluginLCaseName
4960
Description of the plugin: $pluginDescription
5061
Menu name: $menuName
5162
Menu item name: $menuItemName
5263
5364
Warning - Proceeding will make changes to Makefile.am in this directory,
54-
as well as ../configure.in. Please use caution.
65+
as well as ../../configure.in. Please use caution.
5566
EOF
5667
# ask if we should proceed
5768
print "Create the plugin? [y/n]: ";
@@ -64,12 +75,20 @@
6475
#
6576
# create the new plugin directory
6677
system("cp -r plugin_template $pluginDir");
67-
# remove the CVS directory
68-
system("rm -rf $pluginDir/CVS");
78+
# remove the subversion directory
79+
system("rm -rf $pluginDir/.svn");
80+
# copy files to appropriate names
81+
system("cp $pluginDir/plugin.cpp $pluginDir/$pluginLCaseName.cpp");
82+
system("cp $pluginDir/plugin.h $pluginDir/$pluginLCaseName.h");
83+
#todo sort out copying these next items properly
84+
system("cp $pluginDir/pluginbase.cpp $pluginDir/$pluginLCaseName.cpp");
85+
system("cp $pluginDir/plugin.cpp $pluginDir/$pluginLCaseName.cpp");
6986

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

0 commit comments

Comments
 (0)